diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java index a579e8f1839..534045966c5 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java @@ -515,13 +515,13 @@ public void testAttributeWithKeywordArgument() throws Exception { // struct S __attribute__((__packed__)) {}; public void testGCCAttributedStruct() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true); + IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, ScannerKind.GNU); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTCompositeTypeSpecifier.class); } // int a __attribute__ ((aligned ((64)))); public void testGCCAttributedVariableDeclarator_bug391572() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true); + IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, ScannerKind.GNU); checkAttributeRelations(getAttributeSpecifiers(tu), IASTDeclarator.class); } @@ -529,7 +529,7 @@ public void testGCCAttributedVariableDeclarator_bug391572() throws Exception { // void foo() override __attribute__((attr)); // }; public void testGCCAttributeAfterOverride_bug413615() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true); + IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, ScannerKind.GNU); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTFunctionDeclarator.class); } @@ -537,33 +537,33 @@ public void testGCCAttributeAfterOverride_bug413615() throws Exception { // value1 [[attr1]], value2 [[attr2]] = 1 // }; public void testAttributedEnumerator_Bug535269() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true); + IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, ScannerKind.GNU); checkAttributeRelations(getAttributeSpecifiers(tu), IASTEnumerator.class, IASTEnumerator.class); } //void f([[attr1]] int [[attr2]] p) { //} public void testAttributedFunctionParameter_Bug535275() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true); + IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, ScannerKind.GNU); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTParameterDeclaration.class, ICPPASTSimpleDeclSpecifier.class); } //namespace [[attr]] NS {} public void testAttributedNamedNamespace_Bug535274() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true); + IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, ScannerKind.GNU); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTNamespaceDefinition.class); } //namespace [[attr]] {} public void testAttributedUnnamedNamespace_Bug535274() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true); + IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, ScannerKind.GNU); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTNamespaceDefinition.class); } //namespace NS __attribute__((__visibility__("default"))) {} public void testGnuAndCppMixedAttributedNamedNamespace_Bug535274() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true); + IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, ScannerKind.GNU); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTNamespaceDefinition.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 3290710927f..e60b1e376a9 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -416,9 +416,9 @@ public void testBug95411() throws Exception { } public void testBug95424() throws Exception { - IASTTranslationUnit tu = parse("void f(){ traits_type::copy(__r->_M_refdata(), __buf, __i); }", CPP, true, - true); - tu = parse("void f(){ traits_type::copy(__r->_M_refdata(), __buf, __i); }", CPP, false, true); + IASTTranslationUnit tu = parse("void f(){ traits_type::copy(__r->_M_refdata(), __buf, __i); }", CPP, + ScannerKind.GNU, true); + tu = parse("void f(){ traits_type::copy(__r->_M_refdata(), __buf, __i); }", CPP, ScannerKind.STD, true); IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0]; IASTCompoundStatement cs = (IASTCompoundStatement) f.getBody(); IASTExpressionStatement es = (IASTExpressionStatement) cs.getStatements()[0]; @@ -1932,7 +1932,7 @@ public void testBug84371() throws Exception { // AB::f(`c`); // } public void testBug84679() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, false, false); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.STD, false); NameCollector col = new NameCollector(); tu.accept(col); @@ -3666,7 +3666,7 @@ public void testImplicitMethods() throws Exception { } public void testBug87424() throws Exception { - IASTTranslationUnit tu = parse("int * __restrict x;", CPP, true); + IASTTranslationUnit tu = parse("int * __restrict x;", CPP, ScannerKind.GNU); NameCollector col = new NameCollector(); tu.accept(col); @@ -3675,7 +3675,7 @@ public void testBug87424() throws Exception { assertTrue(t instanceof IPointerType); assertTrue(((IPointerType) t).isRestrict()); - tu = parse("class A {}; int A::* __restrict x;", CPP, true); + tu = parse("class A {}; int A::* __restrict x;", CPP, ScannerKind.GNU); col = new NameCollector(); tu.accept(col); @@ -3686,7 +3686,7 @@ public void testBug87424() throws Exception { } public void testBug87705() throws Exception { - IASTTranslationUnit tu = parse("class A { friend class B::C; };", CPP, true); + IASTTranslationUnit tu = parse("class A { friend class B::C; };", CPP, ScannerKind.GNU); NameCollector col = new NameCollector(); tu.accept(col); @@ -4181,6 +4181,44 @@ public void testOperatorNames() throws Exception { assertEquals(col.getName(158).toString(), "operator >"); } + // struct C { + // auto operator<=>(const C&); + // }; + public void testThreeWayComparisonOperatorName() throws Exception { + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.STDCPP20); + NameCollector col = new NameCollector(); + tu.accept(col); + + assertEquals(col.size(), 4); + assertEquals(col.getName(1).toString(), "operator <=>"); + } + + // constexpr bool less(int x, int y) { return x <=> y < 0; } + // constexpr bool equals(int x, int y) { return x <=> y == 0; } + // constexpr bool greater(int x, int y) { return x <=> y > 0; } + // + // static constexpr auto less01 = less(0, 1); + // static constexpr auto less00 = less(0, 0); + // static constexpr auto less10 = less(1, 0); + // static constexpr auto equals01 = equals(0, 1); + // static constexpr auto equals11 = equals(1, 1); + // static constexpr auto equals10 = equals(1, 0); + // static constexpr auto greater01 = greater(0, 1); + // static constexpr auto greater00 = greater(0, 0); + // static constexpr auto greater10 = greater(1, 0); + public void testThreeWayComparisonSimpleCase() throws Exception { + BindingAssertionHelper helper = getAssertionHelper(CPP, ScannerKind.STDCPP20); + helper.assertVariableValue("less01", 1); + helper.assertVariableValue("less00", 0); + helper.assertVariableValue("less10", 0); + helper.assertVariableValue("equals01", 0); + helper.assertVariableValue("equals11", 1); + helper.assertVariableValue("equals10", 0); + helper.assertVariableValue("greater01", 0); + helper.assertVariableValue("greater00", 0); + helper.assertVariableValue("greater10", 1); + } + // typedef int I; // typedef int I; // typedef I I; @@ -4439,7 +4477,7 @@ public void testBug90648() throws ParserException { public void testBug92980() throws Exception { String code = "struct A { A(); A(const A&) throw(1); ~A() throw(X); };"; - parse(code, CPP, true, false); + parse(code, CPP, ScannerKind.GNU, false); } // class Dummy { int v(); int d; }; @@ -4940,7 +4978,7 @@ public void testBug95714() throws Exception { // float _Complex x; // double _Complex y; public void testBug95757() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); IASTDeclaration[] decls = tu.getDeclarations(); assertTrue(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).isComplex()); @@ -4997,7 +5035,7 @@ public void testBug96655() throws Exception { } public void testBug96678() throws Exception { - parse("int x; // comment \r\n", CPP, false, true); + parse("int x; // comment \r\n", CPP, ScannerKind.STD, true); } // struct A {}; @@ -5233,7 +5271,7 @@ public void testAnonymousStructures() throws Exception { } public void testBug99262() throws Exception { - parse("void foo() {void *f; f=__null;}", CPP, true, true); + parse("void foo() {void *f; f=__null;}", CPP, ScannerKind.GNU, true); } // void f1(int*) { @@ -5278,7 +5316,7 @@ public void testBug84478d() throws Exception { // } // } public void testBug84478b() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -5302,7 +5340,7 @@ public void testBug84478b() throws Exception { // free(p); // } public void testBug100415() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -5322,7 +5360,7 @@ public void testBug100415() throws Exception { // }; // } public void testBug86688() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -5337,7 +5375,7 @@ public void testBug86688() throws Exception { // }; // int m::f(){} public void testBug100403() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -5356,7 +5394,7 @@ public void testBug100403() throws Exception { // friend void A::f2(BT); // }; public void testBug90609() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -5379,7 +5417,7 @@ public void testBug90609() throws Exception { // } // } public void testBug103281() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -5403,7 +5441,7 @@ public void testBug78800() throws Exception { // i; // } public void test10_2s3b() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -5476,7 +5514,7 @@ public void testBug107150() throws Exception { // return 0; // } public void testBug108202() throws Exception { - parse(getAboveComment(), CPP, true, true); + parse(getAboveComment(), CPP, ScannerKind.GNU, true); } // // Test redundant class specifiers @@ -5486,7 +5524,7 @@ public void testBug108202() throws Exception { // }; // int MyClass::static_field; public void testBug174791() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); // check class IASTSimpleDeclaration sd = (IASTSimpleDeclaration) tu.getDeclarations()[0]; @@ -5524,7 +5562,7 @@ public void testBug174791() throws Exception { // void nsSplit::a() { // } public void testBug180979() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); // check class IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[2]; @@ -5540,7 +5578,7 @@ public void testBug180979() throws Exception { // _GLIBCXX_BEGIN_NAMESPACE(std) // } // end the namespace public void testBug195701() throws Exception { - parse(getAboveComment(), CPP, true, true); + parse(getAboveComment(), CPP, ScannerKind.GNU, true); } // class A { @@ -5551,14 +5589,14 @@ public void testBug195701() throws Exception { // using A::operator*; // }; public void testBug178059() throws Exception { - parse(getAboveComment(), CPP, true, true); + parse(getAboveComment(), CPP, ScannerKind.GNU, true); } // void foo (void *p) throw () ; // void bar (void *p) __attribute__ ((__nonnull__(1))); // void zot (void *p) throw () __attribute__ ((__nonnull__(1))); public void testBug179712() throws Exception { - parse(getAboveComment(), CPP, true, true); + parse(getAboveComment(), CPP, ScannerKind.GNU, true); } // class C { @@ -5621,7 +5659,7 @@ public void testBug214335() throws Exception { // outer::foo x; // outer::inner::foo y; public void testAttributeInUsingDirective_351228() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // namespace source { @@ -5646,7 +5684,7 @@ public void testAttributeInUsingDirective_351228() throws Exception { // fs(1); // } public void testReferencesOfUsingDecls() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); IASTDeclaration[] decls = tu.getDeclarations(); ICPPASTNamespaceDefinition nsdef = (ICPPASTNamespaceDefinition) decls[0]; @@ -5936,7 +5974,7 @@ public void testLongLiteral_225534() throws Exception { // long l(0L); // long long ll(0LL); public void testInitializeUnsigned_245070() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // void foo/*_a*/(int x) {} @@ -6111,7 +6149,7 @@ public void testNewPlacement() throws Exception { // } public void testTrailingSyntaxErrorInNamespace() throws Exception { final String comment = getAboveComment(); - IASTTranslationUnit tu = parse(comment, CPP, false, false); + IASTTranslationUnit tu = parse(comment, CPP, ScannerKind.STD, false); ICPPASTNamespaceDefinition ns = getDeclaration(tu, 0); IASTDeclaration decl = getDeclaration(ns, 0); IASTProblemDeclaration pdecl = getDeclaration(ns, 1); @@ -6124,7 +6162,7 @@ public void testTrailingSyntaxErrorInNamespace() throws Exception { // } public void testTrailingSyntaxErrorInLinkageSpec() throws Exception { final String comment = getAboveComment(); - IASTTranslationUnit tu = parse(comment, CPP, false, false); + IASTTranslationUnit tu = parse(comment, CPP, ScannerKind.STD, false); ICPPASTLinkageSpecification ls = getDeclaration(tu, 0); IASTDeclaration decl = getDeclaration(ls, 0); IASTProblemDeclaration pdecl = getDeclaration(ls, 1); @@ -6359,8 +6397,8 @@ public void testTypeIdForPtrToMember_242197() throws Exception { // void restrict(); public void testRestrictIsNoCPPKeyword_228826() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, CPP, false); - parseAndCheckBindings(getAboveComment(), CPP, true); // even with gnu extensions + parseAndCheckBindings(code, CPP, ScannerKind.STD); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); // even with gnu extensions } // void test1(); @@ -6598,7 +6636,7 @@ public void testVariadicFunction_2500583() throws Exception { // } public void testFunctionCallOnLHS_252695() throws Exception { final String code = getAboveComment(); - IASTTranslationUnit tu = parseAndCheckBindings(code, CPP, true); + IASTTranslationUnit tu = parseAndCheckBindings(code, CPP, ScannerKind.GNU); IASTFunctionDefinition fdef = getDeclaration(tu, 1); IASTExpressionStatement exstmt = getStatement(fdef, 0); assertInstance(exstmt.getExpression(), IASTBinaryExpression.class); @@ -6614,7 +6652,7 @@ public void testFunctionCallOnLHS_252695() throws Exception { // template class B {}; public void testInvalidClassRedeclaration_254961() throws Exception { final String code = getAboveComment(); - IASTTranslationUnit tu = parse(code, CPP, true, false); + IASTTranslationUnit tu = parse(code, CPP, ScannerKind.GNU, false); NameCollector nc = new NameCollector(); tu.accept(nc); assertProblemBindings(nc, 4); @@ -6632,7 +6670,7 @@ public void testInvalidClassRedeclaration_254961() throws Exception { // template class B {}; public void testInvalidClassRedeclaration_364226() throws Exception { final String code = getAboveComment(); - IASTTranslationUnit tu = parse(code, CPP, true, false); + IASTTranslationUnit tu = parse(code, CPP, ScannerKind.GNU, false); NameCollector nc = new NameCollector(); tu.accept(nc); assertProblemBindings(nc, 4); @@ -9169,7 +9207,7 @@ public void testScopedEnums_305975b() throws Exception { // enum E; // illegal public void testScopedEnums_305975c() throws Exception { String code = getAboveComment(); - IASTTranslationUnit tu = parse(code, CPP, true, false); + IASTTranslationUnit tu = parse(code, CPP, ScannerKind.GNU, false); IASTDeclaration[] decls = tu.getDeclarations(); assertEquals(3, decls.length); assertInstance(decls[0], IASTProblemDeclaration.class); @@ -10499,7 +10537,7 @@ public void testAmbiguityResolution_427854() throws Exception { // ~T(); // }; public void testErrorForDestructorWithWrongName_367590() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, false, false); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.STD, false); IASTCompositeTypeSpecifier S; IASTProblemDeclaration p; IASTSimpleDeclaration s; @@ -10874,7 +10912,7 @@ public void testFinalGccExtension_442457() throws Exception { // static const bool value = __is_trivially_constructible(S, Args...); // }; public void testParsingOfGcc5TypeTraitIntrinsics_485713() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true /* use GNU extensions */); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU /* use GNU extensions */); } // struct S1 {}; @@ -10940,7 +10978,7 @@ public void testADL_485710() throws Exception { // const bool b = __is_base_of(S, int); // typedef A::type T; public void testIsBaseOf_395019() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // template @@ -10978,7 +11016,7 @@ public void testIsBaseOf_395019() throws Exception { // // Waldo c; public void testIsBaseOf_446094() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // struct Bool { Bool(bool); }; @@ -11117,7 +11155,7 @@ public void testNarrowingConversionInListInitialization_491748() throws Exceptio // return i ? "a" : "b"; // } public void testThrowExpressionInConditional_396663() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // struct A {}; @@ -11155,7 +11193,7 @@ public void testTypedefOfPointerInConditional_481078() throws Exception { // struct derived : base {}; // typedef enable_if<__is_base_of(base, derived)>::type T; public void testIsBaseOf_399353() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // struct base {}; @@ -11291,7 +11329,7 @@ public void testMemberAccessibilities() throws Exception { // __sync_synchronize(); // } public void testGNUSyncBuiltins_389578() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // int main() { @@ -11300,7 +11338,7 @@ public void testGNUSyncBuiltins_389578() throws Exception { // __sync_fetch_and_add(&p, p, 2); // } public void testGNUSyncBuiltinsOnVoidPtr_533822() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // // __int128_t and __uint128_t are available but are not keywords. @@ -11313,7 +11351,7 @@ public void testGNUSyncBuiltinsOnVoidPtr_533822() throws Exception { // int __uint128_t; // } public void testGCCIntBuiltins_444577() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // template @@ -11379,7 +11417,7 @@ public void testUnderlyingType_548954() throws Exception { // bar(2); // } public void testUnderlyingType_540909() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true /* use GNU extensions */); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU /* use GNU extensions */); } // enum class TestEnum : char { @@ -11392,7 +11430,7 @@ public void testUnderlyingType_540909() throws Exception { // bar('a'); // Invalid arguments 'Candidates are: void bar(@120932903)' // } public void testUnderlyingType_568625() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true /* use GNU extensions */); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU /* use GNU extensions */); } // void ptrFunc(void*); @@ -11404,7 +11442,7 @@ public void testUnderlyingType_568625() throws Exception { // ptrFunc(__builtin_return_address(4)); // } public void testGCCBuiltins_512932a() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // void ptrFunc(void*); @@ -11532,7 +11570,7 @@ public void testConversionFromLambdaToFunctionPointer_424765() throws Exception // void bar(void *a1, void *a2) __attribute__((nonnull(1, 2))); public void testGCCAttributeSequence_416430() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); IASTDeclaration[] declarations = tu.getDeclarations(); assertEquals(1, declarations.length); IASTDeclaration declaration = declarations[0]; @@ -11722,7 +11760,7 @@ public void testAlignas_475739() throws Exception { // __attribute__((section(".example"))) alignas(4) static int waldo; public void testAlignasAfterAttribute_538615() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true /* use GNU extensions */); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU /* use GNU extensions */); } // int operator "" _A(unsigned long long i) { return 1; } @@ -12102,7 +12140,7 @@ public void testUserDefinedLiteralConcatenation_528196_4c() throws Exception { // Ret operator "" _Y(const char* s, unsigned sz) { return Ret(); } // auto test = "123"_X "123"_Y; public void testUserDefinedLiteralBadConcatenation1() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, false); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, false); IASTProblem[] problems = tu.getPreprocessorProblems(); assertEquals(1, problems.length); @@ -12183,7 +12221,7 @@ public void testUserDefinedLiteralNoWhiteSpace1() throws Exception { // auto e5 = U"1" _X "2"; // auto d5 = U"1" _X; public void testUserDefinedLiteralNoWhiteSpace2() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, false); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, false); IASTDeclaration[] decls = tu.getDeclarations(); for (int i = 1; i < decls.length; i++) { @@ -12648,7 +12686,7 @@ public void testContextualBooleanConversion_506972() throws Exception { // el1, // }; public void testEnumeratorAttribute_514821() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true /* use GNU extensions */); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU /* use GNU extensions */); } // void foo([[maybe_unused]] int a); @@ -13655,7 +13693,7 @@ public void testExplicitSpecPointerType_562697() throws Exception { // Test::Value>::true_val; // } public void testIsSame() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // void function(int * a) { } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java index 0f2aef8f87f..fa820d64fb0 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java @@ -76,7 +76,7 @@ public void testSimpleKRCTest1() throws Exception { buffer.append("int f(char x);\n"); //$NON-NLS-1$ buffer.append("int f(x) char x;\n"); //$NON-NLS-1$ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, ScannerKind.GNU); IASTSimpleDeclaration f1 = (IASTSimpleDeclaration) tu.getDeclarations()[0]; IASTFunctionDefinition f2 = (IASTFunctionDefinition) tu.getDeclarations()[1]; @@ -118,7 +118,7 @@ public void testSimpleKRCTest2() throws Exception { buffer.append("int f();\n"); //$NON-NLS-1$ buffer.append("int f(x) char x;\n"); //$NON-NLS-1$ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, ScannerKind.GNU); IASTSimpleDeclaration f1 = (IASTSimpleDeclaration) tu.getDeclarations()[0]; IASTFunctionDefinition f2 = (IASTFunctionDefinition) tu.getDeclarations()[1]; @@ -154,7 +154,7 @@ public void testSimpleKRCTest3() throws Exception { buffer.append("int const *f();\n"); //$NON-NLS-1$ buffer.append("int const *f(x) char x;\n"); //$NON-NLS-1$ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, ScannerKind.GNU); IASTSimpleDeclaration f1 = (IASTSimpleDeclaration) tu.getDeclarations()[0]; IASTFunctionDefinition f2 = (IASTFunctionDefinition) tu.getDeclarations()[1]; @@ -181,7 +181,7 @@ public void testKRC_1() throws Exception { buffer.append("int x;\n"); //$NON-NLS-1$ buffer.append("int y;\n"); //$NON-NLS-1$ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, ScannerKind.GNU); IASTFunctionDefinition isroot_def = (IASTFunctionDefinition) tu.getDeclarations()[0]; @@ -235,7 +235,7 @@ public void testKRCWithTypes() throws Exception { buffer.append("int isroot (x) \n"); //$NON-NLS-1$ buffer.append("c x;\n"); //$NON-NLS-1$ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, ScannerKind.GNU); IASTSimpleDeclaration c_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0]; IASTSimpleDeclaration isroot_decl = (IASTSimpleDeclaration) tu.getDeclarations()[1]; @@ -291,7 +291,7 @@ public void testKRCProblem1() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int f(x) char\n"); //$NON-NLS-1$ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, ScannerKind.GNU, false); IASTDeclaration[] decls = tu.getDeclarations(); assertTrue(CVisitor.getProblems(tu).length > 0); @@ -302,7 +302,7 @@ public void testKRCProblem2() throws Exception { buffer.append("int i=0;\n"); //$NON-NLS-1$ buffer.append("int f(x) i++;\n"); //$NON-NLS-1$ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, ScannerKind.GNU, false); IASTSimpleDeclaration sd = getDeclaration(tu, 0); assertTrue(CVisitor.getProblems(tu).length > 0); @@ -312,7 +312,7 @@ public void testKRCProblem3() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int f(x) char y;\n"); //$NON-NLS-1$ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, ScannerKind.GNU, false); IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0]; assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator); @@ -348,7 +348,7 @@ public void testKRCProblem4() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int f(x,y,z) char x,y,z; int a;\n"); //$NON-NLS-1$ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, ScannerKind.GNU, false); IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0]; assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator); @@ -409,7 +409,7 @@ public void testKRCProblem5() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int f(x) char x,a;\n"); //$NON-NLS-1$ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, ScannerKind.GNU, false); IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0]; assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator); @@ -460,7 +460,7 @@ public void testKRC_monop_cards1() throws Exception { buffer.append("x->a = 0;\n"); //$NON-NLS-1$ buffer.append("x->c[1]=x->c[2];\n"); //$NON-NLS-1$ buffer.append("}\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, ScannerKind.GNU); IASTSimpleDeclaration A_struct = (IASTSimpleDeclaration) tu.getDeclarations()[0]; IASTSimpleDeclaration A = (IASTSimpleDeclaration) tu.getDeclarations()[1]; @@ -583,7 +583,7 @@ public void testKRC_monop_cards2() throws Exception { buffer.append("getinp(prompt, list)\n"); //$NON-NLS-1$ buffer.append(" const char *prompt, *const list[];\n"); //$NON-NLS-1$ buffer.append("{\n *list[1] = 'a';\n}\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, ScannerKind.GNU); IASTFunctionDefinition getinp = (IASTFunctionDefinition) tu.getDeclarations()[0]; @@ -628,7 +628,7 @@ public void testKRC_monop_cards2() throws Exception { public void testKRC_getParametersOrder() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int f(a, b) int b,a;{}\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, ScannerKind.GNU); IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0]; ICASTKnRFunctionDeclarator f_decltor = (ICASTKnRFunctionDeclarator) f.getDeclarator(); @@ -650,7 +650,7 @@ public void testKRC_Ethereal_1() throws Exception { buffer.append("struct lemon *lemp;\n{\n"); //$NON-NLS-1$ buffer.append("lemp->symbols[1]->lambda = 1;\n"); //$NON-NLS-1$ buffer.append("lemp->errorcnt++;}\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, ScannerKind.GNU); IASTSimpleDeclaration symbol_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0]; IASTSimpleDeclaration lemon_decl = (IASTSimpleDeclaration) tu.getDeclarations()[1]; @@ -700,7 +700,7 @@ public void testBug97447() throws Exception { buffer.append("void f(a) int a; {} \n"); //$NON-NLS-1$ buffer.append("void f(int); \n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, ScannerKind.GNU); NameCollector col = new NameCollector(); tu.accept(col); @@ -720,7 +720,7 @@ public void testBug100104() throws Exception { buffer.append("};\n"); //$NON-NLS-1$ buffer.append("}\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, true); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, ScannerKind.GNU, true); assertTrue(tu.getDeclarations()[0] instanceof IASTSimpleDeclaration); assertTrue(tu.getDeclarations()[1] instanceof IASTFunctionDefinition); IASTStatement[] stmts = ((IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[1]).getBody()) @@ -748,7 +748,7 @@ public void testBug100104() throws Exception { // return 0; // } public void testBug203050() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, ScannerKind.GNU, true); assertTrue(tu.getDeclarations()[0] instanceof IASTSimpleDeclaration); assertTrue(tu.getDeclarations()[1] instanceof IASTFunctionDefinition); assertTrue(tu.getDeclarations()[2] instanceof IASTFunctionDefinition); @@ -775,6 +775,6 @@ public void testBug203050() throws Exception { // {} public void testFunctionPtrParameter_378614() throws Exception { String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C, true); + parseAndCheckBindings(code, ParserLanguage.C, ScannerKind.GNU); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateLValueRValueTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateLValueRValueTests.java index a0598857c48..02764bb0445 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateLValueRValueTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateLValueRValueTests.java @@ -862,7 +862,7 @@ public void test_templatedLvalue_caller_templatedRvalue_function() throws Except private void parseAndCheckBindingsForOneProblem() throws IOException, ParserException { final String code = getAboveComment(); - IASTTranslationUnit tu = parse(code, CPP, true, false); + IASTTranslationUnit tu = parse(code, CPP, ScannerKind.GNU, false); NameCollector nc = new NameCollector(); tu.accept(nc); assertProblemBindings(nc, 1); @@ -870,7 +870,7 @@ private void parseAndCheckBindingsForOneProblem() throws IOException, ParserExce private void parseAndCheckBindingsForProblem() throws IOException, ParserException { final String code = getAboveComment(); - IASTTranslationUnit tu = parse(code, CPP, true, false); + IASTTranslationUnit tu = parse(code, CPP, ScannerKind.GNU, false); NameCollector nc = new NameCollector(); tu.accept(nc); assertProblemBindings(nc); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index ab237d266b2..335dfe78fc1 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -1936,7 +1936,7 @@ public void testBug95208() throws Exception { // A broken; // }; public void testBug103578() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -1956,7 +1956,7 @@ public void testBug103578() throws Exception { // a.base; // } public void testBug103715() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -1981,7 +1981,7 @@ public void testBug103715() throws Exception { // void complex::f(float){ // } public void testBug74276() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -2007,7 +2007,7 @@ public void testBug74276() throws Exception { // myType t; // } public void testBug105852() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -2030,7 +2030,7 @@ public void testBug105852() throws Exception { // k.c; // } public void testBug105769() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -2046,7 +2046,7 @@ public void testBug105769() throws Exception { // template <> C(wchar_t * c) : blah(c) {} // }; public void testBug162230() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -2081,7 +2081,7 @@ public void testBug162230() throws Exception { // template< class T > class C {}; // typedef struct C CInt; public void testBug169628() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -2450,7 +2450,7 @@ public void testFunctionTemplateWithFunctionPointer_281783() throws Exception { // // foo -> CPPMethodInstance // } public void testCPPConstructorTemplateSpecialization() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(true); tu.accept(col); @@ -2472,7 +2472,7 @@ public void testCPPConstructorTemplateSpecialization() throws Exception { // return (lhs < rhs ? rhs : lhs); // } public void testNestedFuncTemplatedDeclarator_bug190241() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -2522,7 +2522,7 @@ public void testNestedFuncTemplatedDeclarator_bug190241() throws Exception { // void f(B::tb r) {} public void testTemplateTypedef_214447() throws Exception { CPPASTNameBase.sAllowNameComputation = true; - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -2556,7 +2556,7 @@ public void testTemplateTypedef_214447() throws Exception { // void f(Vec::reference r) {} public void testRebindPattern_214447a() throws Exception { CPPASTNameBase.sAllowNameComputation = true; - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -2596,7 +2596,7 @@ public void testRebindPattern_214447a() throws Exception { // void f(Vec::reference r) {} public void testRebindPattern_214447b() throws Exception { CPPASTNameBase.sAllowNameComputation = true; - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -2635,7 +2635,7 @@ public void testRebindPattern_214447b() throws Exception { // void f(map::value_type r) {} public void testRebindPattern_236197() throws Exception { CPPASTNameBase.sAllowNameComputation = true; - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); for (IASTName name : col.nameList) { @@ -2667,7 +2667,7 @@ public void testRebindPattern_236197() throws Exception { // void main(Iter::iter_reference r); public void testSpecializationSelection_229218() throws Exception { CPPASTNameBase.sAllowNameComputation = true; - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); for (IASTName name : col.nameList) { @@ -2797,7 +2797,7 @@ public void testSpecializationSelection_509255c() throws Exception { // B::b::a x; public void testDefaultTemplateParameter() throws Exception { CPPASTNameBase.sAllowNameComputation = true; - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -2942,7 +2942,7 @@ public void testUserDefinedConversions_239023() throws Exception { // const int i= 1; // A a1; public void testNonTypeArgumentIsIDExpression_229942a() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -2961,7 +2961,7 @@ public void testNonTypeArgumentIsIDExpression_229942a() throws Exception { // const int i= 1; // }; public void testNonTypeArgumentIsIDExpression_229942b() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -2975,7 +2975,7 @@ public void testNonTypeArgumentIsIDExpression_229942b() throws Exception { // const int i= 1; // A a1; public void testExpressionArgumentIsExpression_229942() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -2990,7 +2990,7 @@ public void testExpressionArgumentIsExpression_229942() throws Exception { // const int i= 1; // A a1; public void testTypeIdOperatorArgumentIsUnaryExpression_229942() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -3003,7 +3003,7 @@ public void testTypeIdOperatorArgumentIsUnaryExpression_229942() throws Exceptio // template< class T1, class T2, int q1, int q2> // class A< C, C > {}; public void testTemplateIdAsTemplateArgumentIsTypeId_229942() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -3036,7 +3036,7 @@ public void testTypeIdAsTemplateArgumentIsTypeId_229942a() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); ba.assertNonProblem("T> at) {", 1); - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -3056,7 +3056,7 @@ public void testTypeIdAsTemplateArgumentIsTypeId_229942a() throws Exception { // inline const void foo(void (*f)(A), T* t) { // disallowed, but we're testing the AST // } public void testTypeIdAsTemplateArgumentIsTypeId_229942b() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -3747,7 +3747,7 @@ public void run() { // }; // template void A::foo(T t) {} public void testBug177418() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); tu.accept(col); @@ -4201,7 +4201,7 @@ public void testTypedefPreservation_380498c() throws Exception { // p.waldo(); // } public void testTypeTraitWithQualifier_511143() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // template @@ -4973,7 +4973,7 @@ public void testClosingAngleBrackets1_261268() throws Exception { // } public void testClosingAngleBrackets2_261268() throws Exception { final String code = getAboveComment(); - IASTTranslationUnit tu = parse(code, CPP, true, false); + IASTTranslationUnit tu = parse(code, CPP, ScannerKind.GNU, false); IASTFunctionDefinition fdef = getDeclaration(tu, 2); IASTProblemStatement p1 = getStatement(fdef, 1); } @@ -5618,7 +5618,7 @@ public void testBug316704() throws Exception { code.append('\n').append("int_<0> >::type,"); } code.append("int_<0> >::type tdef;"); - IASTTranslationUnit tu = parse(code.toString(), CPP, true, true); + IASTTranslationUnit tu = parse(code.toString(), CPP, ScannerKind.GNU, true); tu = validateCopy(tu); assertEquals(1, tu.getDeclarations().length); } @@ -6884,7 +6884,7 @@ public void testSfinae_b() throws Exception { // f(); // } public void testIsPOD_367993() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // template class A { @@ -6907,7 +6907,7 @@ public void testIsPOD_367993() throws Exception { // c.callDelegate(a); /* Invalid arguments 'Candidates are: void callDelegate(A<#0,#1> &)' */ // } public void testDeductionOfNonTypeTemplateArg_372587() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // template void b(_Functor __f) {} @@ -6917,7 +6917,7 @@ public void testDeductionOfNonTypeTemplateArg_372587() throws Exception { // b(f); // } public void testFunctionSetWithNonMatchingTemplateArgs_379604() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // template struct C { @@ -6933,7 +6933,7 @@ public void testFunctionSetWithNonMatchingTemplateArgs_379604() throws Exception // f(v); // } public void testPointerToMemberAsDependentExpression_391001() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // template @@ -6991,7 +6991,7 @@ public void testDependentTemplateParameterInNestedTemplate_399454() throws Excep // it.test; // Field 'test' could not be resolved // } public void testAddressAsTemplateArgument_391190() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // template struct CT { @@ -7001,7 +7001,7 @@ public void testAddressAsTemplateArgument_391190() throws Exception { // off < CT::const_min || off > CT::const_min; // } public void testTemplateIDAmbiguity_393959() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // template class CT { @@ -10104,7 +10104,7 @@ public void testAmbiguityResolution_515453() throws Exception { // C::c; // problems on C, T and ::c // } public void testRegression_485388a() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // template 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 5453037a149..610c48038c4 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 @@ -99,12 +99,36 @@ * @author aniefer */ public abstract class AST2TestBase extends SemanticTestBase { + public static enum ScannerKind { + STD { + @Override + public boolean isUseGNUExtensions() { + return false; + } + }, + GNU { + @Override + public boolean isUseGNUExtensions() { + return true; + } + }, + STDCPP20 { + @Override + public boolean isUseGNUExtensions() { + return false; + } + }; + + public abstract boolean isUseGNUExtensions(); + } + public final static String TEST_CODE = ""; protected static final IParserLogService NULL_LOG = new NullLogService(); protected static boolean sValidateCopy; private static final ScannerInfo GNU_SCANNER_INFO = new ScannerInfo(getGnuMap()); private static final ScannerInfo SCANNER_INFO = new ScannerInfo(getStdMap()); + private static final ScannerInfo STDCPP20_SCANNER_INFO = new ScannerInfo(getStdCpp20Map()); private static Map getGnuMap() { Map map = new HashMap<>(); @@ -130,6 +154,12 @@ private static Map getStdMap() { return map; } + private static Map getStdCpp20Map() { + Map map = getStdMap(); + map.put("__cpp_impl_three_way_comparison", "201907L"); + return map; + } + public AST2TestBase() { super(); } @@ -145,28 +175,28 @@ protected void setUp() throws Exception { } protected IASTTranslationUnit parse(String code, ParserLanguage lang) throws ParserException { - return parse(code, lang, false, true); + return parse(code, lang, ScannerKind.STD, true); } - protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions) + protected IASTTranslationUnit parse(String code, ParserLanguage lang, ScannerKind scannerKind) throws ParserException { - return parse(code, lang, useGNUExtensions, true); + return parse(code, lang, scannerKind, true); } - protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions, + protected IASTTranslationUnit parse(String code, ParserLanguage lang, ScannerKind scannerKind, boolean expectNoProblems) throws ParserException { - return parse(code, lang, useGNUExtensions, expectNoProblems, Integer.MAX_VALUE); + return parse(code, lang, scannerKind, expectNoProblems, Integer.MAX_VALUE); } - protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions, + protected IASTTranslationUnit parse(String code, ParserLanguage lang, ScannerKind scannerKind, boolean expectNoProblems, int limitTrivialInitializers) throws ParserException { IScanner scanner = createScanner(FileContent.create(TEST_CODE, code.toCharArray()), lang, - ParserMode.COMPLETE_PARSE, createScannerInfo(useGNUExtensions)); + ParserMode.COMPLETE_PARSE, createScannerInfo(scannerKind)); configureScanner(scanner); AbstractGNUSourceCodeParser parser = null; if (lang == ParserLanguage.CPP) { ICPPParserExtensionConfiguration config = null; - if (useGNUExtensions) { + if (scannerKind.isUseGNUExtensions()) { config = new GPPParserExtensionConfiguration(); } else { config = new ANSICPPParserExtensionConfiguration(); @@ -175,7 +205,7 @@ protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean us } else { ICParserExtensionConfiguration config = null; - if (useGNUExtensions) { + if (scannerKind.isUseGNUExtensions()) { config = new GCCParserExtensionConfiguration(); } else { config = new ANSICParserExtensionConfiguration(); @@ -206,10 +236,16 @@ protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean us return tu; } - public ScannerInfo createScannerInfo(boolean useGnu) { - if (useGnu) + public static ScannerInfo createScannerInfo(ScannerKind scannerKind) { + switch (scannerKind) { + case GNU: return GNU_SCANNER_INFO; - return SCANNER_INFO; + case STDCPP20: + return STDCPP20_SCANNER_INFO; + case STD: + default: + return SCANNER_INFO; + } } protected void configureScanner(IScanner scanner) { @@ -273,23 +309,37 @@ protected void validateConditionalExpressionC(String code) throws ParserExceptio assertEquals(x.getName().toString(), x2.getName().toString()); } - protected void validateSimpleBinaryExpressionC(String code, int operand) throws ParserException { - IASTBinaryExpression e = (IASTBinaryExpression) getExpressionFromStatementInCode(code, ParserLanguage.C); + protected void validateSimpleBinaryExpression(String code, int operator, ParserLanguage language, + ScannerKind scannerKind) throws ParserException { + IASTBinaryExpression e = (IASTBinaryExpression) getExpressionFromStatementInCode(code, language, scannerKind); assertNotNull(e); - assertEquals(e.getOperator(), operand); + assertEquals(e.getOperator(), operator); IASTIdExpression x = (IASTIdExpression) e.getOperand1(); assertEquals(x.getName().toString(), "x"); //$NON-NLS-1$ IASTIdExpression y = (IASTIdExpression) e.getOperand2(); assertEquals(y.getName().toString(), "y"); //$NON-NLS-1$ } + protected void validateSimpleBinaryExpressionC(String code, int operator) throws ParserException { + validateSimpleBinaryExpression(code, operator, ParserLanguage.C, ScannerKind.STD); + } + + protected void validateSimpleBinaryExpressionCPP20(String code, int operator) throws ParserException { + validateSimpleBinaryExpression(code, operator, ParserLanguage.CPP, ScannerKind.STDCPP20); + } + protected IASTExpression getExpressionFromStatementInCode(String code, ParserLanguage language) throws ParserException { + return getExpressionFromStatementInCode(code, language, ScannerKind.STD); + } + + protected IASTExpression getExpressionFromStatementInCode(String code, ParserLanguage language, + ScannerKind scannerKind) throws ParserException { StringBuilder buffer = new StringBuilder("void f() { "); //$NON-NLS-1$ buffer.append("int x, y;\n"); //$NON-NLS-1$ buffer.append(code); buffer.append(";\n}"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), language); + IASTTranslationUnit tu = parse(buffer.toString(), language, scannerKind); IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0]; IASTCompoundStatement cs = (IASTCompoundStatement) f.getBody(); IASTExpressionStatement s = (IASTExpressionStatement) cs.getStatements()[1]; @@ -489,23 +539,28 @@ public AST2AssertionHelper(String contents, boolean isCPP) throws ParserExceptio } public AST2AssertionHelper(String contents, ParserLanguage lang) throws ParserException { - super(contents, parse(contents, lang, true, 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(); } } final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang) throws Exception { - return parseAndCheckBindings(code, lang, false); + return parseAndCheckBindings(code, lang, ScannerKind.STD); } - final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang, - boolean useGnuExtensions) throws Exception { - return parseAndCheckBindings(code, lang, useGnuExtensions, Integer.MAX_VALUE); + final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang, ScannerKind scannerKind) + throws Exception { + return parseAndCheckBindings(code, lang, scannerKind, Integer.MAX_VALUE); } - final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang, - boolean useGnuExtensions, int limitTrivialInitializers) throws Exception { - IASTTranslationUnit tu = parse(code, lang, useGnuExtensions, true, limitTrivialInitializers); + final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang, ScannerKind scannerKind, + int limitTrivialInitializers) throws Exception { + IASTTranslationUnit tu = parse(code, lang, scannerKind, true, limitTrivialInitializers); NameCollector col = new NameCollector(); tu.accept(col); assertNoProblemBindings(col); @@ -513,7 +568,7 @@ final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLan } final protected IASTTranslationUnit parseAndCheckImplicitNameBindings() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, false, true); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.STD, true); NameCollector col = new NameCollector(true /* Visit implicit names */); tu.accept(col); assertNoProblemBindings(col); @@ -521,8 +576,13 @@ final protected IASTTranslationUnit parseAndCheckImplicitNameBindings() throws E } protected BindingAssertionHelper getAssertionHelper(ParserLanguage lang) throws ParserException, IOException { + return getAssertionHelper(lang, ScannerKind.GNU); + } + + protected BindingAssertionHelper getAssertionHelper(ParserLanguage lang, ScannerKind scannerKind) + throws ParserException, IOException { String code = getAboveComment(); - return new AST2AssertionHelper(code, lang); + return new AST2AssertionHelper(code, lang, scannerKind); } final protected void assertNoProblemBindings(NameCollector col) { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index 571fa566393..92946d6caa6 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -157,13 +157,13 @@ public AST2Tests(String name) { } private void parseAndCheckBindings() throws Exception { - parseAndCheckBindings(false); + parseAndCheckBindings(ScannerKind.STD); } - private void parseAndCheckBindings(boolean useGnuExtensions) throws Exception { + private void parseAndCheckBindings(ScannerKind scannerKind) throws Exception { String code = getAboveComment(); - parseAndCheckBindings(code, C, useGnuExtensions); - parseAndCheckBindings(code, CPP, useGnuExtensions); + parseAndCheckBindings(code, C, scannerKind); + parseAndCheckBindings(code, CPP, scannerKind); } protected IASTTranslationUnit parseAndCheckBindings(String code) throws Exception { @@ -505,6 +505,10 @@ public void testCExpressions() throws ParserException { validateConditionalExpressionC("x ? y : x"); //$NON-NLS-1$ } + public void testCPP20Expressions() throws ParserException { + validateSimpleBinaryExpressionCPP20("x<=>y", IASTBinaryExpression.op_threewaycomparison); //$NON-NLS-1$ + } + public void testMultipleDeclarators() throws Exception { IASTTranslationUnit tu = parse("int r, s;", C); //$NON-NLS-1$ assertTrue(tu.isFrozen()); @@ -2724,7 +2728,7 @@ public void testBug84096_FieldDesignatorRef() throws Exception { } public void testProblems() throws Exception { - IASTTranslationUnit tu = parse(" a += ;", C, true, false); //$NON-NLS-1$ + IASTTranslationUnit tu = parse(" a += ;", C, ScannerKind.GNU, false); //$NON-NLS-1$ IASTProblem[] ps = CVisitor.getProblems(tu); assertEquals(1, ps.length); ps[0].getMessage(); @@ -2797,7 +2801,7 @@ public void testBug84185_2() throws Exception { // p = &((struct s) { j++ }); // } public void testBug84176() throws Exception { - parse(getAboveComment(), C, false, true); + parse(getAboveComment(), C, ScannerKind.STD, true); } // struct s { double i; } f(void); @@ -3136,7 +3140,7 @@ public void testBug81739() throws Exception { // float _Complex x; // double _Complex y; public void testBug95757() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), C, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), C, ScannerKind.GNU, true); IASTDeclaration[] decls = tu.getDeclarations(); assertTrue(((ICASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).isComplex()); @@ -3151,7 +3155,7 @@ public void testBug95757() throws Exception { // typeof({ int x = foo(); // x; }) zoot; public void testBug93980() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), C, true); + IASTTranslationUnit tu = parse(getAboveComment(), C, ScannerKind.GNU); NameCollector col = new NameCollector(); tu.accept(col); @@ -3165,14 +3169,14 @@ public void testBug93980() throws Exception { } public void testBug95866() throws Exception { - IASTTranslationUnit tu = parse("int test[10] = { [0 ... 9] = 2 };", C, true, true); //$NON-NLS-1$ + IASTTranslationUnit tu = parse("int test[10] = { [0 ... 9] = 2 };", C, ScannerKind.GNU, true); //$NON-NLS-1$ NameCollector col = new NameCollector(); tu.accept(col); assertNoProblemBindings(col); } public void testBug98502() throws Exception { - IASTTranslationUnit tu = parse("typedef enum { ONE } e;", C, true, true); //$NON-NLS-1$ + IASTTranslationUnit tu = parse("typedef enum { ONE } e;", C, ScannerKind.GNU, true); //$NON-NLS-1$ NameCollector col = new NameCollector(); tu.accept(col); @@ -3188,7 +3192,7 @@ public void testBug98502() throws Exception { // PIPERR; // } public void testBug98365() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), C, true); + IASTTranslationUnit tu = parse(getAboveComment(), C, ScannerKind.GNU); NameCollector col = new NameCollector(); tu.accept(col); @@ -3197,7 +3201,7 @@ public void testBug98365() throws Exception { } public void testBug99262() throws Exception { - parse("void foo() {void *f; f=__null;}", C, true, true); //$NON-NLS-1$ + parse("void foo() {void *f; f=__null;}", C, ScannerKind.GNU, true); //$NON-NLS-1$ } // void f1(int*) { @@ -3215,7 +3219,7 @@ public void testBug240567() throws Exception { // { a; int a; } // } public void testBug98960() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), C, true); + IASTTranslationUnit tu = parse(getAboveComment(), C, ScannerKind.GNU); NameCollector col = new NameCollector(); tu.accept(col); @@ -3244,7 +3248,7 @@ public void testBug100408() throws Exception { // { // } public void testBug98760() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), C, true); + IASTTranslationUnit tu = parse(getAboveComment(), C, ScannerKind.GNU); NameCollector col = new NameCollector(); tu.accept(col); @@ -3321,7 +3325,7 @@ public void test1043290() throws Exception { // blah: x; // } public void testBug104390_2() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), C, true); + IASTTranslationUnit tu = parse(getAboveComment(), C, ScannerKind.GNU); NameCollector col = new NameCollector(); tu.accept(col); @@ -3447,7 +3451,7 @@ public void testBug107150b() throws Exception { // return newWindow; // } public void testBug143502() throws Exception { - parse(getAboveComment(), C, true, false); + parse(getAboveComment(), C, ScannerKind.GNU, false); } // void func(int a) { @@ -3462,13 +3466,13 @@ public void testBug143502() throws Exception { // } public void testBracketAroundIdentifier_168924() throws IOException, ParserException { String content = getAboveComment(); - IASTTranslationUnit tu = parse(content, C, true, true); + IASTTranslationUnit tu = parse(content, C, ScannerKind.GNU, true); IASTFunctionDefinition func = (IASTFunctionDefinition) tu.getDeclarations()[0]; IASTParameterDeclaration[] params = ((IASTStandardFunctionDeclarator) func.getDeclarator()).getParameters(); IBinding binding = params[0].getDeclarator().getName().resolveBinding(); assertEquals(7, tu.getReferences(binding).length); - tu = parse(content, CPP, true, true); + tu = parse(content, CPP, ScannerKind.GNU, true); func = (IASTFunctionDefinition) tu.getDeclarations()[0]; params = ((IASTStandardFunctionDeclarator) func.getDeclarator()).getParameters(); binding = params[0].getDeclarator().getName().resolveBinding(); @@ -3480,7 +3484,7 @@ public void testBracketAroundIdentifier_168924() throws IOException, ParserExcep // MAC("); // } public void testBug179383() throws ParserException, IOException { - parse(getAboveComment(), C, false, false); + parse(getAboveComment(), C, ScannerKind.STD, false); } /** @@ -3492,7 +3496,7 @@ public void testMacroCommentsBug_177154() throws Exception { String simple = "#define LIT 1 // my value\r\n" + "int func(int x) {\r\n" + "}\r\n" + "int main() {\r\n" + " return func(LIT); // fails to parse\r\n" + "}\r\n"; - IASTTranslationUnit tu = parse(simple, CPP, true, true); + IASTTranslationUnit tu = parse(simple, CPP, ScannerKind.GNU, true); // actual reduced test case, plus extra cases String text = "#define KBOOT 1 //0x00000002\r\n" @@ -3504,7 +3508,7 @@ public void testMacroCommentsBug_177154() throws Exception { + "__KTRACE_OPT(KBOOT2,fail());\r\n" + "}\r\n"; // essential test: this code should be parseable - tu = parse(text, CPP, true, true); + tu = parse(text, CPP, ScannerKind.GNU, true); // verify macros IASTPreprocessorMacroDefinition[] macroDefinitions = tu.getMacroDefinitions(); @@ -3526,7 +3530,7 @@ public void testMacroCommentsBug_177154() throws Exception { // } public void testBug181305_1() throws Exception { for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(getAboveComment(), lang, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), lang, ScannerKind.GNU, true); // check class IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[1]; @@ -3547,7 +3551,7 @@ public void testBug181305_1() throws Exception { // } public void testBug181305_2() throws Exception { for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(getAboveComment(), lang, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), lang, ScannerKind.GNU, true); // check class IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[1]; @@ -3574,7 +3578,7 @@ public void testBug181735() throws Exception { // } public void testBug181942() throws Exception { for (ParserLanguage lang : ParserLanguage.values()) - parse(getAboveComment(), lang, true, true); + parse(getAboveComment(), lang, ScannerKind.GNU, true); } public void testMacroCommentsBug_177154_2() throws Exception { @@ -3594,18 +3598,18 @@ public void testMacroCommentsBug_177154_2() throws Exception { // this should work String textNoComment = noCommentMacro + textTail; - IASTTranslationUnit tu = parse(textNoComment, CPP, true, true); + IASTTranslationUnit tu = parse(textNoComment, CPP, ScannerKind.GNU, true); // this fails String textComment = commentMacro + textTail; - tu = parse(textComment, CPP, true, true); + tu = parse(textComment, CPP, ScannerKind.GNU, true); } // int __builtin_sin; public void testBug182464() throws Exception { for (ParserLanguage lang : ParserLanguage.values()) - parseAndCheckBindings(getAboveComment(), lang, true); + parseAndCheckBindings(getAboveComment(), lang, ScannerKind.GNU); } public void testBug186018() throws Exception { @@ -3761,7 +3765,7 @@ public void testBug188707_backslashNewline() throws Exception { // typedef int (*J)(J); public void testBug192165() throws Exception { for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(getAboveComment(), lang, true, false); + IASTTranslationUnit tu = parse(getAboveComment(), lang, ScannerKind.GNU, false); NameCollector col = new NameCollector(); tu.accept(col); assertInstance(col.getName(0).resolveBinding(), IProblemBinding.class); @@ -3797,8 +3801,8 @@ public void testBug192165() throws Exception { // INVALID(1, 2) // public void test192639() throws Exception { - parse(getAboveComment(), CPP, false, false); - parse(getAboveComment(), C, false, false); + parse(getAboveComment(), CPP, ScannerKind.STD, false); + parse(getAboveComment(), C, ScannerKind.STD, false); } public void test195943() throws Exception { @@ -3818,11 +3822,11 @@ public void test195943() throws Exception { // int array[12]= {}; public void testBug196468_emptyArrayInitializer() throws Exception { final String content = getAboveComment(); - parse(content, CPP, false); - parse(content, CPP, true); - parse(content, C, true); + parse(content, CPP, ScannerKind.STD); + parse(content, CPP, ScannerKind.GNU); + parse(content, C, ScannerKind.GNU); try { - parse(content, C, false); + parse(content, C, ScannerKind.STD); fail("C89 does not allow empty braces in array initializer"); } catch (ParserException e) { } @@ -3848,8 +3852,8 @@ public void testBug197633_parenthesisInVarargMacros() throws Exception { // void (* __attribute__((__stdcall__)) foo2) (int); // void (* __attribute__((__stdcall__))* foo3) (int); public void testBug191450_attributesInBetweenPointers() throws Exception { - parse(getAboveComment(), CPP, true, true); - parse(getAboveComment(), C, true, true); + parse(getAboveComment(), CPP, ScannerKind.GNU, true); + parse(getAboveComment(), C, ScannerKind.GNU, true); } // class NameClash {}; @@ -3857,7 +3861,7 @@ public void testBug191450_attributesInBetweenPointers() throws Exception { // namespace NameClash2 {}; // class NameClash2 {}; public void testBug202271_nameClash() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), CPP, true); + IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { NameCollector col = new NameCollector(); @@ -3877,7 +3881,7 @@ public void testBug202271_nameClash() throws Exception { // int b= WRAP(MACRO); public void testBug94673_refsForMacrosAsArguments() throws Exception { String content = getAboveComment(); - IASTTranslationUnit tu = parseAndCheckBindings(content, CPP, true); + IASTTranslationUnit tu = parseAndCheckBindings(content, CPP, ScannerKind.GNU); IASTPreprocessorMacroDefinition[] defs = tu.getMacroDefinitions(); assertEquals(2, defs.length); IASTPreprocessorMacroDefinition md = defs[1]; @@ -4096,7 +4100,7 @@ public void testBug183126_nestedLinkageSpecs() throws Exception { // f3(&i); // ok // } public void testBug213029_cvConversion() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, false); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.STD); NameCollector col = new NameCollector(); tu.accept(col); for (Object o : col.nameList) { @@ -4597,16 +4601,16 @@ public void testOmittedPositiveExpression_212905() throws Exception { // } public void testRedefinedGCCKeywords_226112() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, C, true); - parseAndCheckBindings(code, CPP, true); + parseAndCheckBindings(code, C, ScannerKind.GNU); + parseAndCheckBindings(code, CPP, ScannerKind.GNU); } // int foo asm ("myfoo") __attribute__((__used__)), ff asm("ss") = 2; // extern void func () asm ("FUNC") __attribute__((__used__)); public void testASMLabels_226121() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, C, true); - parseAndCheckBindings(code, CPP, true); + parseAndCheckBindings(code, C, ScannerKind.GNU); + parseAndCheckBindings(code, CPP, ScannerKind.GNU); } // void test() { @@ -4614,8 +4618,8 @@ public void testASMLabels_226121() throws Exception { // } public void testCompoundStatementExpression_226274() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, C, true); - parseAndCheckBindings(code, CPP, true); + parseAndCheckBindings(code, C, ScannerKind.GNU); + parseAndCheckBindings(code, CPP, ScannerKind.GNU); } // int main() { @@ -4623,8 +4627,8 @@ public void testCompoundStatementExpression_226274() throws Exception { // } public void testTypeofStatementExpressionInCastExpression_427950() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, C, true); - parseAndCheckBindings(code, CPP, true); + parseAndCheckBindings(code, C, ScannerKind.GNU); + parseAndCheckBindings(code, CPP, ScannerKind.GNU); } // void test(int count) { @@ -4633,8 +4637,8 @@ public void testTypeofStatementExpressionInCastExpression_427950() throws Except // } public void testTypeofUnaryExpression_226492() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, C, true); - parseAndCheckBindings(code, CPP, true); + parseAndCheckBindings(code, C, ScannerKind.GNU); + parseAndCheckBindings(code, CPP, ScannerKind.GNU); } // void test(int count) { @@ -4642,8 +4646,8 @@ public void testTypeofUnaryExpression_226492() throws Exception { // } public void testTypeofExpression_226492() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, C, true); - parseAndCheckBindings(code, CPP, true); + parseAndCheckBindings(code, C, ScannerKind.GNU); + parseAndCheckBindings(code, CPP, ScannerKind.GNU); } // void func() { @@ -4651,8 +4655,8 @@ public void testTypeofExpression_226492() throws Exception { // } public void testTypeofExpressionWithAttribute_226492() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, C, true); - parseAndCheckBindings(code, CPP, true); + parseAndCheckBindings(code, C, ScannerKind.GNU); + parseAndCheckBindings(code, CPP, ScannerKind.GNU); } // struct test { @@ -4676,7 +4680,7 @@ public void testTypeofInsideQualifier_471907() throws Exception { public void testCaseRange_211882() throws Exception { final String code = getAboveComment(); { - IASTTranslationUnit tu = parseAndCheckBindings(code, C, true); + IASTTranslationUnit tu = parseAndCheckBindings(code, C, ScannerKind.GNU); IASTCompoundStatement body = (IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[0]) .getBody(); IASTSwitchStatement switchStmt = (IASTSwitchStatement) body.getStatements()[0]; @@ -4688,7 +4692,7 @@ public void testCaseRange_211882() throws Exception { assertTrue(binExpr.getOperand2() instanceof IASTLiteralExpression); } { - IASTTranslationUnit tu = parseAndCheckBindings(code, CPP, true); + IASTTranslationUnit tu = parseAndCheckBindings(code, CPP, ScannerKind.GNU); IASTCompoundStatement body = (IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[0]) .getBody(); IASTSwitchStatement switchStmt = (IASTSwitchStatement) body.getStatements()[0]; @@ -4706,8 +4710,8 @@ public void testCaseRange_211882() throws Exception { // int x(int(TIntPtr)); public void testInfiniteRecursion_269052() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, C, true); - parseAndCheckBindings(code, CPP, true); + parseAndCheckBindings(code, C, ScannerKind.GNU); + parseAndCheckBindings(code, CPP, ScannerKind.GNU); } // template class X { @@ -4723,15 +4727,15 @@ public void testTypenameInExpression() throws Exception { // struct __attribute__((declspec)) bla; public void testAttributeInElaboratedTypeSpecifier_227085() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, C, true); - parseAndCheckBindings(code, CPP, true); + parseAndCheckBindings(code, C, ScannerKind.GNU); + parseAndCheckBindings(code, CPP, ScannerKind.GNU); } // struct X; // void test(struct X* __restrict result); public void testRestrictReference_227110() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, CPP, true); + parseAndCheckBindings(code, CPP, ScannerKind.GNU); } // char buf[256]; @@ -4761,7 +4765,7 @@ public void testPlacementNewInConditionalExpression_227104() throws Exception { // } public void testBug228422_noKnrParam() throws Exception { CharSequence buffer = getContents(1)[0]; - parse(buffer.toString(), C, false); + parse(buffer.toString(), C, ScannerKind.STD); } // struct { @@ -4878,8 +4882,8 @@ public void testRedefineStructInScopeThatIsFullyResolved() throws Exception { // } public void testReturnTypeOfBuiltin_234309() throws Exception { String code = getAboveComment(); - parseAndCheckBindings(code, C, true); - parseAndCheckBindings(code, CPP, true); + parseAndCheckBindings(code, C, ScannerKind.GNU); + parseAndCheckBindings(code, CPP, ScannerKind.GNU); } // typedef void VOID; @@ -5064,7 +5068,7 @@ public void testComplexParameterBinding_214482() throws Exception { public void testTrailingSyntaxErrorInTU() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(comment, lang, false, false); + IASTTranslationUnit tu = parse(comment, lang, ScannerKind.STD, false); IASTDeclaration decl = getDeclaration(tu, 0); IASTProblemDeclaration pdecl = getDeclaration(tu, 1); assertEquals("+", pdecl.getRawSignature()); @@ -5078,7 +5082,7 @@ public void testTrailingSyntaxErrorInTU() throws Exception { public void testTrailingSyntaxErrorInCompositeType() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(comment, lang, false, false); + IASTTranslationUnit tu = parse(comment, lang, ScannerKind.STD, false); IASTCompositeTypeSpecifier ct = getCompositeType(tu, 0); IASTDeclaration decl = getDeclaration(ct, 0); IASTProblemDeclaration pdecl = getDeclaration(ct, 1); @@ -5095,7 +5099,7 @@ public void testTrailingSyntaxErrorInCompositeType() throws Exception { public void testTrailingSyntaxErrorInCompoundStatements() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(comment, lang, false, false); + IASTTranslationUnit tu = parse(comment, lang, ScannerKind.STD, false); IASTFunctionDefinition def = getDeclaration(tu, 0); IASTCompoundStatement compStmt = getStatement(def, 0); IASTDeclarationStatement dstmt = getStatement(compStmt, 0); @@ -5111,7 +5115,7 @@ public void testTrailingSyntaxErrorInCompoundStatements() throws Exception { public void testEmptyDeclarations() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(comment, lang, false, false); + IASTTranslationUnit tu = parse(comment, lang, ScannerKind.STD, false); IASTCompositeTypeSpecifier ct = getCompositeType(tu, 0); IASTDeclaration empty = getDeclaration(ct, 0); assertEquals(";", empty.getRawSignature()); @@ -5411,13 +5415,13 @@ private void polishNotation(IASTInitializerClause expr, StringBuilder buf) { // spinlock_t _lock = (spinlock_t) { }; public void testCompoundInitializer_145387() throws Exception { // valid in C99, not in C++. - parseAndCheckBindings(getAboveComment(), C, true); + parseAndCheckBindings(getAboveComment(), C, ScannerKind.GNU); } // enum __declspec(uuid("uuid")) bla { a, b}; public void testDeclspecInEnumSpecifier_241203() throws Exception { for (ParserLanguage lang : ParserLanguage.values()) { - parseAndCheckBindings(getAboveComment(), lang, true); + parseAndCheckBindings(getAboveComment(), lang, ScannerKind.GNU); } } @@ -5430,7 +5434,7 @@ public void testDeclspecInEnumSpecifier_241203() throws Exception { // Vector <__declspec(dllexport) int> a; // } public void testDeclspecTypeId_574578() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } //typedef struct _MyStruct { @@ -5440,7 +5444,7 @@ public void testDeclspecTypeId_574578() throws Exception { //MyStruct __declspec(dllexport) __declspec(deprecated) bar; public void testDeclspecAfterDeclSpecifierIdentifier_464624() throws Exception { for (ParserLanguage lang : ParserLanguage.values()) { - parseAndCheckBindings(getAboveComment(), lang, true); + parseAndCheckBindings(getAboveComment(), lang, ScannerKind.GNU); } } @@ -5469,7 +5473,7 @@ public void testAnonymousUnionMember() throws Exception { // } public void testBuiltinTypesCompatible_241570() throws Exception { for (ParserLanguage lang : ParserLanguage.values()) { - parseAndCheckBindings(getAboveComment(), lang, true); + parseAndCheckBindings(getAboveComment(), lang, ScannerKind.GNU); } } @@ -5478,8 +5482,8 @@ public void testBuiltinTypesCompatible_241570() throws Exception { // alloc(__func__); // } public void testPredefinedFunctionName_247747() throws Exception { - parseAndCheckBindings(getAboveComment(), C, false); - parseAndCheckBindings(getAboveComment(), CPP, false); + parseAndCheckBindings(getAboveComment(), C, ScannerKind.STD); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.STD); } // void alloc(const char * id) {} @@ -5489,16 +5493,16 @@ public void testPredefinedFunctionName_247747() throws Exception { // alloc(__PRETTY_FUNCTION__); // } public void testPredefinedFunctionNameGcc_247747() throws Exception { - parseAndCheckBindings(getAboveComment(), C, true); - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), C, ScannerKind.GNU); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // int foo = 42; // typedef char StupidType; // StupidType const *bar = (StupidType const*)&foo; public void testUnusualDeclSpecOrdering_251514() throws Exception { - parseAndCheckBindings(getAboveComment(), C, true); - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), C, ScannerKind.GNU); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // #define IF if @@ -5837,7 +5841,7 @@ private void checkValue(IValue initialValue, int i) { public void testReferencesInInitializer_251514() throws Exception { final String code = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parseAndCheckBindings(code, lang, true); + IASTTranslationUnit tu = parseAndCheckBindings(code, lang, ScannerKind.GNU); IASTFunctionDefinition fdef = getDeclaration(tu, 0); IASTName name = fdef.getDeclarator().getName(); assertEquals(2, tu.getReferences(name.resolveBinding()).length); @@ -5867,7 +5871,7 @@ public void testScalabilityOfLargeTrivialInitializer_253690() throws Exception { for (ParserLanguage lang : ParserLanguage.values()) { intermittentTest(() -> { long mem = memoryUsed(); - IASTTranslationUnit tu = parse(code, lang, false, true, 0); + IASTTranslationUnit tu = parse(code, lang, ScannerKind.STD, true, 0); long diff = memoryUsed() - mem; // Allow a copy of the buffer, plus less than 1.5 bytes per initializer. final int expected = code.length() * 2 + AMOUNT + AMOUNT / 2; @@ -5895,7 +5899,7 @@ public void testLargeTrivialAggregateInitializer_253690() throws Exception { for (ParserLanguage lang : ParserLanguage.values()) { intermittentTest(() -> { long mem = memoryUsed(); - IASTTranslationUnit tu = parse(code, lang, false, true, 0); + IASTTranslationUnit tu = parse(code, lang, ScannerKind.STD, true, 0); long diff = memoryUsed() - mem; // Allow a copy of the buffer, plus less than 1.5 bytes per // initializer. @@ -5921,7 +5925,8 @@ public void testMaximumTrivialExpressionsInInitializers_412380() throws Exceptio for (ParserLanguage lang : ParserLanguage.values()) { intermittentTest(() -> { long mem = memoryUsed(); - IASTTranslationUnit tu = parse(code, lang, false, true, maximumTrivialExpressionsInInitializer); + IASTTranslationUnit tu = parse(code, lang, ScannerKind.STD, true, + maximumTrivialExpressionsInInitializer); long diff = memoryUsed() - mem; final int initializerSize = maximumTrivialExpressionsInInitializer * additionalBytesPerInitializer; // Allow a copy of the buffer, plus less than 1.5 bytes per initializer. @@ -6016,7 +6021,7 @@ private long memoryUsed() throws InterruptedException { public void testNonTrivialInitializer_253690() throws Exception { final String code = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(code, lang, false, true, 0); + IASTTranslationUnit tu = parse(code, lang, ScannerKind.STD, true, 0); IASTSimpleDeclaration d = getDeclaration(tu, 0); IBinding b = d.getDeclarators()[0].getName().resolveBinding(); IASTName[] refs = tu.getReferences(b); @@ -6098,8 +6103,8 @@ public void testCompoundLiterals_258496() throws Exception { // extern __thread int k; public void testThreadLocalVariables_260387() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, C, true); - parseAndCheckBindings(code, CPP, true); + parseAndCheckBindings(code, C, ScannerKind.GNU); + parseAndCheckBindings(code, CPP, ScannerKind.GNU); } // void test() { @@ -6109,7 +6114,7 @@ public void testThreadLocalVariables_260387() throws Exception { public void testAmbiguityResolutionInIfCondition_261043() throws Exception { final String code = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parseAndCheckBindings(code, lang, true); + IASTTranslationUnit tu = parseAndCheckBindings(code, lang, ScannerKind.GNU); IASTFunctionDefinition fdef = getDeclaration(tu, 0); IASTIfStatement ifstmt = getStatement(fdef, 1); IASTExpression expr = ifstmt.getConditionExpression(); @@ -6124,7 +6129,7 @@ public void testAmbiguityResolutionInIfCondition_261043() throws Exception { // }; public void testAmbiguousDeclaration_259373() throws Exception { final String code = getAboveComment(); - IASTTranslationUnit tu = parseAndCheckBindings(code, C, true); + IASTTranslationUnit tu = parseAndCheckBindings(code, C, ScannerKind.GNU); BindingAssertionHelper bh = new AST2AssertionHelper(code, false); ITypedef td = bh.assertNonProblem("TInt; //", 4); IField f = bh.assertNonProblem("a;", 1); @@ -6147,7 +6152,7 @@ public void testAmbiguousDeclaration_259373() throws Exception { public void testLocalVsGlobalStruct_255973() throws Exception { final String code = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parseAndCheckBindings(code, lang, true); + IASTTranslationUnit tu = parseAndCheckBindings(code, lang, ScannerKind.GNU); } } @@ -6157,7 +6162,7 @@ public void testLocalVsGlobalStruct_255973() throws Exception { public void testTypedefWithSameName() throws Exception { final String code = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parseAndCheckBindings(code, lang, true); + IASTTranslationUnit tu = parseAndCheckBindings(code, lang, ScannerKind.GNU); BindingAssertionHelper ba = new AST2AssertionHelper(code, lang == CPP); ITypedef t = ba.assertNonProblem("A;", 1); @@ -6235,7 +6240,7 @@ public void testSizeofFunctionType_252243() throws Exception { public void testPointerOperatorsAsChildren_260461() throws Exception { final String code = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parseAndCheckBindings(code, lang, true); + IASTTranslationUnit tu = parseAndCheckBindings(code, lang, ScannerKind.GNU); IASTSimpleDeclaration decl = getDeclaration(tu, 0); IASTDeclarator dtor = decl.getDeclarators()[0]; IASTNode[] nodes = dtor.getChildren(); @@ -6622,7 +6627,7 @@ public void testTypePromotion_float() throws Exception { // public void testTypePromotion_longlongint() throws Exception { for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit ast = parseAndCheckBindings(getAboveComment(), lang, true); // support for long long + IASTTranslationUnit ast = parseAndCheckBindings(getAboveComment(), lang, ScannerKind.GNU); // support for long long IASTFunctionDefinition func = null; for (IASTDeclaration d : ast.getDeclarations()) { @@ -7095,7 +7100,7 @@ public void testBug295851() throws Exception { // structure.ptr = goo; // } public void testBindingsOnFields() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), C, false); + IASTTranslationUnit tu = parse(getAboveComment(), C, ScannerKind.STD); IASTCompoundStatement bodyStmt = (IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[2]) .getBody(); @@ -7255,14 +7260,14 @@ public void testLargeExpression_294029() throws Exception { // static a[2]= {0,0}; public void testSkipAggregateInitializer_297550() throws Exception { final String code = getAboveComment(); - IASTTranslationUnit tu = parseAndCheckBindings(code, C, false, 0); + IASTTranslationUnit tu = parseAndCheckBindings(code, C, ScannerKind.STD, 0); assertTrue(tu.hasNodesOmitted()); } // static a[2]= {0,0}; public void testNoSkipTrivialAggregateInitializer_412380() throws Exception { final String code = getAboveComment(); - IASTTranslationUnit tu = parseAndCheckBindings(code, C, false); + IASTTranslationUnit tu = parseAndCheckBindings(code, C, ScannerKind.STD); assertFalse(tu.hasNodesOmitted()); } @@ -7270,7 +7275,7 @@ public void testNoSkipTrivialAggregateInitializer_412380() throws Exception { // static a[1]= {i}; public void testNoSkipNonTrivialAggregateInitializer_412380() throws Exception { final String code = getAboveComment(); - IASTTranslationUnit tu = parseAndCheckBindings(code, C, false, 0); + IASTTranslationUnit tu = parseAndCheckBindings(code, C, ScannerKind.STD, 0); assertFalse(tu.hasNodesOmitted()); } @@ -7312,8 +7317,8 @@ public void testDeepElseif_298455() throws Exception { // void f () __attribute__ ((int)); public void testAttributeSyntax_298841() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, C, true); - parseAndCheckBindings(code, CPP, true); + parseAndCheckBindings(code, C, ScannerKind.GNU); + parseAndCheckBindings(code, CPP, ScannerKind.GNU); } // void func(int* obj) { @@ -7359,8 +7364,8 @@ public void testPragmaOperator_294730() throws Exception { // } public void testFunctionNameExpression() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, C, true); - parseAndCheckBindings(code, CPP, true); + parseAndCheckBindings(code, C, ScannerKind.GNU); + parseAndCheckBindings(code, CPP, ScannerKind.GNU); } // #define MACRO @@ -7389,8 +7394,8 @@ public void testEmptyTrailingMacro_303152() throws Exception { // } public void testVaArgWithFunctionPtr_311030() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, C, true); - parseAndCheckBindings(code, CPP, true); + parseAndCheckBindings(code, C, ScannerKind.GNU); + parseAndCheckBindings(code, CPP, ScannerKind.GNU); } // void test() { @@ -7433,7 +7438,7 @@ public void testParameterBindings_316931() throws Exception { public void testPtrDiffRecursion_317004() throws Exception { final String comment = getAboveComment(); String code = comment; - parseAndCheckBindings(code, C, true); + parseAndCheckBindings(code, C, ScannerKind.GNU); BindingAssertionHelper bh = new AST2AssertionHelper(code, false); ITypedef td = bh.assertNonProblem("ptrdiff_t", 0); assertEquals("long int", ASTTypeUtil.getType(td.getType())); @@ -7441,7 +7446,7 @@ public void testPtrDiffRecursion_317004() throws Exception { assertEquals("unsigned long int", ASTTypeUtil.getType(td.getType())); code = "namespace std {" + comment + "}"; - parseAndCheckBindings(code, CPP, true); + parseAndCheckBindings(code, CPP, ScannerKind.GNU); bh = new AST2AssertionHelper(code, true); td = bh.assertNonProblem("ptrdiff_t", 0); assertEquals("long int", ASTTypeUtil.getType(td.getType())); @@ -7544,12 +7549,12 @@ public void testCommentAfterMacroExpansion_367827() throws Exception { // } // } public void testGCCDecltype_397227() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP, true); + parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } // #define macro(R) #R"" public void testNoRawStringInPlainC_397127() throws Exception { - parseAndCheckBindings(getAboveComment(), C, true); + parseAndCheckBindings(getAboveComment(), C, ScannerKind.GNU); } // #define X @@ -7629,7 +7634,7 @@ public void testU8TokenAfterIfdef_429361() throws Exception { // return; // } public void testExpressionLabelReference_84144() throws Exception { - parseAndCheckBindings(true); + parseAndCheckBindings(ScannerKind.GNU); } // void f() { @@ -7641,7 +7646,7 @@ public void testExpressionLabelReference_84144() throws Exception { // } public void testExpressionLabelReferenceCast_486140a() throws Exception { // Here, the cast-expression is the only valid parse. - parseAndCheckBindings(true); + parseAndCheckBindings(ScannerKind.GNU); } // typedef unsigned long long ULL; @@ -7655,7 +7660,7 @@ public void testExpressionLabelReferenceCast_486140a() throws Exception { public void testExpressionLabelReferenceCast_486140b() throws Exception { // Here, the cast-expression and the binary-expression are both // syntactically valid, but the correct parse is the cast-expression. - parseAndCheckBindings(true); + parseAndCheckBindings(ScannerKind.GNU); } // int test(int waldo, int other) { @@ -7664,7 +7669,7 @@ public void testExpressionLabelReferenceCast_486140b() throws Exception { public void testBinaryExprNotMisparsedAsCast_486140() throws Exception { // Again cast-expression and binary-expression are both syntactically // valid, but this time the correct parse is binary-expression. - parseAndCheckBindings(true); + parseAndCheckBindings(ScannerKind.GNU); } // int version = 0; @@ -7672,7 +7677,7 @@ public void testBinaryExprNotMisparsedAsCast_486140() throws Exception { // return __atomic_add_fetch(&version, 1, 5); // } public void testAtomicBuiltin_bug456131() throws Exception { - parseAndCheckBindings(true); + parseAndCheckBindings(ScannerKind.GNU); } // void waldo(...); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java index c533a173631..efaab92a9d7 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java @@ -223,7 +223,7 @@ public void testKnRC() throws Exception { buff.append("int foo(x, y) char x; int y; {}\n"); //$NON-NLS-1$ buff.append("int foo2(char x, int y) {}\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C, true); + IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C, ScannerKind.GNU); IASTDeclaration[] d = tu.getDeclarations(); String fooSignature = ASTStringUtil.getSignatureString(((IASTFunctionDefinition) d[0]).getDeclarator()); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java index 4279a24a257..fe5e5661a85 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java @@ -33,14 +33,14 @@ public static TestSuite suite() { } public void testCountCommentsInHeaderFile() throws ParserException { - IASTTranslationUnit tu = parse(getHSource(), ParserLanguage.CPP, false, true); + IASTTranslationUnit tu = parse(getHSource(), ParserLanguage.CPP, ScannerKind.STD, true); IASTComment[] comments = tu.getComments(); assertEquals(9, comments.length); } public void testCommentsInHeaderFile() throws ParserException { - IASTTranslationUnit tu = parse(getHSource(), ParserLanguage.CPP, false, true); + IASTTranslationUnit tu = parse(getHSource(), ParserLanguage.CPP, ScannerKind.STD, true); IASTComment[] comments = tu.getComments(); assertEquals("/* A very cool class\n * isn't it?\n */", new String(comments[0].getComment())); @@ -55,14 +55,14 @@ public void testCommentsInHeaderFile() throws ParserException { } public void testCountCommentsInCPPFile() throws ParserException { - IASTTranslationUnit tu = parse(getCppSource(), ParserLanguage.CPP, false, true); + IASTTranslationUnit tu = parse(getCppSource(), ParserLanguage.CPP, ScannerKind.STD, true); IASTComment[] comments = tu.getComments(); assertEquals(10, comments.length); } public void testCommentsInCPPFile() throws ParserException { - IASTTranslationUnit tu = parse(getCppSource(), ParserLanguage.CPP, false, true); + IASTTranslationUnit tu = parse(getCppSource(), ParserLanguage.CPP, ScannerKind.STD, true); IASTComment[] comments = tu.getComments(); assertEquals("// Comment in cpp", new String(comments[0].getComment())); @@ -78,14 +78,14 @@ public void testCommentsInCPPFile() throws ParserException { } public void testCountCommentsInCFile() throws ParserException { - IASTTranslationUnit tu = parse(getCSource(), ParserLanguage.C, false, true); + IASTTranslationUnit tu = parse(getCSource(), ParserLanguage.C, ScannerKind.STD, true); IASTComment[] comments = tu.getComments(); assertEquals(4, comments.length); } public void testCommentsInCFile() throws ParserException { - IASTTranslationUnit tu = parse(getCSource(), ParserLanguage.C, false, true); + IASTTranslationUnit tu = parse(getCSource(), ParserLanguage.C, ScannerKind.STD, true); IASTComment[] comments = tu.getComments(); assertEquals("//A little input/output programm", new String(comments[0].getComment())); @@ -205,7 +205,7 @@ private String getCSource() { // #endif public void testCommentsInInactiveCode_bug183930() throws Exception { CharSequence code = getContents(1)[0]; - IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, true); + IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, ScannerKind.STD, true); IASTComment[] comments = tu.getComments(); assertEquals(2, comments.length); @@ -216,14 +216,14 @@ public void testCommentsInInactiveCode_bug183930() throws Exception { // //comment public void testCommentLocation_bug186337() throws Exception { CharSequence code = getContents(1)[0]; - IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, true); + IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, ScannerKind.STD, true); IASTComment[] comments = tu.getComments(); assertEquals(1, comments.length); assertNotNull(comments[0].getFileLocation()); assertNotNull(comments[0].getNodeLocations()); - tu = parse(code.toString(), ParserLanguage.C, false, true); + tu = parse(code.toString(), ParserLanguage.C, ScannerKind.STD, true); comments = tu.getComments(); assertEquals(1, comments.length); @@ -239,7 +239,7 @@ public void testCommentLocation_bug186337() throws Exception { // // TODO: shows up in task list public void testCommentInDirectives_bug192546() throws Exception { CharSequence code = getContents(1)[0]; - IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, false); + IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, ScannerKind.STD, false); IASTComment[] comments = tu.getComments(); assertEquals(5, comments.length); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationMacroTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationMacroTests.java index 8a2de1cfbd7..3e1d6b525bc 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationMacroTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationMacroTests.java @@ -249,7 +249,7 @@ public void testStdioBug() throws ParserException { String code = buffer.toString(); for (ParserLanguage language : languages) { - IASTTranslationUnit tu = parse(code, language, true, true); + IASTTranslationUnit tu = parse(code, language, ScannerKind.GNU, true); final IASTPreprocessorMacroDefinition[] macroDefinitions = tu.getMacroDefinitions(); IASTPreprocessorObjectStyleMacroDefinition _PTR = (IASTPreprocessorObjectStyleMacroDefinition) macroDefinitions[0]; IASTPreprocessorFunctionStyleMacroDefinition _EXFUN = (IASTPreprocessorFunctionStyleMacroDefinition) macroDefinitions[2]; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java index 6a7b86be2f7..a182c06be61 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java @@ -204,7 +204,7 @@ private void assertFileLocation(IASTNode n, int offset, int length) { public void testBug83664() throws Exception { String code = "int foo(x) int x; {\n return x;\n }\n"; //$NON-NLS-1$ - IASTTranslationUnit tu = parse(code, ParserLanguage.C, true); + IASTTranslationUnit tu = parse(code, ParserLanguage.C, ScannerKind.GNU); IASTDeclaration[] declarations = tu.getDeclarations(); assertEquals(declarations.length, 1); IASTFunctionDefinition definition = (IASTFunctionDefinition) declarations[0]; @@ -412,7 +412,7 @@ public void testBug162180() throws Exception { buffer.append("int x;\n"); //$NON-NLS-1$ String code = buffer.toString(); for (ParserLanguage p : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(code, p, false, false); + IASTTranslationUnit tu = parse(code, p, ScannerKind.STD, false); IASTDeclaration[] decls = tu.getDeclarations(); assertEquals(decls.length, 1); IASTPreprocessorStatement[] statements = tu.getAllPreprocessorStatements(); @@ -439,7 +439,7 @@ public void testBug162180_0() throws Exception { buffer.append("int x;\n"); //$NON-NLS-1$ String code = buffer.toString(); for (ParserLanguage p : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(code, p, false, false); + IASTTranslationUnit tu = parse(code, p, ScannerKind.STD, false); IASTDeclaration[] decls = tu.getDeclarations(); IASTPreprocessorStatement[] statements = tu.getAllPreprocessorStatements(); IASTProblem[] problems = tu.getPreprocessorProblems(); @@ -462,7 +462,7 @@ public void test162180_1() throws Exception { buffer.append("int x2;\n"); // [37-44] String code = buffer.toString(); for (ParserLanguage p : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(code, p, false, false); + IASTTranslationUnit tu = parse(code, p, ScannerKind.STD, false); IASTDeclaration[] decls = tu.getDeclarations(); IASTPreprocessorStatement[] statements = tu.getAllPreprocessorStatements(); IASTProblem[] problems = tu.getPreprocessorProblems(); @@ -483,7 +483,7 @@ public void test162180_2() throws Exception { buffer.append("int x;\n"); String code = buffer.toString(); for (ParserLanguage p : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(code, p, false, false); + IASTTranslationUnit tu = parse(code, p, ScannerKind.STD, false); IASTDeclaration[] decls = tu.getDeclarations(); IASTPreprocessorStatement[] statements = tu.getAllPreprocessorStatements(); IASTProblem[] problems = tu.getPreprocessorProblems(); @@ -502,7 +502,7 @@ public void test162180_3() throws Exception { buffer.append("int x;\n"); String code = buffer.toString(); for (ParserLanguage p : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(code, p, false, false); + IASTTranslationUnit tu = parse(code, p, ScannerKind.STD, false); IASTDeclaration[] decls = tu.getDeclarations(); IASTPreprocessorStatement[] statements = tu.getAllPreprocessorStatements(); IASTProblem[] problems = tu.getPreprocessorProblems(); @@ -521,7 +521,7 @@ public void test162180_4() throws Exception { buffer.append("int x;\n"); String code = buffer.toString(); for (ParserLanguage p : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(code, p, false, false); + IASTTranslationUnit tu = parse(code, p, ScannerKind.STD, false); IASTDeclaration[] decls = tu.getDeclarations(); IASTProblem[] problems = tu.getPreprocessorProblems(); assertEquals(1, decls.length); @@ -597,7 +597,7 @@ public void testBug86698_2() throws Exception { public void testBug157009_1() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("#ifndef A\r\n#error X\r\n#else\r\n#error Y\r\n#endif"); - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, false, false); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, ScannerKind.STD, false); IASTProblem[] problems = tu.getPreprocessorProblems(); assertEquals(1, problems.length); @@ -607,7 +607,7 @@ public void testBug157009_1() throws Exception { public void testBug157009_2() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("#ifndef A\n#error X\n#else\n#error Y\n#endif"); - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, false, false); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, ScannerKind.STD, false); IASTProblem[] problems = tu.getPreprocessorProblems(); assertEquals(1, problems.length); @@ -618,7 +618,7 @@ public void testBug171520() throws Exception { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171520 StringBuilder buffer = new StringBuilder(); buffer.append("int i = sizeof(int);"); - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, false, false); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, ScannerKind.STD, false); IASTDeclaration[] decls = tu.getDeclarations(); assertEquals(1, decls.length); assertSoleLocation(decls[0], 0, buffer.length()); @@ -646,7 +646,7 @@ public void testBug120607() throws Exception { buffer.append("#unassert thisIsTrue(value)\n"); buffer.append("#invalid"); String code = buffer.toString(); - IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, true, false); + IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, ScannerKind.GNU, false); IASTProblem[] problems = tu.getPreprocessorProblems(); assertEquals(3, problems.length); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java index 0242505d264..fb0d903ca39 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java @@ -95,7 +95,7 @@ public void testIfnDef() throws Exception { public void testError() throws Exception { String msg = "Message"; StringBuilder buffer = new StringBuilder("#error " + msg + "\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, false, false); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, ScannerKind.STD, false); IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements(); assertEquals(1, st.length); assertTrue(st[0] instanceof IASTPreprocessorErrorStatement); @@ -161,7 +161,7 @@ public void testIfnDefWithSpaces() throws Exception { public void testErrorWithSpaces() throws Exception { String msg = "Message"; StringBuilder buffer = new StringBuilder("# error \t" + msg + " \n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, false, false); + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, ScannerKind.STD, false); IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements(); assertEquals(1, st.length); assertTrue(st[0] instanceof IASTPreprocessorErrorStatement); @@ -175,7 +175,7 @@ public void testMacroExpansion() throws Exception { sb.append("int x = add(foo, bar); \n"); String code = sb.toString(); - IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, false, false); + IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, ScannerKind.STD, false); IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements(); assertEquals(1, st.length); assertTrue(st[0] instanceof IASTPreprocessorFunctionStyleMacroDefinition); @@ -193,7 +193,7 @@ public void testMacroExpansion() throws Exception { // #endif public void testElifWithoutCondition_bug185324() throws Exception { CharSequence code = getContents(1)[0]; - IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, false); + IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, ScannerKind.STD, false); IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements(); assertEquals(3, st.length); assertTrue(st[0] instanceof IASTPreprocessorIfdefStatement); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/FaultToleranceTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/FaultToleranceTests.java index 45dbabb9260..f902391ba08 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/FaultToleranceTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/FaultToleranceTests.java @@ -55,7 +55,7 @@ public FaultToleranceTests(String name) { public void testCompositeTypeWithoutSemi() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(comment, lang, false, false); + IASTTranslationUnit tu = parse(comment, lang, ScannerKind.STD, false); IASTCompositeTypeSpecifier def = getCompositeType(tu, 1); IASTProblemDeclaration pdecl = getDeclaration(tu, 2); IASTSimpleDeclaration sdecl = getDeclaration(tu, 3); @@ -70,7 +70,7 @@ public void testCompositeTypeWithoutSemi() throws Exception { public void testCompositeTypeWithDtorWithoutSemi() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(comment, lang, false, false); + IASTTranslationUnit tu = parse(comment, lang, ScannerKind.STD, false); IASTSimpleDeclaration sdecl = getDeclaration(tu, 1); assertInstance(sdecl.getDeclSpecifier(), IASTCompositeTypeSpecifier.class); assertEquals(1, sdecl.getDeclarators().length); @@ -85,7 +85,7 @@ public void testCompositeTypeWithDtorWithoutSemi() throws Exception { public void testVariableWithoutSemi() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(comment, lang, false, false); + IASTTranslationUnit tu = parse(comment, lang, ScannerKind.STD, false); IASTSimpleDeclaration sdecl = getDeclaration(tu, 1); assertEquals("int a", sdecl.getRawSignature()); IASTProblemDeclaration pdecl = getDeclaration(tu, 2); @@ -99,7 +99,7 @@ public void testVariableWithoutSemi() throws Exception { public void testPrototypeWithoutSemi() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(comment, lang, false, false); + IASTTranslationUnit tu = parse(comment, lang, ScannerKind.STD, false); IASTSimpleDeclaration sdecl = getDeclaration(tu, 1); assertEquals("int a()", sdecl.getRawSignature()); IASTProblemDeclaration pdecl = getDeclaration(tu, 2); @@ -114,7 +114,7 @@ public void testPrototypeWithoutSemi() throws Exception { public void testExpressionWithoutSemi_314593() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(comment, lang, false, false); + IASTTranslationUnit tu = parse(comment, lang, ScannerKind.STD, false); IASTFunctionDefinition fdef = getDeclaration(tu, 0); IASTStatement stmt = getStatement(fdef, 0); assertEquals("int a= 1", stmt.getRawSignature()); @@ -130,7 +130,7 @@ public void testExpressionWithoutSemi_314593() throws Exception { public void testIncompleteCompositeType() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(comment, lang, false, false); + IASTTranslationUnit tu = parse(comment, lang, ScannerKind.STD, false); IASTCompositeTypeSpecifier comp = getCompositeType(tu, 0); IASTProblemDeclaration pdecl = getDeclaration(tu, 1); @@ -143,7 +143,7 @@ public void testIncompleteCompositeType() throws Exception { public void testIncompleteFunctionDefinition() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(comment, lang, false, false); + IASTTranslationUnit tu = parse(comment, lang, ScannerKind.STD, false); IASTFunctionDefinition fdef = getDeclaration(tu, 0); IASTProblemDeclaration pdecl = getDeclaration(tu, 1); @@ -155,7 +155,7 @@ public void testIncompleteFunctionDefinition() throws Exception { // int a; public void testIncompleteNamespace() throws Exception { final String comment = getAboveComment(); - IASTTranslationUnit tu = parse(comment, ParserLanguage.CPP, false, false); + IASTTranslationUnit tu = parse(comment, ParserLanguage.CPP, ScannerKind.STD, false); ICPPASTNamespaceDefinition ns = getDeclaration(tu, 0); IASTProblemDeclaration pdecl = getDeclaration(tu, 1); @@ -166,7 +166,7 @@ public void testIncompleteNamespace() throws Exception { // int a; public void testIncompleteLinkageSpec() throws Exception { final String comment = getAboveComment(); - IASTTranslationUnit tu = parse(comment, ParserLanguage.CPP, false, false); + IASTTranslationUnit tu = parse(comment, ParserLanguage.CPP, ScannerKind.STD, false); ICPPASTLinkageSpecification ls = getDeclaration(tu, 0); IASTProblemDeclaration pdecl = getDeclaration(tu, 1); @@ -179,7 +179,7 @@ public void testIncompleteLinkageSpec() throws Exception { public void testRangeOfProblemNode_Bug238151() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(comment, lang, false, false); + IASTTranslationUnit tu = parse(comment, lang, ScannerKind.STD, false); IASTFunctionDefinition fdef = getDeclaration(tu, 0); IASTProblemStatement pdecl = getStatement(fdef, 0); assertEquals("int a= offsetof(struct mystruct, singlechar);", pdecl.getRawSignature()); @@ -194,7 +194,7 @@ public void testRangeOfProblemNode_Bug238151() throws Exception { public void testProblemInIfExpression_Bug100321() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(comment, lang, false, false); + IASTTranslationUnit tu = parse(comment, lang, ScannerKind.STD, false); IASTFunctionDefinition fdef = getDeclaration(tu, 0); IASTIfStatement ifstmt = getStatement(fdef, 0); assertInstance(ifstmt.getConditionExpression(), IASTProblemExpression.class); @@ -209,7 +209,7 @@ public void testProblemInIfExpression_Bug100321() throws Exception { public void testUndefinedMacrosInFunctionDeclarations_Bug234085() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(comment, lang, false, false); + IASTTranslationUnit tu = parse(comment, lang, ScannerKind.STD, false); IASTProblemDeclaration pd = getDeclaration(tu, 0); assertEquals("_MYMACRO_", pd.getRawSignature()); IASTSimpleDeclaration sdecl = getDeclaration(tu, 1); @@ -239,7 +239,7 @@ public void testUndefinedMacrosInFunctionDeclarations_Bug234085() throws Excepti public void testEnumProblem() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse(comment, lang, false, false); + IASTTranslationUnit tu = parse(comment, lang, ScannerKind.STD, false); IASTSimpleDeclaration e = getDeclaration(tu, 0); IASTProblemDeclaration p = getDeclaration(tu, 1); assertEquals("J, K };", p.getRawSignature()); @@ -254,7 +254,7 @@ public void testEnumProblem() throws Exception { // }; public void testEnumError_Bug72685() throws Exception { final String comment = getAboveComment(); - IASTTranslationUnit tu = parse(comment, ParserLanguage.CPP, false, false); + IASTTranslationUnit tu = parse(comment, ParserLanguage.CPP, ScannerKind.STD, false); IASTCompositeTypeSpecifier ct = getCompositeType(tu, 0); IASTSimpleDeclaration e = getDeclaration(ct, 0); IASTProblemDeclaration p = getDeclaration(ct, 1); @@ -269,12 +269,12 @@ public void testEnumError_Bug72685() throws Exception { // ); // int d; public void testErrorRecovery_273759() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, false, false); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, ScannerKind.STD, false); IASTSimpleDeclaration s = getDeclaration(tu, 0); IASTProblemDeclaration p = getDeclaration(tu, 1); s = getDeclaration(tu, 2); - tu = parse(getAboveComment(), ParserLanguage.CPP, false, false); + tu = parse(getAboveComment(), ParserLanguage.CPP, ScannerKind.STD, false); s = getDeclaration(tu, 0); p = getDeclaration(tu, 1); s = getDeclaration(tu, 2); @@ -313,7 +313,7 @@ public void testErrorRecovery_273759() throws Exception { // } public void testPerformanceIssue_364108() throws Exception { final String comment = getAboveComment(); - parse(comment, ParserLanguage.CPP, false, false); - parse(comment, ParserLanguage.C, false, false); + parse(comment, ParserLanguage.CPP, ScannerKind.STD, false); + parse(comment, ParserLanguage.C, ScannerKind.STD, false); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java index 531cb5bd75f..d170900ee05 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java @@ -44,7 +44,7 @@ public GCCCompleteParseExtensionsTest(String name) { } private IASTTranslationUnit parseGCC(String code) throws ParserException { - IASTTranslationUnit tu = parse(code, ParserLanguage.C, true, true); + IASTTranslationUnit tu = parse(code, ParserLanguage.C, ScannerKind.GNU, true); CNameResolver resolver = new CNameResolver(); tu.accept(resolver); @@ -56,7 +56,7 @@ private IASTTranslationUnit parseGCC(String code) throws ParserException { } private IASTTranslationUnit parseGPP(String code) throws ParserException { - IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, true, true); + IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, ScannerKind.GNU, true); CPPNameResolver resolver = new CPPNameResolver(); tu.accept(resolver); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TaskParserTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TaskParserTest.java index 891fdaafa90..e3939ca04ea 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TaskParserTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TaskParserTest.java @@ -39,7 +39,7 @@ public void testTaskParser() throws Exception { String code = "/* TODO tag 1\n" + " * FIXME tag 2\n" + " */\n" + "\n" + "// TODO(my name): tag 3\n" + "// TODO(his name): tag 4\n" + "// todo Not a tag\n" + "// TODO FIXME tag 5\n" + "\n" + "const char* x = \"TODO Not a tag\";"; - IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, false, true); + IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, ScannerKind.STD, true); TodoTaskParser parser = new TodoTaskParser(taskTags, taskPriorities, isTaskCaseSensitive); Task[] tasks = parser.parse(tu.getComments()); 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.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 @@ protected class AssertionHelper extends AST2AssertionHelper { 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 @@ protected AssertionHelper getCPPAssertionHelper() throws ParserException, IOExce 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 void testSimpleAccess() throws Exception { 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); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTestSourceFile.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTestSourceFile.java index 6de1935ec1e..3752ede10ae 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTestSourceFile.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTestSourceFile.java @@ -15,6 +15,7 @@ package org.eclipse.cdt.core.parser.tests.rewrite.astwriter; import org.eclipse.cdt.core.parser.ParserLanguage; +import org.eclipse.cdt.core.parser.tests.ast2.AST2TestBase.ScannerKind; import org.eclipse.cdt.core.parser.tests.rewrite.TestSourceFile; /** @@ -22,7 +23,7 @@ */ public class ASTWriterTestSourceFile extends TestSourceFile { private ParserLanguage parserLanguage = ParserLanguage.CPP; - private boolean useGNUExtensions = false; + private ScannerKind scannerKind = ScannerKind.STD; public ASTWriterTestSourceFile(String name) { super(name); @@ -36,11 +37,11 @@ public ParserLanguage getParserLanguage() { return parserLanguage; } - public boolean isUseGNUExtensions() { - return useGNUExtensions; + public ScannerKind getScannerKind() { + return scannerKind; } - public void setUseGNUExtensions(boolean useGNUExtensions) { - this.useGNUExtensions = useGNUExtensions; + public void setScannerKind(ScannerKind scannerKind) { + this.scannerKind = scannerKind; } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTester.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTester.java index 17b7480144e..c7cd80c8c4b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTester.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTester.java @@ -32,6 +32,7 @@ import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.core.parser.tests.ast2.AST2TestBase; +import org.eclipse.cdt.core.parser.tests.ast2.AST2TestBase.ScannerKind; import org.eclipse.cdt.core.parser.tests.rewrite.RewriteBaseTest; import org.eclipse.cdt.core.parser.tests.rewrite.TestHelper; import org.eclipse.cdt.core.parser.tests.rewrite.TestSourceFile; @@ -94,16 +95,16 @@ public String generateSource(TestSourceFile testFile) throws Exception { protected ISourceCodeParser getParser(TestSourceFile testFile) throws Exception { FileContent codeReader = FileContent.create(file); - ScannerInfo scannerInfo = new ScannerInfo(); ParserLanguage language = getLanguage(testFile); - boolean useGNUExtensions = getGNUExtension(testFile); + ScannerKind scannerKind = getScannerKind(testFile); + ScannerInfo scannerInfo = AST2TestBase.createScannerInfo(scannerKind); IScanner scanner = AST2TestBase.createScanner(codeReader, language, ParserMode.COMPLETE_PARSE, scannerInfo); ISourceCodeParser parser = null; if (language == ParserLanguage.CPP) { ICPPParserExtensionConfiguration config = null; - if (useGNUExtensions) { + if (scannerKind.isUseGNUExtensions()) { config = new GPPParserExtensionConfiguration(); } else { config = new ANSICPPParserExtensionConfiguration(); @@ -112,7 +113,7 @@ protected ISourceCodeParser getParser(TestSourceFile testFile) throws Exception } else { ICParserExtensionConfiguration config = null; - if (useGNUExtensions) { + if (scannerKind.isUseGNUExtensions()) { config = new GCCParserExtensionConfiguration(); } else { config = new ANSICParserExtensionConfiguration(); @@ -123,10 +124,10 @@ protected ISourceCodeParser getParser(TestSourceFile testFile) throws Exception return parser; } - private boolean getGNUExtension(TestSourceFile file) { + private ScannerKind getScannerKind(TestSourceFile file) { if (file instanceof ASTWriterTestSourceFile) - return ((ASTWriterTestSourceFile) file).isUseGNUExtensions(); - return false; + return ((ASTWriterTestSourceFile) file).getScannerKind(); + return ScannerKind.STD; } private ParserLanguage getLanguage(TestSourceFile file) { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/SourceRewriteTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/SourceRewriteTest.java index 8e1333480f2..4709a38eea3 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/SourceRewriteTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/SourceRewriteTest.java @@ -22,6 +22,7 @@ import java.util.regex.Pattern; import org.eclipse.cdt.core.parser.ParserLanguage; +import org.eclipse.cdt.core.parser.tests.ast2.AST2TestBase.ScannerKind; import org.eclipse.cdt.core.parser.tests.rewrite.RewriteBaseTest; import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.core.runtime.FileLocator; @@ -34,7 +35,7 @@ public class SourceRewriteTest extends TestSuite { private static final String testRegexp = "//!(.*)\\s*(\\w*)*$"; //$NON-NLS-1$ - private static final String codeTypeRegexp = "//%(C|CPP)( GNU)?$"; //$NON-NLS-1$ + private static final String codeTypeRegexp = "//%(C|CPP|CPP20)( GNU)?$"; //$NON-NLS-1$ private static final String resultRegexp = "//=.*$"; //$NON-NLS-1$ enum MatcherState { @@ -149,7 +150,7 @@ private static ArrayList createTests(BufferedReader inputReader matcherState = MatcherState.inSource; if (file != null) { file.setParserLanguage(getParserLanguage(line)); - file.setUseGNUExtensions(useGNUExtensions(line)); + file.setScannerKind(getScannerKind(line)); } continue; } @@ -172,17 +173,20 @@ private static ArrayList createTests(BufferedReader inputReader return testCases; } - protected static boolean useGNUExtensions(String line) { + protected static ScannerKind getScannerKind(String line) { Matcher matcherBeginOfTest = createMatcherFromString(codeTypeRegexp, line); if (matcherBeginOfTest.find()) { - String codeType = matcherBeginOfTest.group(2); - if (codeType == null) { - return false; + String codeType = matcherBeginOfTest.group(1); + String gnuExtensionsType = matcherBeginOfTest.group(2); + if (gnuExtensionsType == null) { + if (codeType.equalsIgnoreCase("CPP20")) { //$NON-NLS-1$ + return ScannerKind.STDCPP20; + } } else { - return true; + return ScannerKind.GNU; } } - return false; + return ScannerKind.STD; } protected static ParserLanguage getParserLanguage(String line) { @@ -191,6 +195,8 @@ protected static ParserLanguage getParserLanguage(String line) { String codeType = matcherBeginOfTest.group(1); if (codeType.equalsIgnoreCase("CPP")) { //$NON-NLS-1$ return ParserLanguage.CPP; + } else if (codeType.equalsIgnoreCase("CPP20")) { //$NON-NLS-1$ + return ParserLanguage.CPP; } else { return ParserLanguage.C; } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LexerTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LexerTests.java index 6fef3fe2675..6edc6b13712 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LexerTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LexerTests.java @@ -29,14 +29,18 @@ public class LexerTests extends BaseTestCase { private static final LexerOptions DEFAULT_OPTIONS = new LexerOptions(); private static final LexerOptions NO_DOLLAR = new LexerOptions(); private static final LexerOptions NO_MINMAX = new LexerOptions(); + private static final LexerOptions NO_MINMAX_CPP = new LexerOptions(); private static final LexerOptions SLASH_PERCENT = new LexerOptions(); private static final LexerOptions CPP_OPTIONS = new LexerOptions(); static { NO_DOLLAR.fSupportDollarInIdentifiers = false; NO_MINMAX.fSupportMinAndMax = false; + NO_MINMAX_CPP.fSupportMinAndMax = false; + NO_MINMAX_CPP.fSupportThreeWayComparisonOperator = true; SLASH_PERCENT.fSupportSlashPercentComments = true; CPP_OPTIONS.fSupportRawStringLiterals = true; CPP_OPTIONS.fSupportDigitSeparators = true; + CPP_OPTIONS.fSupportThreeWayComparisonOperator = true; } static String TRIGRAPH_REPLACES_CHARS = "#^[]|{}~\\"; @@ -716,11 +720,26 @@ public void testOperatorAndPunctuators() throws Exception { IToken.tGTEQUAL, IToken.tAND, IToken.tOR, IToken.tINCR, IToken.tDECR, IToken.tCOMMA, IToken.tARROWSTAR, IToken.tARROW, IGCCToken.tMIN, IGCCToken.tMAX, Lexer.tOTHER_CHARACTER, }; + verifyOperatorAndPunctuators(ops, tokens, DEFAULT_OPTIONS, NO_MINMAX); + } + + public void testOperatorAndPunctuatorsCpp20() throws Exception { + final String ops = "<<>><<=>>===!=<=>>=<=&&"; + + final int[] tokens = new int[] { IToken.tSHIFTL, IToken.tSHIFTR, IToken.tSHIFTLASSIGN, IToken.tSHIFTRASSIGN, + IToken.tEQUAL, IToken.tNOTEQUAL, IToken.tTHREEWAYCOMPARISON, IToken.tGTEQUAL, IToken.tLTEQUAL, + IToken.tAND, }; + + verifyOperatorAndPunctuators(ops, tokens, CPP_OPTIONS, NO_MINMAX_CPP); + } + + private void verifyOperatorAndPunctuators(String ops, int[] tokens, LexerOptions options, + LexerOptions optionsNoMinMax) throws Exception { for (int splices = 0; splices < 9; splices++) { for (int trigraphs = 0; trigraphs < 6; trigraphs++) { StringBuilder buf = new StringBuilder(); String input = useTrigraphs(ops.toCharArray(), trigraphs); - init(instertLineSplices(input, splices)); + init(instertLineSplices(input, splices), options); for (int token2 : tokens) { Token token = fLexer.currentToken(); buf.append(token.getCharImage()); @@ -729,7 +748,7 @@ public void testOperatorAndPunctuators() throws Exception { eof(); assertEquals(ops, buf.toString()); // check token image - init(input, NO_MINMAX); + init(input, optionsNoMinMax); for (int token : tokens) { switch (token) { case IGCCToken.tMIN: diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterExpressionTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterExpressionTestSource.awts index 03e210bec9e..13f7a50fc11 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterExpressionTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterExpressionTestSource.awts @@ -84,6 +84,10 @@ bool b = 1 != x; int i = a.x; int i = a->x; +//!CPP20BinaryExpression +//%CPP20 +auto r = x <=> y; + //!BinaryExpression with MacroExpansions //%CPP #define ZWO 2 diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF index 27b238fe1ac..723c5cf2840 100644 --- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.core; singleton:=true -Bundle-Version: 8.0.100.qualifier +Bundle-Version: 8.1.0.qualifier Bundle-Activator: org.eclipse.cdt.core.CCorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java index a8bb67cfdd5..63f376c1188 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java @@ -1167,6 +1167,8 @@ public static char[] getBinaryOperatorString(IASTBinaryExpression be) { return Keywords.cpEQUAL; case IASTBinaryExpression.op_notequals: return Keywords.cpNOTEQUAL; + case IASTBinaryExpression.op_threewaycomparison: + return Keywords.cpTHREEWAYCOMPARISON; case IASTBinaryExpression.op_max: return Keywords.cpMAX; case IASTBinaryExpression.op_min: diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java index d3ac4a8b088..cae8555cda0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java @@ -1311,6 +1311,9 @@ public static String getBinaryOperatorString(IASTBinaryExpression be) { case IASTBinaryExpression.op_notequals: opString = String.valueOf(Keywords.cpNOTEQUAL); break; + case IASTBinaryExpression.op_threewaycomparison: + opString = String.valueOf(Keywords.cpTHREEWAYCOMPARISON); + break; case IASTBinaryExpression.op_max: opString = String.valueOf(Keywords.cpMAX); break; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java index af70cd64de0..45ee9eddc70 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java @@ -226,6 +226,13 @@ public interface IASTBinaryExpression extends IASTExpression { */ public static final int op_ellipses = 34; + /** + * For c++, only. + * op_threewaycompare represents <=> three-way comparison operator. + * @since 8.1 + */ + public static final int op_threewaycomparison = 35; + /** * Get the first operand. * diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java index 7fbc0234437..007150f5d6c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java @@ -85,6 +85,8 @@ public interface IToken { int tNOTEQUAL = 35; int tNOT = 36; int tEQUAL = 37; + /** @since 8.1 */ + int tTHREEWAYCOMPARISON = 8001; int tASSIGN = 38; int tUNKNOWN_CHAR = 39; int tSHIFTL = 40; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java index 88b56e076db..2d066c10aa1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java @@ -279,6 +279,8 @@ public class Keywords { public static final char[] cpNOTEQUAL = "!=".toCharArray(); public static final char[] cpNOT = "!".toCharArray(); public static final char[] cpEQUAL = "==".toCharArray(); + /** @since 8.1 */ + public static final char[] cpTHREEWAYCOMPARISON = "<=>".toCharArray(); public static final char[] cpASSIGN = "=".toCharArray(); public static final char[] cpSHIFTL = "<<".toCharArray(); public static final char[] cpLTEQUAL = "<=".toCharArray(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousBinaryVsCastExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousBinaryVsCastExpression.java index 562956b5ca6..65dc11bd7e5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousBinaryVsCastExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousBinaryVsCastExpression.java @@ -224,19 +224,21 @@ private int getPrecendence(IASTBinaryExpression r) { case IASTBinaryExpression.op_max: case IASTBinaryExpression.op_min: return 7; + case IASTBinaryExpression.op_threewaycomparison: + return 8; case IASTBinaryExpression.op_shiftLeft: case IASTBinaryExpression.op_shiftRight: - return 8; + return 9; case IASTBinaryExpression.op_plus: case IASTBinaryExpression.op_minus: - return 9; + return 10; case IASTBinaryExpression.op_multiply: case IASTBinaryExpression.op_divide: case IASTBinaryExpression.op_modulo: - return 10; + return 11; case IASTBinaryExpression.op_pmarrow: case IASTBinaryExpression.op_pmdot: - return 11; + return 12; } assert false; return 0; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java index 9b7b8232643..440e8bc6ebe 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java @@ -1123,6 +1123,9 @@ private IASTExpression buildExpression(IASTExpression left, BinaryOperator opera case IToken.tNOTEQUAL: op = IASTBinaryExpression.op_notequals; break; + case IToken.tTHREEWAYCOMPARISON: + op = IASTBinaryExpression.op_threewaycomparison; + break; case IToken.tGT: op = IASTBinaryExpression.op_greaterThan; break; @@ -2731,6 +2734,7 @@ protected boolean canBeCastExpression() throws EndOfFileException { case IToken.tDOT: case IToken.tDOTSTAR: case IToken.tEQUAL: + case IToken.tTHREEWAYCOMPARISON: case IToken.tGT: case IToken.tGT_in_SHIFTR: case IToken.tGTEQUAL: diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ValueFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ValueFactory.java index 68651b83224..2b08f3223a0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ValueFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ValueFactory.java @@ -224,6 +224,10 @@ private static IntegralValue applyBinaryOperator(final int op, final long v1, fi case IASTBinaryExpression.op_greaterEqual: value = v1 >= v2 ? 1l : 0l; break; + case IASTBinaryExpression.op_threewaycomparison: + // TODO: implement for <=> + value = v1 < v2 ? -1l : (v1 > v2 ? 1l : 0); + break; case IASTBinaryExpression.op_binaryAnd: value = v1 & v2; break; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java index 594a4240d0d..ef5e55a71d0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java @@ -439,6 +439,7 @@ protected Optional rwInBinaryExpression(IASTNode node, IASTBinaryExpres case IASTBinaryExpression.op_notequals: case IASTBinaryExpression.op_shiftLeft: case IASTBinaryExpression.op_shiftRight: + case IASTBinaryExpression.op_threewaycomparison: return Optional.of(READ); case IASTBinaryExpression.op_minus: diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java index b93f604f461..420f943ff31 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java @@ -234,6 +234,10 @@ public IType getExpressionType() { case op_notequals: return new CBasicType(Kind.eInt, 0, this); + case op_threewaycomparison: + // TODO: implement for <=> + break; + case IASTBinaryExpression.op_plus: if (type1 instanceof IArrayType) { return Conversions.arrayTypeToPointerType((ICArrayType) type1); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java index 4709d51a4e7..c85bad81c44 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java @@ -1121,6 +1121,9 @@ private ICPPASTExpression expression(final ExprKind kind, final BinaryExprCtx ct case IGCCToken.tMIN: lastOperator = new BinaryOperator(lastOperator, expr, lt1, 90, 91); break; + case IToken.tTHREEWAYCOMPARISON: + lastOperator = new BinaryOperator(lastOperator, expr, lt1, 95, 96); + break; case IToken.tGT_in_SHIFTR: if (ctx == BinaryExprCtx.eInTemplateID) { doneExpression = true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/OverloadableOperator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/OverloadableOperator.java index 5303b2c5367..5df33da292a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/OverloadableOperator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/OverloadableOperator.java @@ -34,9 +34,9 @@ public enum OverloadableOperator { GT(">"), LT("<"), NOT("!"), BITCOMPLEMENT("~"), BITOR("|"), AMPER("&"), XOR("^"), MOD("%"), DIV("/"), STAR("*"), PLUS("+"), BRACKET("[]"), PAREN("()"), ARROW("->"), ARROWSTAR("->*"), COMMA(","), MINUS("-"), DECR("--"), INCR("++"), OR("||"), AND("&&"), ASSIGN("="), GTEQUAL(">="), LTEQUAL("<="), NOTEQUAL("!="), EQUAL("=="), - SHIFTR(">>"), SHIFTL("<<"), SHIFTLASSIGN("<<="), SHIFTRASSIGN(">>="), BITORASSIGN("|="), AMPERASSIGN("&="), - XORASSIGN("^="), MODASSIGN("%="), DIVASSIGN("/="), STARASSIGN("*="), MINUSASSIGN("-="), PLUSASSIGN("+="), - NEW("new"), DELETE_ARRAY("delete[]"), DELETE("delete"), NEW_ARRAY("new[]"), + SHIFTR(">>"), SHIFTL("<<"), SHIFTLASSIGN("<<="), SHIFTRASSIGN(">>="), THREEWAYCOMPARISON("<=>"), BITORASSIGN("|="), + AMPERASSIGN("&="), XORASSIGN("^="), MODASSIGN("%="), DIVASSIGN("/="), STARASSIGN("*="), MINUSASSIGN("-="), + PLUSASSIGN("+="), NEW("new"), DELETE_ARRAY("delete[]"), DELETE("delete"), NEW_ARRAY("new[]"), /** * Cannot be overloaded by the user, however overload resolution needs to be performed. @@ -155,6 +155,8 @@ public static OverloadableOperator valueOf(IToken token) { return LT; case IToken.tLTEQUAL: return LTEQUAL; + case IToken.tTHREEWAYCOMPARISON: + return THREEWAYCOMPARISON; // other case IToken.tASSIGN: @@ -247,6 +249,8 @@ public static OverloadableOperator fromBinaryExpression(int binaryOp) { return LT; case IASTBinaryExpression.op_lessEqual: return LTEQUAL; + case IASTBinaryExpression.op_threewaycomparison: + return THREEWAYCOMPARISON; // other case IASTBinaryExpression.op_assign: diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java index 26276e39bfe..ab6e4ce51f3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java @@ -167,6 +167,10 @@ private ICPPFunction[] create() { comparison(true); break; + case THREEWAYCOMPARISON: + // TODO: implement for <=> + break; + case GT: case GTEQUAL: case LT: diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java index 8cfda662951..e9408f89e1a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java @@ -45,6 +45,7 @@ import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_shiftLeftAssign; import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_shiftRight; import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_shiftRightAssign; +import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_threewaycomparison; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.glvalueType; @@ -388,6 +389,10 @@ public IType computeType() { case op_notequals: return CPPBasicType.BOOLEAN; + case op_threewaycomparison: + // TODO: implement for <=> + return ProblemType.UNKNOWN_FOR_EXPRESSION; + case op_plus: if (type1 instanceof IPointerType) { return ExpressionTypes.restoreTypedefs(type1, originalType1); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java index f335097b89a..cd5cc76cf33 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java @@ -91,6 +91,7 @@ public class ExpressionWriter extends NodeWriter { private static final String ELLIPSES = " ... "; //$NON-NLS-1$ private static final String NOT_EQUALS_OP = " != "; //$NON-NLS-1$ private static final String EQUALS_OP = " == "; //$NON-NLS-1$ + private static final String THREEWAYCOMPARISON_OP = " <=> "; //$NON-NLS-1$ private static final String BINARY_OR_ASSIGN = " |= "; //$NON-NLS-1$ private static final String BINARY_XOR_ASSIGN_OP = " ^= "; //$NON-NLS-1$ private static final String BINARY_AND_ASSIGN_OP = " &= "; //$NON-NLS-1$ @@ -226,6 +227,8 @@ private String getBinaryExpressionOperator(int operator) { return EQUALS_OP; case IASTBinaryExpression.op_notequals: return NOT_EQUALS_OP; + case IASTBinaryExpression.op_threewaycomparison: + return THREEWAYCOMPARISON_OP; case ICPPASTBinaryExpression.op_pmdot: return PMDOT_OP; case ICPPASTBinaryExpression.op_pmarrow: diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java index 4a8762f0af7..efd581d5661 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java @@ -99,6 +99,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { private static final int ORIGIN_INACTIVE_CODE = OffsetLimitReachedException.ORIGIN_INACTIVE_CODE; private static final char[] ONE = "1".toCharArray(); //$NON-NLS-1$ + private static final char[] CPP_IMPL_THREE_WAY_COMPARISON = "__cpp_impl_three_way_comparison".toCharArray(); //$NON-NLS-1$ // Standard built-ins private static final ObjectStyleMacro __CDT_PARSER__ = new ObjectStyleMacro("__CDT_PARSER__".toCharArray(), //$NON-NLS-1$ @@ -352,6 +353,10 @@ public CPreprocessor(FileContent fileContent, IScannerInfo info, ParserLanguage fIncludeSearchPath = configureIncludeSearchPath(new File(contextPath).getParentFile(), info); setupMacroDictionary(configuration, info, language); + if (fMacroDictionary.containsKey(CPP_IMPL_THREE_WAY_COMPARISON)) { + fLexOptions.fSupportThreeWayComparisonOperator = true; + } + ILocationCtx ctx = fLocationMap.pushTranslationUnit(fRootContent.getFileLocation(), fRootContent.getSource()); Lexer lexer = new Lexer(fRootContent.getSource(), fLexOptions, this, this); fRootContext = fCurrentContext = new ScannerContext(ctx, null, lexer); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java index 98b8f29e007..0f509b022c9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java @@ -63,6 +63,7 @@ public final static class LexerOptions implements Cloneable { public boolean fSupportRawStringLiterals = false; public boolean fSupportUserDefinedLiterals = false; public boolean fSupportDigitSeparators = false; + public boolean fSupportThreeWayComparisonOperator = false; public IncludeExportPatterns fIncludeExportPatterns; @Override @@ -641,7 +642,13 @@ private Token fetchToken() throws OffsetLimitReachedException { switch (d) { case '=': - nextCharPhase3(); + final int se = nextCharPhase3(); + if (fOptions.fSupportThreeWayComparisonOperator) { + if (se == '>') { + nextCharPhase3(); + return newToken(IToken.tTHREEWAYCOMPARISON, start); + } + } return newToken(IToken.tLTEQUAL, start); case '<': final int e = nextCharPhase3(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/TokenUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/TokenUtil.java index 910451816f5..a56716ec4a1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/TokenUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/TokenUtil.java @@ -78,6 +78,7 @@ public static boolean isOperator(int kind) { case IToken.tGTEQUAL: case IToken.tLT: case IToken.tLTEQUAL: + case IToken.tTHREEWAYCOMPARISON: // other case IToken.tASSIGN: @@ -164,6 +165,8 @@ public static char[] getImage(int type) { return Keywords.cpNOT; case IToken.tEQUAL: return Keywords.cpEQUAL; + case IToken.tTHREEWAYCOMPARISON: + return Keywords.cpTHREEWAYCOMPARISON; case IToken.tASSIGN: return Keywords.cpASSIGN; case IToken.tSHIFTL: diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/DwarfConstants.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/DwarfConstants.java index f38a8c80106..6508da7ff62 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/DwarfConstants.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/DwarfConstants.java @@ -209,7 +209,7 @@ public class DwarfConstants { */ public final static int DW_FORM_flag_present = 0x19; /** - * @since 8.0 + * @since 8.1 */ public final static int DW_FORM_line_strp = 0x1f; /** diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/BindingClassifier.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/BindingClassifier.java index b8287e83117..0d24c71443b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/BindingClassifier.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/BindingClassifier.java @@ -650,6 +650,11 @@ public int leave(IASTExpression expression) { } } + if (binaryExpression.getOperator() == IASTBinaryExpression.op_threewaycomparison) { + // TODO: implement for three-way comparison operator x <=> y + return PROCESS_CONTINUE; + } + IType operand1Type = binaryExpression.getOperand1().getExpressionType(); IASTInitializerClause operand2 = binaryExpression.getInitOperand2(); IType operand2Type;