From ae8da7ef883a63be6d6ac1d3e731e8e6e48d2284 Mon Sep 17 00:00:00 2001 From: "Igor V. Kovalenko" Date: Thu, 19 Jan 2023 23:25:12 +0300 Subject: [PATCH] Add variable read/write flag test for c++20 three-way comparison --- .../core/parser/tests/ast2/AST2TestBase.java | 7 ++++++- .../tests/ast2/VariableReadWriteFlagsTest.java | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java index 5c6b2dacd16..13743cbd05b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java @@ -539,7 +539,12 @@ public abstract class AST2TestBase extends SemanticTestBase { } public AST2AssertionHelper(String contents, ParserLanguage lang) throws ParserException { - super(contents, parse(contents, lang, ScannerKind.GNU, false)); + this(contents, lang, ScannerKind.GNU); + } + + public AST2AssertionHelper(String contents, ParserLanguage lang, ScannerKind scannerKind) + throws ParserException { + super(contents, parse(contents, lang, scannerKind, false)); this.isCPP = lang.isCPP(); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/VariableReadWriteFlagsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/VariableReadWriteFlagsTest.java index a39ecccaded..cd95b8ad84d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/VariableReadWriteFlagsTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/VariableReadWriteFlagsTest.java @@ -17,6 +17,7 @@ import java.io.IOException; import java.util.Optional; import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.internal.core.dom.parser.c.CVariableReadWriteFlags; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWriteFlags; import org.eclipse.cdt.internal.core.parser.ParserException; @@ -36,6 +37,10 @@ public class VariableReadWriteFlagsTest extends AST2TestBase { super(contents, isCPP); } + AssertionHelper(String contents, ParserLanguage lang, ScannerKind scannerKind) throws ParserException { + super(contents, lang, scannerKind); + } + void assertReadWriteFlags(String context, String name, Optional expectedFlags) throws Exception { IASTName variable = findName(context, name); assertNotNull(variable); @@ -95,6 +100,11 @@ public class VariableReadWriteFlagsTest extends AST2TestBase { return new AssertionHelper(code, true); } + protected AssertionHelper getCPP20AssertionHelper() throws ParserException, IOException { + String code = getAboveComment(); + return new AssertionHelper(code, ParserLanguage.CPP, ScannerKind.STDCPP20); + } + // int test(int a) { // a = 2; // a *= 3; @@ -107,6 +117,14 @@ public class VariableReadWriteFlagsTest extends AST2TestBase { a.assertReadWriteFlags("a + 1", "a", READ); } + // auto test(int a) { + // return a <=> 1; + // } + public void testThreeWayComparisonAccess() throws Exception { + AssertionHelper a = getCPP20AssertionHelper(); + a.assertReadWriteFlags("a <=> 1", "a", READ); + } + // class C { // public: // C(int);