Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonah Graham2018-11-20 16:20:42 +0000
committerJonah Graham2018-11-22 21:47:02 +0000
commit170e654b4796bad1453ae85a427b97317d67a69a (patch)
tree6ca9b8a8fedd5fd25f97eb79c408312e256ff981 /core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2
parent35996a5c5ca5c254959ba48241eaada6dbf8628d (diff)
downloadorg.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.tar.gz
org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.tar.xz
org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.zip
Bug 540373: Cleanup: Format & Remove trailing whitespace
This was done by selecting all projects in Eclipse then Source -> Clean Up... -> choosing: - Format source code - Remove trailing white spaces on all lines and completing the wizard Change-Id: I63685372c6bcc67719bcf145123bcb72e5b00394
Diffstat (limited to 'core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java12
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPImplicitNameTests.java50
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java367
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTestBase.java6
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java1937
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java184
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTestCase.java126
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java1204
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java1606
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTestBase.java130
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecTestBase.java167
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java1072
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java426
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java3129
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilOldTests.java671
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java242
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTCPPSpecDefectTests.java22
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTInactiveCodeTests.java155
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTNodeSelectorTest.java428
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AccessControlTests.java24
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CharArrayMapTest.java139
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java76
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java2595
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMFileBasePluginTest.java191
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCParserExtensionTestSuite.java12
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCSelectionParseExtensionsTest.java13
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationMacroTests.java872
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java1374
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java117
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSearchUtil.java217
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTest.java892
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTestBase.java25
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/FaultToleranceTests.java412
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java468
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCTests.java1557
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ImageLocationTests.java98
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/LanguageExtensionsTest.java276
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java2929
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticTestBase.java566
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticsTests.java39
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TaskParserTest.java48
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TestLexerLog.java12
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TypeTraitsTests.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/VariableReadWriteFlagsTest.java11
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaIndexTests.java16
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaTests.java6
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/InitCaptureTests.java26
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionIndexTests.java8
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionTests.java62
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/VariableTemplateTests.java22
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/AllConstexprEvalTests.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ArrayTests.java78
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryExpressionTests.java32
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryOperatorOverloadingTests.java52
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/CStringValueTests.java46
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ClassTemplateTests.java48
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ConstructorTests.java175
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/DoWhileStatementTests.java42
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FloatingPointValueTests.java56
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ForStatementTests.java74
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTemplateTests.java114
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTests.java100
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IfStatementTests.java92
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IntegralValueTests.java122
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberFunctionTests.java66
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberVariableTests.java88
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/PointerTests.java136
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/RangeBasedForStatementTests.java96
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ReferenceTests.java38
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/SwitchStatementTests.java71
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TestBase.java10
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TypeAliasTests.java30
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryExpressionTests.java94
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryOperatorOverloadingTests.java38
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UserDefinedLiteralTests.java100
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/WhileStatementTests.java46
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx17/LambdaExpressionTests.java6
78 files changed, 13772 insertions, 13121 deletions
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 1ed102a602e..d64b48a1a45 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
@@ -140,7 +140,8 @@ public class AST2CPPAttributeTests extends AST2TestBase {
return specifier.getAttributes();
}
- private void checkAttributeRelations(List<IASTAttributeSpecifier> specifiers, Class<? extends IASTAttributeOwner>... parentType) {
+ private void checkAttributeRelations(List<IASTAttributeSpecifier> specifiers,
+ Class<? extends IASTAttributeOwner>... parentType) {
assertEquals(parentType.length, specifiers.size());
for (int i = 0; i < specifiers.size(); i++) {
IASTAttributeSpecifier specifier = specifiers.get(i);
@@ -487,9 +488,8 @@ public class AST2CPPAttributeTests extends AST2TestBase {
IASTAttribute attribute = attributes[0];
IASTToken argumentClause = attribute.getArgumentClause();
final int startOffset = 8;
- final String[] tokenImages = new String[] { "this", "(", "is", ")", "{", "[",
- "my", "]", "}", "(", "argument", "[", "with", "]", "{", "some",
- "}", ",", "parentheses", ")"};
+ final String[] tokenImages = new String[] { "this", "(", "is", ")", "{", "[", "my", "]", "}", "(", "argument",
+ "[", "with", "]", "{", "some", "}", ",", "parentheses", ")" };
argumentClause.accept(new TokenPositionCheckVisitor(startOffset, tokenImages));
}
@@ -526,7 +526,6 @@ public class AST2CPPAttributeTests extends AST2TestBase {
checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTFunctionDeclarator.class);
}
-
// enum E {
// value1 [[attr1]], value2 [[attr2]] = 1
// };
@@ -539,7 +538,8 @@ public class AST2CPPAttributeTests extends AST2TestBase {
//}
public void testAttributedFunctionParameter_Bug535275() throws Exception {
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true);
- checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTParameterDeclaration.class, ICPPASTSimpleDeclSpecifier.class);
+ checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTParameterDeclaration.class,
+ ICPPASTSimpleDeclSpecifier.class);
}
//namespace [[attr]] NS {}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPImplicitNameTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPImplicitNameTests.java
index 5276fa4b5e6..3f3b11961a8 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPImplicitNameTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPImplicitNameTests.java
@@ -52,7 +52,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
}
protected BindingAssertionHelper getAssertionHelper() throws ParserException, IOException {
- String code= getAboveComment();
+ String code = getAboveComment();
return new AST2AssertionHelper(code, ParserLanguage.CPP);
}
@@ -104,7 +104,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// +p;
// }
public void testBinaryExpressions() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTTranslationUnit tu = ba.getTranslationUnit();
NameCollector col = new NameCollector();
tu.accept(col);
@@ -148,7 +148,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// *y; //2
// }
public void testPointerDereference() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertImplicitName("*x;", 1, ICPPFunction.class);
ba.assertNoImplicitName("*y; //2", 1);
}
@@ -166,7 +166,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// X* px2 = &y; // overloaded
// }
public void testPointerToMember() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTTranslationUnit tu = ba.getTranslationUnit();
NameCollector col = new NameCollector();
tu.accept(col);
@@ -227,7 +227,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// (++p1).x; //2
// }
public void testUnaryPrefixAndPostfix() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertImplicitName("++).x; //1", 2, ICPPFunction.class);
ba.assertImplicitName("++p1).x; //2", 2, ICPPMethod.class);
}
@@ -253,7 +253,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// test(a, b, c, d); // func
// }
public void testCommaOperator1() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
// expression lists are used in function calls but they should not resolve to the comma operator
ba.assertNoImplicitName(", b, c, d); // func", 1);
ba.assertNoImplicitName(", c, d); // func", 1);
@@ -319,7 +319,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// x(1, 2); // 3
// }
public void testFunctionCallOperator() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTTranslationUnit tu = ba.getTranslationUnit();
NameCollector col = new NameCollector();
tu.accept(col);
@@ -360,7 +360,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// b = a; // should not resolve
// }
public void testCopyAssignmentOperator() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNoImplicitName("= a;", 1);
}
@@ -378,7 +378,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// func(y[q]); //2
// }
public void testArraySubscript() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTTranslationUnit tu = ba.getTranslationUnit();
NameCollector col = new NameCollector();
tu.accept(col);
@@ -413,7 +413,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// delete 1;
// }
public void testDelete() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTImplicitName[] names = ba.getImplicitNames("delete x;", 6);
assertEquals(2, names.length);
IASTImplicitName destructor = names[0];
@@ -447,9 +447,9 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// delete b;
// }
public void testOverloadedDelete_Bug351547() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
- IBinding m= bh.assertNonProblem("operator delete(void * a)", 15);
- IBinding f= bh.assertNonProblem("operator delete(void * b)", 15);
+ BindingAssertionHelper bh = getAssertionHelper();
+ IBinding m = bh.assertNonProblem("operator delete(void * a)", 15);
+ IBinding f = bh.assertNonProblem("operator delete(void * b)", 15);
IASTImplicitName[] names = bh.getImplicitNames("delete a;", 6);
assertEquals(2, names.length);
@@ -474,9 +474,9 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// B* b = new B;
// }
public void testOverloadedNew_Bug354585() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
- IBinding m= bh.assertNonProblem("operator new(size_t a)", 12);
- IBinding f= bh.assertNonProblem("operator new(size_t b)", 12);
+ BindingAssertionHelper bh = getAssertionHelper();
+ IBinding m = bh.assertNonProblem("operator new(size_t a)", 12);
+ IBinding f = bh.assertNonProblem("operator new(size_t b)", 12);
IASTImplicitName[] names = bh.getImplicitNames("new A;", 3);
assertEquals(2, names.length);
@@ -512,7 +512,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// int* p2 = new (5, 6) int[5];
// }
public void testNew() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTImplicitName n1 = ba.assertImplicitName("new (nothrow) X", 3, ICPPFunction.class);
IASTImplicitName n2 = ba.assertImplicitName("new (nothrow) int", 3, ICPPFunction.class);
IASTImplicitName n3 = ba.assertImplicitName("new (5, 6) int", 3, ICPPFunction.class);
@@ -530,7 +530,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// throw;
// }
public void testEmptyThrow() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNoImplicitName("throw;", 5);
}
@@ -559,7 +559,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// };
// B C::t = 1;
public void testConstructorCall() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTTranslationUnit tu = ba.getTranslationUnit();
ICPPConstructor ctor0 = ba.assertNonProblem("A()", 1, ICPPConstructor.class);
ICPPConstructor ctor1 = ba.assertNonProblem("A(int)", 1, ICPPConstructor.class);
@@ -596,7 +596,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// }
// }
public void testBuiltinOperators_294543() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTTranslationUnit tu = ba.getTranslationUnit();
ICPPFunction op = ba.assertNonProblem("operator==", 0);
IASTImplicitName a = ba.assertImplicitName("==b", 2, ICPPFunction.class);
@@ -612,7 +612,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// x = A().a;
// }
public void testTemporaryDestruction() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("x = A().a");
assertEquals(1, names.length);
assertEquals("~A", names[0].resolveBinding().getName());
@@ -627,7 +627,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// x = A();
// }
public void testTemporaryNotCreatedWhenBoundToVariable() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("x = A()");
assertEquals(0, names.length);
}
@@ -640,7 +640,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// return (new A())->a;
// }
public void testTemporaryNotCreatesInNewExpression() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("(new A())->a");
assertEquals(0, names.length);
}
@@ -653,7 +653,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// A& x = A();
// }
public void testTemporaryBoundToReference() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("A()");
assertEquals(0, names.length);
}
@@ -670,7 +670,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// S s3;
// }//1
public void testOrderOfDestruction() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("}//1", 1);
assertEquals(3, names.length);
assertEquals("~S", names[0].resolveBinding().getName());
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java
index 4d889618d21..dcc6441edac 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java
@@ -396,8 +396,8 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// // resolution chooses Z::h(double)
// }
public void test3_4_3_2s2() throws Exception {
- String[] problems= {"AB::x", "x", "AB::i", "i"};
- parse(getAboveComment(), ParserLanguage.CPP, problems); // qualified names are counted double, so 4
+ String[] problems = { "AB::x", "x", "AB::i", "i" };
+ parse(getAboveComment(), ParserLanguage.CPP, problems); // qualified names are counted double, so 4
}
// namespace A {
@@ -529,7 +529,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// struct Base::Datum; // error: Datum undefined
// struct Base::Data* pBase; // OK: refers to nested Data
public void test3_4_4s3() throws Exception {
- String[] problems= {"::Glob", "Glob", "Base::Datum", "Datum"};
+ String[] problems = { "::Glob", "Glob", "Base::Datum", "Datum" };
parse(getAboveComment(), ParserLanguage.CPP, problems);
}
@@ -799,15 +799,15 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// new (int (*[10])());
// };
public void test5_3_4s3() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 0);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTExpression expr= getExpressionOfStatement(fdef, 0);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, 0);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTExpression expr = getExpressionOfStatement(fdef, 0);
assertInstance(expr, ICPPASTNewExpression.class);
- ICPPASTNewExpression newExpr= (ICPPASTNewExpression) expr;
+ ICPPASTNewExpression newExpr = (ICPPASTNewExpression) expr;
assertNull(newExpr.getNewPlacement());
assertNull(newExpr.getNewInitializer());
- IASTTypeId typeid= newExpr.getTypeId();
+ IASTTypeId typeid = newExpr.getTypeId();
isTypeEqual(CPPVisitor.createType(typeid), "int (* [10])()");
}
@@ -821,37 +821,37 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
public void test5_3_4s12() throws Exception {
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236856
- IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 0);
- IASTFunctionDefinition fdef= getDeclaration(tu, 1);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, 0);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 1);
// new T;
- IASTExpression expr= getExpressionOfStatement(fdef, 0);
+ IASTExpression expr = getExpressionOfStatement(fdef, 0);
assertInstance(expr, ICPPASTNewExpression.class);
- ICPPASTNewExpression newExpr= (ICPPASTNewExpression) expr;
+ ICPPASTNewExpression newExpr = (ICPPASTNewExpression) expr;
assertNull(newExpr.getNewPlacement());
assertNull(newExpr.getNewInitializer());
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int");
// new(2,f) T;
- expr= getExpressionOfStatement(fdef, 1);
+ expr = getExpressionOfStatement(fdef, 1);
assertInstance(expr, ICPPASTNewExpression.class);
- newExpr= (ICPPASTNewExpression) expr;
+ newExpr = (ICPPASTNewExpression) expr;
assertInstance(newExpr.getNewPlacement(), IASTExpressionList.class);
assertNull(newExpr.getNewInitializer());
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int");
// new T[5];
- expr= getExpressionOfStatement(fdef, 2);
+ expr = getExpressionOfStatement(fdef, 2);
assertInstance(expr, ICPPASTNewExpression.class);
- newExpr= (ICPPASTNewExpression) expr;
+ newExpr = (ICPPASTNewExpression) expr;
assertNull(newExpr.getNewPlacement());
assertNull(newExpr.getNewInitializer());
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int [5]");
// new (2,f) T[5];
- expr= getExpressionOfStatement(fdef, 3);
+ expr = getExpressionOfStatement(fdef, 3);
assertInstance(expr, ICPPASTNewExpression.class);
- newExpr= (ICPPASTNewExpression) expr;
+ newExpr = (ICPPASTNewExpression) expr;
assertInstance(newExpr.getNewPlacement(), IASTExpressionList.class);
assertNull(newExpr.getNewInitializer());
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int [5]");
@@ -1160,7 +1160,6 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
-
// class complex { //
// };
// typedef int complex; // error: redefinition
@@ -1196,9 +1195,9 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// // an ordinary member function, not a constructor
// } S;
public void test7_1_3s5b() throws Exception {
- IASTTranslationUnit tu= parseWithErrors(getAboveComment(), ParserLanguage.CPP);
- IASTCompositeTypeSpecifier comp= getCompositeType(tu, 0);
- IASTDeclaration d= getDeclaration(comp, 0);
+ IASTTranslationUnit tu = parseWithErrors(getAboveComment(), ParserLanguage.CPP);
+ IASTCompositeTypeSpecifier comp = getCompositeType(tu, 0);
+ IASTDeclaration d = getDeclaration(comp, 0);
assertInstance(d, IASTProblemDeclaration.class);
}
@@ -1335,7 +1334,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// j++; // A::unique::j
// }
public void test7_3_1_1s1() throws Exception {
- String[] problems= {"i"};
+ String[] problems = { "i" };
parse(getAboveComment(), ParserLanguage.CPP, problems);
}
@@ -1659,7 +1658,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// i = 5; // illformed; neither i is visible
// }
public void test7_3_4s1() throws Exception {
- String[] problems= {"i", "i"};
+ String[] problems = { "i", "i" };
parse(getAboveComment(), ParserLanguage.CPP, problems);
}
@@ -1676,7 +1675,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// i = 7; // error: both M::i and N::i are visible
// }
public void test7_3_4s2a() throws Exception {
- String[] problems= {"i"};
+ String[] problems = { "i" };
parse(getAboveComment(), ParserLanguage.CPP, problems);
}
@@ -1701,7 +1700,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// }
// }
public void test7_3_4s2b() throws Exception {
- String[] problems= {"k"};
+ String[] problems = { "k" };
parse(getAboveComment(), ParserLanguage.CPP, problems);
}
@@ -1731,7 +1730,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// f('a'); //OK: D::f(char)
// }
public void test7_3_4s5() throws Exception {
- String[] problems= {"d1", "f"};
+ String[] problems = { "d1", "f" };
parse(getAboveComment(), ParserLanguage.CPP, problems);
}
@@ -1855,16 +1854,16 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// S<int()> x; // typeid
// S<int(1)> y; // expression (illformed)
public void test8_2s4() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 1);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, 1);
NameCollector col = new NameCollector();
tu.accept(col);
assertInstance(col.getName(4), ICPPASTTemplateId.class);
- assertInstance(((ICPPASTTemplateId)col.getName(4)).getTemplateArguments()[0], IASTTypeId.class);
+ assertInstance(((ICPPASTTemplateId) col.getName(4)).getTemplateArguments()[0], IASTTypeId.class);
final IASTName S_int_1 = col.getName(7);
assertInstance(S_int_1, ICPPASTTemplateId.class);
- assertInstance(((ICPPASTTemplateId)S_int_1).getTemplateArguments()[0], IASTExpression.class);
+ assertInstance(((ICPPASTTemplateId) S_int_1).getTemplateArguments()[0], IASTExpression.class);
assertInstance(S_int_1.getBinding(), IProblemBinding.class);
}
@@ -1898,8 +1897,8 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
final String code = getAboveComment();
parse(code, ParserLanguage.CPP, true, 1);
- BindingAssertionHelper ba= new AST2AssertionHelper(code, true);
- IFunction f= ba.assertNonProblem("f", 1, IFunction.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, true);
+ IFunction f = ba.assertNonProblem("f", 1, IFunction.class);
isTypeEqual(f.getType(), "void (int (*)(C))");
}
@@ -1909,8 +1908,8 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
public void test8_2s7b() throws Exception {
final String code = getAboveComment();
parse(code, ParserLanguage.CPP, true, 0);
- BindingAssertionHelper ba= new AST2AssertionHelper(code, true);
- IFunction f= ba.assertNonProblem("h", 1, IFunction.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, true);
+ IFunction f = ba.assertNonProblem("h", 1, IFunction.class);
isTypeEqual(f.getType(), "void (int * (*)(C *))");
}
@@ -2251,7 +2250,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
//
// void c() const& {}
// void d() const&& {}
- //
+ //
// void e() volatile & {}
// void f() volatile && {}
//
@@ -2261,7 +2260,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
public void test8s4() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
-
+
// void print(int a, int)
// {
// //printf("a = %d",a);
@@ -2397,7 +2396,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// demonstrate the rules with variable initialiation, but CDT doesn't
// currently issue problem bindings for variable initialization,
// so in the tests the examples are rewritten to use function calls.
-
+
// void f1(double);
// void f2(double&);
// void f3(const double&);
@@ -2653,10 +2652,10 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// y.g(); //error
// }
public void test9_3_2s4() throws Exception {
- String[] problems= {"g"};
+ String[] problems = { "g" };
final String code = getAboveComment();
- IASTTranslationUnit tu= parse(code, ParserLanguage.CPP, problems);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, problems);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("g();", 1);
bh.assertProblem("g(); //error", 1);
}
@@ -3675,16 +3674,16 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
public void test12_4s12() throws Exception {
final String code = getAboveComment();
parse(code, ParserLanguage.CPP, false, 0);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- ICPPFunction dtor= bh.assertNonProblem("~B() {", 2);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ ICPPFunction dtor = bh.assertNonProblem("~B() {", 2);
- ICPPFunction d= bh.assertNonProblem("~B(); //1", 2);
+ ICPPFunction d = bh.assertNonProblem("~B(); //1", 2);
assertSame(dtor, d);
- d= bh.assertNonProblem("~B(); //2", 2);
+ d = bh.assertNonProblem("~B(); //2", 2);
assertSame(dtor, d);
- d= bh.assertNonProblem("~B_alias(); //3", 8);
+ d = bh.assertNonProblem("~B_alias(); //3", 8);
assertSame(dtor, d);
- d= bh.assertNonProblem("~B(); //4", 2);
+ d = bh.assertNonProblem("~B(); //4", 2);
assertSame(dtor, d);
bh.assertProblem("~B_alias(); //5", 8);
@@ -4142,7 +4141,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// int f (int) { } // definition of f(int)
// int f (cInt) { } // error: redefinition of f(int)
public void test12_8s3e() throws Exception {
- String[] problems= {"f"};
+ String[] problems = { "f" };
parse(getAboveComment(), ParserLanguage.CPP, problems);
}
@@ -4367,7 +4366,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// b.f(); //Calls X::f()
// }
public void test13_3_3_2s3b() throws Exception {
- String[] problems= {"g"};
+ String[] problems = { "g" };
parse(getAboveComment(), ParserLanguage.CPP, problems);
}
@@ -4687,7 +4686,6 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
-
// void error(const char*);
// template<class T> class Array {
// T* v;
@@ -4741,8 +4739,6 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
-
-
// class B {
// virtual void f(int);
// };
@@ -4951,6 +4947,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
public void test14_5_6_1s1a() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
+
// // file2.c
// template<class T>
// void f(T);
@@ -4969,12 +4966,12 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// // Guaranteed to be different
// template <int I> void f/*3*/(A<I>, A<I+11>);
public void test14_5_6_1s8a() throws Exception {
- final String content= getAboveComment();
- IASTTranslationUnit tu= parse(content, ParserLanguage.CPP, true, 0);
- BindingAssertionHelper bh= new AST2AssertionHelper(content, true);
- ICPPFunctionTemplate f1= bh.assertNonProblem("f/*1*/", 1);
- ICPPFunctionTemplate f2= bh.assertNonProblem("f/*2*/", 1);
- ICPPFunctionTemplate f3= bh.assertNonProblem("f/*3*/", 1);
+ final String content = getAboveComment();
+ IASTTranslationUnit tu = parse(content, ParserLanguage.CPP, true, 0);
+ BindingAssertionHelper bh = new AST2AssertionHelper(content, true);
+ ICPPFunctionTemplate f1 = bh.assertNonProblem("f/*1*/", 1);
+ ICPPFunctionTemplate f2 = bh.assertNonProblem("f/*2*/", 1);
+ ICPPFunctionTemplate f3 = bh.assertNonProblem("f/*3*/", 1);
assertSame(f1, f2);
assertNotSame(f1, f3);
}
@@ -5000,11 +4997,11 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// b * a; // calls #1a
// }
public void test14_5_6_2s3() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IBinding op1= bh.assertNonProblem("operator*(R&)", -4);
- IASTImplicitName name= bh.assertImplicitName("* a", 1, ICPPFunction.class);
- ICPPTemplateInstance inst= (ICPPTemplateInstance) name.resolveBinding();
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IBinding op1 = bh.assertNonProblem("operator*(R&)", -4);
+ IASTImplicitName name = bh.assertImplicitName("* a", 1, ICPPFunction.class);
+ ICPPTemplateInstance inst = (ICPPTemplateInstance) name.resolveBinding();
ICPPSpecialization templateSpecialization = (ICPPSpecialization) inst.getTemplateDefinition();
assertSame(op1, templateSpecialization.getSpecializedBinding());
}
@@ -5242,11 +5239,11 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
public void test14_6_2s2() throws Exception {
final String code = getAboveComment();
parse(code, ParserLanguage.CPP, true, 0);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- ICPPUnknownBinding unknown= bh.assertNonProblem("B<T>", 4);
- unknown= bh.assertNonProblem("T::A", 4);
- unknown= bh.assertNonProblem("B<T>::i", 7);
- unknown= bh.assertNonProblem("j", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ ICPPUnknownBinding unknown = bh.assertNonProblem("B<T>", 4);
+ unknown = bh.assertNonProblem("T::A", 4);
+ unknown = bh.assertNonProblem("B<T>::i", 7);
+ unknown = bh.assertNonProblem("j", 1);
}
// typedef double A;
@@ -5257,13 +5254,13 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// A a; // a has type double
// };
public void test14_6_2s3() throws Exception {
- final String content= getAboveComment();
- IASTTranslationUnit tu= parse(content, ParserLanguage.CPP, true, 0);
- BindingAssertionHelper bh= new AST2AssertionHelper(content, true);
- IVariable v= bh.assertNonProblem("a;", 1);
- IType t= v.getType();
+ final String content = getAboveComment();
+ IASTTranslationUnit tu = parse(content, ParserLanguage.CPP, true, 0);
+ BindingAssertionHelper bh = new AST2AssertionHelper(content, true);
+ IVariable v = bh.assertNonProblem("a;", 1);
+ IType t = v.getType();
assertInstance(t, ITypedef.class);
- t= ((ITypedef) t).getType();
+ t = ((ITypedef) t).getType();
assertInstance(t, IBasicType.class);
assertEquals(IBasicType.t_double, ((IBasicType) t).getType());
}
@@ -5282,12 +5279,12 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// };
// Y<A> ya;
public void test14_6_2s4() throws Exception {
- final String content= getAboveComment();
+ final String content = getAboveComment();
parse(content, ParserLanguage.CPP, true, 0);
- BindingAssertionHelper bh= new AST2AssertionHelper(content, true);
- IBinding b= bh.assertNonProblem("b;", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(content, true);
+ IBinding b = bh.assertNonProblem("b;", 1);
assertEquals("Y", b.getOwner().getName());
- b= bh.assertNonProblem("a = i", 1);
+ b = bh.assertNonProblem("a = i", 1);
assertNull(b.getOwner());
}
@@ -5565,7 +5562,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// // with deduces templateargument of type int
// template<> void sort(Array<int>&);
public void test14_7_3s11() throws Exception {
- parse(getAboveComment(), ParserLanguage.CPP, true, 0 );
+ parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// template<class T1> class A {
@@ -5578,6 +5575,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
public void test14_7_3s17() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
+
// template<class T> class X; // X is a class template
// template<> class X<int>;
// X<int>* p; // OK: pointer to declared class X<int>
@@ -5773,17 +5771,17 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// f<int,char>(); // f<int,char>(0,0)
// }
public void test14_8_2s5() throws Exception {
- final String content= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(content, true);
+ final String content = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(content, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f(1, 'c')", 1);
+ inst = bh.assertNonProblem("f(1, 'c')", 1);
assertEquals("<int,char>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
- inst= bh.assertNonProblem("f(1)", 1);
+ inst = bh.assertNonProblem("f(1)", 1);
assertEquals("<int,double>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
bh.assertProblem("f()", 1);
- inst= bh.assertNonProblem("f<int>()", -2);
+ inst = bh.assertNonProblem("f<int>()", -2);
assertEquals("<int,double>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
- inst= bh.assertNonProblem("f<int,char>()", -2);
+ inst = bh.assertNonProblem("f<int,char>()", -2);
assertEquals("<int,char>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -5803,8 +5801,8 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// int I = f<int>(0);
// int j = f<void>(0); // invalid array
public void _test14_8_2s8b() throws Exception {
- final String content= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(content, true);
+ final String content = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(content, true);
bh.assertNonProblem("f<int>(0)", -3);
bh.assertProblem("f<void>(0)", -3);
}
@@ -5812,9 +5810,9 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// template <class T> int f(typename T::B*);
// int i = f<int>(0);
public void test14_8_2s8c() throws Exception {
- final String content= getAboveComment();
- IASTTranslationUnit tu= parse(content, ParserLanguage.CPP, true, 2);
- BindingAssertionHelper bh= new AST2AssertionHelper(content, true);
+ final String content = getAboveComment();
+ IASTTranslationUnit tu = parse(content, ParserLanguage.CPP, true, 2);
+ BindingAssertionHelper bh = new AST2AssertionHelper(content, true);
bh.assertProblem("f<", 1);
bh.assertProblem("f<int>", 6);
}
@@ -5840,8 +5838,8 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// h<D>(0); // The TT member of D is not a template
// }
public void test14_8_2s8d() throws Exception {
- final String content= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(content, true);
+ final String content = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(content, true);
bh.assertProblem("f<A>", 0);
bh.assertProblem("f<B>", 0);
bh.assertProblem("g<C>", 0);
@@ -5853,7 +5851,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
public void test14_8_2s8e() throws Exception {
final String code = getAboveComment();
parse(code, ParserLanguage.CPP, true, 2);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertProblem("f<int>", 0);
}
@@ -5864,7 +5862,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
public void test14_8_2s8f() throws Exception {
final String code = getAboveComment();
parse(code, ParserLanguage.CPP, true, 2);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertProblem("f<X>", 0);
}
@@ -5893,11 +5891,11 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// g({1,2,3}); // error: no argument deduced for T
// }
public void test14_8_2_1s1a() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f({1,2,3})", 1);
+ inst = bh.assertNonProblem("f({1,2,3})", 1);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
bh.assertProblem("f({1,\"asdf\"})", 1);
bh.assertProblem("g({1,2,3})", 1);
@@ -5911,13 +5909,13 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// g(x, y, z); // T1 is deduced to int; Types is deduced to float, int
// }
public void test14_8_2_1s1b() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f(x, y, z)", 1);
+ inst = bh.assertNonProblem("f(x, y, z)", 1);
assertEquals("<int,float,const int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
- inst= bh.assertNonProblem("g(x, y, z)", 1);
+ inst = bh.assertNonProblem("g(x, y, z)", 1);
assertEquals("<int,float,int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -5929,12 +5927,12 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// int n3 = g(i); // error: would call g<int>(const int&&), which
// // would bind an rvalue reference to an lvalue
public void test14_8_2_1s3() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f(i)", 1);
+ inst = bh.assertNonProblem("f(i)", 1);
assertEquals("<int &>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
- inst= bh.assertNonProblem("f(0)", 1);
+ inst = bh.assertNonProblem("f(0)", 1);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
bh.assertProblem("g(i)", 1);
}
@@ -5946,10 +5944,10 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// int g(char);
// int i = f(g); // calls f(int (*)(int))
public void test14_8_2_1s7() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f(g)", 1);
+ inst = bh.assertNonProblem("f(g)", 1);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -5960,10 +5958,10 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// char g(char);
// int i = f(1, g); // calls f(int, int (*)(int))
public void test14_8_2_1s8() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f(1, g)", 1);
+ inst = bh.assertNonProblem("f(1, g)", 1);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -5974,10 +5972,10 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// template <class T> T g(T);
// int i = f(1, g); // calls f(int, int (*)(int))
public void test14_8_2_1s9() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f(1, g)", 1);
+ inst = bh.assertNonProblem("f(1, g)", 1);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -6012,21 +6010,21 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// g(Tuple<int>()); // calls #3
// }
public void test14_8_2_4s12() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parse(code, ParserLanguage.CPP, true, 0);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- ICPPFunction g1= bh.assertNonProblem("g(Tuple<Types...>)", 1);
- ICPPFunction g2= bh.assertNonProblem("g(Tuple<T1, Types...>)", 1);
- ICPPFunction g3= bh.assertNonProblem("g(Tuple<T1, Types&...>)", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ ICPPFunction g1 = bh.assertNonProblem("g(Tuple<Types...>)", 1);
+ ICPPFunction g2 = bh.assertNonProblem("g(Tuple<T1, Types...>)", 1);
+ ICPPFunction g3 = bh.assertNonProblem("g(Tuple<T1, Types&...>)", 1);
- ICPPTemplateInstance x= bh.assertNonProblem("g(Tuple<>())", 1);
+ ICPPTemplateInstance x = bh.assertNonProblem("g(Tuple<>())", 1);
assertSame(g1, x.getTemplateDefinition());
- x= bh.assertNonProblem("g(Tuple<int, float>())", 1);
+ x = bh.assertNonProblem("g(Tuple<int, float>())", 1);
assertSame(g2, x.getTemplateDefinition());
- x= bh.assertNonProblem("g(Tuple<int, float&>())", 1);
+ x = bh.assertNonProblem("g(Tuple<int, float&>())", 1);
assertSame(g3, x.getTemplateDefinition());
- x= bh.assertNonProblem("g(Tuple<int>())", 1);
+ x = bh.assertNonProblem("g(Tuple<int>())", 1);
assertSame(g3, x.getTemplateDefinition());
}
@@ -6035,8 +6033,8 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// g({1,2,3}); // error: no argument deduced for T
// }
public void test14_8_2_5s5() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertProblem("g({1,2,3})", 1);
}
@@ -6065,10 +6063,10 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// f(g3); //error: U could be char or float
// }
public void test14_8_2_5s7b() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f(g1)", 1);
+ inst = bh.assertNonProblem("f(g1)", 1);
assertEquals("<int,float>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
bh.assertProblem("f(g2)", 1);
bh.assertProblem("f(g3)", 1);
@@ -6107,12 +6105,12 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// f(0); // calls f<int>(int&&), i.e., #2
// }
public void test14_8_2_5s10() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f(i)", 1);
+ inst = bh.assertNonProblem("f(i)", 1);
assertEquals("<int &>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
- inst= bh.assertNonProblem("f(0)", 1);
+ inst = bh.assertNonProblem("f(0)", 1);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -6123,8 +6121,8 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// //T cannot be deduced
// }
public void test14_8_2_5s14() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertProblem("f(v)", 1);
}
@@ -6141,17 +6139,17 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// f3(v); //OK: i deduced to be 10
// }
public void test14_8_2_5s15() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f1(v)", 2);
+ inst = bh.assertNonProblem("f1(v)", 2);
assertEquals("<int20>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
- inst= bh.assertNonProblem("f1<20>(v)", -3);
+ inst = bh.assertNonProblem("f1<20>(v)", -3);
assertEquals("<int20>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
bh.assertProblem("f2(v)", 2);
- inst= bh.assertNonProblem("f2<10>(v)", -3);
+ inst = bh.assertNonProblem("f2<10>(v)", -3);
assertEquals("<int10>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
- inst= bh.assertNonProblem("f3(v)", 2);
+ inst = bh.assertNonProblem("f3(v)", 2);
assertEquals("<int10>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -6166,13 +6164,13 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// f(a1, a2); // OK
// }
public void test14_8_2_5s16a() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
bh.assertProblem("g(a1)", 1);
- inst= bh.assertNonProblem("g<0>(a1)", -4);
+ inst = bh.assertNonProblem("g<0>(a1)", -4);
assertEquals("<int0>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
- inst= bh.assertNonProblem("f(a1, a2)", 1);
+ inst = bh.assertNonProblem("f(a1, a2)", 1);
assertEquals("<int1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -6199,7 +6197,6 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
-
// template<int i> class A {};
// template<short s> void f(A<s>);
// void k1() {
@@ -6214,13 +6211,13 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// g(b); // OK: cv-qualifiers are ignored on template parameter types
// }
public void test14_8_2_5s17() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
bh.assertProblem("f(a)", 1);
- inst= bh.assertNonProblem("f<1>(a)", -3);
+ inst = bh.assertNonProblem("f<1>(a)", -3);
assertEquals("<short int1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
- inst= bh.assertNonProblem("g(b)", 1);
+ inst = bh.assertNonProblem("g(b)", 1);
assertEquals("<short int1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -6236,11 +6233,11 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// f(&foo); // error: type deduction fails because foo is a template
// }
public void test14_8_2_5s18() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
bh.assertProblem("f(&g)", 1);
- inst= bh.assertNonProblem("f(&h)", 1);
+ inst = bh.assertNonProblem("f(&h)", 1);
assertEquals("<char>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
bh.assertProblem("f(&foo)", 1);
}
@@ -6252,13 +6249,13 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// f<int>(); // OK: call f<int>(5,7)
// }
public void test14_8_2_5s19() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f(1)", 1);
+ inst = bh.assertNonProblem("f(1)", 1);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
bh.assertProblem("f()", 1);
- inst= bh.assertNonProblem("f<int>()", -2);
+ inst = bh.assertNonProblem("f<int>()", -2);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -6300,18 +6297,18 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// // specialized than the variadic templates #1 and #2
// }
public void test14_8_2_5s22() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- ICPPFunctionTemplate f1= bh.assertNonProblem("f(Args ... args)", 1);
- ICPPFunctionTemplate f2= bh.assertNonProblem("f(T1 a1, Args ... args)", 1);
- ICPPFunctionTemplate f3= bh.assertNonProblem("f(T1 a1, T2 a2)", 1);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ ICPPFunctionTemplate f1 = bh.assertNonProblem("f(Args ... args)", 1);
+ ICPPFunctionTemplate f2 = bh.assertNonProblem("f(T1 a1, Args ... args)", 1);
+ ICPPFunctionTemplate f3 = bh.assertNonProblem("f(T1 a1, T2 a2)", 1);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f()", 1);
+ inst = bh.assertNonProblem("f()", 1);
assertSame(f1, inst.getTemplateDefinition());
- inst= bh.assertNonProblem("f(1, 2, 3)", 1);
+ inst = bh.assertNonProblem("f(1, 2, 3)", 1);
assertSame(f2, inst.getTemplateDefinition());
- inst= bh.assertNonProblem("f(1, 2)", 1);
+ inst = bh.assertNonProblem("f(1, 2)", 1);
assertSame(f3, inst.getTemplateDefinition());
}
@@ -6813,7 +6810,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// void f(int);
// template<void (*pf)(int)> struct A { };
// A<&f> a; // selects f(int)
- public void test14_3_2s5() throws Exception {
+ public void test14_3_2s5() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@@ -6831,7 +6828,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// ac.f<>(1); //template
// }
public void test14_5_2s2() throws Exception {
- parse(getAboveComment(), ParserLanguage.CPP, true, 0); //should be 0
+ parse(getAboveComment(), ParserLanguage.CPP, true, 0); //should be 0
}
// template<class T1, class T2, int I> class A<T1, T2, I> { }; // error
@@ -6877,12 +6874,12 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// template <int K, int L> A<K+L> f/*2*/(A<K>, A<L>); // same as #1
// template <int I, int J> A<I-J> f/*3*/(A<I>, A<J>); // different from #1
public void test14_5_6_1s5() throws Exception {
- final String content= getAboveComment();
- IASTTranslationUnit tu= parse(content, ParserLanguage.CPP, true, 0);
- BindingAssertionHelper bh= new AST2AssertionHelper(content, true);
- ICPPFunctionTemplate f1= bh.assertNonProblem("f/*1*/", 1);
- ICPPFunctionTemplate f2= bh.assertNonProblem("f/*2*/", 1);
- ICPPFunctionTemplate f3= bh.assertNonProblem("f/*3*/", 1);
+ final String content = getAboveComment();
+ IASTTranslationUnit tu = parse(content, ParserLanguage.CPP, true, 0);
+ BindingAssertionHelper bh = new AST2AssertionHelper(content, true);
+ ICPPFunctionTemplate f1 = bh.assertNonProblem("f/*1*/", 1);
+ ICPPFunctionTemplate f2 = bh.assertNonProblem("f/*2*/", 1);
+ ICPPFunctionTemplate f3 = bh.assertNonProblem("f/*3*/", 1);
assertSame(f1, f2);
assertNotSame(f1, f3);
}
@@ -6891,11 +6888,11 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// template <int I, int J> void f/*1*/(A<I+J>); // #1
// template <int K, int L> void f/*2*/(A<K+L>); // same as #1
public void test14_5_6_1s6() throws Exception {
- final String content= getAboveComment();
- IASTTranslationUnit tu= parse(content, ParserLanguage.CPP, true, 0);
- BindingAssertionHelper bh= new AST2AssertionHelper(content, true);
- ICPPFunctionTemplate f1= bh.assertNonProblem("f/*1*/", 1);
- ICPPFunctionTemplate f2= bh.assertNonProblem("f/*2*/", 1);
+ final String content = getAboveComment();
+ IASTTranslationUnit tu = parse(content, ParserLanguage.CPP, true, 0);
+ BindingAssertionHelper bh = new AST2AssertionHelper(content, true);
+ ICPPFunctionTemplate f1 = bh.assertNonProblem("f/*1*/", 1);
+ ICPPFunctionTemplate f2 = bh.assertNonProblem("f/*2*/", 1);
assertSame(f1, f2);
}
@@ -6927,7 +6924,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// int (&ra)[3] = a; // ra refers to the array a
// ra[1] = i; // modifies a[1]
// }
- public void test8_5_3s1() throws Exception { // TODO raised bug 90648
+ public void test8_5_3s1() throws Exception { // TODO raised bug 90648
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@@ -6939,7 +6936,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// this->A::operator=(s); // wellformed
// return *this;
// }
- public void test12s1() throws Exception {
+ public void test12s1() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@@ -6960,7 +6957,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// // C/B/D/A sublattice is fully constructed
// { }
// };
- public void test12_7s2() throws Exception {
+ public void test12_7s2() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@@ -6996,7 +6993,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// void g() {
// (int (*)(int))&f; // cast expression as selector
// }
- public void test13_4s5a() throws Exception { // bug 90674
+ public void test13_4s5a() throws Exception { // bug 90674
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
}
@@ -7032,9 +7029,9 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// int ef(D&);
// int ff(X&);
public void test11_3s2() throws Exception { //bug 92793
- IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 0);
- IASTCompositeTypeSpecifier D= getCompositeType(tu, 2);
- IASTDeclaration accessDecl= getDeclaration(D, 2);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, 0);
+ IASTCompositeTypeSpecifier D = getCompositeType(tu, 2);
+ IASTDeclaration accessDecl = getDeclaration(D, 2);
assertInstance(accessDecl, ICPPASTUsingDeclaration.class);
}
@@ -7044,7 +7041,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// int b = f(a);
// int c(b);
// }
- public void test8_5s2() throws Exception { // 90641
+ public void test8_5s2() throws Exception { // 90641
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@@ -7066,7 +7063,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// {
// f<int()>(); // int() is a typeid:call the first f()
// }
- public void test14_3s2() throws Exception {
+ public void test14_3s2() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTestBase.java
index a9130252cd4..f8c07d3b8b0 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTestBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTestBase.java
@@ -20,17 +20,17 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
public class AST2CPPTestBase extends AST2TestBase {
public AST2CPPTestBase() {
}
-
+
public AST2CPPTestBase(String name) {
super(name);
}
-
+
protected IASTTranslationUnit parseAndCheckBindings(String code) throws Exception {
return parseAndCheckBindings(code, CPP);
}
protected IASTTranslationUnit parseAndCheckBindings() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
return parseAndCheckBindings(code);
}
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 cb85c0d289d..3ec4cf786d3 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
@@ -200,12 +200,13 @@ public class AST2CPPTests extends AST2CPPTestBase {
return (ICPPClassType) bindings[0];
}
- private void checkNewExpression(IASTFunctionDefinition fdef, int i_expr, Class<?> placement, String type, Class<?> init) {
+ private void checkNewExpression(IASTFunctionDefinition fdef, int i_expr, Class<?> placement, String type,
+ Class<?> init) {
IASTExpression expr;
ICPPASTNewExpression newExpr;
- expr= getExpressionOfStatement(fdef, i_expr);
+ expr = getExpressionOfStatement(fdef, i_expr);
assertInstance(expr, ICPPASTNewExpression.class);
- newExpr= (ICPPASTNewExpression) expr;
+ newExpr = (ICPPASTNewExpression) expr;
if (placement == null) {
assertNull(newExpr.getNewPlacement());
} else {
@@ -220,10 +221,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
private void checkDeclDef(String[] declNames, String[] defNames, IASTDeclaration[] decls) {
- int i= 0, j= 0;
+ int i = 0, j = 0;
for (IASTDeclaration decl : decls) {
if (decl instanceof ICPPASTLinkageSpecification) {
- decl= ((ICPPASTLinkageSpecification) decl).getDeclarations()[0];
+ decl = ((ICPPASTLinkageSpecification) decl).getDeclarations()[0];
}
final IASTDeclarator[] dtors = ((IASTSimpleDeclaration) decl).getDeclarators();
for (IASTDeclarator dtor : dtors) {
@@ -246,23 +247,24 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertEquals(defNames.length, j);
}
- protected static void assertSameType(IType first, IType second){
+ protected static void assertSameType(IType first, IType second) {
assertNotNull(first);
assertNotNull(second);
- assertTrue("Expected types to be the same, but first was: '" + first.toString() + "' and second was: '" + second + "'", first.isSameType(second));
+ assertTrue("Expected types to be the same, but first was: '" + first.toString() + "' and second was: '" + second
+ + "'", first.isSameType(second));
}
-
+
private void checkUserDefinedLiteralIsType(String code, String type_name) throws Exception {
IASTTranslationUnit tu = parseAndCheckBindings(code, CPP);
IASTDeclaration[] declarations = tu.getDeclarations();
IASTDeclaration declaration = declarations[declarations.length - 1];
-
+
IASTInitializer init = ((IASTSimpleDeclaration) declaration).getDeclarators()[0].getInitializer();
- IType type = ((IASTExpression)((IASTEqualsInitializer) init).getInitializerClause()).getExpressionType();
-
+ IType type = ((IASTExpression) ((IASTEqualsInitializer) init).getInitializerClause()).getExpressionType();
+
assertEquals(type_name, type.toString());
}
-
+
private void checkUserDefinedLiteralIsRet(String code) throws Exception {
checkUserDefinedLiteralIsType(code, "Ret");
}
@@ -407,7 +409,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testBug95424() throws Exception {
- IASTTranslationUnit tu = parse("void f(){ traits_type::copy(__r->_M_refdata(), __buf, __i); }", CPP, true, true);
+ 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);
IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
IASTCompoundStatement cs = (IASTCompoundStatement) f.getBody();
@@ -456,8 +459,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testSimpleClass() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTCompositeTypeSpecifier compTypeSpec =
- (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
+ IASTCompositeTypeSpecifier compTypeSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
IASTName name_A = compTypeSpec.getName();
IASTDeclarator dtor = decl.getDeclarators()[0];
@@ -748,7 +750,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class A a;
// }
public void testNameHiding() throws Exception {
- String content= getAboveComment();
+ String content = getAboveComment();
IASTTranslationUnit tu = parse(content, CPP);
NameCollector collector = new NameCollector();
@@ -1024,8 +1026,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IPointerType pt = (IPointerType) pf.getType();
assertTrue(pt.getType() instanceof IFunctionType);
- tu = parse(
- "struct A; int (*pfi)(int, struct A *);", CPP);
+ tu = parse("struct A; int (*pfi)(int, struct A *);", CPP);
collector = new NameCollector();
tu.accept(collector);
ICPPClassType A = (ICPPClassType) collector.getName(0).resolveBinding();
@@ -1055,13 +1056,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
IFunction f = (IFunction) decl.getDeclarators()[0].getName().resolveBinding();
decl = (IASTSimpleDeclaration) tu.getDeclarations()[2];
- IVariable g =
- (IVariable) decl.getDeclarators()[0].getNestedDeclarator().getName().resolveBinding();
+ IVariable g = (IVariable) decl.getDeclarators()[0].getNestedDeclarator().getName().resolveBinding();
decl = (IASTSimpleDeclaration) tu.getDeclarations()[3];
- IVariable h =
- (IVariable) decl.getDeclarators()[0].getNestedDeclarator().getNestedDeclarator()
- .getName().resolveBinding();
+ IVariable h = (IVariable) decl.getDeclarators()[0].getNestedDeclarator().getNestedDeclarator().getName()
+ .resolveBinding();
IFunctionType t_f = f.getType();
IType t_f_return = t_f.getReturnType();
@@ -1112,8 +1111,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testFnReturningPtrToFn() throws Exception {
- IASTTranslationUnit tu = parse(
- "void (* f(int))(){}", CPP);
+ IASTTranslationUnit tu = parse("void (* f(int))(){}", CPP);
IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[0];
IFunction f = (IFunction) def.getDeclarator().getName().resolveBinding();
@@ -1175,20 +1173,20 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testUsingDeclaration_86368() throws Exception {
BindingAssertionHelper bh = getAssertionHelper();
- IFunction f1= bh.assertNonProblem("f(int)", 1);
- IFunction f2= bh.assertNonProblem("f('i')", 1);
+ IFunction f1 = bh.assertNonProblem("f(int)", 1);
+ IFunction f2 = bh.assertNonProblem("f('i')", 1);
assertSame(f1, f2);
- IFunction g1= bh.assertNonProblem("f(char)", 1);
- IFunction g2= bh.assertNonProblem("f('c')", 1);
+ IFunction g1 = bh.assertNonProblem("f(char)", 1);
+ IFunction g2 = bh.assertNonProblem("f('c')", 1);
assertSame(g1, g2);
// Alternative binding resolution order.
bh = getAssertionHelper();
- f2= bh.assertNonProblem("f('i')", 1);
- f1= bh.assertNonProblem("f(int)", 1);
+ f2 = bh.assertNonProblem("f('i')", 1);
+ f1 = bh.assertNonProblem("f(int)", 1);
assertSame(f1, f2);
- g2= bh.assertNonProblem("f('c')", 1);
- g1= bh.assertNonProblem("f(char)", 1);
+ g2 = bh.assertNonProblem("f('c')", 1);
+ g1 = bh.assertNonProblem("f(char)", 1);
assertSame(g1, g2);
}
@@ -1377,18 +1375,18 @@ public class AST2CPPTests extends AST2CPPTestBase {
// typedef E F;
// F::E() {}
public void testImplicitConstructors_360223() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
- ICPPClassType c= bh.assertNonProblem("C", 0);
+ BindingAssertionHelper bh = getAssertionHelper();
+ ICPPClassType c = bh.assertNonProblem("C", 0);
ICPPConstructor[] ctors = c.getConstructors();
assertEquals(1, ctors.length);
assertFalse(ctors[0].isImplicit());
- c= bh.assertNonProblem("D", 0);
+ c = bh.assertNonProblem("D", 0);
ctors = c.getConstructors();
assertEquals(1, ctors.length);
assertFalse(ctors[0].isImplicit());
- IBinding ctor= bh.assertNonProblem("E() {}", 1);
+ IBinding ctor = bh.assertNonProblem("E() {}", 1);
assertTrue(ctor instanceof ICPPConstructor);
}
@@ -1465,7 +1463,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testInheritedTemplateConstructor() throws Exception {
parseAndCheckBindings();
}
-
+
// struct base {};
//
// struct derived : public base {
@@ -1482,8 +1480,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class F { (~)F(); };
// class G { (~)G(void); };
- BufferedReader br= new BufferedReader(new StringReader(getAboveComment()));
- for (String line= br.readLine(); line != null; line= br.readLine()) {
+ BufferedReader br = new BufferedReader(new StringReader(getAboveComment()));
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
IASTTranslationUnit tu = parse(line, CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
@@ -1491,14 +1489,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPMethod[] methods = ((ICPPClassScope) A.getCompositeScope()).getImplicitMethods();
assertNotNull(methods);
- int count= 0;
+ int count = 0;
for (ICPPMethod method : methods)
count += method.getName().startsWith("~") ? 1 : 0;
assertEquals(line, 0, count);
methods = A.getDeclaredMethods();
assertNotNull(methods);
- count= 0;
+ count = 0;
for (ICPPMethod method : methods)
count += method.getName().startsWith("~") ? 1 : 0;
assertEquals(line, 1, count);
@@ -1509,8 +1507,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class D {D();};
// class E {E(void);};
public void testImplicitDestructor_183160() throws Exception {
- BufferedReader br= new BufferedReader(new StringReader(getAboveComment()));
- for (String line= br.readLine(); line != null; line= br.readLine()) {
+ BufferedReader br = new BufferedReader(new StringReader(getAboveComment()));
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
IASTTranslationUnit tu = parse(line, CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
@@ -1518,14 +1516,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPMethod[] methods = ((ICPPClassScope) A.getCompositeScope()).getImplicitMethods();
assertNotNull(methods);
- int count= 0;
+ int count = 0;
for (ICPPMethod method : methods)
count += method.getName().startsWith("~") ? 1 : 0;
assertEquals(line, 1, count);
methods = A.getDeclaredMethods();
assertNotNull(methods);
- count= 0;
+ count = 0;
for (ICPPMethod method : methods)
count += method.getName().startsWith("~") ? 1 : 0;
assertEquals(line, 0, count);
@@ -1553,8 +1551,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class S {public: S(int k=5, int* ip= 0);};
// class T {public: T(int k=5, int* ip= 0, T* t= 0);};
public void testExplicitDefaultConstructor_183160() throws Exception {
- BufferedReader br= new BufferedReader(new StringReader(getAboveComment()));
- for (String line= br.readLine(); line != null; line= br.readLine()) {
+ BufferedReader br = new BufferedReader(new StringReader(getAboveComment()));
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
IASTTranslationUnit tu = parse(line, CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
@@ -1571,8 +1569,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class S {public: S(int k=5, int* ip);};
// class T {public: T(int k, int* ip= 0, T* t= 0);};
public void testExplicitNonDefaultConstructor_183160() throws Exception {
- BufferedReader br= new BufferedReader(new StringReader(getAboveComment()));
- for (String line= br.readLine(); line != null; line= br.readLine()) {
+ BufferedReader br = new BufferedReader(new StringReader(getAboveComment()));
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
IASTTranslationUnit tu = parse(line, CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
@@ -1593,8 +1591,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class G {protected: G(volatile G &, int i=4, int l=2);};
// class H {H(const volatile H &, int i=1, long k=2) {}};
public void testExplicitCopyConstructor_183160() throws Exception {
- BufferedReader br= new BufferedReader(new StringReader(getAboveComment()));
- for (String line= br.readLine(); line != null; line= br.readLine()) {
+ BufferedReader br = new BufferedReader(new StringReader(getAboveComment()));
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
IASTTranslationUnit tu = parse(line, CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
@@ -1612,8 +1610,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class K {protected: K(volatile K *, int i=4, int l=2);}; // K * rather than K &
// class L {L(const volatile L &, int i=1, long k=2, int* x) {}}; // param int* x has no initializer
public void testNotExplicitCopyConstructor_183160() throws Exception {
- BufferedReader br= new BufferedReader(new StringReader(getAboveComment()));
- for (String line= br.readLine(); line != null; line= br.readLine()) {
+ BufferedReader br = new BufferedReader(new StringReader(getAboveComment()));
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
IASTTranslationUnit tu = parse(line, CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
@@ -1631,17 +1629,17 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class C {public: void operator=(C &c, int k=5) {} }; // compile error
// class D {public: void operator=(const D &, const D &); }; // compile error
public void testNotExplicitCopyAssignmentOperator_183160() throws Exception {
- BufferedReader br= new BufferedReader(new StringReader(getAboveComment()));
- for (String line= br.readLine(); line != null; line= br.readLine()) {
+ BufferedReader br = new BufferedReader(new StringReader(getAboveComment()));
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
IASTTranslationUnit tu = parse(line, CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
ICPPClassType A = (ICPPClassType) compSpec.getName().resolveBinding();
- ICPPMethod[] methods = ((ICPPClassScope)A.getCompositeScope()).getImplicitMethods();
+ ICPPMethod[] methods = ((ICPPClassScope) A.getCompositeScope()).getImplicitMethods();
assertNotNull(methods);
- int count= 0;
+ int count = 0;
for (ICPPMethod method : methods) {
- boolean eq= Arrays.equals(method.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
+ boolean eq = Arrays.equals(method.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
count += eq ? 1 : 0;
}
@@ -1649,9 +1647,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
methods = A.getDeclaredMethods();
assertNotNull(methods);
- count= 0;
+ count = 0;
for (ICPPMethod method : methods) {
- boolean eq= Arrays.equals(method.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
+ boolean eq = Arrays.equals(method.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
count += eq ? 1 : 0;
}
@@ -1664,17 +1662,17 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class C {private: void operator=(volatile C &) {} };
// class D {D& operator=(volatile const D &); };
public void testExplicitCopyAssignmentOperator_183160() throws Exception {
- BufferedReader br= new BufferedReader(new StringReader(getAboveComment()));
- for (String line= br.readLine(); line != null; line= br.readLine()) {
+ BufferedReader br = new BufferedReader(new StringReader(getAboveComment()));
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
IASTTranslationUnit tu = parse(line, CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
ICPPClassType A = (ICPPClassType) compSpec.getName().resolveBinding();
- ICPPMethod[] methods = ((ICPPClassScope)A.getCompositeScope()).getImplicitMethods();
+ ICPPMethod[] methods = ((ICPPClassScope) A.getCompositeScope()).getImplicitMethods();
assertNotNull(methods);
- int count= 0;
+ int count = 0;
for (ICPPMethod method : methods) {
- boolean eq= Arrays.equals(method.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
+ boolean eq = Arrays.equals(method.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
count += eq ? 1 : 0;
}
@@ -1682,9 +1680,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
methods = A.getDeclaredMethods();
assertNotNull(methods);
- count= 0;
+ count = 0;
for (ICPPMethod method : methods) {
- boolean eq= Arrays.equals(method.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
+ boolean eq = Arrays.equals(method.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
count += eq ? 1 : 0;
}
@@ -1740,14 +1738,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
// This assertion fails because conv is the copy ctor A(const A&), not the conversion operator B::operator A()
assertSame(oper, conv);
}
-
+
// struct S {
// operator int() &;
// operator int() &&;
// };
- //
+ //
// void waldo(int);
- //
+ //
// int main() {
// S s;
// waldo(s); // ERROR
@@ -1927,8 +1925,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// AB::f(`c`);
// }
public void testBug84679() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), CPP,
- false, false);
+ IASTTranslationUnit tu = parse(getAboveComment(), CPP, false, false);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -1958,7 +1955,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
public void testBug84692() throws Exception {
// also tests bug 234042.
- CPPASTNameBase.sAllowRecursionBindings= false;
+ CPPASTNameBase.sAllowRecursionBindings = false;
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
NameCollector col = new NameCollector();
@@ -2033,12 +2030,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- ICPPClassType A =
- (ICPPClassType) ((IASTCompositeTypeSpecifier) decl.getDeclSpecifier()).getName().resolveBinding();
+ ICPPClassType A = (ICPPClassType) ((IASTCompositeTypeSpecifier) decl.getDeclSpecifier()).getName()
+ .resolveBinding();
IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[1];
- IASTExpressionStatement expStatement =
- (IASTExpressionStatement) ((IASTCompoundStatement) def.getBody()).getStatements()[0];
+ IASTExpressionStatement expStatement = (IASTExpressionStatement) ((IASTCompoundStatement) def.getBody())
+ .getStatements()[0];
assertTrue(expStatement.getExpression() instanceof IASTLiteralExpression);
IType type = expStatement.getExpression().getExpressionType();
@@ -2046,8 +2043,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertSame(((IPointerType) type).getType(), A);
def = (IASTFunctionDefinition) tu.getDeclarations()[2];
- expStatement =
- (IASTExpressionStatement) ((IASTCompoundStatement) def.getBody()).getStatements()[0];
+ expStatement = (IASTExpressionStatement) ((IASTCompoundStatement) def.getBody()).getStatements()[0];
IASTUnaryExpression ue = (IASTUnaryExpression) expStatement.getExpression();
type = ue.getExpressionType();
@@ -2061,8 +2057,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
NameCollector col = new NameCollector();
tu.accept(col);
ICPPConstructor T = (ICPPConstructor) col.getName(1).resolveBinding();
- assertTrue(CharArrayUtils.equals(T.getNameCharArray(),
- "T".toCharArray()));
+ assertTrue(CharArrayUtils.equals(T.getNameCharArray(), "T".toCharArray()));
assertEquals(T.getName(), "T");
}
@@ -2186,8 +2181,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testPointerToMemberType() throws Exception {
- IASTTranslationUnit tu = parse("struct S; int S::* pm;",
- CPP);
+ IASTTranslationUnit tu = parse("struct S; int S::* pm;", CPP);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -2432,7 +2426,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
public void testFriend_275358() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPClassType A = bh.assertNonProblem("A", 1);
IFunction set = bh.assertNonProblem("set()", 3);
IFunction m = bh.assertNonProblem("Other::m()", 8);
@@ -2442,9 +2436,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertSame(friends[0], set);
assertSame(friends[1], m);
- IBinding[] declaredMethods= A.getAllDeclaredMethods();
+ IBinding[] declaredMethods = A.getAllDeclaredMethods();
assertEquals(0, declaredMethods.length);
- declaredMethods= A.getDeclaredMethods();
+ declaredMethods = A.getDeclaredMethods();
assertEquals(0, declaredMethods.length);
}
@@ -2625,7 +2619,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IBinding[] bs = CPPSemantics.findBindingsForContentAssist(name, true, null);
// check the result
- HashSet result= new HashSet();
+ HashSet result = new HashSet();
for (IBinding binding : bs) {
result.add(binding.getName());
}
@@ -2653,10 +2647,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTName name = col.getName(5);
assertEquals("v_", name.toString());
- IBinding[] bs = CPPSemantics.findBindingsForContentAssist(name, true, new String[] {"ns::inner"});
+ IBinding[] bs = CPPSemantics.findBindingsForContentAssist(name, true, new String[] { "ns::inner" });
// check the result
- HashSet result= new HashSet();
+ HashSet result = new HashSet();
for (IBinding binding : bs) {
result.add(binding.getName());
}
@@ -2794,8 +2788,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
String code = "int *foo(int *b) { return (int *)(b); }";
IASTTranslationUnit tu = parse(code, CPP);
IASTFunctionDefinition function = (IASTFunctionDefinition) tu.getDeclarations()[0];
- IASTReturnStatement r =
- (IASTReturnStatement) ((IASTCompoundStatement) function.getBody()).getStatements()[0];
+ IASTReturnStatement r = (IASTReturnStatement) ((IASTCompoundStatement) function.getBody()).getStatements()[0];
assertTrue(r.getReturnValue() instanceof IASTCastExpression);
}
@@ -2807,10 +2800,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testBug84476() throws Exception {
String code = getAboveComment();
- IASTFunctionDefinition foo = (IASTFunctionDefinition) parse(code,
- CPP).getDeclarations()[0];
- IASTDeclarationStatement decl =
- (IASTDeclarationStatement) ((IASTCompoundStatement) foo.getBody()).getStatements()[1];
+ IASTFunctionDefinition foo = (IASTFunctionDefinition) parse(code, CPP).getDeclarations()[0];
+ IASTDeclarationStatement decl = (IASTDeclarationStatement) ((IASTCompoundStatement) foo.getBody())
+ .getStatements()[1];
IASTSimpleDeclaration pb = (IASTSimpleDeclaration) decl.getDeclaration();
IASTDeclarator d = pb.getDeclarators()[0];
assertEquals(d.getNestedDeclarator().getPointerOperators().length, 1);
@@ -2931,10 +2923,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
// }
public void testBug84478() throws Exception {
- IASTFunctionDefinition foo = (IASTFunctionDefinition) parse(
- getAboveComment(), CPP).getDeclarations()[0];
- ICPPASTWhileStatement whileStatement =
- (ICPPASTWhileStatement) ((IASTCompoundStatement) foo.getBody()).getStatements()[2];
+ IASTFunctionDefinition foo = (IASTFunctionDefinition) parse(getAboveComment(), CPP).getDeclarations()[0];
+ ICPPASTWhileStatement whileStatement = (ICPPASTWhileStatement) ((IASTCompoundStatement) foo.getBody())
+ .getStatements()[2];
assertNull(whileStatement.getCondition());
assertNotNull(whileStatement.getConditionDeclaration());
}
@@ -3147,7 +3138,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPUsingDeclaration u = (ICPPUsingDeclaration) col.getName(7).resolveBinding();
IASTName[] decls = tu.getDeclarationsInAST(u);
- assertEquals(3, decls.length); // 2 function-decls + using-decl
+ assertEquals(3, decls.length); // 2 function-decls + using-decl
assertSame(decls[0], col.getName(1));
assertSame(decls[1], col.getName(3));
@@ -3155,12 +3146,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertEquals(delegates.length, 2);
decls = tu.getDeclarationsInAST(delegates[0]);
- assertEquals(2, decls.length); // function-decl + using-decl
+ assertEquals(2, decls.length); // function-decl + using-decl
assertSame(decls[0], col.getName(1));
assertSame(decls[1], col.getName(7));
decls = tu.getDeclarationsInAST(delegates[0]);
- assertEquals(2, decls.length); // function-decl + using-decl
+ assertEquals(2, decls.length); // function-decl + using-decl
assertSame(decls[0], col.getName(1));
}
@@ -3208,12 +3199,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPClassType g_struct = (ICPPClassType) col.getName(1).resolveBinding();
IFunction g_func = (IFunction) col.getName(2).resolveBinding();
- assertSame(g_struct,ref2);
+ assertSame(g_struct, ref2);
assertSame(g_func, ref1);
ICPPUsingDeclaration comp = (ICPPUsingDeclaration) col.getName(7).resolveBinding();
IASTName[] decls = tu.getDeclarationsInAST(comp);
- assertEquals(3, decls.length); // struct, func and using-decl
+ assertEquals(3, decls.length); // struct, func and using-decl
assertSame(decls[0], col.getName(1));
assertSame(decls[1], col.getName(2));
assertSame(decls[2], col.getName(7));
@@ -3246,7 +3237,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertSame(x_var, ref1);
IASTName[] refs = tu.getReferences(x_struct);
- assertEquals(2, refs.length); // 1 ref + using-decl
+ assertEquals(2, refs.length); // 1 ref + using-decl
assertSame(refs[0], col.getName(10));
assertSame(refs[1], col.getName(12));
@@ -3527,11 +3518,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertSame(bs[1], f1);
assertSame(bs[2], f2);
- String[] s = ((ICPPBinding) bs[1]).getQualifiedName();
+ String[] s = ((ICPPBinding) bs[1]).getQualifiedName();
assertEquals(2, s.length);
assertEquals("A", s[0]);
assertEquals("f", s[1]);
- assertTrue(((ICPPBinding) bs[1]).isGloballyQualified());
+ assertTrue(((ICPPBinding) bs[1]).isGloballyQualified());
}
// namespace A {
@@ -3582,22 +3573,22 @@ public class AST2CPPTests extends AST2CPPTestBase {
tu.accept(col);
IFunction f1 = (IFunction) col.getName(6).resolveBinding();
- IScope classScope= f1.getScope();
+ IScope classScope = f1.getScope();
assertTrue(classScope instanceof ICPPClassScope);
IBinding[] bindings = classScope.find("bf", tu);
- ICPPMethod method= extractSingleMethod(bindings);
+ ICPPMethod method = extractSingleMethod(bindings);
assertEquals("B", method.getQualifiedName()[0]);
- bindings= classScope.find("f", tu);
- method= extractSingleMethod(bindings);
+ bindings = classScope.find("f", tu);
+ method = extractSingleMethod(bindings);
assertEquals("A", method.getQualifiedName()[0]);
- bindings= classScope.find("B", tu);
- ICPPClassType classType= extractSingleClass(bindings);
+ bindings = classScope.find("B", tu);
+ ICPPClassType classType = extractSingleClass(bindings);
assertEquals("B", classType.getQualifiedName()[0]);
- bindings= classScope.find("A", tu);
- classType= extractSingleClass(bindings);
+ bindings = classScope.find("A", tu);
+ classType = extractSingleClass(bindings);
assertEquals("A", classType.getQualifiedName()[0]);
}
@@ -3781,7 +3772,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// B () : A() {}
// };
public void testBug89539() throws Exception {
- String content= getAboveComment();
+ String content = getAboveComment();
IASTTranslationUnit tu = parse(content, CPP);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -3817,8 +3808,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testBug89828() throws Exception {
- IASTTranslationUnit tu = parse(
- "class B * b; void f(); void f(int);", CPP);
+ IASTTranslationUnit tu = parse("class B * b; void f(); void f(int);", CPP);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -3890,8 +3880,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTTypeId typeId = ((ICPPASTConversionName) name1).getTypeId();
assertNotNull(typeId);
- assertEquals(((IASTSimpleDeclSpecifier) typeId.getDeclSpecifier()).getType(),
- IASTSimpleDeclSpecifier.t_int);
+ assertEquals(((IASTSimpleDeclSpecifier) typeId.getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_int);
}
@@ -3912,13 +3901,13 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertTrue(int1 instanceof ICPPASTConversionName);
assertNotNull(((ICPPASTConversionName) int1).getTypeId());
- IASTFunctionDefinition fdef= getDeclaration(tu, 1);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 1);
final IASTName x_int = fdef.getDeclarator().getName();
assertNotNull(x_int);
assertTrue(x_int instanceof ICPPASTQualifiedName);
assertTrue(((ICPPASTQualifiedName) x_int).isConversionOrOperator());
- final IASTName int2= ((ICPPASTQualifiedName)x_int).getLastName();
+ final IASTName int2 = ((ICPPASTQualifiedName) x_int).getLastName();
assertNotNull(int2);
assertTrue(int2 instanceof ICPPASTConversionName);
assertNotNull(((ICPPASTConversionName) int2).getTypeId());
@@ -3928,33 +3917,31 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertTrue(int3 instanceof ICPPASTConversionName);
assertNotNull(((ICPPASTConversionName) int3).getTypeId());
- ICPPASTTemplateDeclaration tdef= getDeclaration(tu, 3);
- fdef= (IASTFunctionDefinition) tdef.getDeclaration();
+ ICPPASTTemplateDeclaration tdef = getDeclaration(tu, 3);
+ fdef = (IASTFunctionDefinition) tdef.getDeclaration();
final IASTName x_ac_int = fdef.getDeclarator().getName();
assertNotNull(x_ac_int);
assertTrue(x_ac_int instanceof ICPPASTQualifiedName);
assertTrue(((ICPPASTQualifiedName) x_ac_int).isConversionOrOperator());
- final IASTName int4= ((ICPPASTQualifiedName)x_ac_int).getLastName();
+ final IASTName int4 = ((ICPPASTQualifiedName) x_ac_int).getLastName();
assertNotNull(int4);
assertTrue(int4 instanceof ICPPASTConversionName);
assertNotNull(((ICPPASTConversionName) int4).getTypeId());
}
public void testBug88662() throws Exception {
- IASTTranslationUnit tu = parse(
- "int foo() { return int();}", CPP);
- IASTReturnStatement returnStatement =
- (IASTReturnStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[0]).getBody()).getStatements()[0];
- ICPPASTSimpleTypeConstructorExpression expression =
- (ICPPASTSimpleTypeConstructorExpression) returnStatement.getReturnValue();
+ IASTTranslationUnit tu = parse("int foo() { return int();}", CPP);
+ IASTReturnStatement returnStatement = (IASTReturnStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
+ .getDeclarations()[0]).getBody()).getStatements()[0];
+ ICPPASTSimpleTypeConstructorExpression expression = (ICPPASTSimpleTypeConstructorExpression) returnStatement
+ .getReturnValue();
assertEquals(expression.getInitialValue(), null);
assertEquals(expression.getSimpleType(), ICPPASTSimpleTypeConstructorExpression.t_int);
}
public void testBug90498a() throws Exception {
- IASTTranslationUnit tu = parse(
- "typedef int INT;\ntypedef INT (FOO) (INT);", CPP);
+ IASTTranslationUnit tu = parse("typedef int INT;\ntypedef INT (FOO) (INT);", CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
IASTDeclSpecifier declSpec = decl.getDeclSpecifier();
@@ -3969,8 +3956,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testBug90498b() throws Exception {
- IASTTranslationUnit tu = parse(
- "int (* foo) (int) (0);", CPP);
+ IASTTranslationUnit tu = parse("int (* foo) (int) (0);", CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTDeclSpecifier declSpec = decl.getDeclSpecifier();
@@ -3998,8 +3984,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTCompoundStatement cs = (IASTCompoundStatement) foo.getBody();
IASTStatement[] subs = cs.getStatements();
for (int i = 0; i < subs.length; ++i) {
- IASTBinaryExpression be =
- (IASTBinaryExpression) ((IASTExpressionStatement) subs[i]).getExpression();
+ IASTBinaryExpression be = (IASTBinaryExpression) ((IASTExpressionStatement) subs[i]).getExpression();
if (i == 1) {
IASTTypeIdExpression expression = (IASTTypeIdExpression) be.getOperand1();
IASTTypeId typeId = expression.getTypeId();
@@ -4059,8 +4044,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testBug90603() throws Exception {
- IASTTranslationUnit tu = parse(
- "class X { void f(){} };", CPP);
+ IASTTranslationUnit tu = parse("class X { void f(){} };", CPP);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -4091,8 +4075,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IVariable x = (IVariable) col.getName(2).resolveBinding();
IProblemBinding problem = (IProblemBinding) col.getName(3).resolveBinding();
assertSame(x.getType(), X);
- assertEquals(problem.getID(),
- IProblemBinding.SEMANTIC_INVALID_REDEFINITION);
+ assertEquals(problem.getID(), IProblemBinding.SEMANTIC_INVALID_REDEFINITION);
}
// struct C {
@@ -4379,8 +4362,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IVariable a1 = (IVariable) col.getName(1).resolveBinding();
IVariable a2 = (IVariable) col.getName(2).resolveBinding();
- IBinding[] bs = col.getName(3).getCompletionContext().findBindings(
- col.getName(3), true);
+ IBinding[] bs = col.getName(3).getCompletionContext().findBindings(col.getName(3), true);
assertEquals(bs.length, 2);
assertSame(bs[0], a1);
assertSame(bs[1], a2);
@@ -4434,8 +4416,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testBug90648() throws ParserException {
- IASTTranslationUnit tu = parse(
- "int f() { int (&ra)[3] = a; }", CPP);
+ IASTTranslationUnit tu = parse("int f() { int (&ra)[3] = a; }", CPP);
IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
IASTCompoundStatement body = (IASTCompoundStatement) f.getBody();
final IASTDeclarationStatement statement = (IASTDeclarationStatement) body.getStatements()[0];
@@ -4482,8 +4463,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testBug90647() throws Exception {
- parse(
- "char msg[] = \"Syntax error on line %s\\n\";", CPP);
+ parse("char msg[] = \"Syntax error on line %s\\n\";", CPP);
}
// int main(int argc, char **argv)
@@ -4520,16 +4500,15 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testBug83997() throws Exception {
- IASTTranslationUnit tu = parse(
- "namespace { int x; }", CPP);
+ IASTTranslationUnit tu = parse("namespace { int x; }", CPP);
NameCollector col = new NameCollector();
tu.accept(col);
assertNoProblemBindings(col);
}
public void testBug85786() throws Exception {
- IASTTranslationUnit tu = parse(
- "void f(int); void foo () { void * p = &f; ((void (*) (int)) p) (1); }", ParserLanguage.C);
+ IASTTranslationUnit tu = parse("void f(int); void foo () { void * p = &f; ((void (*) (int)) p) (1); }",
+ ParserLanguage.C);
NameCollector nameResolver = new NameCollector();
tu.accept(nameResolver);
assertNoProblemBindings(nameResolver);
@@ -4653,8 +4632,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTCompoundStatement body = (IASTCompoundStatement) f.getBody();
for (int i = 0; i < 2; ++i) {
IASTDeclarationStatement ds = (IASTDeclarationStatement) body.getStatements()[i];
- String s1 = ((IASTNamedTypeSpecifier) ((IASTSimpleDeclaration) ds.getDeclaration())
- .getDeclSpecifier()).getName().toString();
+ String s1 = ((IASTNamedTypeSpecifier) ((IASTSimpleDeclaration) ds.getDeclaration()).getDeclSpecifier())
+ .getName().toString();
String s2 = ((IASTCompositeTypeSpecifier) A.getDeclSpecifier()).getName().toString();
assertEquals(s1, s2);
}
@@ -4705,7 +4684,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPASTPointerToMember po = (ICPPASTPointerToMember) d.getPointerOperators()[0];
assertEquals("X::", po.getName().toString());
}
-
+
// struct cat {
// void meow();
// };
@@ -4726,14 +4705,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testBug84466() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
- ICPPASTCastExpression dynamic_cast =
- (ICPPASTCastExpression) ((IASTEqualsInitializer) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
- .getDeclarations()[2]).getBody()).getStatements()[0])
- .getDeclaration()).getDeclarators()[0].getInitializer())
- .getInitializerClause();
+ ICPPASTCastExpression dynamic_cast = (ICPPASTCastExpression) ((IASTEqualsInitializer) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
+ .getDeclarations()[2]).getBody()).getStatements()[0]).getDeclaration()).getDeclarators()[0]
+ .getInitializer()).getInitializerClause();
- assertEquals(dynamic_cast.getOperator(),
- ICPPASTCastExpression.op_dynamic_cast);
+ assertEquals(dynamic_cast.getOperator(), ICPPASTCastExpression.op_dynamic_cast);
}
public void testBug88338_CPP() throws Exception {
@@ -4801,10 +4777,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
// Sub::Sub(Other * b) : Base(b) {}
public void testBug95673() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
- ICPPConstructor ctor= ba.assertNonProblem("Base(Other", 4, ICPPConstructor.class);
- ICPPConstructor ctor2= ba.assertNonProblem("Base(b)", 4, ICPPConstructor.class);
+ ICPPConstructor ctor = ba.assertNonProblem("Base(Other", 4, ICPPConstructor.class);
+ ICPPConstructor ctor2 = ba.assertNonProblem("Base(b)", 4, ICPPConstructor.class);
assertSame(ctor, ctor2);
}
@@ -4920,8 +4896,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testBug94779() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
- IASTDeclarationStatement ds =
- (IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
+ IASTDeclarationStatement ds = (IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
.getDeclarations()[0]).getBody()).getStatements()[0];
IASTDeclarator d = ((IASTSimpleDeclaration) ds.getDeclaration()).getDeclarators()[0];
assertTrue(d.getName().resolveBinding() instanceof IVariable);
@@ -4959,10 +4934,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
IASTDeclaration[] decls = tu.getDeclarations();
- assertTrue(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).isComplex());
- assertEquals(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
- assertTrue(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).isComplex());
- assertEquals(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
+ assertTrue(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).isComplex());
+ assertEquals(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).getType(),
+ IASTSimpleDeclSpecifier.t_float);
+ assertTrue(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[1]).getDeclSpecifier()).isComplex());
+ assertEquals(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[1]).getDeclSpecifier()).getType(),
+ IASTSimpleDeclSpecifier.t_double);
}
// class _A {
@@ -5039,7 +5016,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
ICPPConstructor ctor = (ICPPConstructor) col.getName(1).resolveBinding();
- ICPPConstructor [] cs = A.getConstructors();
+ ICPPConstructor[] cs = A.getConstructors();
assertTrue(cs.length == 2);
assertSame(cs[1], ctor);
}
@@ -5080,7 +5057,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPClassType B = (ICPPClassType) col.getName(2).resolveBinding();
ICPPClassType C = (ICPPClassType) col.getName(3).resolveBinding();
- ICPPClassType [] classes = A.getNestedClasses();
+ ICPPClassType[] classes = A.getNestedClasses();
assertEquals(classes.length, 2);
assertSame(classes[0], B);
assertSame(classes[1], C);
@@ -5096,7 +5073,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
tu.accept(col);
ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
- IBinding [] bindings = A.getMemberBindings();
+ IBinding[] bindings = A.getMemberBindings();
assertEquals(bindings.length, 3);
assertSame(bindings[0], col.getName(1).resolveBinding());
assertSame(bindings[1], col.getName(2).resolveBinding());
@@ -5164,32 +5141,32 @@ public class AST2CPPTests extends AST2CPPTestBase {
// i(&a); // i(int * const &)
// }
public void testRankingQualificationConversions_c() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
-
- ICPPFunction f1= bh.assertNonProblem("f(const int&)", 1);
- ICPPFunction f2= bh.assertNonProblem("f(int&)", 1);
- ICPPFunction g1= bh.assertNonProblem("g(const int&)", 1);
- ICPPFunction g2= bh.assertNonProblem("g(int)", 1);
- ICPPFunction h1= bh.assertNonProblem("h(const int * const&)", 1);
- ICPPFunction h2= bh.assertNonProblem("h(int *)", 1);
- ICPPFunction i1= bh.assertNonProblem("i(int * const &)", 1);
- ICPPFunction i2= bh.assertNonProblem("i(const int *)", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+
+ ICPPFunction f1 = bh.assertNonProblem("f(const int&)", 1);
+ ICPPFunction f2 = bh.assertNonProblem("f(int&)", 1);
+ ICPPFunction g1 = bh.assertNonProblem("g(const int&)", 1);
+ ICPPFunction g2 = bh.assertNonProblem("g(int)", 1);
+ ICPPFunction h1 = bh.assertNonProblem("h(const int * const&)", 1);
+ ICPPFunction h2 = bh.assertNonProblem("h(int *)", 1);
+ ICPPFunction i1 = bh.assertNonProblem("i(int * const &)", 1);
+ ICPPFunction i2 = bh.assertNonProblem("i(const int *)", 1);
ICPPFunction ref;
- ref= bh.assertNonProblem("f(ca)", 1);
+ ref = bh.assertNonProblem("f(ca)", 1);
assertSame(f1, ref);
- ref= bh.assertNonProblem("f(a)", 1);
+ ref = bh.assertNonProblem("f(a)", 1);
assertSame(f2, ref);
bh.assertProblem("g(ca)", 1);
bh.assertProblem("g(a)", 1);
- ref= bh.assertNonProblem("h(&ca)", 1);
+ ref = bh.assertNonProblem("h(&ca)", 1);
assertSame(h1, ref);
- ref= bh.assertNonProblem("h(&a)", 1);
+ ref = bh.assertNonProblem("h(&a)", 1);
assertSame(h2, ref);
- ref= bh.assertNonProblem("i(&ca)", 1);
+ ref = bh.assertNonProblem("i(&ca)", 1);
assertSame(i2, ref);
- ref= bh.assertNonProblem("i(&a)", 1);
+ ref = bh.assertNonProblem("i(&a)", 1);
assertSame(i1, ref);
}
@@ -5256,7 +5233,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f1(__null);
// }
public void testBug240567() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
bh.assertNonProblem("f1(__null", 2, ICPPFunction.class);
}
@@ -5405,7 +5382,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testBug78800() throws Exception {
- parseAndCheckBindings("class Matrix { public: Matrix & operator *(Matrix &); }; Matrix rotate, translate; Matrix transform = rotate * translate;");
+ parseAndCheckBindings(
+ "class Matrix { public: Matrix & operator *(Matrix &); }; Matrix rotate, translate; Matrix transform = rotate * translate;");
}
// struct U { static int i; };
@@ -5435,7 +5413,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testBug1043290() throws Exception {
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment());
IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[0];
- IASTStatement [] statements = ((IASTCompoundStatement)fd.getBody()).getStatements();
+ IASTStatement[] statements = ((IASTCompoundStatement) fd.getBody()).getStatements();
IASTWhileStatement whileStmt = (IASTWhileStatement) statements[1];
IASTLabelStatement labelStmt = (IASTLabelStatement) whileStmt.getBody();
assertTrue(labelStmt.getNestedStatement() instanceof IASTExpressionStatement);
@@ -5541,9 +5519,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// check class
IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[2];
- IASTDeclarator fdecl= fd.getDeclarator();
- IASTName name= fdecl.getName();
- IBinding binding= name.resolveBinding();
+ IASTDeclarator fdecl = fd.getDeclarator();
+ IASTName name = fdecl.getName();
+ IBinding binding = name.resolveBinding();
assertTrue(binding instanceof IFunction);
assertFalse(binding instanceof IProblemBinding);
}
@@ -5605,21 +5583,21 @@ public class AST2CPPTests extends AST2CPPTestBase {
// problem5(ptm);
// }
public void testBug214335() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
-
- IBinding b00= bh.assertProblem("problem1(\"", 8);
- IBinding b01= bh.assertProblem("problem2(\"", 8);
- IBinding b02= bh.assertProblem("problem3(\"", 8);
- IBinding b03= bh.assertNonProblem("nonproblem1(\"", 11);
- IBinding b04= bh.assertProblem("problem4(\"", 8);
- IBinding b05= bh.assertProblem("problem5(\"", 8);
-
- IBinding b06= bh.assertProblem("problem1(ptm", 8);
- IBinding b07= bh.assertProblem("problem2(ptm", 8);
- IBinding b08= bh.assertProblem("problem3(ptm", 8);
- IBinding b09= bh.assertNonProblem("nonproblem1(ptm", 11);
- IBinding b10= bh.assertProblem("problem4(ptm", 8);
- IBinding b11= bh.assertProblem("problem5(ptm", 8);
+ BindingAssertionHelper bh = getAssertionHelper();
+
+ IBinding b00 = bh.assertProblem("problem1(\"", 8);
+ IBinding b01 = bh.assertProblem("problem2(\"", 8);
+ IBinding b02 = bh.assertProblem("problem3(\"", 8);
+ IBinding b03 = bh.assertNonProblem("nonproblem1(\"", 11);
+ IBinding b04 = bh.assertProblem("problem4(\"", 8);
+ IBinding b05 = bh.assertProblem("problem5(\"", 8);
+
+ IBinding b06 = bh.assertProblem("problem1(ptm", 8);
+ IBinding b07 = bh.assertProblem("problem2(ptm", 8);
+ IBinding b08 = bh.assertProblem("problem3(ptm", 8);
+ IBinding b09 = bh.assertNonProblem("nonproblem1(ptm", 11);
+ IBinding b10 = bh.assertProblem("problem4(ptm", 8);
+ IBinding b11 = bh.assertProblem("problem5(ptm", 8);
assertInstance(b03, ICPPFunction.class);
assertInstance(b09, ICPPFunction.class);
@@ -5662,64 +5640,70 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
IASTDeclaration[] decls = tu.getDeclarations();
- ICPPASTNamespaceDefinition nsdef= (ICPPASTNamespaceDefinition) decls[0];
- ICPPASTUsingDeclaration udcl= (ICPPASTUsingDeclaration) decls[2];
- ICPPASTUsingDeclaration udf= (ICPPASTUsingDeclaration) decls[3];
- IASTFunctionDefinition fdef= (IASTFunctionDefinition) decls[4];
-
- IASTDeclaration[] nsdecls= nsdef.getDeclarations();
- ICPPASTCompositeTypeSpecifier cldef= (ICPPASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) nsdecls[0]).getDeclSpecifier();
- ICPPASTFunctionDeclarator fdecl1= (ICPPASTFunctionDeclarator) ((IASTSimpleDeclaration) nsdecls[1]).getDeclarators()[0];
- ICPPASTFunctionDeclarator fdecl2= (ICPPASTFunctionDeclarator) ((IASTSimpleDeclaration) nsdecls[2]).getDeclarators()[0];
-
- IASTStatement[] stmts= ((IASTCompoundStatement) fdef.getBody()).getStatements();
- IASTName clname= ((IASTNamedTypeSpecifier) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) stmts[0]).getDeclaration()).getDeclSpecifier()).getName();
- IASTName fnname1= ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTExpressionStatement) stmts[1]).getExpression()).getFunctionNameExpression()).getName();
- IASTName fnname2= ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTExpressionStatement) stmts[2]).getExpression()).getFunctionNameExpression()).getName();
+ ICPPASTNamespaceDefinition nsdef = (ICPPASTNamespaceDefinition) decls[0];
+ ICPPASTUsingDeclaration udcl = (ICPPASTUsingDeclaration) decls[2];
+ ICPPASTUsingDeclaration udf = (ICPPASTUsingDeclaration) decls[3];
+ IASTFunctionDefinition fdef = (IASTFunctionDefinition) decls[4];
+
+ IASTDeclaration[] nsdecls = nsdef.getDeclarations();
+ ICPPASTCompositeTypeSpecifier cldef = (ICPPASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) nsdecls[0])
+ .getDeclSpecifier();
+ ICPPASTFunctionDeclarator fdecl1 = (ICPPASTFunctionDeclarator) ((IASTSimpleDeclaration) nsdecls[1])
+ .getDeclarators()[0];
+ ICPPASTFunctionDeclarator fdecl2 = (ICPPASTFunctionDeclarator) ((IASTSimpleDeclaration) nsdecls[2])
+ .getDeclarators()[0];
+
+ IASTStatement[] stmts = ((IASTCompoundStatement) fdef.getBody()).getStatements();
+ IASTName clname = ((IASTNamedTypeSpecifier) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) stmts[0])
+ .getDeclaration()).getDeclSpecifier()).getName();
+ IASTName fnname1 = ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTExpressionStatement) stmts[1])
+ .getExpression()).getFunctionNameExpression()).getName();
+ IASTName fnname2 = ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTExpressionStatement) stmts[2])
+ .getExpression()).getFunctionNameExpression()).getName();
// check class
- IBinding b= cldef.getName().resolveBinding();
- assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
- assertEquals(1, tu.getDefinitionsInAST(b).length); // class-def
- assertEquals(2, tu.getDeclarationsInAST(b).length); // class-def + using-decl
+ IBinding b = cldef.getName().resolveBinding();
+ assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
+ assertEquals(1, tu.getDefinitionsInAST(b).length); // class-def
+ assertEquals(2, tu.getDeclarationsInAST(b).length); // class-def + using-decl
// check functions
- b= fdecl1.getName().resolveBinding();
- assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
- assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
- assertEquals(2, tu.getDeclarationsInAST(b).length); // func-decl + using-decl
- b= fdecl2.getName().resolveBinding();
- assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
- assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
- assertEquals(2, tu.getDeclarationsInAST(b).length); // func-decl + using-decl
+ b = fdecl1.getName().resolveBinding();
+ assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
+ assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
+ assertEquals(2, tu.getDeclarationsInAST(b).length); // func-decl + using-decl
+ b = fdecl2.getName().resolveBinding();
+ assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
+ assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
+ assertEquals(2, tu.getDeclarationsInAST(b).length); // func-decl + using-decl
// check using declaration class
- b= udcl.getName().resolveBinding();
- assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
- assertEquals(1, tu.getDefinitionsInAST(b).length); // class-def
- assertEquals(2, tu.getDeclarationsInAST(b).length); // class-def + using-decl
+ b = udcl.getName().resolveBinding();
+ assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
+ assertEquals(1, tu.getDefinitionsInAST(b).length); // class-def
+ assertEquals(2, tu.getDeclarationsInAST(b).length); // class-def + using-decl
// check using declaration function
- b= udf.getName().resolveBinding();
- assertEquals(5, tu.getReferences(b).length); // 4 refs + using-decl
- assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
- assertEquals(3, tu.getDeclarationsInAST(b).length); // using-decl + 2 func-decls
+ b = udf.getName().resolveBinding();
+ assertEquals(5, tu.getReferences(b).length); // 4 refs + using-decl
+ assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
+ assertEquals(3, tu.getDeclarationsInAST(b).length); // using-decl + 2 func-decls
// check class reference
- b= clname.resolveBinding();
- assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
- assertEquals(1, tu.getDefinitionsInAST(b).length); // class-def
- assertEquals(2, tu.getDeclarationsInAST(b).length); // class-def + using-decl
+ b = clname.resolveBinding();
+ assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
+ assertEquals(1, tu.getDefinitionsInAST(b).length); // class-def
+ assertEquals(2, tu.getDeclarationsInAST(b).length); // class-def + using-decl
// check function references
- b= fnname1.resolveBinding();
- assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
- assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
- assertEquals(2, tu.getDeclarationsInAST(b).length); // using-decl + func-decl
- b= fnname2.resolveBinding();
- assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
- assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
- assertEquals(2, tu.getDeclarationsInAST(b).length); // using-decl + func-decl
+ b = fnname1.resolveBinding();
+ assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
+ assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
+ assertEquals(2, tu.getDeclarationsInAST(b).length); // using-decl + func-decl
+ b = fnname2.resolveBinding();
+ assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
+ assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
+ assertEquals(2, tu.getDeclarationsInAST(b).length); // using-decl + func-decl
}
// namespace x {
@@ -5735,9 +5719,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// a=0;
// }
public void testUsingDirectiveWithNestedClass_209582() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
- IBinding b= bh.assertNonProblem("a=", 1);
+ IBinding b = bh.assertNonProblem("a=", 1);
assertEquals("x", b.getScope().getScopeName().toString());
}
@@ -5754,7 +5738,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// Test foo3 (&bar);
// }
public void testCastAmbiguity_211756() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
bh.assertNonProblem("foo1", 4);
bh.assertNonProblem("foo2", 4);
@@ -5768,7 +5752,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// return 0;
// }
public void testTemplateIDAmbiguity_104706() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
bh.assertNonProblem("relayIndex <", 10);
bh.assertNonProblem("relayIndex >", 10);
@@ -5806,7 +5790,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// func(unqualified);
// }
public void testScopeOfUsingDelegates_219424() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
bh.assertNonProblem("cl c", 2);
bh.assertNonProblem("func(qualified)", 4);
@@ -5822,40 +5806,40 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testQualifiedMemberDeclaration_222026() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
- IBinding b= bh.assertNonProblem("member1", 7);
- IBinding b2= bh.assertNonProblem("member1(){", 7);
+ IBinding b = bh.assertNonProblem("member1", 7);
+ IBinding b2 = bh.assertNonProblem("member1(){", 7);
assertTrue(b instanceof ICPPMethod);
- ICPPMethod m1= (ICPPMethod) b;
+ ICPPMethod m1 = (ICPPMethod) b;
assertEquals("member1", m1.getName());
assertEquals("Test", m1.getScope().getScopeName().toString());
assertSame(b, b2);
- bh= new AST2AssertionHelper(code, true);
- b= bh.assertNonProblem("member2", 7);
- b2= bh.assertNonProblem("member2();", 7);
+ bh = new AST2AssertionHelper(code, true);
+ b = bh.assertNonProblem("member2", 7);
+ b2 = bh.assertNonProblem("member2();", 7);
assertTrue(b instanceof ICPPMethod);
- m1= (ICPPMethod) b;
+ m1 = (ICPPMethod) b;
assertEquals("member2", m1.getName());
assertEquals("Test", m1.getScope().getScopeName().toString());
assertSame(b, b2);
// different resolution order
- bh= new AST2AssertionHelper(code, true);
- b2= bh.assertNonProblem("member1(){", 7);
- b= bh.assertNonProblem("member1", 7);
+ bh = new AST2AssertionHelper(code, true);
+ b2 = bh.assertNonProblem("member1(){", 7);
+ b = bh.assertNonProblem("member1", 7);
assertTrue(b instanceof ICPPMethod);
- m1= (ICPPMethod) b;
+ m1 = (ICPPMethod) b;
assertEquals("member1", m1.getName());
assertEquals("Test", m1.getScope().getScopeName().toString());
assertSame(b, b2);
- bh= new AST2AssertionHelper(code, true);
- b2= bh.assertNonProblem("member2();", 7);
- b= bh.assertNonProblem("member2", 7);
+ bh = new AST2AssertionHelper(code, true);
+ b2 = bh.assertNonProblem("member2();", 7);
+ b = bh.assertNonProblem("member2", 7);
assertTrue(b instanceof ICPPMethod);
- m1= (ICPPMethod) b;
+ m1 = (ICPPMethod) b;
assertEquals("member2", m1.getName());
assertEquals("Test", m1.getScope().getScopeName().toString());
assertSame(b, b2);
@@ -5870,49 +5854,49 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testQualifiedMemberDeclarationInNamespace_222026() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
- IBinding b= bh.assertNonProblem("member1", 7);
- IBinding b2= bh.assertNonProblem("member1(){", 7);
+ IBinding b = bh.assertNonProblem("member1", 7);
+ IBinding b2 = bh.assertNonProblem("member1(){", 7);
assertTrue(b instanceof ICPPFunction);
- ICPPFunction m1= (ICPPFunction) b;
+ ICPPFunction m1 = (ICPPFunction) b;
assertEquals("member1", m1.getName());
assertEquals("Test", m1.getScope().getScopeName().toString());
assertSame(b, b2);
- bh= new AST2AssertionHelper(code, true);
- b= bh.assertNonProblem("member2", 7);
- b2= bh.assertNonProblem("member2();", 7);
+ bh = new AST2AssertionHelper(code, true);
+ b = bh.assertNonProblem("member2", 7);
+ b2 = bh.assertNonProblem("member2();", 7);
assertTrue(b instanceof ICPPFunction);
- m1= (ICPPFunction) b;
+ m1 = (ICPPFunction) b;
assertEquals("member2", m1.getName());
assertEquals("Test", m1.getScope().getScopeName().toString());
assertSame(b, b2);
// different resolution order
- bh= new AST2AssertionHelper(code, true);
- b2= bh.assertNonProblem("member1(){", 7);
- b= bh.assertNonProblem("member1", 7);
+ bh = new AST2AssertionHelper(code, true);
+ b2 = bh.assertNonProblem("member1(){", 7);
+ b = bh.assertNonProblem("member1", 7);
assertTrue(b instanceof ICPPFunction);
- m1= (ICPPFunction) b;
+ m1 = (ICPPFunction) b;
assertEquals("member1", m1.getName());
assertEquals("Test", m1.getScope().getScopeName().toString());
assertSame(b, b2);
- bh= new AST2AssertionHelper(code, true);
- b2= bh.assertNonProblem("member2();", 7);
- b= bh.assertNonProblem("member2", 7);
+ bh = new AST2AssertionHelper(code, true);
+ b2 = bh.assertNonProblem("member2();", 7);
+ b = bh.assertNonProblem("member2", 7);
assertTrue(b instanceof ICPPFunction);
- m1= (ICPPFunction) b;
+ m1 = (ICPPFunction) b;
assertEquals("member2", m1.getName());
assertEquals("Test", m1.getScope().getScopeName().toString());
assertSame(b, b2);
}
// namespace ns { typedef int ns::TINT; } // illegal, still no CCE is expected.
- public void testQualifiedTypedefs_222093() throws Exception{
- BindingAssertionHelper bh= getAssertionHelper();
- IBinding td= bh.assertProblem("TINT", 4);
+ public void testQualifiedTypedefs_222093() throws Exception {
+ BindingAssertionHelper bh = getAssertionHelper();
+ IBinding td = bh.assertProblem("TINT", 4);
bh.assertProblem("ns::", 2);
}
@@ -5922,17 +5906,17 @@ public class AST2CPPTests extends AST2CPPTestBase {
// if (a > b) {
// }
// }
- public void testResettingTemplateIdScopesStack_223777() throws Exception{
+ public void testResettingTemplateIdScopesStack_223777() throws Exception {
parseAndCheckBindings(getAboveComment());
}
// long x= 10L;
public void testLongLiteral_225534() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
- IASTDeclarator decltor= ((IASTSimpleDeclaration)tu.getDeclarations()[0]).getDeclarators()[0];
- IASTEqualsInitializer init= (IASTEqualsInitializer) decltor.getInitializer();
- ICPPASTLiteralExpression exp= (ICPPASTLiteralExpression) init.getInitializerClause();
- ICPPBasicType type= (ICPPBasicType) exp.getExpressionType();
+ IASTDeclarator decltor = ((IASTSimpleDeclaration) tu.getDeclarations()[0]).getDeclarators()[0];
+ IASTEqualsInitializer init = (IASTEqualsInitializer) decltor.getInitializer();
+ ICPPASTLiteralExpression exp = (ICPPASTLiteralExpression) init.getInitializerClause();
+ ICPPBasicType type = (ICPPBasicType) exp.getExpressionType();
assertTrue(type.isLong());
}
@@ -5995,13 +5979,13 @@ public class AST2CPPTests extends AST2CPPTestBase {
// foo/*k2*/(11.1E1L);
// }
public void testLiteralsViaOverloads_225534() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
- char[] cs= {'a','b','e','f','g','h','i','j','k'};
+ BindingAssertionHelper ba = getAssertionHelper();
+ char[] cs = { 'a', 'b', 'e', 'f', 'g', 'h', 'i', 'j', 'k' };
for (char c : cs) {
- for (int i=1; i<(c < 'i' ? 4 : 3); i++) {
- ICPPFunction def= ba.assertNonProblem("foo/*_"+c+"*/", 3, ICPPFunction.class);
- ICPPFunction ref= ba.assertNonProblem("foo/*"+c+""+i+"*/", 3, ICPPFunction.class);
- assertSame("function ref: "+c+""+i, def, ref);
+ for (int i = 1; i < (c < 'i' ? 4 : 3); i++) {
+ ICPPFunction def = ba.assertNonProblem("foo/*_" + c + "*/", 3, ICPPFunction.class);
+ ICPPFunction ref = ba.assertNonProblem("foo/*" + c + "" + i + "*/", 3, ICPPFunction.class);
+ assertSame("function ref: " + c + "" + i, def, ref);
}
}
}
@@ -6055,7 +6039,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// X::operator int() {}
// X::xtint(a); // 2
public void testEmptyDeclSpecifier() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("X {", 1, ICPPClassType.class);
ba.assertNonProblem("X()", 1, ICPPConstructor.class);
ba.assertNonProblem("~X", 2, ICPPMethod.class);
@@ -6090,8 +6074,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// new (p) (T[f][f]);
// };
public void testNewPlacement() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment());
- IASTFunctionDefinition fdef= getDeclaration(tu, 3);
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment());
+ IASTFunctionDefinition fdef = getDeclaration(tu, 3);
checkNewExpression(fdef, 0, null, "int", null);
checkNewExpression(fdef, 1, null, "int", IASTExpressionList.class);
@@ -6117,11 +6101,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
// +
// }
public void testTrailingSyntaxErrorInNamespace() throws Exception {
- final String comment= getAboveComment();
- IASTTranslationUnit tu= parse(comment, CPP, false, false);
- ICPPASTNamespaceDefinition ns= getDeclaration(tu, 0);
- IASTDeclaration decl= getDeclaration(ns, 0);
- IASTProblemDeclaration pdecl= getDeclaration(ns, 1);
+ final String comment = getAboveComment();
+ IASTTranslationUnit tu = parse(comment, CPP, false, false);
+ ICPPASTNamespaceDefinition ns = getDeclaration(tu, 0);
+ IASTDeclaration decl = getDeclaration(ns, 0);
+ IASTProblemDeclaration pdecl = getDeclaration(ns, 1);
assertEquals("+", pdecl.getRawSignature());
}
@@ -6130,23 +6114,23 @@ public class AST2CPPTests extends AST2CPPTestBase {
// +
// }
public void testTrailingSyntaxErrorInLinkageSpec() throws Exception {
- final String comment= getAboveComment();
- IASTTranslationUnit tu= parse(comment, CPP, false, false);
- ICPPASTLinkageSpecification ls= getDeclaration(tu, 0);
- IASTDeclaration decl= getDeclaration(ls, 0);
- IASTProblemDeclaration pdecl= getDeclaration(ls, 1);
+ final String comment = getAboveComment();
+ IASTTranslationUnit tu = parse(comment, CPP, false, false);
+ ICPPASTLinkageSpecification ls = getDeclaration(tu, 0);
+ IASTDeclaration decl = getDeclaration(ls, 0);
+ IASTProblemDeclaration pdecl = getDeclaration(ls, 1);
assertEquals("+", pdecl.getRawSignature());
}
// class C;
// void func(void (C::*m)(int) const);
public void test233889_a() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
- ICPPFunction func= bh.assertNonProblem("func(", 4, ICPPFunction.class);
- assertEquals(1,func.getParameters().length);
- IType type= func.getParameters()[0].getType();
- ICPPPointerToMemberType ptm= assertInstance(type, ICPPPointerToMemberType.class);
- ICPPFunctionType t= ((ICPPFunctionType)ptm.getType());
+ BindingAssertionHelper bh = getAssertionHelper();
+ ICPPFunction func = bh.assertNonProblem("func(", 4, ICPPFunction.class);
+ assertEquals(1, func.getParameters().length);
+ IType type = func.getParameters()[0].getType();
+ ICPPPointerToMemberType ptm = assertInstance(type, ICPPPointerToMemberType.class);
+ ICPPFunctionType t = ((ICPPFunctionType) ptm.getType());
assertTrue(t.isConst());
}
@@ -6163,9 +6147,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// func(&C::m2);
// }
public void testBug233889_b() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
- ICPPFunction fn1= bh.assertNonProblem("func(&C::m1", 4, ICPPFunction.class);
- ICPPFunction fn2= bh.assertNonProblem("func(&C::m2", 4, ICPPFunction.class);
+ BindingAssertionHelper bh = getAssertionHelper();
+ ICPPFunction fn1 = bh.assertNonProblem("func(&C::m1", 4, ICPPFunction.class);
+ ICPPFunction fn2 = bh.assertNonProblem("func(&C::m2", 4, ICPPFunction.class);
assertNotSame(fn1, fn2);
}
@@ -6184,21 +6168,24 @@ public class AST2CPPTests extends AST2CPPTestBase {
// void member4() const volatile { foo(this);/*4*/ }
// };
public void testThisType() throws Exception {
- BindingAssertionHelper ba=getAssertionHelper();
- ICPPFunction pt1= ba.assertNonProblem("foo(this);/*1*/", 3, ICPPFunction.class);
- ICPPFunction pt2= ba.assertNonProblem("foo(this);/*2*/", 3, ICPPFunction.class);
- ICPPFunction pt3= ba.assertNonProblem("foo(this);/*3*/", 3, ICPPFunction.class);
- ICPPFunction pt4= ba.assertNonProblem("foo(this);/*4*/", 3, ICPPFunction.class);
+ BindingAssertionHelper ba = getAssertionHelper();
+ ICPPFunction pt1 = ba.assertNonProblem("foo(this);/*1*/", 3, ICPPFunction.class);
+ ICPPFunction pt2 = ba.assertNonProblem("foo(this);/*2*/", 3, ICPPFunction.class);
+ ICPPFunction pt3 = ba.assertNonProblem("foo(this);/*3*/", 3, ICPPFunction.class);
+ ICPPFunction pt4 = ba.assertNonProblem("foo(this);/*4*/", 3, ICPPFunction.class);
- IType t1= ((IPointerType)pt1.getType().getParameterTypes()[0]).getType();
- IQualifierType t2= (IQualifierType) ((IPointerType) pt2.getType().getParameterTypes()[0]).getType();
- IQualifierType t3= (IQualifierType) ((IPointerType) pt3.getType().getParameterTypes()[0]).getType();
- IQualifierType t4= (IQualifierType) ((IPointerType) pt4.getType().getParameterTypes()[0]).getType();
+ IType t1 = ((IPointerType) pt1.getType().getParameterTypes()[0]).getType();
+ IQualifierType t2 = (IQualifierType) ((IPointerType) pt2.getType().getParameterTypes()[0]).getType();
+ IQualifierType t3 = (IQualifierType) ((IPointerType) pt3.getType().getParameterTypes()[0]).getType();
+ IQualifierType t4 = (IQualifierType) ((IPointerType) pt4.getType().getParameterTypes()[0]).getType();
assertTrue(!(t1 instanceof IQualifierType));
- assertTrue(t2.isConst()); assertTrue(!t2.isVolatile());
- assertTrue(!t3.isConst()); assertTrue(t3.isVolatile());
- assertTrue(t4.isConst()); assertTrue(t4.isVolatile());
+ assertTrue(t2.isConst());
+ assertTrue(!t2.isVolatile());
+ assertTrue(!t3.isConst());
+ assertTrue(t3.isVolatile());
+ assertTrue(t4.isConst());
+ assertTrue(t4.isVolatile());
}
// class A {
@@ -6213,7 +6200,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// a2->foo();/*2*/
// }
public void testMemberAccessOperator_a() throws Exception {
- BindingAssertionHelper ba=getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertProblem("foo();/*1*/", 3);
ba.assertNonProblem("foo();/*2*/", 3);
}
@@ -6236,9 +6223,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// b2->foo();/*2*/
// }
public void testMemberAccessOperator_b() throws Exception {
- BindingAssertionHelper ba=getAssertionHelper();
- ICPPMethod m1= ba.assertNonProblem("foo();/*1*/", 3, ICPPMethod.class);
- ICPPMethod m2= ba.assertNonProblem("foo();/*2*/", 3, ICPPMethod.class);
+ BindingAssertionHelper ba = getAssertionHelper();
+ ICPPMethod m1 = ba.assertNonProblem("foo();/*1*/", 3, ICPPMethod.class);
+ ICPPMethod m2 = ba.assertNonProblem("foo();/*2*/", 3, ICPPMethod.class);
assertEquals(m1.getClassOwner().getName(), "A");
assertEquals(m2.getClassOwner().getName(), "B");
}
@@ -6252,7 +6239,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// c->foo();/**/ // refers to A::foo
// }
public void testMemberAccessOperator_c() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("foo();/**/", 3);
}
@@ -6265,7 +6252,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// c->foo();/**/ // expect problem - foo is not in B
// }
public void testMemberAccessOperator_d() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertProblem("foo();/**/", 3);
}
@@ -6281,7 +6268,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// c->foo();/**/ // refers to A::foo
// }
public void testMemberAccessOperator_e() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("foo();/**/", 3);
}
@@ -6309,7 +6296,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f4(s);
// }
public void testArrayToPointerConversion() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("f1(p)", 2, ICPPFunction.class);
ba.assertProblem("f2(q)", 2);
ba.assertNonProblem("f3(r)", 2, ICPPFunction.class);
@@ -6364,30 +6351,30 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testRestrictIsNoCPPKeyword_228826() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code, CPP, false);
- parseAndCheckBindings(getAboveComment(), CPP, true); // even with gnu extensions
+ parseAndCheckBindings(getAboveComment(), CPP, true); // even with gnu extensions
}
// void test1();
// void test2() throw ();
// void test3() throw (int);
public void testEmptyExceptionSpecification_86943() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP);
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), CPP);
- IASTSimpleDeclaration d= getDeclaration(tu, 0);
- ICPPASTFunctionDeclarator fdtor= (ICPPASTFunctionDeclarator) d.getDeclarators()[0];
- IASTTypeId[] specs= fdtor.getExceptionSpecification();
+ IASTSimpleDeclaration d = getDeclaration(tu, 0);
+ ICPPASTFunctionDeclarator fdtor = (ICPPASTFunctionDeclarator) d.getDeclarators()[0];
+ IASTTypeId[] specs = fdtor.getExceptionSpecification();
assertEquals(0, specs.length);
assertSame(ICPPASTFunctionDeclarator.NO_EXCEPTION_SPECIFICATION, specs);
- d= getDeclaration(tu, 1);
- fdtor= (ICPPASTFunctionDeclarator) d.getDeclarators()[0];
- specs= fdtor.getExceptionSpecification();
+ d = getDeclaration(tu, 1);
+ fdtor = (ICPPASTFunctionDeclarator) d.getDeclarators()[0];
+ specs = fdtor.getExceptionSpecification();
assertEquals(0, specs.length);
assertNotSame(ICPPASTFunctionDeclarator.NO_EXCEPTION_SPECIFICATION, specs);
- d= getDeclaration(tu, 2);
- fdtor= (ICPPASTFunctionDeclarator) d.getDeclarators()[0];
- specs= fdtor.getExceptionSpecification();
+ d = getDeclaration(tu, 2);
+ fdtor = (ICPPASTFunctionDeclarator) d.getDeclarators()[0];
+ specs = fdtor.getExceptionSpecification();
assertEquals(1, specs.length);
}
@@ -6409,9 +6396,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// func(y);
// }
public void testOverloadedFunction_248774() throws Exception {
- BindingAssertionHelper helper= getAssertionHelper();
- ICPPFunction func1= helper.assertNonProblem("func(x)", 4, ICPPFunction.class);
- ICPPFunction func2= helper.assertNonProblem("func(y)", 4, ICPPFunction.class);
+ BindingAssertionHelper helper = getAssertionHelper();
+ ICPPFunction func1 = helper.assertNonProblem("func(x)", 4, ICPPFunction.class);
+ ICPPFunction func2 = helper.assertNonProblem("func(y)", 4, ICPPFunction.class);
assertNotSame(func1, func2);
}
@@ -6428,9 +6415,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// func(y[0]);
// }
public void testOverloadedOperator_248803() throws Exception {
- BindingAssertionHelper helper= getAssertionHelper();
- ICPPFunction func1= helper.assertNonProblem("func(x[0])", 4, ICPPFunction.class);
- ICPPFunction func2= helper.assertNonProblem("func(y[0])", 4, ICPPFunction.class);
+ BindingAssertionHelper helper = getAssertionHelper();
+ ICPPFunction func1 = helper.assertNonProblem("func(x[0])", 4, ICPPFunction.class);
+ ICPPFunction func2 = helper.assertNonProblem("func(y[0])", 4, ICPPFunction.class);
assertNotSame(func1, func2);
}
@@ -6453,13 +6440,13 @@ public class AST2CPPTests extends AST2CPPTestBase {
// void m();//5
// };
public void testOverridden_248846() throws Exception {
- BindingAssertionHelper helper= getAssertionHelper();
- ICPPMethod m0= helper.assertNonProblem("m();//0", 1, ICPPMethod.class);
- ICPPMethod m1= helper.assertNonProblem("m();//1", 1, ICPPMethod.class);
- ICPPMethod m2= helper.assertNonProblem("m();//2", 1, ICPPMethod.class);
- ICPPMethod m3= helper.assertNonProblem("m(int);", 1, ICPPMethod.class);
- ICPPMethod m4= helper.assertNonProblem("m();//4", 1, ICPPMethod.class);
- ICPPMethod m5= helper.assertNonProblem("m();//5", 1, ICPPMethod.class);
+ BindingAssertionHelper helper = getAssertionHelper();
+ ICPPMethod m0 = helper.assertNonProblem("m();//0", 1, ICPPMethod.class);
+ ICPPMethod m1 = helper.assertNonProblem("m();//1", 1, ICPPMethod.class);
+ ICPPMethod m2 = helper.assertNonProblem("m();//2", 1, ICPPMethod.class);
+ ICPPMethod m3 = helper.assertNonProblem("m(int);", 1, ICPPMethod.class);
+ ICPPMethod m4 = helper.assertNonProblem("m();//4", 1, ICPPMethod.class);
+ ICPPMethod m5 = helper.assertNonProblem("m();//5", 1, ICPPMethod.class);
assertFalse(ClassTypeHelper.isVirtual(m0));
assertFalse(ClassTypeHelper.isVirtual(m3));
@@ -6489,20 +6476,20 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertFalse(ClassTypeHelper.isOverrider(m5, m2));
assertTrue(ClassTypeHelper.isOverrider(m4, m2));
- ICPPMethod[] ors= ClassTypeHelper.findOverridden(m0);
+ ICPPMethod[] ors = ClassTypeHelper.findOverridden(m0);
assertEquals(0, ors.length);
- ors= ClassTypeHelper.findOverridden(m1);
+ ors = ClassTypeHelper.findOverridden(m1);
assertEquals(0, ors.length);
- ors= ClassTypeHelper.findOverridden(m2);
+ ors = ClassTypeHelper.findOverridden(m2);
assertEquals(1, ors.length);
assertEquals(ors[0], m1);
- ors= ClassTypeHelper.findOverridden(m3);
+ ors = ClassTypeHelper.findOverridden(m3);
assertEquals(0, ors.length);
- ors= ClassTypeHelper.findOverridden(m4);
+ ors = ClassTypeHelper.findOverridden(m4);
assertEquals(2, ors.length);
assertEquals(ors[0], m2);
assertEquals(ors[1], m1);
- ors= ClassTypeHelper.findOverridden(m5);
+ ors = ClassTypeHelper.findOverridden(m5);
assertEquals(1, ors.length);
assertEquals(ors[0], m1);
}
@@ -6515,10 +6502,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
// p.a; // should not resolve
// }
public void testPointerMemberAccess_245068() throws Exception {
- final String comment= getAboveComment();
- final boolean[] isCpps= {false, true};
+ final String comment = getAboveComment();
+ final boolean[] isCpps = { false, true };
for (boolean isCpp : isCpps) {
- BindingAssertionHelper ba= new AST2AssertionHelper(comment, isCpp);
+ BindingAssertionHelper ba = new AST2AssertionHelper(comment, isCpp);
ba.assertProblem("a; // should not resolve", 1);
}
}
@@ -6540,7 +6527,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
public void testNamespaceQualifiedOperator_256840() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("operator ns::A", 14);
parseAndCheckBindings(code, CPP);
}
@@ -6551,7 +6538,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(p);
// }
public void testFunctionExtraArgument() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertProblem("f(p)", 1);
}
@@ -6561,10 +6548,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(p);
// }
public void testVariadicFunction_2500582() throws Exception {
- final String comment= getAboveComment();
- final boolean[] isCpps= {false, true};
+ final String comment = getAboveComment();
+ final boolean[] isCpps = { false, true };
for (boolean isCpp : isCpps) {
- BindingAssertionHelper ba= new AST2AssertionHelper(comment, isCpp);
+ BindingAssertionHelper ba = new AST2AssertionHelper(comment, isCpp);
ba.assertNonProblem("f(p)", 1, IFunction.class);
}
}
@@ -6579,12 +6566,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(0);
// }
public void testVariadicFunction_2500583() throws Exception {
- final String comment= getAboveComment();
- final boolean[] isCpps= {false, true};
+ final String comment = getAboveComment();
+ final boolean[] isCpps = { false, true };
for (boolean isCpp : isCpps) {
- BindingAssertionHelper ba= new AST2AssertionHelper(comment, isCpp);
- IFunction decl= ba.assertNonProblem("f(Incomplete* p)", 1, IFunction.class);
- IFunction func= ba.assertNonProblem("f(0)", 1, IFunction.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(comment, isCpp);
+ IFunction decl = ba.assertNonProblem("f(Incomplete* p)", 1, IFunction.class);
+ IFunction func = ba.assertNonProblem("f(0)", 1, IFunction.class);
assertSame(decl, func);
}
}
@@ -6602,11 +6589,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testFunctionCallOnLHS_252695() throws Exception {
final String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, CPP, true);
- IASTFunctionDefinition fdef= getDeclaration(tu, 1);
- IASTExpressionStatement exstmt= getStatement(fdef, 0);
+ IASTTranslationUnit tu = parseAndCheckBindings(code, CPP, true);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 1);
+ IASTExpressionStatement exstmt = getStatement(fdef, 0);
assertInstance(exstmt.getExpression(), IASTBinaryExpression.class);
- exstmt= getStatement(fdef, 1);
+ exstmt = getStatement(fdef, 1);
assertInstance(exstmt.getExpression(), IASTBinaryExpression.class);
}
@@ -6618,8 +6605,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// template <int E> class B {};
public void testInvalidClassRedeclaration_254961() throws Exception {
final String code = getAboveComment();
- IASTTranslationUnit tu= parse(code, CPP, true, false);
- NameCollector nc= new NameCollector();
+ IASTTranslationUnit tu = parse(code, CPP, true, false);
+ NameCollector nc = new NameCollector();
tu.accept(nc);
assertProblemBindings(nc, 4);
assertProblemBinding(IProblemBinding.SEMANTIC_INVALID_REDEFINITION, nc.getName(2).resolveBinding());
@@ -6636,8 +6623,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// template <typename T> class B {};
public void testInvalidClassRedeclaration_364226() throws Exception {
final String code = getAboveComment();
- IASTTranslationUnit tu= parse(code, CPP, true, false);
- NameCollector nc= new NameCollector();
+ IASTTranslationUnit tu = parse(code, CPP, true, false);
+ NameCollector nc = new NameCollector();
tu.accept(nc);
assertProblemBindings(nc, 4);
assertProblemBinding(IProblemBinding.SEMANTIC_INVALID_REDEFINITION, nc.getName(4).resolveBinding());
@@ -6694,7 +6681,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// int y;
// };
public void testScopeOfClassMember_259460() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("B b", 1, ICPPClassType.class);
ba.assertProblem("B p", 1);
ba.assertProblem("B method", 1);
@@ -6713,7 +6700,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
// };
public void testScopeOfClassMember_259648() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("GREEN)", 5, IEnumerator.class);
ba.assertNonProblem("RED;", 3, IEnumerator.class);
ba.assertProblem("GREEN;", 5);
@@ -6731,9 +6718,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// func(*b);
// }
public void testSmartPointerReference_259680() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
- ICPPFunction f1= ba.assertNonProblem("func(*a)", 4, ICPPFunction.class);
- ICPPFunction f2= ba.assertNonProblem("func(*b)", 4, ICPPFunction.class);
+ BindingAssertionHelper ba = getAssertionHelper();
+ ICPPFunction f1 = ba.assertNonProblem("func(*a)", 4, ICPPFunction.class);
+ ICPPFunction f2 = ba.assertNonProblem("func(*b)", 4, ICPPFunction.class);
assertNotSame(f1, f2);
}
@@ -6748,7 +6735,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// ))))))))))))))))))))))))))))));
// }
public void testNestedTemplateIDAmbiguity_259501() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code);
}
@@ -6772,7 +6759,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// (p1 % p2).a; //5
// }
public void testOverloadedBinaryOperator_259927a() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("a; //1", 1, ICPPField.class);
ba.assertNonProblem("a; //2", 1, ICPPField.class);
ba.assertNonProblem("a; //3", 1, ICPPField.class);
@@ -6801,7 +6788,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// (b + i).a; //6
// }
public void testOverloadedBinaryOperator_259927b() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("a; //1", 1, ICPPField.class);
ba.assertNonProblem("a; //2", 1, ICPPField.class);
ba.assertNonProblem("a; //3", 1, ICPPField.class);
@@ -6824,7 +6811,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// (++p1).x; //2
// }
public void testOverloadedUnaryOperator_259927c() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("x; //1", 1, ICPPField.class);
ba.assertNonProblem("x; //2", 1, ICPPField.class);
}
@@ -6841,7 +6828,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// (++p1).x; //2
// }
public void testOverloadedUnaryOperator_259927d() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("x; //1", 1, ICPPField.class);
ba.assertNonProblem("x; //2", 1, ICPPField.class);
}
@@ -6871,9 +6858,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// (~b).xx; // 6
// }
public void testOverloadedUnaryOperator_259927e() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
- for (int i = 1; i <=6; i++)
- ba.assertNonProblem("xx; // "+i, 2, ICPPField.class);
+ BindingAssertionHelper ba = getAssertionHelper();
+ for (int i = 1; i <= 6; i++)
+ ba.assertNonProblem("xx; // " + i, 2, ICPPField.class);
}
// struct A {
@@ -6902,9 +6889,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// (~b).xx; // 6
//}
public void testOverloadedUnaryOperator_259927f() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
for (int i = 1; i <= 6; i++)
- ba.assertNonProblem("xx; // "+i, 2, ICPPField.class);
+ ba.assertNonProblem("xx; // " + i, 2, ICPPField.class);
}
// int a,b,c,d ;
@@ -6921,18 +6908,18 @@ public class AST2CPPTests extends AST2CPPTestBase {
// typedef int S2 (int(t)); // resolve this ambiguity first
// };
public void testOrderOfAmbiguityResolution_259373() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
- ICPPVariable a= ba.assertNonProblem("a;", 1);
+ BindingAssertionHelper ba = getAssertionHelper();
+ ICPPVariable a = ba.assertNonProblem("a;", 1);
assertInstance(a.getType(), IPointerType.class);
- ICPPVariable b= ba.assertNonProblem("b;", 1);
+ ICPPVariable b = ba.assertNonProblem("b;", 1);
assertInstance(b.getType(), IBasicType.class);
- ICPPVariable c= ba.assertNonProblem("c;", 1);
+ ICPPVariable c = ba.assertNonProblem("c;", 1);
assertInstance(c.getType(), IPointerType.class);
- ITypedef s1= (ITypedef) ((IPointerType) c.getType()).getType();
+ ITypedef s1 = (ITypedef) ((IPointerType) c.getType()).getType();
assertInstance(((IFunctionType) s1.getType()).getParameterTypes()[0], IPointerType.class);
- ICPPVariable d= ba.assertNonProblem("d;", 1);
+ ICPPVariable d = ba.assertNonProblem("d;", 1);
assertInstance(d.getType(), IPointerType.class);
- ITypedef s2= (ITypedef) ((IPointerType) d.getType()).getType();
+ ITypedef s2 = (ITypedef) ((IPointerType) d.getType()).getType();
assertInstance(((IFunctionType) s2.getType()).getParameterTypes()[0], IBasicType.class);
}
@@ -6950,20 +6937,20 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testFriendFunctionResolution_86368() throws Exception {
BindingAssertionHelper bh = getAssertionHelper();
- IFunction f1= bh.assertNonProblem("f(int)", 1);
- IFunction f2= bh.assertNonProblem("f(1)", 1);
+ IFunction f1 = bh.assertNonProblem("f(int)", 1);
+ IFunction f2 = bh.assertNonProblem("f(1)", 1);
assertSame(f1, f2);
- IFunction g1= bh.assertNonProblem("g(int)", 1);
- IFunction g2= bh.assertNonProblem("g(1)", 1);
+ IFunction g1 = bh.assertNonProblem("g(int)", 1);
+ IFunction g2 = bh.assertNonProblem("g(1)", 1);
assertSame(g1, g2);
// Alternative binding resolution order.
bh = getAssertionHelper();
- f2= bh.assertNonProblem("f(1)", 1);
- f1= bh.assertNonProblem("f(int)", 1);
+ f2 = bh.assertNonProblem("f(1)", 1);
+ f1 = bh.assertNonProblem("f(int)", 1);
assertSame(f1, f2);
- g2= bh.assertNonProblem("g(1)", 1);
- g1= bh.assertNonProblem("g(int)", 1);
+ g2 = bh.assertNonProblem("g(1)", 1);
+ g1 = bh.assertNonProblem("g(int)", 1);
assertSame(g1, g2);
}
@@ -6980,9 +6967,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// int func(int i) { return i; }
public void testFriendFunction_438114() throws Exception {
BindingAssertionHelper bh = getAssertionHelper();
- ICPPFunction f1= bh.assertNonProblemOnFirstIdentifier("func(int i);");
- ICPPFunction f2= bh.assertNonProblemOnFirstIdentifier("func(int i = 0);");
- ICPPFunction f3= bh.assertNonProblemOnFirstIdentifier("func(int i) {");
+ ICPPFunction f1 = bh.assertNonProblemOnFirstIdentifier("func(int i);");
+ ICPPFunction f2 = bh.assertNonProblemOnFirstIdentifier("func(int i = 0);");
+ ICPPFunction f3 = bh.assertNonProblemOnFirstIdentifier("func(int i) {");
assertSame(f1, f2);
assertSame(f2, f3);
assertEquals(0, f1.getRequiredArgumentCount());
@@ -7014,36 +7001,44 @@ public class AST2CPPTests extends AST2CPPTestBase {
// a.bar();/*8*/
// }
public void testMemberFunctionDisambiguationByCVness_238409() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
-
- ICPPMethod bar_cv= bh.assertNonProblem("bar();/*1*/", 3, ICPPMethod.class);
- ICPPMethod bar_v= bh.assertNonProblem("bar();/*2*/", 3, ICPPMethod.class);
- ICPPMethod bar_c= bh.assertNonProblem("bar();/*3*/", 3, ICPPMethod.class);
- ICPPMethod bar= bh.assertNonProblem("bar();/*4*/", 3, ICPPMethod.class);
- ICPPFunctionType bar_cv_ft= bar_cv.getType();
- ICPPFunctionType bar_v_ft= bar_v.getType();
- ICPPFunctionType bar_c_ft= bar_c.getType();
- ICPPFunctionType bar_ft= bar.getType();
-
- assertTrue(bar_cv_ft.isConst()); assertTrue(bar_cv_ft.isVolatile());
- assertTrue(!bar_v_ft.isConst()); assertTrue(bar_v_ft.isVolatile());
- assertTrue(bar_c_ft.isConst()); assertTrue(!bar_c_ft.isVolatile());
- assertTrue(!bar_ft.isConst()); assertTrue(!bar_ft.isVolatile());
-
- bar_cv= bh.assertNonProblem("bar();/*5*/", 3, ICPPMethod.class);
- bar_v= bh.assertNonProblem("bar();/*6*/", 3, ICPPMethod.class);
- bar_c= bh.assertNonProblem("bar();/*7*/", 3, ICPPMethod.class);
- bar= bh.assertNonProblem("bar();/*8*/", 3, ICPPMethod.class);
- bar_cv_ft= bar_cv.getType();
- bar_v_ft= bar_v.getType();
- bar_c_ft= bar_c.getType();
- bar_ft= bar.getType();
-
- assertTrue(bar_cv_ft.isConst()); assertTrue(bar_cv_ft.isVolatile());
- assertTrue(!bar_v_ft.isConst()); assertTrue(bar_v_ft.isVolatile());
- assertTrue(bar_c_ft.isConst()); assertTrue(!bar_c_ft.isVolatile());
- assertTrue(!bar_ft.isConst()); assertTrue(!bar_ft.isVolatile());
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+
+ ICPPMethod bar_cv = bh.assertNonProblem("bar();/*1*/", 3, ICPPMethod.class);
+ ICPPMethod bar_v = bh.assertNonProblem("bar();/*2*/", 3, ICPPMethod.class);
+ ICPPMethod bar_c = bh.assertNonProblem("bar();/*3*/", 3, ICPPMethod.class);
+ ICPPMethod bar = bh.assertNonProblem("bar();/*4*/", 3, ICPPMethod.class);
+ ICPPFunctionType bar_cv_ft = bar_cv.getType();
+ ICPPFunctionType bar_v_ft = bar_v.getType();
+ ICPPFunctionType bar_c_ft = bar_c.getType();
+ ICPPFunctionType bar_ft = bar.getType();
+
+ assertTrue(bar_cv_ft.isConst());
+ assertTrue(bar_cv_ft.isVolatile());
+ assertTrue(!bar_v_ft.isConst());
+ assertTrue(bar_v_ft.isVolatile());
+ assertTrue(bar_c_ft.isConst());
+ assertTrue(!bar_c_ft.isVolatile());
+ assertTrue(!bar_ft.isConst());
+ assertTrue(!bar_ft.isVolatile());
+
+ bar_cv = bh.assertNonProblem("bar();/*5*/", 3, ICPPMethod.class);
+ bar_v = bh.assertNonProblem("bar();/*6*/", 3, ICPPMethod.class);
+ bar_c = bh.assertNonProblem("bar();/*7*/", 3, ICPPMethod.class);
+ bar = bh.assertNonProblem("bar();/*8*/", 3, ICPPMethod.class);
+ bar_cv_ft = bar_cv.getType();
+ bar_v_ft = bar_v.getType();
+ bar_c_ft = bar_c.getType();
+ bar_ft = bar.getType();
+
+ assertTrue(bar_cv_ft.isConst());
+ assertTrue(bar_cv_ft.isVolatile());
+ assertTrue(!bar_v_ft.isConst());
+ assertTrue(bar_v_ft.isVolatile());
+ assertTrue(bar_c_ft.isConst());
+ assertTrue(!bar_c_ft.isVolatile());
+ assertTrue(!bar_ft.isConst());
+ assertTrue(!bar_ft.isVolatile());
}
// void test1(float f);
@@ -7059,7 +7054,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// test2(e1);
// }
public void testOverloadResolution_262191() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code);
}
@@ -7073,7 +7068,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// select (int (h) + 1);
// }
public void testSimpleTypeConstructorExpressions() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code);
}
@@ -7086,7 +7081,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(a());
// }
public void testBug263152a() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertProblem("f(a())", 1);
}
@@ -7102,7 +7097,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// p.m(a());
// }
public void testBug263152b() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("m(a())", 1, ICPPMethod.class);
}
@@ -7113,7 +7108,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
// };
public void _testInstanceMemberInStaticMethod_263154() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertProblem("a =", 1);
}
@@ -7132,28 +7127,28 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testAmbiguityResolutionInCondition_263158() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper ba= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, true);
ba.assertNonProblem("A*", 1, ICPPClassType.class);
ba.assertNonProblem("a", 1, ICPPVariable.class);
ba.assertNonProblem("B*", 1, ICPPVariable.class);
parseAndCheckBindings(code, CPP);
}
-
+
// typedef struct xx{} type;
// void test(void* ptr) {
// delete (type)(ptr);
// }
public void testAmbiguityResolutionInDeleteExpression_428922() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper ba= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, true);
ba.assertNonProblem("type)", 4, ITypedef.class);
ba.assertNonProblem("ptr);", 3, ICPPVariable.class);
IASTTranslationUnit tu = parseAndCheckBindings(code, CPP);
- ICPPASTFunctionDefinition test= getDeclaration(tu, 1);
- IASTExpressionStatement stmt= getStatement(test, 0);
- ICPPASTDeleteExpression dexpr= (ICPPASTDeleteExpression) stmt.getExpression();
+ ICPPASTFunctionDefinition test = getDeclaration(tu, 1);
+ IASTExpressionStatement stmt = getStatement(test, 0);
+ ICPPASTDeleteExpression dexpr = (ICPPASTDeleteExpression) stmt.getExpression();
assertTrue(dexpr.getOperand() instanceof ICPPASTCastExpression);
}
@@ -7166,7 +7161,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(s);
// }
public void testPointerToNonPointerConversion_263159() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertProblem("f(p)", 1);
ba.assertProblem("f(q)", 1);
ba.assertProblem("f(r)", 1);
@@ -7183,7 +7178,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// fia(0);
// }
public void testNonPointerToPointerConversion_263707() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertProblem("fip(1)", 3);
ba.assertProblem("fia(1)", 3);
ba.assertNonProblem("fip(0)", 3, ICPPFunction.class);
@@ -7199,7 +7194,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// reset(new cl[1]);
// }
public void testTypeOfNewExpression_264163() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code, CPP);
}
@@ -7214,7 +7209,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testConstructorTemplateInImplicitConversion_264314() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper ba= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, true);
ba.assertNonProblem("onRange(ir)", 7);
parseAndCheckBindings(code, CPP);
}
@@ -7234,10 +7229,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
// CT<pcpi2> ct2;
public void testConstTypedef_264474() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper ba= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, true);
ba.assertNonProblem("check(p2)", 5);
- IBinding ct1= ba.assertNonProblem("CT<pcpi>", 8);
- IBinding ct2= ba.assertNonProblem("CT<pcpi2>", 9);
+ IBinding ct1 = ba.assertNonProblem("CT<pcpi>", 8);
+ IBinding ct2 = ba.assertNonProblem("CT<pcpi2>", 9);
assertSame(ct1, ct2);
parseAndCheckBindings(code, CPP);
@@ -7281,7 +7276,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testMemberPtrs_264479() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper ba= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, true);
ba.assertNonProblem("mpr(&X::f)", 3);
ba.assertNonProblem("mpr(&X::m)", 3);
ba.assertNonProblem("mprc(&X::cm)", 4);
@@ -7305,7 +7300,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(!p);
// }
public void testTypeOfNotExpression_265779() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("f(!p)", 1);
}
@@ -7458,14 +7453,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testPointerToArrayWithDefaultVal_267184() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper ba= new AST2AssertionHelper(code, true);
- ICPPParameter p= ba.assertNonProblem("names", 5);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, true);
+ ICPPParameter p = ba.assertNonProblem("names", 5);
assertTrue(p.hasDefaultValue());
- IType t= p.getType();
- assertInstance(t, IPointerType.class); // parameter of type array is converted to pointer
- t= ((IPointerType) t).getType();
+ IType t = p.getType();
+ assertInstance(t, IPointerType.class); // parameter of type array is converted to pointer
+ t = ((IPointerType) t).getType();
assertInstance(t, IPointerType.class);
- t= ((IPointerType) t).getType();
+ t = ((IPointerType) t).getType();
assertInstance(t, IBasicType.class);
parseAndCheckBindings(code, CPP);
@@ -7477,15 +7472,15 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
public void testPureVirtualVsInitDeclarator_267184() throws Exception {
final String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, CPP);
- ICPPASTCompositeTypeSpecifier ct= getCompositeType(tu, 0);
- IASTSimpleDeclaration sdecl= getDeclaration(ct, 0);
- ICPPASTFunctionDeclarator dtor= (ICPPASTFunctionDeclarator) sdecl.getDeclarators()[0];
+ IASTTranslationUnit tu = parseAndCheckBindings(code, CPP);
+ ICPPASTCompositeTypeSpecifier ct = getCompositeType(tu, 0);
+ IASTSimpleDeclaration sdecl = getDeclaration(ct, 0);
+ ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) sdecl.getDeclarators()[0];
assertTrue(dtor.isPureVirtual());
assertNull(dtor.getInitializer());
- sdecl= getDeclaration(ct, 1);
- dtor= (ICPPASTFunctionDeclarator) sdecl.getDeclarators()[0];
+ sdecl = getDeclaration(ct, 1);
+ dtor = (ICPPASTFunctionDeclarator) sdecl.getDeclarators()[0];
assertFalse(dtor.isPureVirtual());
assertNotNull(dtor.getInitializer());
@@ -7553,7 +7548,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// (x + 1.0).b; //3
// }
public void testOverloadResolutionForOperators_266211() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("a; //1", 1, ICPPField.class);
ba.assertNonProblem("a; //2", 1, ICPPField.class);
ba.assertNonProblem("b; //3", 1, ICPPField.class);
@@ -7573,7 +7568,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// (x + 1.0).a; //2
// }
public void testOverloadResolutionForOperators_268534() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("a; //1", 1, ICPPField.class);
ba.assertNonProblem("a; //2", 1, ICPPField.class);
}
@@ -7587,7 +7582,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// test(c);
// }
public void testInvalidUserDefinedConversion_269729() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertProblem("test(c)", 4);
}
@@ -7612,7 +7607,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertSame(col.getName(4).resolveBinding(), col.getName(11).resolveBinding());
assertSame(col.getName(6).resolveBinding(), col.getName(12).resolveBinding());
}
-
+
// auto L = L"";
// auto u8 = u8"";
// auto u = u"";
@@ -7651,16 +7646,16 @@ public class AST2CPPTests extends AST2CPPTestBase {
// struct A;
// A a;
public void testForwardDeclarationAfterUsing_271236() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("A a;", 1, ICPPClassType.class);
}
// template <class T> class Moo;
// bool getFile(Moo <class Foo> & res);
public void testScopeOfClassFwdDecl_270831() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
- ICPPClassType t= ba.assertNonProblem("Foo", 3, ICPPClassType.class);
- IScope scope= t.getScope();
+ BindingAssertionHelper ba = getAssertionHelper();
+ ICPPClassType t = ba.assertNonProblem("Foo", 3, ICPPClassType.class);
+ IScope scope = t.getScope();
assertEquals(EScopeKind.eGlobal, scope.getKind());
}
@@ -7680,13 +7675,13 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testDerivedToBaseConversion_269318() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper ba= new AST2AssertionHelper(code, true);
- ICPPFunction t= ba.assertNonProblem("test(d1);", 4, ICPPFunction.class);
- ICPPClassType ct= (ICPPClassType) t.getParameters()[0].getType();
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, true);
+ ICPPFunction t = ba.assertNonProblem("test(d1);", 4, ICPPFunction.class);
+ ICPPClassType ct = (ICPPClassType) t.getParameters()[0].getType();
assertEquals("C", ct.getName());
- t= ba.assertNonProblem("test(d2);", 4, ICPPFunction.class);
- ct= (ICPPClassType) t.getParameters()[0].getType();
+ t = ba.assertNonProblem("test(d2);", 4, ICPPFunction.class);
+ ct = (ICPPClassType) t.getParameters()[0].getType();
assertEquals("C", ct.getName());
parseAndCheckBindings(code, CPP);
@@ -7713,15 +7708,15 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
public void testDeclarationAmbiguity_269953() throws Exception {
final String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, CPP);
- ICPPASTCompositeTypeSpecifier ct= getCompositeType(tu, 1);
- ICPPClassType c= (ICPPClassType) ct.getName().resolveBinding();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, CPP);
+ ICPPASTCompositeTypeSpecifier ct = getCompositeType(tu, 1);
+ ICPPClassType c = (ICPPClassType) ct.getName().resolveBinding();
- ICPPMethod[] methods= c.getDeclaredMethods();
+ ICPPMethod[] methods = c.getDeclaredMethods();
assertEquals(1, methods.length);
assertEquals("C", methods[0].getName());
- ICPPField[] fields= c.getDeclaredFields();
+ ICPPField[] fields = c.getDeclaredFields();
assertEquals(1, fields.length);
assertEquals("s", fields[0].getName());
}
@@ -7785,11 +7780,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testNestedOverloadedFunctionCalls_283324() throws Exception {
final String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, CPP);
- IASTFunctionDefinition test= getDeclaration(tu, 1);
- IASTExpressionStatement stmt= getStatement(test, 1);
- long now= System.currentTimeMillis();
- IType t= stmt.getExpression().getExpressionType();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, CPP);
+ IASTFunctionDefinition test = getDeclaration(tu, 1);
+ IASTExpressionStatement stmt = getStatement(test, 1);
+ long now = System.currentTimeMillis();
+ IType t = stmt.getExpression().getExpressionType();
assertInstance(t, ICPPClassType.class);
assertTrue(stmt.getExpression().isLValue());
final long time = System.currentTimeMillis() - now;
@@ -7821,7 +7816,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(l1);
// }
public void testEnumToIntConversion_285368() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ICPPFunction f1 = ba.assertNonProblem("f(i1)", 1, ICPPFunction.class);
IType t1 = f1.getType().getParameterTypes()[0];
assertTrue(t1 instanceof ICPPBasicType);
@@ -7852,7 +7847,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(i3);
// }
public void testCastInEnumeratorValue_446380() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IEnumerator i2 = ba.assertNonProblem("i2", IEnumerator.class);
Number v2 = i2.getValue().numberValue();
assertNotNull(v2);
@@ -7861,7 +7856,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
Number v3 = i3.getValue().numberValue();
assertNotNull(v3);
assertEquals(2, v3.intValue());
- ICPPFunction f = ba.assertNonProblemOnFirstIdentifier("f(i3)",ICPPFunction.class);
+ ICPPFunction f = ba.assertNonProblemOnFirstIdentifier("f(i3)", ICPPFunction.class);
IType t = f.getType().getParameterTypes()[0];
// The declared types of the enum values don't affect the underlying type of the enum,
// only the values themselves do.
@@ -7870,7 +7865,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// typedef enum enum_name enum_name;
public void testTypedefRecursion_285457() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertProblem("enum_name", 9);
}
@@ -7908,7 +7903,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testTypeLookupWithMultipleInheritance_286213() throws Exception {
parseAndCheckBindings();
}
-
+
// template<class>
// struct ContainerOf {
// int numParts;
@@ -7938,14 +7933,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
// const int X::v7= 1;
public void testVariableDefVsDecl_286259() throws Exception {
- String[] declNames= {"v3"};
- String[] defNames= {"v1", "v2", "v4", "v5", "X::v7"};
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP);
+ String[] declNames = { "v3" };
+ String[] defNames = { "v1", "v2", "v4", "v5", "X::v7" };
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), CPP);
checkDeclDef(declNames, defNames, tu.getDeclarations());
- declNames= new String[] {"v7", "v8"};
- defNames= new String[] {"v6"};
- IASTCompositeTypeSpecifier cls= getCompositeType(tu, 5);
+ declNames = new String[] { "v7", "v8" };
+ defNames = new String[] { "v6" };
+ IASTCompositeTypeSpecifier cls = getCompositeType(tu, 5);
checkDeclDef(declNames, defNames, cls.getMembers());
}
@@ -7955,14 +7950,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
// const int X::v2;
public void testVariableDefVsDecl_292635() throws Exception {
- String[] declNames= {"v1"};
- String[] defNames= {"X::v2"};
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP);
+ String[] declNames = { "v1" };
+ String[] defNames = { "X::v2" };
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), CPP);
checkDeclDef(declNames, defNames, tu.getDeclarations());
- declNames= new String[] {"v2"};
- defNames= new String[] {};
- IASTCompositeTypeSpecifier cls= getCompositeType(tu, 1);
+ declNames = new String[] { "v2" };
+ defNames = new String[] {};
+ IASTCompositeTypeSpecifier cls = getCompositeType(tu, 1);
checkDeclDef(declNames, defNames, cls.getMembers());
}
@@ -7975,22 +7970,22 @@ public class AST2CPPTests extends AST2CPPTestBase {
final String code = getAboveComment();
parseAndCheckBindings(code, CPP);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- ICPPClassType S= bh.assertNonProblem("S*", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ ICPPClassType S = bh.assertNonProblem("S*", 1);
assertNull(S.getOwner());
- ICPPClassType X= bh.assertNonProblem("X {", 1);
- ICPPClassType T= bh.assertNonProblem("T;", 1);
+ ICPPClassType X = bh.assertNonProblem("X {", 1);
+ ICPPClassType T = bh.assertNonProblem("T;", 1);
assertSame(X, T.getOwner());
- T= bh.assertNonProblem("T* m2", 1);
+ T = bh.assertNonProblem("T* m2", 1);
assertSame(X, T.getOwner());
}
// class ULONGLONG {
// public :
// ULONGLONG (unsigned long long val) {}
- // friend ULONGLONG operator ~ (const ULONGLONG &) { return 0; }
+ // friend ULONGLONG operator ~ (const ULONGLONG &) { return 0; }
// };
//
// int main() {
@@ -7998,10 +7993,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testNonUserdefinedOperator_291409b() throws Exception {
final String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, CPP);
- IASTFunctionDefinition def= getDeclaration(tu, 1);
- IASTReturnStatement rstmt= getStatement(def, 0);
- IASTImplicitNameOwner expr= (IASTImplicitNameOwner) rstmt.getReturnValue();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, CPP);
+ IASTFunctionDefinition def = getDeclaration(tu, 1);
+ IASTReturnStatement rstmt = getStatement(def, 0);
+ IASTImplicitNameOwner expr = (IASTImplicitNameOwner) rstmt.getReturnValue();
assertEquals(0, expr.getImplicitNames().length);
}
@@ -8016,8 +8011,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testMethodTemplateWithSameName_292051() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code, CPP);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- ICPPMethod m= bh.assertNonProblem("t<1>", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ ICPPMethod m = bh.assertNonProblem("t<1>", 1);
assertTrue(m.isInline());
}
@@ -8086,7 +8081,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testUserDefinedConversion_222444c() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("foo(c);", 3);
bh.assertProblem("foo(cc);", 3);
}
@@ -8102,10 +8097,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testInvalidOverload_291409() throws Exception {
final String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, CPP);
- IASTFunctionDefinition fdef= getDeclaration(tu, 2);
- IASTReturnStatement stmt= getStatement(fdef, 0);
- IASTImplicitNameOwner no= (IASTImplicitNameOwner) stmt.getReturnValue();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, CPP);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 2);
+ IASTReturnStatement stmt = getStatement(fdef, 0);
+ IASTImplicitNameOwner no = (IASTImplicitNameOwner) stmt.getReturnValue();
assertEquals(0, no.getImplicitNames().length);
}
@@ -8135,7 +8130,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testLookupInConstructorChainInitializer_293566() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("B>(1)", 1);
parseAndCheckBindings(code, CPP);
}
@@ -8165,21 +8160,21 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testFunctionDeclViaTypedef_86495() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code, CPP);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
- ICPPFunctionTemplate template= bh.assertNonProblem("functionTemplate", 16);
+ ICPPFunctionTemplate template = bh.assertNonProblem("functionTemplate", 16);
assertNotNull(template.getType());
assertEquals(1, template.getParameters().length);
- ICPPMethod method= bh.assertNonProblem("method", 6);
+ ICPPMethod method = bh.assertNonProblem("method", 6);
assertNotNull(method.getType());
assertEquals(1, method.getParameters().length);
- ICPPFunction friendFunction= bh.assertNonProblem("friendFunction", 14);
+ ICPPFunction friendFunction = bh.assertNonProblem("friendFunction", 14);
assertNotNull(friendFunction.getType());
assertEquals(1, friendFunction.getParameters().length);
- ICPPMethod methodTemplate= bh.assertNonProblem("methodTemplate", 14);
+ ICPPMethod methodTemplate = bh.assertNonProblem("methodTemplate", 14);
assertTrue(methodTemplate instanceof ICPPFunctionTemplate);
assertNotNull(methodTemplate.getType());
assertEquals(1, methodTemplate.getParameters().length);
@@ -8308,34 +8303,34 @@ public class AST2CPPTests extends AST2CPPTestBase {
// foo(source_const_rvalue_ref()); // #1
// }
public void testRValueReference_294730() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IBinding foo1= bh.assertNonProblem("foo(const A&)", 3);
- IBinding foo2= bh.assertNonProblem("foo(A&&)", 3);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IBinding foo1 = bh.assertNonProblem("foo(const A&)", 3);
+ IBinding foo2 = bh.assertNonProblem("foo(A&&)", 3);
IBinding b;
- b= bh.assertNonProblem("foo(a)", 3);
+ b = bh.assertNonProblem("foo(a)", 3);
assertSame(b, foo1);
- b= bh.assertNonProblem("foo(ra)", 3);
+ b = bh.assertNonProblem("foo(ra)", 3);
assertSame(b, foo1);
- b= bh.assertNonProblem("foo(rra)", 3);
+ b = bh.assertNonProblem("foo(rra)", 3);
assertSame(b, foo1);
- b= bh.assertNonProblem("foo(ca)", 3);
+ b = bh.assertNonProblem("foo(ca)", 3);
assertSame(b, foo1);
- b= bh.assertNonProblem("foo(rca)", 3);
+ b = bh.assertNonProblem("foo(rca)", 3);
assertSame(b, foo1);
- b= bh.assertNonProblem("foo(rrca)", 3);
+ b = bh.assertNonProblem("foo(rrca)", 3);
assertSame(b, foo1);
- b= bh.assertNonProblem("foo(source_rvalue())", 3);
+ b = bh.assertNonProblem("foo(source_rvalue())", 3);
assertSame(b, foo2);
- b= bh.assertNonProblem("foo(source_ref())", 3);
+ b = bh.assertNonProblem("foo(source_ref())", 3);
assertSame(b, foo1);
- b= bh.assertNonProblem("foo(source_rvalue_ref())", 3);
+ b = bh.assertNonProblem("foo(source_rvalue_ref())", 3);
assertSame(b, foo2);
- b= bh.assertNonProblem("foo(source_const_rvalue())", 3);
+ b = bh.assertNonProblem("foo(source_const_rvalue())", 3);
assertSame(b, foo1);
- b= bh.assertNonProblem("foo(source_const_ref())", 3);
+ b = bh.assertNonProblem("foo(source_const_ref())", 3);
assertSame(b, foo1);
- b= bh.assertNonProblem("foo(source_const_rvalue_ref())", 3);
+ b = bh.assertNonProblem("foo(source_const_rvalue_ref())", 3);
assertSame(b, foo1);
}
@@ -8348,18 +8343,18 @@ public class AST2CPPTests extends AST2CPPTestBase {
// RRI& r4 = i; // r4 has the type int&
// RRI&& r5 = i; // r5 has the type int&&
public void testRValueReferenceTypedefs_294730() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
IVariable v;
- v= bh.assertNonProblem("r1", 2);
+ v = bh.assertNonProblem("r1", 2);
assertEquals("int &", ASTTypeUtil.getType(v.getType()));
- v= bh.assertNonProblem("r2", 2);
+ v = bh.assertNonProblem("r2", 2);
assertEquals("int &", ASTTypeUtil.getType(v.getType()));
- v= bh.assertNonProblem("r3", 2);
+ v = bh.assertNonProblem("r3", 2);
assertEquals("int &", ASTTypeUtil.getType(v.getType()));
- v= bh.assertNonProblem("r4", 2);
+ v = bh.assertNonProblem("r4", 2);
assertEquals("int &", ASTTypeUtil.getType(v.getType()));
- v= bh.assertNonProblem("r5", 2);
+ v = bh.assertNonProblem("r5", 2);
assertEquals("int &&", ASTTypeUtil.getType(v.getType()));
}
@@ -8395,8 +8390,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// cdref(cvd); // error: type qualifiers dropped
// }
public void testDirectBinding_294730() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("dref(d)", 4);
bh.assertNonProblem("cdref(d)", 5);
bh.assertNonProblem("aref(b)", 4);
@@ -8420,7 +8415,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// test(s());
// }
public void testSpecialRuleForImplicitObjectType_294730() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code, CPP);
}
@@ -8477,10 +8472,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testInitOfClassObjectsByRValues_294730() throws Exception {
final CharSequence[] contents = getContents(3);
- final String code= contents[0].toString();
- final String end= contents[2].toString();
+ final String code = contents[0].toString();
+ final String end = contents[2].toString();
parseAndCheckBindings(code + end, CPP);
- BindingAssertionHelper bh= new AST2AssertionHelper(code + contents[1] + end, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code + contents[1] + end, true);
bh.assertProblem("sink3(source())", 5);
bh.assertProblem("sink3(csource())", 5);
bh.assertProblem("sink3(z7)", 5);
@@ -8502,7 +8497,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// check(c+a);
// }
public void testADLForOperators_296906() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code, CPP);
}
@@ -8518,16 +8513,16 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(a, 1); // calls ns::f(ns::A, char)
// }
public void testADL_299101() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code, CPP);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction inns= bh.assertNonProblem("f(ns::A, char)", 1);
- IFunction glob= bh.assertNonProblem("f(ns::A, int)", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction inns = bh.assertNonProblem("f(ns::A, char)", 1);
+ IFunction glob = bh.assertNonProblem("f(ns::A, int)", 1);
- IBinding b= bh.assertNonProblem("f(a, '1')", 1);
+ IBinding b = bh.assertNonProblem("f(a, '1')", 1);
assertSame(b, inns);
- b= bh.assertNonProblem("f(a, 1)", 1);
+ b = bh.assertNonProblem("f(a, 1)", 1);
assertSame(b, glob);
}
@@ -8545,25 +8540,25 @@ public class AST2CPPTests extends AST2CPPTestBase {
// __typeof((a->x)) t8(); // type is const double
public void testDecltype_294730() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code, CPP);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction f= bh.assertNonProblem("t1", 2);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction f = bh.assertNonProblem("t1", 2);
assertEquals("const int &&", ASTTypeUtil.getType(f.getType().getReturnType()));
- f= bh.assertNonProblem("t2", 2);
+ f = bh.assertNonProblem("t2", 2);
assertEquals("int", ASTTypeUtil.getType(f.getType().getReturnType()));
- f= bh.assertNonProblem("t3", 2);
+ f = bh.assertNonProblem("t3", 2);
assertEquals("double", ASTTypeUtil.getType(f.getType().getReturnType()));
- f= bh.assertNonProblem("t4", 2);
+ f = bh.assertNonProblem("t4", 2);
assertEquals("const double &", ASTTypeUtil.getType(f.getType().getReturnType()));
- f= bh.assertNonProblem("t5", 2);
+ f = bh.assertNonProblem("t5", 2);
assertEquals("const int", ASTTypeUtil.getType(f.getType().getReturnType()));
- f= bh.assertNonProblem("t6", 2);
+ f = bh.assertNonProblem("t6", 2);
assertEquals("int", ASTTypeUtil.getType(f.getType().getReturnType()));
- f= bh.assertNonProblem("t7", 2);
+ f = bh.assertNonProblem("t7", 2);
assertEquals("const double", ASTTypeUtil.getType(f.getType().getReturnType()));
- f= bh.assertNonProblem("t8", 2);
+ f = bh.assertNonProblem("t8", 2);
assertEquals("const double", ASTTypeUtil.getType(f.getType().getReturnType()));
}
@@ -8580,7 +8575,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testDecltypeInNameQualifier_380751() throws Exception {
parseAndCheckBindings();
}
-
+
// struct Base {};
// struct Derived : decltype(Base()) {};
public void testDecltypeInBaseSpecifier_438348() throws Exception {
@@ -8623,8 +8618,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// auto bar = [foo] { return foo; };
public void testLambdaWithCapture_446225() throws Exception {
BindingAssertionHelper bh = getAssertionHelper();
- ICPPVariable foo1= bh.assertNonProblemOnFirstIdentifier("foo =", ICPPVariable.class);
- ICPPVariable foo2= bh.assertNonProblemOnFirstIdentifier("[foo]", ICPPVariable.class);
+ ICPPVariable foo1 = bh.assertNonProblemOnFirstIdentifier("foo =", ICPPVariable.class);
+ ICPPVariable foo2 = bh.assertNonProblemOnFirstIdentifier("[foo]", ICPPVariable.class);
assertTrue(foo1 == foo2);
assertEquals(2, bh.getTranslationUnit().getReferences(foo1).length);
}
@@ -8741,8 +8736,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// g({ "foo", "bar" }); // OK, uses #3
// }
public void testListInitialization_302412b() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("f({1,2,3})", 1);
bh.assertNonProblem("f({'a','b'})", 1);
bh.assertProblem("f({1.0})", 1);
@@ -8791,8 +8786,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// x({x1}); // no matching constructor
// }
public void testListInitialization_302412c() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("e({ 'a', 'b' })", 1);
bh.assertNonProblem("g({ 'a', 'b' })", 1);
bh.assertProblem("g({ 1.0, 1.0 })", 1);
@@ -8815,8 +8810,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f({1.0}); // narrowing not detected by cdt.
// }
public void testListInitialization_302412d() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("f({'a', 'b'})", 1);
// not detected by CDT
// bh.assertProblem("f({1.0})", 1);
@@ -8835,8 +8830,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// h({ }); // OK: identity conversion
// }
public void testListInitialization_302412e() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
// not detected by CDT
// bh.assertProblem("g({1})", 1);
bh.assertNonProblem("h({'a'})", 1);
@@ -8871,7 +8866,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// fH({1}); // H(G(1))
// }
public void testListInitialization_302412f() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
bh.assertProblem("f({1,1})", 1);
bh.assertImplicitName("F({1,1})", 1, ICPPConstructor.class);
bh.assertNonProblem("fF({1,1})", 2);
@@ -8880,8 +8875,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
bh.assertNonProblem("fG({1})", 2);
bh.assertImplicitName("H(1)", 1, ICPPConstructor.class);
- IASTImplicitName n= bh.assertImplicitName("H({1})", 1, IProblemBinding.class);
- IProblemBinding problem= (IProblemBinding) n.resolveBinding();
+ IASTImplicitName n = bh.assertImplicitName("H({1})", 1, IProblemBinding.class);
+ IProblemBinding problem = (IProblemBinding) n.resolveBinding();
assertEquals(IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, problem.getID());
bh.assertProblem("fH(1)", 2);
bh.assertNonProblem("fH({1})", 2);
@@ -8901,7 +8896,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testListInitialization_439477a() throws Exception {
parseAndCheckBindings();
}
-
+
// void waldo(int const (&)[2]);
// void waldo(int const (&)[3]);
// void foo1() {
@@ -8911,19 +8906,19 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testListInitialization_439477b() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
-
+
ICPPFunction def1 = helper.assertNonProblem("waldo(int const (&)[2])", "waldo");
ICPPFunction def2 = helper.assertNonProblem("waldo(int const (&)[3])", "waldo");
-
+
ICPPFunction call1 = helper.assertNonProblem("waldo({1, 2})", "waldo");
ICPPFunction call2 = helper.assertNonProblem("waldo({1, 2, 3})", "waldo");
-
+
assertEquals(call1, def1);
assertEquals(call2, def2);
-
+
helper.assertProblem("waldo({1, 2, 3, 4})", "waldo", IProblemBinding.SEMANTIC_NAME_NOT_FOUND);
}
-
+
// namespace std {
// template<class E>
// class initializer_list {
@@ -8943,7 +8938,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// int b;
// };
//
- // A<B> waldo({{0}, {0}});
+ // A<B> waldo({{0}, {0}});
public void testListInitialization_458679() throws Exception {
parseAndCheckImplicitNameBindings();
}
@@ -8991,7 +8986,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertTrue(binding instanceof ICPPConstructor);
assertEquals(2, ((ICPPConstructor) binding).getType().getParameterTypes().length);
}
-
+
// struct S {
// int a;
// float b;
@@ -9028,29 +9023,29 @@ public class AST2CPPTests extends AST2CPPTestBase {
// auto x; // Error - missing initializer.
// auto y = { 1.0, 5 }; // Error - inconsistent types in the array initializer.
public void testAutoType_289542() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- ICPPVariable b= bh.assertNonProblem("b =", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ ICPPVariable b = bh.assertNonProblem("b =", 1);
assertEquals("A", ASTTypeUtil.getType(b.getType()));
- ICPPVariable c= bh.assertNonProblem("c(a)", "c");
+ ICPPVariable c = bh.assertNonProblem("c(a)", "c");
assertEquals("A", ASTTypeUtil.getType(c.getType()));
- ICPPVariable p= bh.assertNonProblem("p =", 1);
+ ICPPVariable p = bh.assertNonProblem("p =", 1);
assertEquals("const A *", ASTTypeUtil.getType(p.getType()));
- ICPPVariable q= bh.assertNonProblem("q =", 1);
+ ICPPVariable q = bh.assertNonProblem("q =", 1);
assertEquals("const char * const", ASTTypeUtil.getType(q.getType()));
- ICPPVariable d= bh.assertNonProblem("d =", 1);
+ ICPPVariable d = bh.assertNonProblem("d =", 1);
assertEquals("double", ASTTypeUtil.getType(d.getType()));
- ICPPVariable r= bh.assertNonProblem("r =", 1);
+ ICPPVariable r = bh.assertNonProblem("r =", 1);
assertEquals("std::initializer_list<char>", ASTTypeUtil.getType(r.getType()));
- ICPPVariable s= bh.assertNonProblem("s =", 1);
+ ICPPVariable s = bh.assertNonProblem("s =", 1);
assertEquals("long int *", ASTTypeUtil.getType(s.getType()));
- ICPPVariable t= bh.assertNonProblem("t =", 1);
+ ICPPVariable t = bh.assertNonProblem("t =", 1);
assertEquals("std::initializer_list<double> *", ASTTypeUtil.getType(t.getType()));
- ICPPVariable x= bh.assertNonProblem("x;", 1);
- IProblemType pt= (IProblemType) x.getType();
+ ICPPVariable x = bh.assertNonProblem("x;", 1);
+ IProblemType pt = (IProblemType) x.getType();
assertEquals(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE, pt.getID());
- ICPPVariable y= bh.assertNonProblem("y =", 1);
- pt= (IProblemType) y.getType();
+ ICPPVariable y = bh.assertNonProblem("y =", 1);
+ pt = (IProblemType) y.getType();
assertEquals(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE, pt.getID());
}
@@ -9062,35 +9057,35 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testAutoType_305970() throws Exception {
BindingAssertionHelper bh = getAssertionHelper();
- ICPPVariable x= bh.assertNonProblem("x =", 1, ICPPVariable.class);
- IProblemType xt= (IProblemType) x.getType();
+ ICPPVariable x = bh.assertNonProblem("x =", 1, ICPPVariable.class);
+ IProblemType xt = (IProblemType) x.getType();
assertEquals(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE, xt.getID());
- ICPPVariable a= bh.assertNonProblem("a :", "a", ICPPVariable.class);
- IProblemType at= (IProblemType) a.getType();
+ ICPPVariable a = bh.assertNonProblem("a :", "a", ICPPVariable.class);
+ IProblemType at = (IProblemType) a.getType();
assertEquals(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE, at.getID());
}
// struct A { auto a = 1; }; // Auto-typed non-static fields are not allowed.
// struct B { static auto b = 1; }; // Auto-typed static fields are ok.
public void testAutoType_305987() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- ICPPVariable a= bh.assertNonProblem("a =", 1);
- IProblemType pt= (IProblemType) a.getType();
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ ICPPVariable a = bh.assertNonProblem("a =", 1);
+ IProblemType pt = (IProblemType) a.getType();
assertEquals(ISemanticProblem.TYPE_AUTO_FOR_NON_STATIC_FIELD, pt.getID());
- ICPPVariable b= bh.assertNonProblem("b =", 1);
+ ICPPVariable b = bh.assertNonProblem("b =", 1);
}
// auto fpif1(int)->int(*)(int)
// auto fpif2(int)->int(*)(int) {}
public void testNewFunctionDeclaratorSyntax_305972() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
- ICPPFunction f= bh.assertNonProblem("fpif1", 0);
+ ICPPFunction f = bh.assertNonProblem("fpif1", 0);
assertEquals("int (* (int))(int)", ASTTypeUtil.getType(f.getType()));
- f= bh.assertNonProblem("fpif2", 0);
+ f = bh.assertNonProblem("fpif2", 0);
assertEquals("int (* (int))(int)", ASTTypeUtil.getType(f.getType()));
}
@@ -9101,49 +9096,49 @@ public class AST2CPPTests extends AST2CPPTestBase {
// enum EUnscoped2 : long {b2};
// enum EUnscoped3 : int;
public void testScopedEnums_305975a() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPEnumeration e;
ICPPBinding ei;
- e= bh.assertNonProblem("EScoped1", 0);
+ e = bh.assertNonProblem("EScoped1", 0);
assertTrue(e.isScoped());
assertEquals("int", ASTTypeUtil.getType(e.getFixedType()));
assertDefinition(e);
- ei= bh.assertNonProblem("a1", 0);
+ ei = bh.assertNonProblem("a1", 0);
assertSame(e, ei.getOwner());
assertEquals(2, ei.getQualifiedName().length);
- e= bh.assertNonProblem("EScoped2", 0);
+ e = bh.assertNonProblem("EScoped2", 0);
assertTrue(e.isScoped());
assertEquals("short int", ASTTypeUtil.getType(e.getFixedType()));
assertDefinition(e);
- ei= bh.assertNonProblem("a2", 0);
+ ei = bh.assertNonProblem("a2", 0);
assertSame(e, ei.getOwner());
assertEquals(2, ei.getQualifiedName().length);
- e= bh.assertNonProblem("EScoped3", 0);
+ e = bh.assertNonProblem("EScoped3", 0);
assertTrue(e.isScoped());
assertEquals("int", ASTTypeUtil.getType(e.getFixedType()));
assertDeclaration(e);
- e= bh.assertNonProblem("EUnscoped1", 0);
+ e = bh.assertNonProblem("EUnscoped1", 0);
assertFalse(e.isScoped());
assertNull(e.getFixedType());
assertDefinition(e);
- ei= bh.assertNonProblem("b1", 0);
+ ei = bh.assertNonProblem("b1", 0);
assertSame(e, ei.getOwner());
assertEquals(1, ei.getQualifiedName().length);
- e= bh.assertNonProblem("EUnscoped2", 0);
+ e = bh.assertNonProblem("EUnscoped2", 0);
assertFalse(e.isScoped());
assertEquals("long int", ASTTypeUtil.getType(e.getFixedType()));
assertDefinition(e);
- ei= bh.assertNonProblem("b2", 0);
+ ei = bh.assertNonProblem("b2", 0);
assertSame(e, ei.getOwner());
assertEquals(1, ei.getQualifiedName().length);
- e= bh.assertNonProblem("EUnscoped3", 0);
+ e = bh.assertNonProblem("EUnscoped3", 0);
assertFalse(e.isScoped());
assertEquals("int", ASTTypeUtil.getType(e.getFixedType()));
assertDeclaration(e);
@@ -9156,7 +9151,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// enum E1 : int; // OK: E1 is un-scoped, underlying type is int
// enum class F1; // OK: F1 is scoped, underlying type is int
public void testScopedEnums_305975b() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code);
}
@@ -9164,8 +9159,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// enum class F y2 = a; // illegal
// enum E; // illegal
public void testScopedEnums_305975c() throws Exception {
- String code= getAboveComment();
- IASTTranslationUnit tu= parse(code, CPP, true, false);
+ String code = getAboveComment();
+ IASTTranslationUnit tu = parse(code, CPP, true, false);
IASTDeclaration[] decls = tu.getDeclarations();
assertEquals(3, decls.length);
assertInstance(decls[0], IASTProblemDeclaration.class);
@@ -9184,8 +9179,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// fbool(Col::red); // error: no Col to bool conversion
// }
public void testScopedEnums_305975d() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("fCol(Col::red)", 4);
bh.assertProblem("fint(Col::red)", 4);
@@ -9229,8 +9224,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// xl; // error: not in scope
// }
public void testScopedEnums_305975f() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertProblem("high;", -1);
bh.assertProblem("xdir d", -2);
@@ -9243,10 +9238,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
// enum A {e1, e2= e1+2, e3};
// enum B {e1, e2= f(e1)+2, e3};
public void testScopedEnums_305975g() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code);
}
-
+
// typedef int Int;
// struct S {
// enum waldo1 : int;
@@ -9284,12 +9279,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testSizeofReference_397342() throws Exception {
parseAndCheckBindings();
}
-
+
// constexpr int waldo = sizeof("cat\b\\\n");
public void testSizeofStringLiteralWithEscapeCharacters_459279() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
ICPPVariable waldo = helper.assertNonProblem("waldo");
- assertConstantValue(7, waldo); // "cat" + backspace + slash + newline + null terminator
+ assertConstantValue(7, waldo); // "cat" + backspace + slash + newline + null terminator
}
// struct A {
@@ -9309,7 +9304,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
long BSize = getSizeAndAlignment(B, nameB).size;
assertEquals(pointerSize, BSize);
}
-
+
// struct waldo {};
public void testSizeofEmptyStruct_457770() throws Exception {
BindingAssertionHelper bh = getAssertionHelper();
@@ -9342,13 +9337,13 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(c32);
// }
public void testNewCharacterTypes_305976() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction f1= bh.assertNonProblem("f(int)", 1);
- IFunction f2= bh.assertNonProblem("f(unsigned int)", 1);
- IBinding b= bh.assertNonProblem("f(c16)", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction f1 = bh.assertNonProblem("f(int)", 1);
+ IFunction f2 = bh.assertNonProblem("f(unsigned int)", 1);
+ IBinding b = bh.assertNonProblem("f(c16)", 1);
assertSame(f1, b);
- b= bh.assertNonProblem("f(c32)", 1);
+ b = bh.assertNonProblem("f(c32)", 1);
assertSame(f2, b);
}
@@ -9380,11 +9375,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(c+1); // converts c to a char and calls operator+(int, int)
// }
public void testBuiltinOperators_294543a() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction fint= bh.assertNonProblem("f(int)", 1);
- IFunction f= bh.assertNonProblem("f(c+1)", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction fint = bh.assertNonProblem("f(int)", 1);
+ IFunction f = bh.assertNonProblem("f(c+1)", 1);
assertSame(fint, f);
}
@@ -9398,11 +9393,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(a= 1); // A cannot be converted to long& here
// }
public void testBuiltinOperators_294543b() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction fA= bh.assertNonProblem("f(A)", 1);
- IFunction f= bh.assertNonProblem("f(a= 1)", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction fA = bh.assertNonProblem("f(A)", 1);
+ IFunction f = bh.assertNonProblem("f(a= 1)", 1);
assertSame(fA, f);
}
@@ -9417,11 +9412,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
// Y* m(Y*);//3
// };
public void testOverrideSimpleCovariance_321617() throws Exception {
- BindingAssertionHelper helper= getAssertionHelper();
- ICPPMethod m0= helper.assertNonProblem("m();//0", 1, ICPPMethod.class);
- ICPPMethod m1= helper.assertNonProblem("m(X*);//1", 1, ICPPMethod.class);
- ICPPMethod m2= helper.assertNonProblem("m();//2", 1, ICPPMethod.class);
- ICPPMethod m3= helper.assertNonProblem("m(Y*);//3", 1, ICPPMethod.class);
+ BindingAssertionHelper helper = getAssertionHelper();
+ ICPPMethod m0 = helper.assertNonProblem("m();//0", 1, ICPPMethod.class);
+ ICPPMethod m1 = helper.assertNonProblem("m(X*);//1", 1, ICPPMethod.class);
+ ICPPMethod m2 = helper.assertNonProblem("m();//2", 1, ICPPMethod.class);
+ ICPPMethod m3 = helper.assertNonProblem("m(Y*);//3", 1, ICPPMethod.class);
assertTrue(ClassTypeHelper.isVirtual(m0));
assertTrue(ClassTypeHelper.isVirtual(m1));
@@ -9440,14 +9435,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertFalse(ClassTypeHelper.isOverrider(m3, m0));
assertFalse(ClassTypeHelper.isOverrider(m3, m1));
- ICPPMethod[] ors= ClassTypeHelper.findOverridden(m0);
+ ICPPMethod[] ors = ClassTypeHelper.findOverridden(m0);
assertEquals(0, ors.length);
- ors= ClassTypeHelper.findOverridden(m1);
+ ors = ClassTypeHelper.findOverridden(m1);
assertEquals(0, ors.length);
- ors= ClassTypeHelper.findOverridden(m2);
+ ors = ClassTypeHelper.findOverridden(m2);
assertEquals(1, ors.length);
assertSame(ors[0], m0);
- ors= ClassTypeHelper.findOverridden(m3);
+ ors = ClassTypeHelper.findOverridden(m3);
assertEquals(0, ors.length);
}
@@ -9470,11 +9465,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testResolutionToFinalOverrider_86654() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
-
+
ICPPMethod actual = helper.assertNonProblem("c.f()", "f");
ICPPMethod expected = helper.assertNonProblem("virtual void f(); // B", "f");
assertEquals(expected, actual);
-
+
actual = helper.assertNonProblem("c.C::f()", "f");
expected = helper.assertNonProblem("virtual void f(); // A", "f");
assertEquals(expected, actual);
@@ -9487,36 +9482,36 @@ public class AST2CPPTests extends AST2CPPTestBase {
// int f(int) = delete;
// auto g() -> int = delete;
public void testDefaultedAndDeletedFunctions_305978() throws Exception {
- String code= getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code);
+ String code = getAboveComment();
+ IASTTranslationUnit tu = parseAndCheckBindings(code);
- ICPPASTFunctionDefinition f= getDeclaration(tu, 1);
+ ICPPASTFunctionDefinition f = getDeclaration(tu, 1);
assertTrue(f.isDefaulted());
assertFalse(f.isDeleted());
- f= getDeclaration(tu, 2);
+ f = getDeclaration(tu, 2);
assertFalse(f.isDefaulted());
assertTrue(f.isDeleted());
- f= getDeclaration(tu, 3);
+ f = getDeclaration(tu, 3);
assertFalse(f.isDefaulted());
assertTrue(f.isDeleted());
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- ICPPFunction fb= bh.assertNonProblem("X() =", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ ICPPFunction fb = bh.assertNonProblem("X() =", 1);
assertFalse(fb.isDeleted());
- fb= bh.assertNonProblem("f(int)", 1);
+ fb = bh.assertNonProblem("f(int)", 1);
assertTrue(fb.isDeleted());
- fb= bh.assertNonProblem("g()", 1);
+ fb = bh.assertNonProblem("g()", 1);
assertTrue(fb.isDeleted());
}
// const int b=12;
// void f(int a= b) = delete ;
public void testDefaultedAndDeletedFunctions_305978b() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code);
}
@@ -9591,17 +9586,17 @@ public class AST2CPPTests extends AST2CPPTestBase {
// ::g(1);
// }
public void testInlineNamespace_305980c() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction fo= bh.assertNonProblem("f(int)", 1);
- IFunction g= bh.assertNonProblem("g(int)", 1);
- IFunction fi= bh.assertNonProblem("f(char)", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction fo = bh.assertNonProblem("f(int)", 1);
+ IFunction g = bh.assertNonProblem("g(int)", 1);
+ IFunction fi = bh.assertNonProblem("f(char)", 1);
- IFunction ref= bh.assertNonProblem("f(1)", 1);
+ IFunction ref = bh.assertNonProblem("f(1)", 1);
assertSame(fi, ref);
- ref= bh.assertNonProblem("g(1)", 1);
+ ref = bh.assertNonProblem("g(1)", 1);
assertSame(g, ref);
}
@@ -9612,12 +9607,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
// void ns::f() {}
public void testInlineNamespace_305980d() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction f1= bh.assertNonProblem("f();", 1);
- IFunction f2= bh.assertNonProblem("f() {", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction f1 = bh.assertNonProblem("f();", 1);
+ IFunction f2 = bh.assertNonProblem("f() {", 1);
assertSame(f1, f2);
}
@@ -9643,7 +9638,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
// };
public void testLambdaExpression_316307a() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code);
}
@@ -9658,7 +9653,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testLambdaExpression_316307b() throws Exception {
parseAndCheckBindings();
}
-
+
// struct function {
// template <typename T>
// function(T);
@@ -9676,13 +9671,13 @@ public class AST2CPPTests extends AST2CPPTestBase {
// void f(const MyType& val);
// void g(MyType& val);
public void testTypeString_323596() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction f= bh.assertNonProblem("f(", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction f = bh.assertNonProblem("f(", 1);
assertEquals("const MyType &", ASTTypeUtil.getType(f.getType().getParameterTypes()[0], false));
assertEquals("const int &", ASTTypeUtil.getType(f.getType().getParameterTypes()[0], true));
- IFunction g= bh.assertNonProblem("g(", 1);
+ IFunction g = bh.assertNonProblem("g(", 1);
assertEquals("MyType &", ASTTypeUtil.getType(g.getType().getParameterTypes()[0], false));
assertEquals("int &", ASTTypeUtil.getType(g.getType().getParameterTypes()[0], true));
}
@@ -9700,9 +9695,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// container cnt;
// };
public void testConstMember_323599() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction f= bh.assertNonProblem("constBegin(); //ref", 10);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction f = bh.assertNonProblem("constBegin(); //ref", 10);
bh.assertProblem("begin(); //ref", 5);
}
@@ -9720,8 +9715,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// fint(p + p); // converted to boolean and then int.
// };
public void testExplicitConversionOperators() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertProblem("fint(pe + pe);", 4);
bh.assertNonProblem("fint(p + p);", 4);
}
@@ -9737,11 +9732,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
// C c (d);
// }
public void testExplicitOperatorInDirectInit() throws Exception {
- String code= getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code);
- ICPPASTFunctionDefinition fdef= getDeclaration(tu, 2);
- IASTDeclarationStatement declstmt= getStatement(fdef, 1);
- IASTSimpleDeclaration decl= (IASTSimpleDeclaration) declstmt.getDeclaration();
+ String code = getAboveComment();
+ IASTTranslationUnit tu = parseAndCheckBindings(code);
+ ICPPASTFunctionDefinition fdef = getDeclaration(tu, 2);
+ IASTDeclarationStatement declstmt = getStatement(fdef, 1);
+ IASTSimpleDeclaration decl = (IASTSimpleDeclaration) declstmt.getDeclaration();
IASTImplicitName[] names = ((IASTImplicitNameOwner) decl.getDeclarators()[0]).getImplicitNames();
assertEquals(1, names.length);
assertTrue(names[0].resolveBinding() instanceof ICPPConstructor);
@@ -9755,14 +9750,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
// g("abc");
// }
public void testRankingOfDeprecatedConversionOnStringLiteral() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction g= bh.assertNonProblem("g(char *)", 1);
- IFunction fconst= bh.assertNonProblem("f(const char *)", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction g = bh.assertNonProblem("g(char *)", 1);
+ IFunction fconst = bh.assertNonProblem("f(const char *)", 1);
- IBinding ref= bh.assertNonProblem("f(\"abc\")", 1);
+ IBinding ref = bh.assertNonProblem("f(\"abc\")", 1);
assertSame(fconst, ref);
- ref= bh.assertNonProblem("g(\"abc\")", 1);
+ ref = bh.assertNonProblem("g(\"abc\")", 1);
assertSame(g, ref);
}
@@ -9781,29 +9776,29 @@ public class AST2CPPTests extends AST2CPPTestBase {
// ar; // rvalue
// }
public void testXValueCategories() throws Exception {
- String code= getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code);
- ICPPASTFunctionDefinition fdef= getDeclaration(tu, 5);
+ String code = getAboveComment();
+ IASTTranslationUnit tu = parseAndCheckBindings(code);
+ ICPPASTFunctionDefinition fdef = getDeclaration(tu, 5);
IASTExpression expr;
- expr= getExpressionOfStatement(fdef, 0);
+ expr = getExpressionOfStatement(fdef, 0);
assertEquals(XVALUE, expr.getValueCategory());
assertEquals("A", ASTTypeUtil.getType(expr.getExpressionType()));
- expr= getExpressionOfStatement(fdef, 1);
+ expr = getExpressionOfStatement(fdef, 1);
assertEquals(XVALUE, expr.getValueCategory());
assertEquals("int", ASTTypeUtil.getType(expr.getExpressionType()));
- expr= getExpressionOfStatement(fdef, 2);
+ expr = getExpressionOfStatement(fdef, 2);
assertEquals(XVALUE, expr.getValueCategory());
assertEquals("A", ASTTypeUtil.getType(expr.getExpressionType()));
- expr= getExpressionOfStatement(fdef, 3);
+ expr = getExpressionOfStatement(fdef, 3);
assertEquals(XVALUE, expr.getValueCategory());
assertEquals("A", ASTTypeUtil.getType(expr.getExpressionType()));
// ar;
- expr= getExpressionOfStatement(fdef, 4);
+ expr = getExpressionOfStatement(fdef, 4);
assertEquals(LVALUE, expr.getValueCategory());
assertEquals("A", ASTTypeUtil.getType(expr.getExpressionType()));
}
@@ -9819,16 +9814,16 @@ public class AST2CPPTests extends AST2CPPTestBase {
// int l = g(f2()); // calls g(const int&&)
// }
public void testRankingOfReferenceBindings_a() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
- IFunction g1= bh.assertNonProblemOnFirstIdentifier("g(const int&)");
- IFunction g2= bh.assertNonProblemOnFirstIdentifier("g(const int&&)");
+ BindingAssertionHelper bh = getAssertionHelper();
+ IFunction g1 = bh.assertNonProblemOnFirstIdentifier("g(const int&)");
+ IFunction g2 = bh.assertNonProblemOnFirstIdentifier("g(const int&&)");
IFunction ref;
- ref= bh.assertNonProblemOnFirstIdentifier("g(i);");
+ ref = bh.assertNonProblemOnFirstIdentifier("g(i);");
assertSame(g1, ref);
- ref= bh.assertNonProblemOnFirstIdentifier("g(f1());");
+ ref = bh.assertNonProblemOnFirstIdentifier("g(f1());");
assertSame(g2, ref);
- ref= bh.assertNonProblemOnFirstIdentifier("g(f2());");
+ ref = bh.assertNonProblemOnFirstIdentifier("g(f2());");
assertSame(g2, ref);
}
@@ -9849,25 +9844,25 @@ public class AST2CPPTests extends AST2CPPTestBase {
// a.p();//6 // calls A::p()&
// }
public void testRankingOfReferenceBindings_b() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
- ICPPMethod s1= bh.assertNonProblem("operator<<(int)", 10);
- ICPPFunction s2= bh.assertNonProblem("operator<<(A&&, char)", 10);
- ICPPMethod p1= bh.assertNonProblemOnFirstIdentifier("p() &;");
- ICPPMethod p2= bh.assertNonProblemOnFirstIdentifier("p() &&;");
+ BindingAssertionHelper bh = getAssertionHelper();
+ ICPPMethod s1 = bh.assertNonProblem("operator<<(int)", 10);
+ ICPPFunction s2 = bh.assertNonProblem("operator<<(A&&, char)", 10);
+ ICPPMethod p1 = bh.assertNonProblemOnFirstIdentifier("p() &;");
+ ICPPMethod p2 = bh.assertNonProblemOnFirstIdentifier("p() &&;");
IASTImplicitName name;
- name= bh.assertImplicitName("<< 1;//1", 2, ICPPMethod.class);
+ name = bh.assertImplicitName("<< 1;//1", 2, ICPPMethod.class);
assertSame(s1, name.getBinding());
- name= bh.assertImplicitName("<< 'c';//2", 2, ICPPFunction.class);
+ name = bh.assertImplicitName("<< 'c';//2", 2, ICPPFunction.class);
assertSame(s2, name.getBinding());
- name= bh.assertImplicitName("<< 1;//3", 2, ICPPMethod.class);
+ name = bh.assertImplicitName("<< 1;//3", 2, ICPPMethod.class);
assertSame(s1, name.getBinding());
- name= bh.assertImplicitName("<< 'c';//4", 2, ICPPMethod.class);
+ name = bh.assertImplicitName("<< 'c';//4", 2, ICPPMethod.class);
assertSame(s1, name.getBinding());
ICPPMethod ref;
- ref= bh.assertNonProblemOnFirstIdentifier("p();//5");
+ ref = bh.assertNonProblemOnFirstIdentifier("p();//5");
assertSame(p2, ref);
- ref= bh.assertNonProblemOnFirstIdentifier("p();//6");
+ ref = bh.assertNonProblemOnFirstIdentifier("p();//6");
assertSame(p1, ref);
}
@@ -9883,25 +9878,25 @@ public class AST2CPPTests extends AST2CPPTestBase {
// S s2 = { 1, 2, 3 }; // invoke #2
// S s3 = { }; // invoke #3
public void testEmptyInitializerList_324096() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction ctor1= bh.assertNonProblem("S(std::initializer_list<double>);", 1);
- IFunction ctor2= bh.assertNonProblem("S(std::initializer_list<int>);", 1);
- IFunction ctor3= bh.assertNonProblem("S();", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction ctor1 = bh.assertNonProblem("S(std::initializer_list<double>);", 1);
+ IFunction ctor2 = bh.assertNonProblem("S(std::initializer_list<int>);", 1);
+ IFunction ctor3 = bh.assertNonProblem("S();", 1);
IASTName name;
IASTImplicitNameOwner dtor;
- name= bh.findName("s1", 2);
- dtor= (IASTImplicitNameOwner) name.getParent();
+ name = bh.findName("s1", 2);
+ dtor = (IASTImplicitNameOwner) name.getParent();
assertSame(ctor1, dtor.getImplicitNames()[0].resolveBinding());
- name= bh.findName("s2", 2);
- dtor= (IASTImplicitNameOwner) name.getParent();
+ name = bh.findName("s2", 2);
+ dtor = (IASTImplicitNameOwner) name.getParent();
assertSame(ctor2, dtor.getImplicitNames()[0].resolveBinding());
- name= bh.findName("s3", 2);
- dtor= (IASTImplicitNameOwner) name.getParent();
+ name = bh.findName("s3", 2);
+ dtor = (IASTImplicitNameOwner) name.getParent();
assertSame(ctor3, dtor.getImplicitNames()[0].resolveBinding());
}
-
+
// struct S {
// bool a;
// int b;
@@ -9940,9 +9935,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(true ? c : 1); // calls f(int), not f(C);
// }
public void testConditionalOperator_324853a() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
IBinding f = bh.assertNonProblem("f(int);", 1);
- IBinding ref= bh.assertNonProblem("f(true ? c : 1)", 1);
+ IBinding ref = bh.assertNonProblem("f(true ? c : 1)", 1);
assertSame(f, ref);
}
@@ -9955,14 +9950,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
// g(0 ? p : ""); // converts "" to char*
// }
public void testConditionalOperator_324853b() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
IBinding fc = bh.assertNonProblem("f(const char*);", 1);
IBinding ref;
- ref= bh.assertNonProblem("f(0 ? cp : p)", 1);
+ ref = bh.assertNonProblem("f(0 ? cp : p)", 1);
assertSame(fc, ref);
- ref= bh.assertNonProblem("f(0 ? p : \"\")", 1); // "" converted to char*
+ ref = bh.assertNonProblem("f(0 ? p : \"\")", 1); // "" converted to char*
assertSame(fc, ref);
- bh.assertNonProblem("g(0 ? p : \"\")", 1); //
+ bh.assertNonProblem("g(0 ? p : \"\")", 1); //
}
// struct C {
@@ -9976,27 +9971,27 @@ public class AST2CPPTests extends AST2CPPTestBase {
// C c4 ={1,2}; // C(C(int, int)) // copy ctor is elided
// C c5 {1,2}; // C(int, int)
public void testCtorForAutomaticVariables_156668() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction ctor1= bh.assertNonProblem("C();", 1);
- IFunction ctor2= bh.assertNonProblem("C(int a, int b);", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction ctor1 = bh.assertNonProblem("C();", 1);
+ IFunction ctor2 = bh.assertNonProblem("C(int a, int b);", 1);
IASTName name;
IASTImplicitNameOwner dtor;
- name= bh.findName("c1", 2);
- dtor= (IASTImplicitNameOwner) name.getParent();
+ name = bh.findName("c1", 2);
+ dtor = (IASTImplicitNameOwner) name.getParent();
assertSame(ctor1, dtor.getImplicitNames()[0].resolveBinding());
- name= bh.findName("c2", 2);
- dtor= (IASTImplicitNameOwner) name.getParent();
+ name = bh.findName("c2", 2);
+ dtor = (IASTImplicitNameOwner) name.getParent();
assertSame(ctor2, dtor.getImplicitNames()[0].resolveBinding());
- name= bh.findName("c3", 2);
- dtor= (IASTImplicitNameOwner) name.getParent();
+ name = bh.findName("c3", 2);
+ dtor = (IASTImplicitNameOwner) name.getParent();
assertSame(ctor2, dtor.getImplicitNames()[0].resolveBinding());
- name= bh.findName("c4", 2);
- dtor= (IASTImplicitNameOwner) name.getParent();
+ name = bh.findName("c4", 2);
+ dtor = (IASTImplicitNameOwner) name.getParent();
assertSame(ctor2, dtor.getImplicitNames()[0].resolveBinding());
- name= bh.findName("c5", 2);
- dtor= (IASTImplicitNameOwner) name.getParent();
+ name = bh.findName("c5", 2);
+ dtor = (IASTImplicitNameOwner) name.getParent();
assertSame(ctor2, dtor.getImplicitNames()[0].resolveBinding());
}
@@ -10008,13 +10003,13 @@ public class AST2CPPTests extends AST2CPPTestBase {
// g(&number);
// }
public void testTopLevelRestrictQualifier_327328() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction g= bh.assertNonProblem("g(int * __restrict a)", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction g = bh.assertNonProblem("g(int * __restrict a)", 1);
IFunction ref;
- ref= bh.assertNonProblem("g(int * a)", 1);
+ ref = bh.assertNonProblem("g(int * a)", 1);
assertSame(g, ref);
- ref= bh.assertNonProblem("g(&number)", 1);
+ ref = bh.assertNonProblem("g(&number)", 1);
assertSame(g, ref);
}
@@ -10028,14 +10023,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(&number); // calls f(int** a)
// }
public void testOverloadingWithRestrictQualifier_327328() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction f1= bh.assertNonProblem("f(int * __restrict* a)", 1);
- IFunction f2= bh.assertNonProblem("f(int ** a)", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction f1 = bh.assertNonProblem("f(int * __restrict* a)", 1);
+ IFunction f2 = bh.assertNonProblem("f(int ** a)", 1);
IFunction ref;
- ref= bh.assertNonProblem("f(&rnumber)", 1);
+ ref = bh.assertNonProblem("f(&rnumber)", 1);
assertSame(f1, ref);
- ref= bh.assertNonProblem("f(&number)", 1);
+ ref = bh.assertNonProblem("f(&number)", 1);
assertSame(f2, ref);
}
@@ -10110,8 +10105,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// auto f2 (); // missing late return type.
public void testBug332114a() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- IBinding b= bh.assertNonProblem("f2", 0);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ IBinding b = bh.assertNonProblem("f2", 0);
// Must not throw a NPE
IndexCPPSignatureUtil.getSignature(b);
}
@@ -10194,7 +10189,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testAutoTypeInRangeBasedFor_359653() throws Exception {
parseAndCheckBindings();
}
-
+
// struct Iter {
// Iter& operator++();
// int& operator*();
@@ -10238,18 +10233,18 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testOverrideSpecifierAfterTrailingReturnType_489876() throws Exception {
parseAndCheckBindings();
}
-
+
// auto (*x1)() -> int;
// int (*x2)();
//
// auto (*y1)() -> int(*)();
// int (*(*y2)())();
- //
+ //
// auto (*z1)() -> auto(*)() -> int(*)();
// int (*(*(*z2)())())();
public void testTrailingReturnTypeInFunctionPointer() throws Exception {
BindingAssertionHelper bh = getAssertionHelper();
-
+
ICPPVariable x1 = bh.assertNonProblem("x1");
ICPPVariable x2 = bh.assertNonProblem("x2");
assertSameType(x1.getType(), x2.getType());
@@ -10290,7 +10285,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testOverloadedOperatorWithInheritanceDistance_335387() throws Exception {
parseAndCheckBindings();
}
-
+
// struct Object {
// bool IsOk() const;
// };
@@ -10318,9 +10313,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// namespace ns {int a;}
// using ns::a;
public void testPropertyOfUsingDeclaration() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings();
- ICPPASTUsingDeclaration udecl= getDeclaration(tu, 1);
- ICPPASTQualifiedName qn= (ICPPASTQualifiedName) udecl.getName();
+ IASTTranslationUnit tu = parseAndCheckBindings();
+ ICPPASTUsingDeclaration udecl = getDeclaration(tu, 1);
+ ICPPASTQualifiedName qn = (ICPPASTQualifiedName) udecl.getName();
assertFalse(qn.isDefinition());
assertFalse(qn.getLastName().isDefinition());
assertTrue(qn.isDeclaration());
@@ -10349,24 +10344,24 @@ public class AST2CPPTests extends AST2CPPTestBase {
// X x = y2;
// }
public void testReferenceToCopyConstructor() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings();
- ICPPASTFunctionDefinition fdef= getDeclaration(tu, 2);
+ IASTTranslationUnit tu = parseAndCheckBindings();
+ ICPPASTFunctionDefinition fdef = getDeclaration(tu, 2);
- IASTDeclarationStatement dst= getStatement(fdef, 0);
- IASTDeclarator dtor= ((IASTSimpleDeclaration) dst.getDeclaration()).getDeclarators()[0];
- IBinding ctor= ((IASTImplicitNameOwner) dtor).getImplicitNames()[0].resolveBinding();
+ IASTDeclarationStatement dst = getStatement(fdef, 0);
+ IASTDeclarator dtor = ((IASTSimpleDeclaration) dst.getDeclaration()).getDeclarators()[0];
+ IBinding ctor = ((IASTImplicitNameOwner) dtor).getImplicitNames()[0].resolveBinding();
assertTrue(ctor instanceof ICPPConstructor);
assertEquals(0, ((ICPPConstructor) ctor).getType().getParameterTypes().length);
- dst= getStatement(fdef, 1);
- dtor= ((IASTSimpleDeclaration) dst.getDeclaration()).getDeclarators()[0];
- ctor= ((IASTImplicitNameOwner) dtor).getImplicitNames()[0].resolveBinding();
+ dst = getStatement(fdef, 1);
+ dtor = ((IASTSimpleDeclaration) dst.getDeclaration()).getDeclarators()[0];
+ ctor = ((IASTImplicitNameOwner) dtor).getImplicitNames()[0].resolveBinding();
assertTrue(ctor instanceof ICPPConstructor);
assertEquals(1, ((ICPPConstructor) ctor).getType().getParameterTypes().length);
- dst= getStatement(fdef, 2);
- dtor= ((IASTSimpleDeclaration) dst.getDeclaration()).getDeclarators()[0];
- ctor= ((IASTImplicitNameOwner) dtor).getImplicitNames()[0].resolveBinding();
+ dst = getStatement(fdef, 2);
+ dtor = ((IASTSimpleDeclaration) dst.getDeclaration()).getDeclarators()[0];
+ ctor = ((IASTImplicitNameOwner) dtor).getImplicitNames()[0].resolveBinding();
assertTrue(ctor instanceof ICPPConstructor);
assertEquals(1, ((ICPPConstructor) ctor).getType().getParameterTypes().length);
}
@@ -10429,14 +10424,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
// void (g)(int); //1
// void (g)(int); //2
public void testFunctionRedeclarations() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
- IFunction g1= bh.assertNonProblem("g)(char)", 1);
- IFunction g2= bh.assertNonProblem("g)(int); //1", 1);
- IFunction g3= bh.assertNonProblem("g)(int); //2", 1);
+ BindingAssertionHelper bh = getAssertionHelper();
+ IFunction g1 = bh.assertNonProblem("g)(char)", 1);
+ IFunction g2 = bh.assertNonProblem("g)(int); //1", 1);
+ IFunction g3 = bh.assertNonProblem("g)(int); //2", 1);
assertNotSame(g1, g2);
assertSame(g2, g3);
}
-
+
// int test() {
// extern int *e();
// if (auto r = e()) { return *r; }
@@ -10450,8 +10445,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class A : A {
// };
public void testRecursiveClassInheritance_357256() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
- ICPPClassType c= bh.assertNonProblem("A", 1);
+ BindingAssertionHelper bh = getAssertionHelper();
+ ICPPClassType c = bh.assertNonProblem("A", 1);
assertEquals(0, SemanticQueries.getPureVirtualMethods(c, null).length);
}
@@ -10495,16 +10490,16 @@ public class AST2CPPTests extends AST2CPPTestBase {
// ~T();
// };
public void testErrorForDestructorWithWrongName_367590() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(), CPP, false, false);
+ IASTTranslationUnit tu = parse(getAboveComment(), CPP, false, false);
IASTCompositeTypeSpecifier S;
IASTProblemDeclaration p;
IASTSimpleDeclaration s;
- S= getCompositeType(tu, 1);
- s= getDeclaration(S, 0);
- s= getDeclaration(S, 1);
- p= getDeclaration(S, 2);
- p= getDeclaration(S, 3);
+ S = getCompositeType(tu, 1);
+ s = getDeclaration(S, 0);
+ s = getDeclaration(S, 1);
+ p = getDeclaration(S, 2);
+ p = getDeclaration(S, 3);
}
// typedef int int8_t __attribute__ ((__mode__ (__QI__)));
@@ -10524,16 +10519,16 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(word);
// }
public void testModeAttribute_330635() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
String[] calls = { "f(i8)", "f(i16)", "f(i32)", "f(i64)", "f(word)" };
ICPPFunction[] functions = new ICPPFunction[calls.length];
for (int i = 0; i < calls.length; i++) {
functions[i] = bh.assertNonProblem(calls[i], 1, ICPPFunction.class);
}
for (int i = 0; i < functions.length - 1; i++) {
- for (int j = 0; j < i ; j++) {
- assertNotSame(calls[i] + " and " + calls[j] + " resolve to the same function",
- functions[i], functions[j]);
+ for (int j = 0; j < i; j++) {
+ assertNotSame(calls[i] + " and " + calls[j] + " resolve to the same function", functions[i],
+ functions[j]);
}
}
assertSame(calls[calls.length - 1] + " and " + calls[calls.length - 2] + " resolve to different functions",
@@ -10611,7 +10606,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// g( nullptr ); // error
// }
public void testNullptr_327298b() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertProblem("checkNullPtr(1)", 12);
bh.assertProblem("checklvalue(nullptr)", 11);
bh.assertProblem("g( nullptr )", 1);
@@ -10625,18 +10620,18 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testNullptr_327298c() throws Exception {
parseAndCheckBindings();
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- IFunction f= bh.assertNonProblem("f( nullptr )", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ IFunction f = bh.assertNonProblem("f( nullptr )", 1);
assertEquals("void (char *)", ASTTypeUtil.getType(f.getType()));
- f= bh.assertNonProblem("f( 0 )", 1);
+ f = bh.assertNonProblem("f( 0 )", 1);
assertEquals("void (int)", ASTTypeUtil.getType(f.getType()));
}
// void foo(struct S s);
public void testParameterForwardDeclaration_379511() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPClassType struct= bh.assertNonProblem("S", 1, ICPPClassType.class);
- IName[] declarations= bh.getTranslationUnit().getDeclarations(struct);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPClassType struct = bh.assertNonProblem("S", 1, ICPPClassType.class);
+ IName[] declarations = bh.getTranslationUnit().getDeclarations(struct);
assertEquals(1, declarations.length);
assertEquals(bh.findName("S", 1), declarations[0]);
}
@@ -10678,7 +10673,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testFriendConstructorDestructor_400940() throws Exception {
parseAndCheckBindings();
}
-
+
// namespace Hugo {
// class C {
// friend class Waldo;
@@ -10709,14 +10704,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTNode[] functionDeclarators = functionDeclarationBinding.getDeclarations();
assertEquals(1, functionDeclarators.length);
assertInstance(functionDeclarators[0], ICPPASTFunctionDeclarator.class);
- assertVirtualSpecifiers((ICPPASTFunctionDeclarator)functionDeclarators[0], false, true);
+ assertVirtualSpecifiers((ICPPASTFunctionDeclarator) functionDeclarators[0], false, true);
CPPMethod functionDefinitionBinding = bindingHelper.assertNonProblem("mFuncDef()", 8);
assertFalse(functionDefinitionBinding.isOverride());
assertTrue(functionDefinitionBinding.isFinal());
IASTFunctionDeclarator declarator = functionDefinitionBinding.getDefinition();
assertInstance(declarator, ICPPASTFunctionDeclarator.class);
- assertVirtualSpecifiers((ICPPASTFunctionDeclarator)declarator, false, true);
+ assertVirtualSpecifiers((ICPPASTFunctionDeclarator) declarator, false, true);
}
// struct Base {
@@ -10739,14 +10734,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTDeclarator[] functionDeclarators = functionDeclarationBinding.getDeclarations();
assertEquals(1, functionDeclarators.length);
assertInstance(functionDeclarators[0], ICPPASTFunctionDeclarator.class);
- assertVirtualSpecifiers((ICPPASTFunctionDeclarator)functionDeclarators[0], true, false);
+ assertVirtualSpecifiers((ICPPASTFunctionDeclarator) functionDeclarators[0], true, false);
CPPMethod functionDefinitionBinding = bindingHelper.assertNonProblem("mFuncDef() override", 8);
assertTrue(functionDefinitionBinding.isOverride());
assertFalse(functionDefinitionBinding.isFinal());
IASTFunctionDeclarator declarator = functionDefinitionBinding.getDefinition();
assertInstance(declarator, ICPPASTFunctionDeclarator.class);
- assertVirtualSpecifiers((ICPPASTFunctionDeclarator)declarator, true, false);
+ assertVirtualSpecifiers((ICPPASTFunctionDeclarator) declarator, true, false);
}
// struct Base {
@@ -10769,17 +10764,18 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTDeclarator[] functionDeclarators = functionDeclarationBinding.getDeclarations();
assertEquals(1, functionDeclarators.length);
assertInstance(functionDeclarators[0], ICPPASTFunctionDeclarator.class);
- assertVirtualSpecifiers((ICPPASTFunctionDeclarator)functionDeclarators[0], true, true);
+ assertVirtualSpecifiers((ICPPASTFunctionDeclarator) functionDeclarators[0], true, true);
CPPMethod functionDefinitionBinding = bindingHelper.assertNonProblem("mFuncDef() final", 8);
assertTrue(functionDefinitionBinding.isOverride());
assertTrue(functionDefinitionBinding.isFinal());
IASTFunctionDeclarator declarator = functionDefinitionBinding.getDefinition();
assertInstance(declarator, ICPPASTFunctionDeclarator.class);
- assertVirtualSpecifiers((ICPPASTFunctionDeclarator)declarator, true, true);
+ assertVirtualSpecifiers((ICPPASTFunctionDeclarator) declarator, true, true);
}
- private void assertVirtualSpecifiers(ICPPASTFunctionDeclarator declarator, boolean expectOverride, boolean expectFinal) {
+ private void assertVirtualSpecifiers(ICPPASTFunctionDeclarator declarator, boolean expectOverride,
+ boolean expectFinal) {
assertEquals(expectOverride, declarator.isOverride());
assertEquals(expectFinal, declarator.isFinal());
}
@@ -10799,16 +10795,16 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTNode baseDefinitionName = structBase.getDefinition();
IASTNode baseDefinition = baseDefinitionName.getParent();
assertInstance(baseDefinition, ICPPASTCompositeTypeSpecifier.class);
- assertFalse(((ICPPASTCompositeTypeSpecifier)baseDefinition).isFinal());
+ assertFalse(((ICPPASTCompositeTypeSpecifier) baseDefinition).isFinal());
CPPClassType structS = bh.assertNonProblem("S", 1);
assertTrue(structS.isFinal());
IASTNode sDefinitionName = structS.getDefinition();
IASTNode sDefinition = sDefinitionName.getParent();
assertInstance(sDefinition, ICPPASTCompositeTypeSpecifier.class);
- assertTrue(((ICPPASTCompositeTypeSpecifier)sDefinition).isFinal());
+ assertTrue(((ICPPASTCompositeTypeSpecifier) sDefinition).isFinal());
}
-
+
// struct S {
// template<typename T>
// void foo(T t) final {
@@ -10848,7 +10844,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testFinalParameter() throws Exception {
parseAndCheckBindings();
}
-
+
// struct S __final {};
// struct T { void foo() __final; };
public void testFinalGccExtension_442457() throws Exception {
@@ -10858,7 +10854,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPMethod foo = bh.assertNonProblem("foo");
assertTrue(foo.isFinal());
}
-
+
// struct S {};
// bool b1 = __is_trivially_copyable(S);
// bool b2 = __is_trivially_assignable(S, S&);
@@ -10898,7 +10894,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testADLForFunctionObject_388287() throws Exception {
parseAndCheckBindings();
}
-
+
// namespace A {
// template <typename T>
// void foo(T);
@@ -10907,7 +10903,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// namespace B {
// template <typename T>
// void foo(T);
- //
+ //
// struct S {};
// }
//
@@ -11114,7 +11110,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testThrowExpressionInConditional_396663() throws Exception {
parseAndCheckBindings(getAboveComment(), CPP, true);
}
-
+
// struct A {};
//
// struct B : A {};
@@ -11127,7 +11123,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testBasePointerConverstionInConditional_462705() throws Exception {
parseAndCheckBindings();
}
-
+
// struct S {};
// typedef S* S_ptr;
// void waldo(S*);
@@ -11288,7 +11284,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testGNUSyncBuiltins_389578() throws Exception {
parseAndCheckBindings(getAboveComment(), CPP, true);
}
-
+
// int main() {
// void* p;
// __sync_bool_compare_and_swap(&p, p, p);
@@ -11348,7 +11344,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertSameType((ITypedef) helper.assertNonProblem("ulong_type"), CPPBasicType.UNSIGNED_LONG);
assertSameType((ITypedef) helper.assertNonProblem("loong_type"), CPPBasicType.LONG);
}
-
+
// template <typename T>
// struct underlying_type {
// typedef __underlying_type(T) type;
@@ -11365,7 +11361,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testUnderlyingType_540909() throws Exception {
parseAndCheckBindings(getAboveComment(), CPP, true /* use GNU extensions */);
}
-
+
// void ptrFunc(void*);
// void intFunc(int);
// void foo(int* pi, unsigned i) {
@@ -11377,7 +11373,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testGCCBuiltins_512932a() throws Exception {
parseAndCheckBindings(getAboveComment(), CPP, true);
}
-
+
// void ptrFunc(void*);
// void intFunc(int);
// void foo(int* pi, unsigned i) {
@@ -11470,7 +11466,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testBuiltInOperatorFunctionType_423396() throws Exception {
parseAndCheckBindings();
}
-
+
// template <unsigned N>
// void waldo(const char (&)[N]);
// void foo() {
@@ -11479,7 +11475,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testTypeOfBuiltinSymbol_512932() throws Exception {
parseAndCheckBindings();
}
-
+
// struct S {
// int S;
// };
@@ -11524,7 +11520,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertEquals(',', argumentTokens[1].getTokenCharImage()[0]);
assertEquals('2', argumentTokens[2].getTokenCharImage()[0]);
}
-
+
// struct MyStruct {
// struct Inner {
// int waldo;
@@ -11538,12 +11534,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testFieldAndNestedTypeWithSameName_425033() throws Exception {
parseAndCheckBindings();
}
-
+
// void f(double (&(x)));
public void testParenthesizedReferenceArgument_424898() throws Exception {
parseAndCheckBindings();
}
-
+
// constexpr int naive_fibonacci(int x) {
// return x == 0 ? 0
// : x == 1 ? 1
@@ -11556,7 +11552,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IVariable waldo = helper.assertNonProblem("waldo");
assertConstantValue(5, waldo);
}
-
+
// constexpr int naive_fibonacci(int x) {
// return x == 0 ? 0
// : x == 1 ? 1
@@ -11573,7 +11569,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IVariable waldo = helper.assertNonProblem("waldo");
assertNull(waldo.getInitialValue().numberValue());
}
-
+
// constexpr int foo(int a = 42) {
// return a;
// }
@@ -11583,7 +11579,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IVariable waldo = helper.assertNonProblem("waldo");
assertConstantValue(42, waldo);
}
-
+
// struct S1 { S1(int); };
// struct S2 { void operator()(int); };
// S2 s2;
@@ -11593,7 +11589,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testICPPASTFunctionCallExpression_getOverload_441701() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
-
+
ICPPASTFunctionCallExpression call1 = helper.assertNode("S1(42)");
ICPPFunction constructor = helper.assertNonProblem("S1(int)", "S1");
assertEquals(constructor, call1.getOverload());
@@ -11609,7 +11605,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) tu.getDeclarations()[0];
isParameterSignatureEqual(sd.getDeclarators()[0], "(int&&)");
}
-
+
// struct S { S(int); };
// void find(S&&);
// int main() {
@@ -11619,7 +11615,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testRValueReferenceBindingToTemporary_470943() throws Exception {
parseAndCheckBindings();
}
-
+
// constexpr int waldo1 = 42;
// constexpr auto waldo2 = 43;
public void testConstexprVariableIsConst_451091() throws Exception {
@@ -11630,7 +11626,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertSameType(waldo1.getType(), CommonCPPTypes.constInt);
assertSameType(waldo2.getType(), CommonCPPTypes.constInt);
}
-
+
// constexpr int waldo1();
// constexpr int (*waldo2())(int);
// struct S { constexpr int waldo3(); };
@@ -11642,22 +11638,22 @@ public class AST2CPPTests extends AST2CPPTestBase {
// constexpr on a function *should not* make its return type const
assertSameType(waldo1.getType().getReturnType(), CommonCPPTypes.int_);
assertSameType(waldo2.getType().getReturnType(),
- new CPPPointerType(new CPPFunctionType(CommonCPPTypes.int_, new IType[]{ CommonCPPTypes.int_ })));
+ new CPPPointerType(new CPPFunctionType(CommonCPPTypes.int_, new IType[] { CommonCPPTypes.int_ })));
// constexpr on a method *should not* make the method const
- assertSameType(waldo3.getType(), new CPPFunctionType(CommonCPPTypes.int_, new IType[]{}));
+ assertSameType(waldo3.getType(), new CPPFunctionType(CommonCPPTypes.int_, new IType[] {}));
}
-
+
// void waldo() noexcept;
public void testASTCopyForNoexceptDefault_bug456207() throws Exception {
parseAndCheckBindings();
}
-
+
// template <typename> struct waldo { waldo(int); };
// auto x = static_cast<waldo<int>>(0);
public void testTemplateIdInsideCastOperator_460080() throws Exception {
parseAndCheckBindings();
}
-
+
// alignas(8) int x;
// alignas(int) char y;
// alignas(16) struct { int x; int y; };
@@ -11679,7 +11675,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testAlignas_451082() throws Exception {
parseAndCheckBindings();
}
-
+
// struct alignas(16) Node {};
// enum alignas(8) E { E1, E2 };
public void testAlignas_475739() throws Exception {
@@ -11690,7 +11686,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testAlignasAfterAttribute_538615() throws Exception {
parseAndCheckBindings(getAboveComment(), CPP, true /* use GNU extensions */);
}
-
+
// int operator "" _A(unsigned long long i) { return 1; }
// int operator "" _B(long double d) { return 1; }
// int operator "" _C(const char* s, unsigned int sz) { return sz; }
@@ -12155,7 +12151,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
for (int i = 1; i < decls.length; i++) {
IASTDeclaration decl = decls[i];
assertTrue(decl instanceof IASTProblemDeclaration);
- assertEquals(IProblem.SYNTAX_ERROR, ((IASTProblemDeclaration)decl).getProblem().getID());
+ assertEquals(IProblem.SYNTAX_ERROR, ((IASTProblemDeclaration) decl).getProblem().getID());
}
}
@@ -12187,7 +12183,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPVariable test = bh.assertNonProblemOnFirstIdentifier("test");
assertTrue(test.getType() instanceof IProblemType); // resolution is ambiguous
}
-
+
// namespace N {
// class Color {};
// Color operator"" _color(const char*, unsigned long);
@@ -12200,7 +12196,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testUserDefinedLiteralInNamespace_510665() throws Exception {
parseAndCheckBindings();
}
-
+
// double waldo1 = 02.968;
// double waldo2 = 09.268;
// double waldo3 = 02e2;
@@ -12208,22 +12204,22 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testFloatLiteralWithLeadingZero_498434() throws Exception {
parseAndCheckImplicitNameBindings();
}
-
+
// char foo() {
// return '*';
// }
public void testRegression_484618() throws Exception {
parseAndCheckImplicitNameBindings();
}
-
- // constexpr int lambdas_supported =
+
+ // constexpr int lambdas_supported =
// #if __has_feature(cxx_lambdas)
// 1;
// #else
// 0;
// #endif
//
- // constexpr int generic_lambdas_supported =
+ // constexpr int generic_lambdas_supported =
// #if __has_feature(cxx_generic_lambdas)
// 1;
// #else
@@ -12252,31 +12248,31 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testDesignatedInitializers() throws Exception {
BindingAssertionHelper bh = getAssertionHelper();
-// ICPPASTDesignatedInitializer d1 = bh.assertNode(".a = 10");
-// assertEquals(1, d1.getDesignators().length);
-// assertTrue(d1.getDesignators()[0] instanceof ICPPASTFieldDesignator);
-// ICPPASTDesignatedInitializer d2 = bh.assertNode(".b = 11");
-// assertEquals(1, d2.getDesignators().length);
-// assertTrue(d2.getDesignators()[0] instanceof ICPPASTFieldDesignator);
-// ICPPASTDesignatedInitializer d3 = bh.assertNode(".c[4 ... 6] = 3");
-// assertEquals(2, d3.getDesignators().length);
-// assertTrue(d3.getDesignators()[0] instanceof ICPPASTFieldDesignator);
-// assertTrue(d3.getDesignators()[1] instanceof IGPPASTArrayRangeDesignator);
-// ICPPASTDesignatedInitializer d4 = bh.assertNode(".d = 5");
-// assertEquals(1, d4.getDesignators().length);
-// assertTrue(d4.getDesignators()[0] instanceof ICPPASTFieldDesignator);
-// ICPPASTDesignatedInitializer d5 = bh.assertNode("[4] = 29");
-// assertEquals(1, d5.getDesignators().length);
-// assertTrue(d5.getDesignators()[0] instanceof ICPPASTArrayDesignator);
-// ICPPASTDesignatedInitializer d6 = bh.assertNode("[2] = 15");
-// assertEquals(1, d6.getDesignators().length);
-// assertTrue(d6.getDesignators()[0] instanceof ICPPASTArrayDesignator);
-// ICPPASTDesignatedInitializer d7 = bh.assertNode("[2 ... 4] = 29");
-// assertEquals(1, d7.getDesignators().length);
-// assertTrue(d7.getDesignators()[0] instanceof IGPPASTArrayRangeDesignator);
-// ICPPField a = bh.assertNonProblemOnFirstIdentifier(".a");
-// ICPPField b = bh.assertNonProblemOnFirstIdentifier(".b");
-// ICPPField c = bh.assertNonProblemOnFirstIdentifier(".c[4 ... 6]");
+ // ICPPASTDesignatedInitializer d1 = bh.assertNode(".a = 10");
+ // assertEquals(1, d1.getDesignators().length);
+ // assertTrue(d1.getDesignators()[0] instanceof ICPPASTFieldDesignator);
+ // ICPPASTDesignatedInitializer d2 = bh.assertNode(".b = 11");
+ // assertEquals(1, d2.getDesignators().length);
+ // assertTrue(d2.getDesignators()[0] instanceof ICPPASTFieldDesignator);
+ // ICPPASTDesignatedInitializer d3 = bh.assertNode(".c[4 ... 6] = 3");
+ // assertEquals(2, d3.getDesignators().length);
+ // assertTrue(d3.getDesignators()[0] instanceof ICPPASTFieldDesignator);
+ // assertTrue(d3.getDesignators()[1] instanceof IGPPASTArrayRangeDesignator);
+ // ICPPASTDesignatedInitializer d4 = bh.assertNode(".d = 5");
+ // assertEquals(1, d4.getDesignators().length);
+ // assertTrue(d4.getDesignators()[0] instanceof ICPPASTFieldDesignator);
+ // ICPPASTDesignatedInitializer d5 = bh.assertNode("[4] = 29");
+ // assertEquals(1, d5.getDesignators().length);
+ // assertTrue(d5.getDesignators()[0] instanceof ICPPASTArrayDesignator);
+ // ICPPASTDesignatedInitializer d6 = bh.assertNode("[2] = 15");
+ // assertEquals(1, d6.getDesignators().length);
+ // assertTrue(d6.getDesignators()[0] instanceof ICPPASTArrayDesignator);
+ // ICPPASTDesignatedInitializer d7 = bh.assertNode("[2 ... 4] = 29");
+ // assertEquals(1, d7.getDesignators().length);
+ // assertTrue(d7.getDesignators()[0] instanceof IGPPASTArrayRangeDesignator);
+ // ICPPField a = bh.assertNonProblemOnFirstIdentifier(".a");
+ // ICPPField b = bh.assertNonProblemOnFirstIdentifier(".b");
+ // ICPPField c = bh.assertNonProblemOnFirstIdentifier(".c[4 ... 6]");
ICPPField d = bh.assertNonProblemOnFirstIdentifier(".d");
}
@@ -12291,7 +12287,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// struct C : A {
// C() {}
// };
- //
+ //
// struct D : virtual A, virtual B {
// D() {}
// };
@@ -12305,7 +12301,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
public void testImplicitlyCalledBaseConstructor_393717() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
-
+
ICPPConstructor aCtor = helper.assertNonProblem("A()", "A");
ICPPConstructor bCtor = helper.assertNonProblem("B()", "B");
ICPPConstructor dCtor = helper.assertNonProblem("D()", "D");
@@ -12315,14 +12311,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) ctorDef).getImplicitNames();
assertEquals(1, implicitNames.length);
assertEquals(aCtor, implicitNames[0].resolveBinding());
-
+
ctorDef = helper.assertNode("D() {}");
implicitNames = ((IASTImplicitNameOwner) ctorDef).getImplicitNames();
sortNames(implicitNames);
assertEquals(2, implicitNames.length);
assertEquals(aCtor, implicitNames[0].resolveBinding());
assertEquals(bCtor, implicitNames[1].resolveBinding());
-
+
ctorDef = helper.assertNode("F() {}");
implicitNames = ((IASTImplicitNameOwner) ctorDef).getImplicitNames();
sortNames(implicitNames);
@@ -12332,7 +12328,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertEquals(dCtor, implicitNames[2].resolveBinding());
assertEquals(eCtor, implicitNames[3].resolveBinding());
}
-
+
// struct A {
// A(int, int);
// };
@@ -12348,7 +12344,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertEquals(1, implicitNames.length);
assertEquals(ctor, implicitNames[0].resolveBinding());
}
-
+
// template <typename T>
// struct Waldo {
// T x;
@@ -12361,7 +12357,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testShadowingAliasDeclaration_484200() throws Exception {
parseAndCheckBindings();
}
-
+
// struct foo {
// using E = enum { Zero, One, Two };
//
@@ -12372,7 +12368,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testAnonymousEnumInAliasDeclaration_502016() throws Exception {
parseAndCheckBindings();
}
-
+
// struct S {
// void foo() {
// bar(E::A); // ERROR: Symbol 'A' could not be resolved
@@ -12383,7 +12379,6 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testEnumDeclaredLaterInClass_491747() throws Exception {
parseAndCheckBindings();
}
-
// enum E { A = 2 };
// constexpr int operator+(E, E) {
@@ -12394,7 +12389,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableValue("waldo", 5);
}
-
+
// class S {
// static S waldo;
// };
@@ -12405,7 +12400,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// Trigger computation of value representation of S().
foo.getParameters()[0].getDefaultValue();
}
-
+
// class S {
// S waldo; // invalid
// };
@@ -12416,7 +12411,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// Trigger computation of value representation of S().
foo.getParameters()[0].getDefaultValue();
}
-
+
// class T;
// class S {
// T waldo; // invalid
@@ -12430,7 +12425,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPFunction foo = helper.assertNonProblem("foo");
// Trigger computation of value representation of S().
foo.getParameters()[0].getDefaultValue();
- }
+ }
// namespace std {
// template<typename T> class initializer_list;
@@ -12552,7 +12547,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testDecltypeAutoReturnType_482225() throws Exception {
parseAndCheckBindings();
}
-
+
// struct Waldo {
// int foo();
// };
@@ -12564,7 +12559,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testAutoWithTwoDeclarators_522066() throws Exception {
parseAndCheckBindings();
}
-
+
// constexpr int waldo = (sizeof(double) % 16);
public void testSizeofDouble_506170() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
@@ -12586,27 +12581,30 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTNode functionBody = explicitBooleanContextsFunction.getChildren()[2];
IASTNode logicalAndExpressionStatement = functionBody.getChildren()[1];
- ICPPASTBinaryExpression logicalAndExpression = (ICPPASTBinaryExpression)logicalAndExpressionStatement.getChildren()[0];
+ ICPPASTBinaryExpression logicalAndExpression = (ICPPASTBinaryExpression) logicalAndExpressionStatement
+ .getChildren()[0];
ICPPFunction logicalAndOverload = logicalAndExpression.getOverload();
assertNotNull(logicalAndOverload);
ICPPFunctionType logicalAndType = logicalAndOverload.getType();
isTypeEqual(logicalAndType, "bool (bool, bool)");
IASTNode logicalOrExpressionStatement = functionBody.getChildren()[2];
- ICPPASTBinaryExpression logicalOrExpression = (ICPPASTBinaryExpression)logicalOrExpressionStatement.getChildren()[0];
+ ICPPASTBinaryExpression logicalOrExpression = (ICPPASTBinaryExpression) logicalOrExpressionStatement
+ .getChildren()[0];
ICPPFunction logicalOrOverload = logicalOrExpression.getOverload();
assertNotNull(logicalOrOverload);
ICPPFunctionType logicalOrType = logicalOrOverload.getType();
isTypeEqual(logicalOrType, "bool (bool, bool)");
IASTNode logicalNotExpressionStatement = functionBody.getChildren()[3];
- ICPPASTUnaryExpression logicalNotExpression = (ICPPASTUnaryExpression)logicalNotExpressionStatement.getChildren()[0];
+ ICPPASTUnaryExpression logicalNotExpression = (ICPPASTUnaryExpression) logicalNotExpressionStatement
+ .getChildren()[0];
ICPPFunction logicalNotOverload = logicalNotExpression.getOverload();
assertNotNull(logicalNotOverload);
ICPPFunctionType logicalNotType = logicalNotOverload.getType();
isTypeEqual(logicalNotType, "bool (bool)");
}
-
+
// enum enumDecl {
// el0 __attribute__((deprecated)),
// el1,
@@ -12614,13 +12612,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testEnumeratorAttribute_514821() throws Exception {
parseAndCheckBindings(getAboveComment(), CPP, true /* use GNU extensions */);
}
-
+
// void foo([[maybe_unused]] int a);
public void testCxx11AttributeBeforeParameterDeclaration_530729() throws Exception {
parseAndCheckBindings();
}
-
// struct CType {
// char m_Array[4];
// };
@@ -12672,7 +12669,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testNamespaceAliasNamespaceWithPreviousFunctionName_517402() throws Exception {
parseAndCheckBindings();
}
-
+
// class C {};
// typedef C D;
// constexpr bool waldo = __is_class(D);
@@ -12680,19 +12677,19 @@ public class AST2CPPTests extends AST2CPPTestBase {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableValue("waldo", 1);
}
-
+
// struct A {};
// struct A* b = (1 == 1) ? new struct A : new struct A;
- public void test_ElabTypeSpecInNewExprInConditional_526134() throws Exception {
- parseAndCheckBindings();
- }
-
- // constexpr bool waldo1 = __is_trivially_constructible(int, short);
- // struct S { int fMem; S(int mem) : fMem(mem) {} };
- // constexpr bool waldo2 = __is_trivially_constructible(S);
- // constexpr bool waldo3 = __is_trivially_constructible(S, const S&);
- // constexpr bool waldo4 = __is_trivially_constructible(S, int);
- // constexpr bool waldo5 = __is_trivially_constructible(S, const S&, float);
+ public void test_ElabTypeSpecInNewExprInConditional_526134() throws Exception {
+ parseAndCheckBindings();
+ }
+
+ // constexpr bool waldo1 = __is_trivially_constructible(int, short);
+ // struct S { int fMem; S(int mem) : fMem(mem) {} };
+ // constexpr bool waldo2 = __is_trivially_constructible(S);
+ // constexpr bool waldo3 = __is_trivially_constructible(S, const S&);
+ // constexpr bool waldo4 = __is_trivially_constructible(S, int);
+ // constexpr bool waldo5 = __is_trivially_constructible(S, const S&, float);
public void testIsTriviallyConstructible_528072() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableValue("waldo1", 1);
@@ -12701,7 +12698,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
helper.assertVariableValue("waldo4", 0);
helper.assertVariableValue("waldo5", 0);
}
-
+
// template <typename T, typename U>
// struct pair {
// pair();
@@ -12713,7 +12710,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableValue("waldo", 1);
}
-
+
// namespace x {
// void foo();
// }
@@ -12747,7 +12744,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
helper.assertVariableType("v_b", CPPBasicType.UNSIGNED_LONG_LONG);
helper.assertVariableType("v_c", CPPBasicType.LONG_LONG);
}
-
+
// extern void *List[];
// extern void *List[];
// void *List[] = { 0 };
@@ -12764,11 +12761,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testStaticAssertWithoutMessage_534808() throws Exception {
parseAndCheckBindings();
}
-
+
// struct MyStruct {
// unsigned i;
// };
- //
+ //
// auto myFunA() -> struct MyStruct {
// return {5};
// };
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java
index f4892d2c3b3..e38f7146bd1 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java
@@ -30,20 +30,20 @@ public class AST2CSpecTest extends AST2SpecTestBase {
}
// /* Start Example(C 4-6) */
- // #ifdef _ _STDC_IEC_559_ _ // FE_UPWARD defined
+ // #ifdef _ _STDC_IEC_559_ _ // FE_UPWARD defined
// fesetround(FE_UPWARD);
// #endif
public void test4s6() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 5.1.1.3-2) */
// char i;
// int i;
public void test5_1_1_3s2() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 5.1.2.3-10) */
// int f() {
// char c1, c2;
@@ -52,7 +52,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test5_1_2_3s10() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 5.1.2.3-11) */
// int f() {
// float f1, f2;
@@ -62,7 +62,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test5_1_2_3s11() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 5.1.2.3-12) */
// int f() {
// double d1, d2;
@@ -73,7 +73,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test5_1_2_3s12() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 5.1.2.3-13) */
// int f() {
// double x, y, z;
@@ -85,7 +85,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test5_1_2_3s13() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 5.1.2.3-14) */
// int f() {
// int a, b;
@@ -98,7 +98,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test5_1_2_3s14() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 5.1.2.3-15) */
// //#include <stdio.h>
// int f() {
@@ -110,13 +110,13 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test5_1_2_3s15() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.2.5-28) */
// struct tag (* a[5])(float);
public void test6_2_5s28() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.2.7-5) */
// int f(int (*)(), double (*)[3]);
// int f(int (*)(char *), double (*)[]);
@@ -124,7 +124,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_2_7s5() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.4.4.4-12) */
// char x='\023';
// char y='\0';
@@ -132,7 +132,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_4_4_4s12() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.5.2.2-12) */
// int f1() {}
// int f2() {}
@@ -145,7 +145,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_2s12() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.5.2.3-7) */
// struct s { int i; const int ci; };
// struct s s;
@@ -162,7 +162,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_3s7() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.5.2.3-8a) */
// union {
// struct {
@@ -188,7 +188,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_3s8a() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.5.2.3-8b) */
// struct t1 { int m; };
// struct t2 { int m; };
@@ -209,13 +209,13 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_3s8b() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.5.2.5-9) */
// int *p = (int []){2, 4};
public void test6_5_2_5s9() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.5.2.5-10) */
// void f(void)
// {
@@ -225,7 +225,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_5s10() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.5.2.5-11) */
// int f(){
// drawline((struct point){.x=1, .y=1},
@@ -236,7 +236,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_5s11() throws Exception {
parse(getAboveComment(), ParserLanguage.C, false, 0);
}
-
+
// /* Start Example(C 6.5.2.5-12) */
// int f() {
// (const float []){1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6};
@@ -244,7 +244,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_5s12() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.5.2.5-13) */
// int f() {
// "/tmp/fileXXXXXX";
@@ -254,7 +254,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_5s13() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.5.2.5-14) */
// int f() {
// (const char []){"abc"} == "abc";
@@ -262,7 +262,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_5s14() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.5.2.5-15) */
// int f() {
// struct int_list { int car; struct int_list *cdr; };
@@ -272,7 +272,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_5s15() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.5.2.5-16) */
// struct s { int i; };
// int f (void)
@@ -287,14 +287,14 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_5s16() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.5.3.4-5) */
// extern void *alloc(size_t);
// double *dp = alloc(sizeof *dp);
public void test6_5_3_4s5() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.5.3.4-6) */
// int f() {
// int array[5];
@@ -303,7 +303,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_3_4s6() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.5.6-10) */
// int f() {
// int n = 4, m = 3;
@@ -316,7 +316,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_6s10() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.5.15-8) */
// int f(bool cond) {
// const void *c_vp;
@@ -348,7 +348,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
assertSameType(CommonCTypes.pointerToConstInt, c5.getExpressionType());
assertSameType(CommonCTypes.pointerToVoid, c6.getExpressionType());
}
-
+
// /* Start Example(C 6.5.16.1-5) */
// int f() {
// char c;
@@ -359,7 +359,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_16_1s5() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.5.16.1-6) */
// int f() {
// const char **cpp;
@@ -372,7 +372,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_16_1s6() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.2.1-17) */
// // offsetoff is a macro defined in stddef.h, using GNU definition
// #define offsetof(TYPE, MEMBER) ((size_t) (&((TYPE *)0)->MEMBER))
@@ -386,7 +386,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_2_1s17() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.7.2.1-18a) */
// int f() {
// struct s *s1;
@@ -397,14 +397,14 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_2_1s18a() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.7.2.1-18b) */
// struct { int n; double d[8]; } *s1;
// struct { int n; double d[5]; } *s2;
public void test6_7_2_1s18b() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.2.2-5) */
// int f() {
// enum hue { chartreuse, burgundy, claret=20, winedark };
@@ -417,7 +417,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_2_2s5() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.2.3-9) */
// struct tnode {
// int count;
@@ -427,7 +427,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_2_3s9() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.2.3-10) */
// typedef struct tnode TNODE;
// struct tnode {
@@ -438,7 +438,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_2_3s10() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.2.3-11) */
// struct s2;
// struct s1 { struct s2 *s2p; }; // D1
@@ -446,13 +446,13 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_2_3s11() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.3-10) */
// extern const volatile int real_time_clock;
public void test6_7_3s10() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.3-11) */
// int f() {
// const struct s { int mem; } cs = { 1 };
@@ -471,7 +471,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_3s11() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.3.1-7) */
// int * restrict a;
// int * restrict b;
@@ -479,7 +479,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_3_1s7() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.3.1-8) */
// void f(int n, int * restrict p, int * restrict q)
// {
@@ -489,7 +489,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_3_1s8() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.3.1-9) */
// void f(int n, int * restrict p, int * restrict q)
// {
@@ -505,7 +505,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_3_1s9() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.3.1-10) */
// void h(int n, int * restrict p, int * restrict q, int * restrict r)
// {
@@ -516,7 +516,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_3_1s10() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.3.1-11) */
// int f()
// {
@@ -533,7 +533,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_3_1s11() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.3.1-12) */
// typedef struct { int n; float * restrict v; } vector;
// vector new_vector(int n)
@@ -546,7 +546,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_3_1s12() throws Exception {
parse(getAboveComment(), ParserLanguage.C, false, 0);
}
-
+
// /* Start Example(C 6.7.4-7) */
// inline double fahr(double t)
// {
@@ -564,7 +564,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_4s7() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.5.1-4) */
// const int *ptr_to_constant;
// int *const constant_ptr1;
@@ -573,20 +573,20 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_5_1s4() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.5.2-7) */
// float fa[11], *afp[17];
public void test6_7_5_2s7() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.5.2-8) */
// extern int *x;
// extern int y[];
public void test6_7_5_2s8() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.5.2-9) */
// extern int n;
// extern int m;
@@ -603,7 +603,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_5_2s9() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.5.2-10) */
// extern int n;
// int A[n]; // invalid: file scope VLA
@@ -627,25 +627,25 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_5_2s10() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.7.5.3-16) */
// int f(void), *fip(), (*pfi)();
public void test6_7_5_3s16() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.5.3-18) */
// int (*apfi[3])(int *x, int *y);
public void test6_7_5_3s18() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.5.3-19) */
// int (*fpfi(int (*)(long), int))(int, ...);
public void test6_7_5_3s19() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.5.3-20) */
// void addscalar(int n, int m,
// double a[n][n*m+300], double x);
@@ -664,11 +664,11 @@ public class AST2CSpecTest extends AST2SpecTestBase {
// a[i][j] += x;
// }
public void test6_7_5_3s20() throws Exception {
- String code = getAboveComment();
+ String code = getAboveComment();
// no valid c++ code
parse(code, ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.5.3-21) */
// double maximum1(int n, int m, double a[n][m]);
// double maximum2(int n, int m, double a[*][*]);
@@ -681,7 +681,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_5_3s21() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.7-4) */
// typedef int MILES, KLICKSP();
// typedef struct { double hi, lo; } range;
@@ -692,14 +692,14 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_7s4() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.7-5) */
// typedef struct s1 { int x; } t1, *tp1;
// typedef struct s2 { int x; } t2, *tp2;
public void test6_7_7s5() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.7-7) */
// typedef void fv(int), (*pfv)(int);
// void (*signal(int, void (*)(int)))(int);
@@ -708,7 +708,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_7s7() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.7-8) */
// void copyt(int n)
// {
@@ -722,20 +722,20 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_7s8() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.8-24) */
// int i = 3.5;
// complex c = 5 + 3 * I;
public void test6_7_8s24() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.7.8-25) */
// int x[] = { 1, 3, 5 };
public void test6_7_8s25() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.8-26a) */
// int y[4][3] = {
// { 1, 3, 5 },
@@ -745,7 +745,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_8s26a() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.8-26b) */
// int y[4][3] = {
// 1, 3, 5, 2, 4, 6, 3, 5, 7
@@ -753,7 +753,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_8s26b() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.8-27) */
// int z[4][3] = {
// { 1 }, { 2 }, { 3 }, { 4 }
@@ -761,13 +761,13 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_8s27() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.8-28) */
// struct { int a[3], b; } w[] = { { 1 }, 2 };
public void test6_7_8s28() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.8-29) */
// short q1[4][3][2] = {
// { 1 },
@@ -794,7 +794,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_8s29() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.8-31) */
// typedef int A[]; // OK - declared with block scope
// A a1 = { 1, 2 }, b1 = { 3, 4, 5 };
@@ -802,7 +802,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_8s31() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.8-32) */
// int foo() {
// char s1[] = "abc", t1[3] = "abc";
@@ -813,7 +813,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_8s32() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.8-33) */
// enum { member_one, member_two };
// const char *nm[] = {
@@ -823,20 +823,20 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_8s33() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.8-34) */
// div_t answer = { .quot = 2, .rem = -1 };
public void test6_7_8s34() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 1); // div_t (correctly) cannot be resolved
}
-
+
// /* Start Example(C 6.7.8-35) */
// struct { int a[3], b; } w[] =
// { [0].a = {1}, [1].a[0] = 2 };
public void test6_7_8s35() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.8-36) */
// int MAX=15;
// int a[MAX] = {
@@ -845,13 +845,13 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_8s36() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.8-38) */
// union { int any_member; } u = { .any_member = 42 };
public void test6_7_8s38() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.8.3-4) */
// int p(int);
// int f() {
@@ -860,7 +860,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_8_3s4() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.8.3-5) */
// int f() {
// char *s;
@@ -870,7 +870,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_8_3s5() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.8.3-6) */
// int f() {
// int i=1;
@@ -886,7 +886,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_8_3s6() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.8.4-7) */
// int f(int a) {}
// int g(int expr) {
@@ -903,7 +903,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_8_4s7() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.8.6.1-3) */
// int f() {
// goto first_time;
@@ -921,7 +921,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_8_6_1s3() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.8.6.1-4) */
// int f() {
// goto lab3; // invalid: going INTO scope of VLA.
@@ -963,7 +963,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_8_6_4s4() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.9.1-13) */
// extern int max(int a, int b)
// {
@@ -972,7 +972,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_9_1s13() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.9.1-14) */
// void g(int (*funcp)(void))
// {
@@ -982,7 +982,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_9_1s14() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.9.2-4) */
// int i1 = 1; // definition, external linkage
// static int i2 = 2; // definition, internal linkage
@@ -1002,7 +1002,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_9_2s4() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.10.1-4) */
// int g() {}
// int f() {
@@ -1015,7 +1015,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_10_1s4() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.10.3.3-4) */
// #define hash_hash # ## #
// #define mkstr(a) # a
@@ -1026,20 +1026,20 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_10_3_3s4() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.10.3.5-3) */
// #define TABSIZE 100
// int table[TABSIZE];
public void test6_10_3_5s3() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.10.3.5-4) */
// #define max(a, b) ((a) > (b) ? (a) : (b))
public void test6_10_3_5s4() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.10.3.5-5) */
// #define x 3
// #define f(a) f(x * (a))
@@ -1086,7 +1086,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_10_3_5s6() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.10.3.5-7) */
// #define t(x,y,z) x ## y ## z
// int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),
@@ -1099,14 +1099,14 @@ public class AST2CSpecTest extends AST2SpecTestBase {
// #define OBJ_LIKE1 (1-1)
// #define OBJ_LIKE2 \
// (1-1) \
- // #define FUNC_LIKE1(a) ( a )
+ // #define FUNC_LIKE1(a) ( a )
// #define FUNC_LIKE2( a )( \
// a \
// )
public void test6_10_3_5s8() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.10.3.5-9) */
// #define debug(...) fprintf(stderr, __VA_ARGS__)
// #define showlist(...) puts(#__VA_ARGS__)
@@ -1121,7 +1121,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_10_3_5s9() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.7.7-6) */
// typedef signed int t;
// typedef int plain;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTestCase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTestCase.java
index 515566d497a..db53d108ae7 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTestCase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTestCase.java
@@ -39,15 +39,15 @@ import org.eclipse.core.runtime.NullProgressMonitor;
* @author dsteffle
*/
public class AST2FileBasePluginTestCase extends TestCase {
- static NullProgressMonitor monitor;
- static IWorkspace workspace;
- static IProject project;
- static FileManager fileManager;
- static int numProjects;
- static Class className;
+ static NullProgressMonitor monitor;
+ static IWorkspace workspace;
+ static IProject project;
+ static FileManager fileManager;
+ static int numProjects;
+ static Class className;
static ICProject cPrj;
- public AST2FileBasePluginTestCase() {
+ public AST2FileBasePluginTestCase() {
}
public AST2FileBasePluginTestCase(String name) {
@@ -55,88 +55,88 @@ public class AST2FileBasePluginTestCase extends TestCase {
}
private void initialize(Class aClassName) {
- if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) {
+ if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) {
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
monitor = new NullProgressMonitor();
workspace = ResourcesPlugin.getWorkspace();
- try {
- cPrj = CProjectHelper.createCCProject("AST2BasedProjectMofo", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
+ try {
+ cPrj = CProjectHelper.createCCProject("AST2BasedProjectMofo", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
- project = cPrj.getProject();
+ project = cPrj.getProject();
- // ugly
- if (className == null || !className.equals(aClassName)) {
- className = aClassName;
- numProjects++;
- }
- } catch (CoreException e) {
- // Ignore
- }
+ // ugly
+ if (className == null || !className.equals(aClassName)) {
+ className = aClassName;
+ numProjects++;
+ }
+ } catch (CoreException e) {
+ // Ignore
+ }
if (project == null)
throw new NullPointerException("Unable to create project"); //$NON-NLS-1$
// Create file manager
fileManager = new FileManager();
- }
- }
-
- public AST2FileBasePluginTestCase(String name, Class className) {
- super(name);
- initialize(className);
- }
-
- public void cleanupProject() throws Exception {
- numProjects--;
-
- try {
- if (numProjects == 0) {
- project.delete(true, false, monitor);
- project = null;
- }
- } catch (Throwable e) {
- // Ignore
- }
- }
-
- @Override
+ }
+ }
+
+ public AST2FileBasePluginTestCase(String name, Class className) {
+ super(name);
+ initialize(className);
+ }
+
+ public void cleanupProject() throws Exception {
+ numProjects--;
+
+ try {
+ if (numProjects == 0) {
+ project.delete(true, false, monitor);
+ project = null;
+ }
+ } catch (Throwable e) {
+ // Ignore
+ }
+ }
+
+ @Override
protected void tearDown() throws Exception {
- if (project == null || !project.exists())
- return;
-
- IResource[] members = project.members();
- for (int i = 0; i < members.length; i++) {
- if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
- continue;
- if (members[i].getName().equals(".settings"))
- continue;
- try {
- members[i].delete(false, monitor);
- } catch (Throwable e) {
- // Ignore
- }
- }
+ if (project == null || !project.exists())
+ return;
+
+ IResource[] members = project.members();
+ for (int i = 0; i < members.length; i++) {
+ if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
+ continue;
+ if (members[i].getName().equals(".settings"))
+ continue;
+ try {
+ members[i].delete(false, monitor);
+ } catch (Throwable e) {
+ // Ignore
+ }
+ }
}
- protected IFolder importFolder(String folderName) throws Exception {
- IFolder folder = project.getProject().getFolder(folderName);
+ protected IFolder importFolder(String folderName) throws Exception {
+ IFolder folder = project.getProject().getFolder(folderName);
// Create file input stream
if (!folder.exists())
folder.create(false, false, monitor);
return folder;
- }
+ }
- public IFile importFile(String fileName, String contents) throws Exception {
+ public IFile importFile(String fileName, String contents) throws Exception {
// Obtain file handle
IFile file = project.getProject().getFile(fileName);
InputStream stream = new ByteArrayInputStream(contents.getBytes());
// Create file input stream
if (file.exists()) {
- file.setContents(stream, false, false, monitor);
+ file.setContents(stream, false, false, monitor);
} else {
file.create(stream, false, monitor);
}
@@ -147,7 +147,7 @@ public class AST2FileBasePluginTestCase extends TestCase {
}
protected StringBuilder[] getContents(int sections) throws IOException {
- return TestSourceReader.getContentsForTest(
- CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), sections);
+ return TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "parser", getClass(),
+ getName(), sections);
}
}
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 72a44f6d01e..81ca1ccb5c7 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
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Rational Software - Initial API and implementation
* Anton Leherbauer (Wind River Systems)
@@ -63,8 +63,8 @@ import org.eclipse.cdt.internal.core.dom.parser.c.ICInternalBinding;
* @author dsteffle
*/
public class AST2KnRTests extends AST2TestBase {
-
- public AST2KnRTests() {
+
+ public AST2KnRTests() {
}
public AST2KnRTests(String name) {
@@ -72,574 +72,665 @@ public class AST2KnRTests extends AST2TestBase {
}
public void testSimpleKRCTest1() throws Exception {
- StringBuilder buffer = new StringBuilder();
- 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);
-
- IASTSimpleDeclaration f1 = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTFunctionDefinition f2 = (IASTFunctionDefinition) tu.getDeclarations()[1];
-
- assertTrue(f1.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
-
- IParameter x4 = (IParameter) ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f2.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding();
- IParameter x3 = (IParameter) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName().resolveBinding();
- IParameter x2 = (IParameter) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterNames()[0].resolveBinding();
- IParameter x1 = (IParameter) ((IASTStandardFunctionDeclarator) f1.getDeclarators()[0]).getParameters()[0].getDeclarator().getName().resolveBinding();
-
- assertNotNull(x1);
- assertNotNull(x2);
- assertNotNull(x3);
- assertNotNull(x4);
- assertEquals(x1, x2);
- assertEquals(x2, x3);
- assertEquals(x3, x4);
-
+ StringBuilder buffer = new StringBuilder();
+ 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);
+
+ IASTSimpleDeclaration f1 = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTFunctionDefinition f2 = (IASTFunctionDefinition) tu.getDeclarations()[1];
+
+ assertTrue(f1.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
+
+ IParameter x4 = (IParameter) ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f2
+ .getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding();
+ IParameter x3 = (IParameter) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator())
+ .getParameterDeclarations()[0]).getDeclarators()[0].getName().resolveBinding();
+ IParameter x2 = (IParameter) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterNames()[0]
+ .resolveBinding();
+ IParameter x1 = (IParameter) ((IASTStandardFunctionDeclarator) f1.getDeclarators()[0]).getParameters()[0]
+ .getDeclarator().getName().resolveBinding();
+
+ assertNotNull(x1);
+ assertNotNull(x2);
+ assertNotNull(x3);
+ assertNotNull(x4);
+ assertEquals(x1, x2);
+ assertEquals(x2, x3);
+ assertEquals(x3, x4);
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(x1);
assertEquals(decls.length, 2);
- assertEquals(decls[0], ((IASTStandardFunctionDeclarator) f1.getDeclarators()[0]).getParameters()[0].getDeclarator().getName());
- assertEquals(decls[1], ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName());
+ assertEquals(decls[0],
+ ((IASTStandardFunctionDeclarator) f1.getDeclarators()[0]).getParameters()[0].getDeclarator().getName());
+ assertEquals(decls[1], ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator())
+ .getParameterDeclarations()[0]).getDeclarators()[0].getName());
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "f".toCharArray())); //$NON-NLS-1$
- assertNotNull(((CScope) ((IASTCompoundStatement) f2.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
- }
-
- public void testSimpleKRCTest2() throws Exception {
- StringBuilder buffer = new StringBuilder();
- 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);
-
- IASTSimpleDeclaration f1 = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTFunctionDefinition f2 = (IASTFunctionDefinition) tu.getDeclarations()[1];
-
- assertTrue(f1.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
-
- IParameter x4 = (IParameter) ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f2.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding();
- IParameter x3 = (IParameter) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName().resolveBinding();
- IParameter x2 = (IParameter) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterNames()[0].resolveBinding();
-
- assertNotNull(x2);
- assertNotNull(x3);
- assertNotNull(x4);
- assertEquals(x2, x3);
- assertEquals(x3, x4);
-
+ assertNotNull(((CScope) ((IASTCompoundStatement) f2.getBody()).getScope())
+ .getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
+ }
+
+ public void testSimpleKRCTest2() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ 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);
+
+ IASTSimpleDeclaration f1 = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTFunctionDefinition f2 = (IASTFunctionDefinition) tu.getDeclarations()[1];
+
+ assertTrue(f1.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
+
+ IParameter x4 = (IParameter) ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f2
+ .getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding();
+ IParameter x3 = (IParameter) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator())
+ .getParameterDeclarations()[0]).getDeclarators()[0].getName().resolveBinding();
+ IParameter x2 = (IParameter) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterNames()[0]
+ .resolveBinding();
+
+ assertNotNull(x2);
+ assertNotNull(x3);
+ assertNotNull(x4);
+ assertEquals(x2, x3);
+ assertEquals(x3, x4);
+
// test tu.getDeclarationsInAST(IBinding)
- IASTName[] decls = tu.getDeclarationsInAST(x2);
+ IASTName[] decls = tu.getDeclarationsInAST(x2);
assertEquals(decls.length, 1);
- assertEquals(decls[0], ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName());
+ assertEquals(decls[0], ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator())
+ .getParameterDeclarations()[0]).getDeclarators()[0].getName());
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "f".toCharArray())); //$NON-NLS-1$
- assertNotNull(((CScope) ((IASTCompoundStatement) f2.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
- }
-
- public void testSimpleKRCTest3() throws Exception {
- StringBuilder buffer = new StringBuilder();
- 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);
-
- IASTSimpleDeclaration f1 = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTFunctionDefinition f2 = (IASTFunctionDefinition) tu.getDeclarations()[1];
-
- assertTrue(f1.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
-
- IParameter x4 = (IParameter) ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f2.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding();
- IParameter x3 = (IParameter) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName().resolveBinding();
- IParameter x2 = (IParameter) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterNames()[0].resolveBinding();
-
- assertNotNull(x2);
- assertNotNull(x3);
- assertNotNull(x4);
- assertEquals(x2, x3);
- assertEquals(x3, x4);
- }
-
- public void testKRC_1() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("int isroot (x, y) /* comment */ \n"); //$NON-NLS-1$
- 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);
-
- IASTFunctionDefinition isroot_def = (IASTFunctionDefinition) tu.getDeclarations()[0];
-
- IASTName ret_x = ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) isroot_def.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName();
- IASTDeclarator isroot_decltor = isroot_def.getDeclarator();
-
- assertTrue(isroot_decltor instanceof ICASTKnRFunctionDeclarator);
- IASTDeclarator x1 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor).getParameterDeclarations()[0]).getDeclarators()[0];
- IASTDeclarator y1 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor).getParameterDeclarations()[1]).getDeclarators()[0];
-
- IParameter x_parm = (IParameter) x1.getName().resolveBinding();
- IParameter y_parm = (IParameter) y1.getName().resolveBinding();
- assertNotNull(x_parm);
- assertNotNull(y_parm);
-
- IASTDeclarator x2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor).getParameterDeclarations()[0]).getDeclarators()[0];
- IASTDeclarator y2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor).getParameterDeclarations()[1]).getDeclarators()[0];
-
- IParameter x_parm2 = (IParameter) x2.getName().resolveBinding();
- IParameter y_parm2 = (IParameter) y2.getName().resolveBinding();
-
- assertNotNull(x_parm2);
- assertNotNull(y_parm2);
- assertNotNull(ret_x.resolveBinding());
-
- assertEquals(x_parm, x_parm2);
- assertEquals(y_parm, y_parm2);
- assertEquals(ret_x.resolveBinding(), x_parm);
+ assertNotNull(((CScope) ((IASTCompoundStatement) f2.getBody()).getScope())
+ .getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
+ }
+
+ public void testSimpleKRCTest3() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ 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);
+
+ IASTSimpleDeclaration f1 = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTFunctionDefinition f2 = (IASTFunctionDefinition) tu.getDeclarations()[1];
+
+ assertTrue(f1.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
+
+ IParameter x4 = (IParameter) ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f2
+ .getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding();
+ IParameter x3 = (IParameter) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator())
+ .getParameterDeclarations()[0]).getDeclarators()[0].getName().resolveBinding();
+ IParameter x2 = (IParameter) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterNames()[0]
+ .resolveBinding();
+
+ assertNotNull(x2);
+ assertNotNull(x3);
+ assertNotNull(x4);
+ assertEquals(x2, x3);
+ assertEquals(x3, x4);
+ }
+
+ public void testKRC_1() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int isroot (x, y) /* comment */ \n"); //$NON-NLS-1$
+ 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);
+
+ IASTFunctionDefinition isroot_def = (IASTFunctionDefinition) tu.getDeclarations()[0];
+
+ IASTName ret_x = ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) isroot_def
+ .getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName();
+ IASTDeclarator isroot_decltor = isroot_def.getDeclarator();
+
+ assertTrue(isroot_decltor instanceof ICASTKnRFunctionDeclarator);
+ IASTDeclarator x1 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor)
+ .getParameterDeclarations()[0]).getDeclarators()[0];
+ IASTDeclarator y1 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor)
+ .getParameterDeclarations()[1]).getDeclarators()[0];
+
+ IParameter x_parm = (IParameter) x1.getName().resolveBinding();
+ IParameter y_parm = (IParameter) y1.getName().resolveBinding();
+ assertNotNull(x_parm);
+ assertNotNull(y_parm);
+
+ IASTDeclarator x2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor)
+ .getParameterDeclarations()[0]).getDeclarators()[0];
+ IASTDeclarator y2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor)
+ .getParameterDeclarations()[1]).getDeclarators()[0];
+
+ IParameter x_parm2 = (IParameter) x2.getName().resolveBinding();
+ IParameter y_parm2 = (IParameter) y2.getName().resolveBinding();
+
+ assertNotNull(x_parm2);
+ assertNotNull(y_parm2);
+ assertNotNull(ret_x.resolveBinding());
+
+ assertEquals(x_parm, x_parm2);
+ assertEquals(y_parm, y_parm2);
+ assertEquals(ret_x.resolveBinding(), x_parm);
// test tu.getDeclarationsInAST(IBinding)
- IASTName[] decls = tu.getDeclarationsInAST(ret_x.resolveBinding());
+ IASTName[] decls = tu.getDeclarationsInAST(ret_x.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], x1.getName());
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "isroot".toCharArray())); //$NON-NLS-1$
- assertNotNull(((CScope) ((IASTCompoundStatement) isroot_def.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
- assertNotNull(((CScope) ((IASTCompoundStatement) isroot_def.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "y".toCharArray())); //$NON-NLS-1$
- }
-
- public void testKRCWithTypes() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("typedef char c;\n"); //$NON-NLS-1$
- buffer.append("int isroot (c);\n"); //$NON-NLS-1$
- 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);
-
- IASTSimpleDeclaration c_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTSimpleDeclaration isroot_decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
- IASTFunctionDefinition isroot_def = (IASTFunctionDefinition) tu.getDeclarations()[2];
-
- //IASTName x0 = ((IASTStandardFunctionDeclarator) isroot_decl.getDeclarators()[0]).getParameters()[0].getDeclarator().getName();
- IASTName x1 = ((ICASTKnRFunctionDeclarator) isroot_def.getDeclarator()).getParameterNames()[0];
- IASTName x2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_def.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName();
- IASTName x3 = ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) isroot_def.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName();
-
- IParameter x1_var = (IParameter) x1.resolveBinding();
- IParameter x2_var = (IParameter) x2.resolveBinding();
- IParameter x3_var = (IParameter) x3.resolveBinding();
-
- assertNotNull(x1_var);
- assertNotNull(x2_var);
- assertNotNull(x3_var);
- assertEquals(x1_var, x2_var);
- assertEquals(x2_var, x3_var);
-
- IASTName c1 = c_decl.getDeclarators()[0].getName();
- IASTName c2 = ((IASTNamedTypeSpecifier) ((IASTStandardFunctionDeclarator) isroot_decl.getDeclarators()[0]).getParameters()[0].getDeclSpecifier()).getName();
- IASTName c3 = ((IASTNamedTypeSpecifier) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_def.getDeclarator()).getParameterDeclarations()[0]).getDeclSpecifier()).getName();
-
- ITypedef c1_t = (ITypedef) c1.resolveBinding();
- ITypedef c2_t = (ITypedef) c2.resolveBinding();
- ITypedef c3_t = (ITypedef) c3.resolveBinding();
-
- assertNotNull(c1_t);
- assertNotNull(c2_t);
- assertNotNull(c3_t);
- assertEquals(c1_t, c2_t);
- assertEquals(c2_t, c3_t);
- assertTrue(c1_t.getType() instanceof IBasicType);
- assertEquals(((IBasicType) c1_t.getType()).getType(), IBasicType.t_char);
-
+ assertNotNull(((CScope) ((IASTCompoundStatement) isroot_def.getBody()).getScope())
+ .getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
+ assertNotNull(((CScope) ((IASTCompoundStatement) isroot_def.getBody()).getScope())
+ .getBinding(CScope.NAMESPACE_TYPE_OTHER, "y".toCharArray())); //$NON-NLS-1$
+ }
+
+ public void testKRCWithTypes() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("typedef char c;\n"); //$NON-NLS-1$
+ buffer.append("int isroot (c);\n"); //$NON-NLS-1$
+ 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);
+
+ IASTSimpleDeclaration c_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTSimpleDeclaration isroot_decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
+ IASTFunctionDefinition isroot_def = (IASTFunctionDefinition) tu.getDeclarations()[2];
+
+ //IASTName x0 = ((IASTStandardFunctionDeclarator) isroot_decl.getDeclarators()[0]).getParameters()[0].getDeclarator().getName();
+ IASTName x1 = ((ICASTKnRFunctionDeclarator) isroot_def.getDeclarator()).getParameterNames()[0];
+ IASTName x2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_def.getDeclarator())
+ .getParameterDeclarations()[0]).getDeclarators()[0].getName();
+ IASTName x3 = ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) isroot_def
+ .getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName();
+
+ IParameter x1_var = (IParameter) x1.resolveBinding();
+ IParameter x2_var = (IParameter) x2.resolveBinding();
+ IParameter x3_var = (IParameter) x3.resolveBinding();
+
+ assertNotNull(x1_var);
+ assertNotNull(x2_var);
+ assertNotNull(x3_var);
+ assertEquals(x1_var, x2_var);
+ assertEquals(x2_var, x3_var);
+
+ IASTName c1 = c_decl.getDeclarators()[0].getName();
+ IASTName c2 = ((IASTNamedTypeSpecifier) ((IASTStandardFunctionDeclarator) isroot_decl.getDeclarators()[0])
+ .getParameters()[0].getDeclSpecifier()).getName();
+ IASTName c3 = ((IASTNamedTypeSpecifier) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_def
+ .getDeclarator()).getParameterDeclarations()[0]).getDeclSpecifier()).getName();
+
+ ITypedef c1_t = (ITypedef) c1.resolveBinding();
+ ITypedef c2_t = (ITypedef) c2.resolveBinding();
+ ITypedef c3_t = (ITypedef) c3.resolveBinding();
+
+ assertNotNull(c1_t);
+ assertNotNull(c2_t);
+ assertNotNull(c3_t);
+ assertEquals(c1_t, c2_t);
+ assertEquals(c2_t, c3_t);
+ assertTrue(c1_t.getType() instanceof IBasicType);
+ assertEquals(((IBasicType) c1_t.getType()).getType(), IBasicType.t_char);
+
// test tu.getDeclarationsInAST(IBinding)
- IASTName[] decls = tu.getDeclarationsInAST(x3.resolveBinding());
+ IASTName[] decls = tu.getDeclarationsInAST(x3.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], x2);
-
+
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "c".toCharArray())); //$NON-NLS-1$
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "isroot".toCharArray())); //$NON-NLS-1$
- assertNotNull(((CScope) ((IASTCompoundStatement) isroot_def.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
- }
-
- 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);
- IASTDeclaration[] decls= tu.getDeclarations();
-
- assertTrue(CVisitor.getProblems(tu).length > 0);
- }
-
- public void testKRCProblem2() throws Exception {
- StringBuilder buffer = new StringBuilder();
- 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);
-
- IASTSimpleDeclaration sd= getDeclaration(tu, 0);
- assertTrue(CVisitor.getProblems(tu).length > 0);
+ assertNotNull(((CScope) ((IASTCompoundStatement) isroot_def.getBody()).getScope())
+ .getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
+ }
+
+ 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);
+ IASTDeclaration[] decls = tu.getDeclarations();
+
+ assertTrue(CVisitor.getProblems(tu).length > 0);
}
- 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);
-
- IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
- assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
- ICASTKnRFunctionDeclarator f_kr = (ICASTKnRFunctionDeclarator) f.getDeclarator();
- assertEquals(f_kr.getName().toString(), "f"); //$NON-NLS-1$
- assertEquals(f_kr.getParameterNames()[0].toString(), "x"); //$NON-NLS-1$
- assertTrue(f_kr.getParameterDeclarations()[0] instanceof IASTProblemDeclaration);
- assertTrue(f.getBody() instanceof IASTCompoundStatement);
- assertTrue(((IASTCompoundStatement) f.getBody()).getStatements()[0] instanceof IASTReturnStatement);
- assertTrue(((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue() instanceof IASTBinaryExpression);
- assertTrue(((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1() instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().toString(), "x"); //$NON-NLS-1$
- assertTrue(((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand2() instanceof IASTLiteralExpression);
- assertEquals(((IASTLiteralExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand2()).toString(), "0"); //$NON-NLS-1$
+ public void testKRCProblem2() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ 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);
+
+ IASTSimpleDeclaration sd = getDeclaration(tu, 0);
+ assertTrue(CVisitor.getProblems(tu).length > 0);
+ }
+
+ 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);
+
+ IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
+ ICASTKnRFunctionDeclarator f_kr = (ICASTKnRFunctionDeclarator) f.getDeclarator();
+ assertEquals(f_kr.getName().toString(), "f"); //$NON-NLS-1$
+ assertEquals(f_kr.getParameterNames()[0].toString(), "x"); //$NON-NLS-1$
+ assertTrue(f_kr.getParameterDeclarations()[0] instanceof IASTProblemDeclaration);
+ assertTrue(f.getBody() instanceof IASTCompoundStatement);
+ assertTrue(((IASTCompoundStatement) f.getBody()).getStatements()[0] instanceof IASTReturnStatement);
+ assertTrue(((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0])
+ .getReturnValue() instanceof IASTBinaryExpression);
+ assertTrue(
+ ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0])
+ .getReturnValue()).getOperand1() instanceof IASTIdExpression);
+ assertEquals(
+ ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody())
+ .getStatements()[0]).getReturnValue()).getOperand1()).getName().toString(),
+ "x"); //$NON-NLS-1$
+ assertTrue(
+ ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0])
+ .getReturnValue()).getOperand2() instanceof IASTLiteralExpression);
+ assertEquals(((IASTLiteralExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f
+ .getBody()).getStatements()[0]).getReturnValue()).getOperand2()).toString(), "0"); //$NON-NLS-1$
// test tu.getDeclarationsInAST(IBinding)
- IASTName[] decls = tu.getDeclarationsInAST(((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding());
+ IASTName[] decls = tu.getDeclarationsInAST(
+ ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody())
+ .getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding());
assertEquals(decls.length, 0);
- }
-
- 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);
-
- IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
- assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
- ICASTKnRFunctionDeclarator f_kr = (ICASTKnRFunctionDeclarator) f.getDeclarator();
- assertEquals(f_kr.getName().toString(), "f"); //$NON-NLS-1$
- assertEquals(f_kr.getParameterNames()[0].toString(), "x"); //$NON-NLS-1$
- assertTrue(f_kr.getParameterDeclarations()[0] instanceof IASTSimpleDeclaration);
- assertTrue(f_kr.getParameterDeclarations()[1] instanceof IASTProblemDeclaration);
- assertTrue(f.getBody() instanceof IASTCompoundStatement);
- assertTrue(((IASTCompoundStatement) f.getBody()).getStatements()[0] instanceof IASTReturnStatement);
- assertTrue(((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue() instanceof IASTBinaryExpression);
- assertTrue(((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1() instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().toString(), "x"); //$NON-NLS-1$
- assertTrue(((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand2() instanceof IASTLiteralExpression);
- assertEquals(((IASTLiteralExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand2()).toString(), "0"); //$NON-NLS-1$
-
- // bindings should still be ok
- IASTName x1 = f_kr.getParameterNames()[0];
- IASTName y1 = f_kr.getParameterNames()[1];
- IASTName z1 = f_kr.getParameterNames()[2];
- IASTName x2 = ((IASTSimpleDeclaration) f_kr.getParameterDeclarations()[0]).getDeclarators()[0].getName();
- IASTName y2 = ((IASTSimpleDeclaration) f_kr.getParameterDeclarations()[0]).getDeclarators()[1].getName();
- IASTName z2 = ((IASTSimpleDeclaration) f_kr.getParameterDeclarations()[0]).getDeclarators()[2].getName();
- IASTName x3 = ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName();
-
- IParameter x1_parm = (IParameter) x1.resolveBinding();
- IParameter x2_parm = (IParameter) x2.resolveBinding();
- IParameter x3_parm = (IParameter) x3.resolveBinding();
- IParameter y1_parm = (IParameter) y1.resolveBinding();
- IParameter y2_parm = (IParameter) y2.resolveBinding();
- IParameter z1_parm = (IParameter) z1.resolveBinding();
- IParameter z2_parm = (IParameter) z2.resolveBinding();
-
- assertEquals(x1_parm, x2_parm);
- assertEquals(x2_parm, x3_parm);
- assertEquals(y1_parm, y2_parm);
- assertEquals(z1_parm, z2_parm);
-
+ }
+
+ 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);
+
+ IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
+ ICASTKnRFunctionDeclarator f_kr = (ICASTKnRFunctionDeclarator) f.getDeclarator();
+ assertEquals(f_kr.getName().toString(), "f"); //$NON-NLS-1$
+ assertEquals(f_kr.getParameterNames()[0].toString(), "x"); //$NON-NLS-1$
+ assertTrue(f_kr.getParameterDeclarations()[0] instanceof IASTSimpleDeclaration);
+ assertTrue(f_kr.getParameterDeclarations()[1] instanceof IASTProblemDeclaration);
+ assertTrue(f.getBody() instanceof IASTCompoundStatement);
+ assertTrue(((IASTCompoundStatement) f.getBody()).getStatements()[0] instanceof IASTReturnStatement);
+ assertTrue(((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0])
+ .getReturnValue() instanceof IASTBinaryExpression);
+ assertTrue(
+ ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0])
+ .getReturnValue()).getOperand1() instanceof IASTIdExpression);
+ assertEquals(
+ ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody())
+ .getStatements()[0]).getReturnValue()).getOperand1()).getName().toString(),
+ "x"); //$NON-NLS-1$
+ assertTrue(
+ ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0])
+ .getReturnValue()).getOperand2() instanceof IASTLiteralExpression);
+ assertEquals(((IASTLiteralExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f
+ .getBody()).getStatements()[0]).getReturnValue()).getOperand2()).toString(), "0"); //$NON-NLS-1$
+
+ // bindings should still be ok
+ IASTName x1 = f_kr.getParameterNames()[0];
+ IASTName y1 = f_kr.getParameterNames()[1];
+ IASTName z1 = f_kr.getParameterNames()[2];
+ IASTName x2 = ((IASTSimpleDeclaration) f_kr.getParameterDeclarations()[0]).getDeclarators()[0].getName();
+ IASTName y2 = ((IASTSimpleDeclaration) f_kr.getParameterDeclarations()[0]).getDeclarators()[1].getName();
+ IASTName z2 = ((IASTSimpleDeclaration) f_kr.getParameterDeclarations()[0]).getDeclarators()[2].getName();
+ IASTName x3 = ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f
+ .getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName();
+
+ IParameter x1_parm = (IParameter) x1.resolveBinding();
+ IParameter x2_parm = (IParameter) x2.resolveBinding();
+ IParameter x3_parm = (IParameter) x3.resolveBinding();
+ IParameter y1_parm = (IParameter) y1.resolveBinding();
+ IParameter y2_parm = (IParameter) y2.resolveBinding();
+ IParameter z1_parm = (IParameter) z1.resolveBinding();
+ IParameter z2_parm = (IParameter) z2.resolveBinding();
+
+ assertEquals(x1_parm, x2_parm);
+ assertEquals(x2_parm, x3_parm);
+ assertEquals(y1_parm, y2_parm);
+ assertEquals(z1_parm, z2_parm);
+
// test tu.getDeclarationsInAST(IBinding)
- IASTName[] decls = tu.getDeclarationsInAST(((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding());
+ IASTName[] decls = tu.getDeclarationsInAST(
+ ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody())
+ .getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], x2);
- }
-
- 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);
-
- IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
- assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
- ICASTKnRFunctionDeclarator f_kr = (ICASTKnRFunctionDeclarator) f.getDeclarator();
- assertEquals(f_kr.getName().toString(), "f"); //$NON-NLS-1$
- assertEquals(f_kr.getParameterNames()[0].toString(), "x"); //$NON-NLS-1$
- assertTrue(f_kr.getParameterDeclarations()[0] instanceof IASTProblemDeclaration);
- assertTrue(f.getBody() instanceof IASTCompoundStatement);
- assertTrue(((IASTCompoundStatement) f.getBody()).getStatements()[0] instanceof IASTReturnStatement);
- assertTrue(((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue() instanceof IASTBinaryExpression);
- assertTrue(((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1() instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().toString(), "x"); //$NON-NLS-1$
- assertTrue(((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand2() instanceof IASTLiteralExpression);
- assertEquals(((IASTLiteralExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand2()).toString(), "0"); //$NON-NLS-1$
-
+ }
+
+ 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);
+
+ IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
+ ICASTKnRFunctionDeclarator f_kr = (ICASTKnRFunctionDeclarator) f.getDeclarator();
+ assertEquals(f_kr.getName().toString(), "f"); //$NON-NLS-1$
+ assertEquals(f_kr.getParameterNames()[0].toString(), "x"); //$NON-NLS-1$
+ assertTrue(f_kr.getParameterDeclarations()[0] instanceof IASTProblemDeclaration);
+ assertTrue(f.getBody() instanceof IASTCompoundStatement);
+ assertTrue(((IASTCompoundStatement) f.getBody()).getStatements()[0] instanceof IASTReturnStatement);
+ assertTrue(((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0])
+ .getReturnValue() instanceof IASTBinaryExpression);
+ assertTrue(
+ ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0])
+ .getReturnValue()).getOperand1() instanceof IASTIdExpression);
+ assertEquals(
+ ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody())
+ .getStatements()[0]).getReturnValue()).getOperand1()).getName().toString(),
+ "x"); //$NON-NLS-1$
+ assertTrue(
+ ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0])
+ .getReturnValue()).getOperand2() instanceof IASTLiteralExpression);
+ assertEquals(((IASTLiteralExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f
+ .getBody()).getStatements()[0]).getReturnValue()).getOperand2()).toString(), "0"); //$NON-NLS-1$
+
// test tu.getDeclarationsInAST(IBinding)
- IASTName[] decls = tu.getDeclarationsInAST(((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding());
- assertEquals(decls.length, 0);
- }
-
-
- public void testKRC_monop_cards1() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("#ifdef __STDC__\n"); //$NON-NLS-1$
- buffer.append("#define __P(x) x\n"); //$NON-NLS-1$
- buffer.append("#else\n"); //$NON-NLS-1$
- buffer.append("#define __P(x) ()\n"); //$NON-NLS-1$
- buffer.append("#endif\n"); //$NON-NLS-1$
- buffer.append("struct A_struct {\n"); //$NON-NLS-1$
- buffer.append("int a;\n"); //$NON-NLS-1$
- buffer.append("long *c;\n"); //$NON-NLS-1$
- buffer.append("};\n"); //$NON-NLS-1$
- buffer.append("typedef struct A_struct A;\n"); //$NON-NLS-1$
- buffer.append("static void f __P((A *));\n"); //$NON-NLS-1$
- buffer.append("static void\n"); //$NON-NLS-1$
- buffer.append("f(x)\n"); //$NON-NLS-1$
- buffer.append("A *x; {\n"); //$NON-NLS-1$
- 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);
-
- IASTSimpleDeclaration A_struct = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTSimpleDeclaration A = (IASTSimpleDeclaration) tu.getDeclarations()[1];
- IASTSimpleDeclaration f_decl = (IASTSimpleDeclaration) tu.getDeclarations()[2];
- IASTFunctionDefinition f_def = (IASTFunctionDefinition) tu.getDeclarations()[3];
-
- // check A_struct
- assertTrue(A_struct.getDeclSpecifier() instanceof IASTCompositeTypeSpecifier);
- assertEquals(A_struct.getDeclarators().length, 0);
- IASTName A_struct_name1 = ((IASTCompositeTypeSpecifier)A_struct.getDeclSpecifier()).getName();
- assertEquals(A_struct_name1.toString(), "A_struct"); //$NON-NLS-1$
- ICompositeType A_struct_type1 = (ICompositeType)A_struct_name1.resolveBinding();
- assertEquals(((ICInternalBinding)A_struct_type1).getPhysicalNode(), ((IASTCompositeTypeSpecifier)A_struct.getDeclSpecifier()).getName());
- IField[] fields = A_struct_type1.getFields();
- IField a1 = fields[0];
- IField c1 = fields[1];
- assertEquals(a1.getName().toString(), "a"); //$NON-NLS-1$
- assertEquals(c1.getName().toString(), "c"); //$NON-NLS-1$
- IBasicType a1_t = (IBasicType) a1.getType();
- IPointerType c1_t = (IPointerType) c1.getType();
- assertEquals(a1_t.getType(), IBasicType.t_int);
- assertTrue(c1_t.getType() instanceof IBasicType);
- assertTrue(((IBasicType) c1_t.getType()).isLong());
-
- // check A
- IASTName A_name1 = A.getDeclarators()[0].getName();
- assertEquals(A_name1.toString(), "A"); //$NON-NLS-1$
- ITypedef A_var1 = (ITypedef)A_name1.resolveBinding();
- assertTrue(A.getDeclSpecifier() instanceof IASTElaboratedTypeSpecifier);
- IASTName A_struct_name_2 = ((IASTElaboratedTypeSpecifier)A.getDeclSpecifier()).getName();
- assertEquals(A_struct_name_2.toString(), "A_struct"); //$NON-NLS-1$
- assertEquals(((IASTElaboratedTypeSpecifier)A.getDeclSpecifier()).getStorageClass(), IASTDeclSpecifier.sc_typedef);
- ICompositeType A_struct_type2 = (ICompositeType)A_struct_name_2.resolveBinding();
- assertEquals(A_struct_type2, A_struct_type1);
-
- // check f_decl
- assertTrue(f_decl.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
- IASTStandardFunctionDeclarator f_decltor1 = ((IASTStandardFunctionDeclarator) f_decl.getDeclarators()[0]);
- IASTName f_name1 = f_decltor1.getName();
- IFunction f_fun1 = (IFunction) f_name1.resolveBinding();
- assertEquals(f_name1.toString(), "f"); //$NON-NLS-1$
- assertEquals(f_decltor1.getParameters().length, 1);
- //IASTName x0 = f_decltor1.getParameters()[0].getDeclarator().getName();
- IASTName A_name2 = ((ICASTTypedefNameSpecifier) f_decltor1.getParameters()[0].getDeclSpecifier()).getName();
- assertEquals(A_name2.toString(), "A"); //$NON-NLS-1$
- ITypedef A_var2 = (ITypedef)A_name2.resolveBinding();
- assertEquals(A_var1, A_var2);
-
- // check f_def
- assertTrue(f_def.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
-
- ICASTKnRFunctionDeclarator f_decltor2 = (ICASTKnRFunctionDeclarator) f_def.getDeclarator();
- assertEquals(f_decltor2.getName().toString(), "f"); //$NON-NLS-1$
- IFunction f_fun2 = (IFunction) f_decltor2.getName().resolveBinding();
- assertEquals(f_fun1, f_fun2);
- ICBasicType f_ret_t = (ICBasicType) f_fun2.getType().getReturnType();
- assertEquals(f_ret_t.getType(), IBasicType.t_void);
- IASTName x1 = f_decltor2.getParameterNames()[0];
- assertEquals(x1.toString(), "x"); //$NON-NLS-1$
- IASTSimpleDeclaration x_parm = (IASTSimpleDeclaration) f_decltor2.getParameterDeclarations()[0];
- IASTName x2 = x_parm.getDeclarators()[0].getName();
- assertEquals(x2.toString(), "x"); //$NON-NLS-1$
- assertEquals(x_parm.getDeclarators()[0].getPointerOperators().length, 1);
- IASTName A3 = ((IASTNamedTypeSpecifier) x_parm.getDeclSpecifier()).getName();
- ITypedef A_var3 = (ITypedef)A3.resolveBinding();
- assertEquals(A_var2, A_var3);
- assertEquals(A3.toString(), "A"); //$NON-NLS-1$;
- assertEquals(x1.resolveBinding(), x2.resolveBinding());
-
- // check f_def body
- assertTrue(f_def.getBody() instanceof IASTCompoundStatement);
- IASTCompoundStatement f_def_body = (IASTCompoundStatement) f_def.getBody();
- IASTExpressionStatement stmt1 = (IASTExpressionStatement) f_def_body.getStatements()[0];
- IASTExpressionStatement stmt2 = (IASTExpressionStatement) f_def_body.getStatements()[1];
- IASTName a2 = ((IASTFieldReference) ((IASTBinaryExpression) stmt1.getExpression()).getOperand1()).getFieldName();
- assertEquals(((IASTName) ((ICInternalBinding) a1).getPhysicalNode()).resolveBinding(), a2.resolveBinding());
- IASTName x3 = ((IASTIdExpression) ((IASTFieldReference) ((IASTBinaryExpression) stmt1.getExpression()).getOperand1()).getFieldOwner()).getName();
- assertEquals(x2.resolveBinding(), x3.resolveBinding());
- assertEquals(((IASTBinaryExpression) stmt1.getExpression()).getOperand2().toString(), "0"); //$NON-NLS-1$
- assertTrue(((IASTBinaryExpression) stmt2.getExpression()).getOperand1() instanceof IASTArraySubscriptExpression);
- assertTrue(((IASTBinaryExpression) stmt2.getExpression()).getOperand2() instanceof IASTArraySubscriptExpression);
- IASTName c2 = ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2.getExpression()).getOperand1()).getArrayExpression()).getFieldName();
- IASTName x4 = ((IASTIdExpression) ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2.getExpression()).getOperand1()).getArrayExpression()).getFieldOwner()).getName();
- IASTName c3 = ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2.getExpression()).getOperand2()).getArrayExpression()).getFieldName();
- IASTName x5 = ((IASTIdExpression) ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2.getExpression()).getOperand1()).getArrayExpression()).getFieldOwner()).getName();
- assertEquals(((IASTName) ((ICInternalBinding) c1).getPhysicalNode()).resolveBinding(), c2.resolveBinding());
- assertEquals(((IASTName) ((ICInternalBinding) c1).getPhysicalNode()).resolveBinding(), c3.resolveBinding());
- assertEquals(x3.resolveBinding(), x4.resolveBinding());
- assertEquals(x4.resolveBinding(), x5.resolveBinding());
-
- // test CFunction.getParameters size
- IParameter[] f1_parms = f_fun1.getParameters();
- assertEquals(f1_parms.length, 1);
+ IASTName[] decls = tu.getDeclarationsInAST(
+ ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody())
+ .getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding());
+ assertEquals(decls.length, 0);
+ }
+
+ public void testKRC_monop_cards1() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#ifdef __STDC__\n"); //$NON-NLS-1$
+ buffer.append("#define __P(x) x\n"); //$NON-NLS-1$
+ buffer.append("#else\n"); //$NON-NLS-1$
+ buffer.append("#define __P(x) ()\n"); //$NON-NLS-1$
+ buffer.append("#endif\n"); //$NON-NLS-1$
+ buffer.append("struct A_struct {\n"); //$NON-NLS-1$
+ buffer.append("int a;\n"); //$NON-NLS-1$
+ buffer.append("long *c;\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+ buffer.append("typedef struct A_struct A;\n"); //$NON-NLS-1$
+ buffer.append("static void f __P((A *));\n"); //$NON-NLS-1$
+ buffer.append("static void\n"); //$NON-NLS-1$
+ buffer.append("f(x)\n"); //$NON-NLS-1$
+ buffer.append("A *x; {\n"); //$NON-NLS-1$
+ 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);
+
+ IASTSimpleDeclaration A_struct = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTSimpleDeclaration A = (IASTSimpleDeclaration) tu.getDeclarations()[1];
+ IASTSimpleDeclaration f_decl = (IASTSimpleDeclaration) tu.getDeclarations()[2];
+ IASTFunctionDefinition f_def = (IASTFunctionDefinition) tu.getDeclarations()[3];
+
+ // check A_struct
+ assertTrue(A_struct.getDeclSpecifier() instanceof IASTCompositeTypeSpecifier);
+ assertEquals(A_struct.getDeclarators().length, 0);
+ IASTName A_struct_name1 = ((IASTCompositeTypeSpecifier) A_struct.getDeclSpecifier()).getName();
+ assertEquals(A_struct_name1.toString(), "A_struct"); //$NON-NLS-1$
+ ICompositeType A_struct_type1 = (ICompositeType) A_struct_name1.resolveBinding();
+ assertEquals(((ICInternalBinding) A_struct_type1).getPhysicalNode(),
+ ((IASTCompositeTypeSpecifier) A_struct.getDeclSpecifier()).getName());
+ IField[] fields = A_struct_type1.getFields();
+ IField a1 = fields[0];
+ IField c1 = fields[1];
+ assertEquals(a1.getName().toString(), "a"); //$NON-NLS-1$
+ assertEquals(c1.getName().toString(), "c"); //$NON-NLS-1$
+ IBasicType a1_t = (IBasicType) a1.getType();
+ IPointerType c1_t = (IPointerType) c1.getType();
+ assertEquals(a1_t.getType(), IBasicType.t_int);
+ assertTrue(c1_t.getType() instanceof IBasicType);
+ assertTrue(((IBasicType) c1_t.getType()).isLong());
+
+ // check A
+ IASTName A_name1 = A.getDeclarators()[0].getName();
+ assertEquals(A_name1.toString(), "A"); //$NON-NLS-1$
+ ITypedef A_var1 = (ITypedef) A_name1.resolveBinding();
+ assertTrue(A.getDeclSpecifier() instanceof IASTElaboratedTypeSpecifier);
+ IASTName A_struct_name_2 = ((IASTElaboratedTypeSpecifier) A.getDeclSpecifier()).getName();
+ assertEquals(A_struct_name_2.toString(), "A_struct"); //$NON-NLS-1$
+ assertEquals(((IASTElaboratedTypeSpecifier) A.getDeclSpecifier()).getStorageClass(),
+ IASTDeclSpecifier.sc_typedef);
+ ICompositeType A_struct_type2 = (ICompositeType) A_struct_name_2.resolveBinding();
+ assertEquals(A_struct_type2, A_struct_type1);
+
+ // check f_decl
+ assertTrue(f_decl.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
+ IASTStandardFunctionDeclarator f_decltor1 = ((IASTStandardFunctionDeclarator) f_decl.getDeclarators()[0]);
+ IASTName f_name1 = f_decltor1.getName();
+ IFunction f_fun1 = (IFunction) f_name1.resolveBinding();
+ assertEquals(f_name1.toString(), "f"); //$NON-NLS-1$
+ assertEquals(f_decltor1.getParameters().length, 1);
+ //IASTName x0 = f_decltor1.getParameters()[0].getDeclarator().getName();
+ IASTName A_name2 = ((ICASTTypedefNameSpecifier) f_decltor1.getParameters()[0].getDeclSpecifier()).getName();
+ assertEquals(A_name2.toString(), "A"); //$NON-NLS-1$
+ ITypedef A_var2 = (ITypedef) A_name2.resolveBinding();
+ assertEquals(A_var1, A_var2);
+
+ // check f_def
+ assertTrue(f_def.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
+
+ ICASTKnRFunctionDeclarator f_decltor2 = (ICASTKnRFunctionDeclarator) f_def.getDeclarator();
+ assertEquals(f_decltor2.getName().toString(), "f"); //$NON-NLS-1$
+ IFunction f_fun2 = (IFunction) f_decltor2.getName().resolveBinding();
+ assertEquals(f_fun1, f_fun2);
+ ICBasicType f_ret_t = (ICBasicType) f_fun2.getType().getReturnType();
+ assertEquals(f_ret_t.getType(), IBasicType.t_void);
+ IASTName x1 = f_decltor2.getParameterNames()[0];
+ assertEquals(x1.toString(), "x"); //$NON-NLS-1$
+ IASTSimpleDeclaration x_parm = (IASTSimpleDeclaration) f_decltor2.getParameterDeclarations()[0];
+ IASTName x2 = x_parm.getDeclarators()[0].getName();
+ assertEquals(x2.toString(), "x"); //$NON-NLS-1$
+ assertEquals(x_parm.getDeclarators()[0].getPointerOperators().length, 1);
+ IASTName A3 = ((IASTNamedTypeSpecifier) x_parm.getDeclSpecifier()).getName();
+ ITypedef A_var3 = (ITypedef) A3.resolveBinding();
+ assertEquals(A_var2, A_var3);
+ assertEquals(A3.toString(), "A"); //$NON-NLS-1$;
+ assertEquals(x1.resolveBinding(), x2.resolveBinding());
+
+ // check f_def body
+ assertTrue(f_def.getBody() instanceof IASTCompoundStatement);
+ IASTCompoundStatement f_def_body = (IASTCompoundStatement) f_def.getBody();
+ IASTExpressionStatement stmt1 = (IASTExpressionStatement) f_def_body.getStatements()[0];
+ IASTExpressionStatement stmt2 = (IASTExpressionStatement) f_def_body.getStatements()[1];
+ IASTName a2 = ((IASTFieldReference) ((IASTBinaryExpression) stmt1.getExpression()).getOperand1())
+ .getFieldName();
+ assertEquals(((IASTName) ((ICInternalBinding) a1).getPhysicalNode()).resolveBinding(), a2.resolveBinding());
+ IASTName x3 = ((IASTIdExpression) ((IASTFieldReference) ((IASTBinaryExpression) stmt1.getExpression())
+ .getOperand1()).getFieldOwner()).getName();
+ assertEquals(x2.resolveBinding(), x3.resolveBinding());
+ assertEquals(((IASTBinaryExpression) stmt1.getExpression()).getOperand2().toString(), "0"); //$NON-NLS-1$
+ assertTrue(
+ ((IASTBinaryExpression) stmt2.getExpression()).getOperand1() instanceof IASTArraySubscriptExpression);
+ assertTrue(
+ ((IASTBinaryExpression) stmt2.getExpression()).getOperand2() instanceof IASTArraySubscriptExpression);
+ IASTName c2 = ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2
+ .getExpression()).getOperand1()).getArrayExpression()).getFieldName();
+ IASTName x4 = ((IASTIdExpression) ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2
+ .getExpression()).getOperand1()).getArrayExpression()).getFieldOwner()).getName();
+ IASTName c3 = ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2
+ .getExpression()).getOperand2()).getArrayExpression()).getFieldName();
+ IASTName x5 = ((IASTIdExpression) ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2
+ .getExpression()).getOperand1()).getArrayExpression()).getFieldOwner()).getName();
+ assertEquals(((IASTName) ((ICInternalBinding) c1).getPhysicalNode()).resolveBinding(), c2.resolveBinding());
+ assertEquals(((IASTName) ((ICInternalBinding) c1).getPhysicalNode()).resolveBinding(), c3.resolveBinding());
+ assertEquals(x3.resolveBinding(), x4.resolveBinding());
+ assertEquals(x4.resolveBinding(), x5.resolveBinding());
+
+ // test CFunction.getParameters size
+ IParameter[] f1_parms = f_fun1.getParameters();
+ assertEquals(f1_parms.length, 1);
// test tu.getDeclarationsInAST(IBinding)
- IASTName[] decls = tu.getDeclarationsInAST(x2.resolveBinding());
+ IASTName[] decls = tu.getDeclarationsInAST(x2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], x2);
-
+
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_TAG, "A_struct".toCharArray())); //$NON-NLS-1$
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "A".toCharArray())); //$NON-NLS-1$
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "f".toCharArray())); //$NON-NLS-1$
- assertNotNull(((CScope) ((IASTCompoundStatement) f_def.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
- }
-
- public void testKRC_monop_cards2() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("int\n"); //$NON-NLS-1$
- 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);
-
- IASTFunctionDefinition getinp = (IASTFunctionDefinition) tu.getDeclarations()[0];
-
- IASTName prompt1 = ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()).getParameterNames()[0];
- IASTName list1 = ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()).getParameterNames()[1];
- IASTName prompt2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName();
- IASTName list2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[1].getName();
- IASTName list3 = ((IASTIdExpression) ((IASTArraySubscriptExpression) ((IASTUnaryExpression) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) getinp.getBody()).getStatements()[0]).getExpression()).getOperand1()).getOperand()).getArrayExpression()).getName();
-
- assertEquals(prompt1.resolveBinding(), prompt2.resolveBinding());
- assertEquals(list1.resolveBinding(), list2.resolveBinding());
- assertEquals(list2.resolveBinding(), list3.resolveBinding());
-
- IASTSimpleDeclaration parm_decl = (IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()).getParameterDeclarations()[0];
- assertTrue(((IASTSimpleDeclSpecifier) parm_decl.getDeclSpecifier()).isConst());
- assertEquals(((IASTSimpleDeclSpecifier) parm_decl.getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_char);
- IASTDeclarator prompt = parm_decl.getDeclarators()[0];
- IASTArrayDeclarator list = (IASTArrayDeclarator) parm_decl.getDeclarators()[1];
- assertEquals(prompt.getName().toString(), "prompt"); //$NON-NLS-1$
- assertEquals(prompt.getPointerOperators().length, 1);
- assertEquals(list.getName().toString(), "list"); //$NON-NLS-1$
- assertEquals(list.getArrayModifiers().length, 1);
- assertNull(list.getArrayModifiers()[0].getConstantExpression());
- assertEquals(list.getPointerOperators().length, 1);
-
+ assertNotNull(((CScope) ((IASTCompoundStatement) f_def.getBody()).getScope())
+ .getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
+ }
+
+ public void testKRC_monop_cards2() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int\n"); //$NON-NLS-1$
+ 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);
+
+ IASTFunctionDefinition getinp = (IASTFunctionDefinition) tu.getDeclarations()[0];
+
+ IASTName prompt1 = ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()).getParameterNames()[0];
+ IASTName list1 = ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()).getParameterNames()[1];
+ IASTName prompt2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) getinp.getDeclarator())
+ .getParameterDeclarations()[0]).getDeclarators()[0].getName();
+ IASTName list2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) getinp.getDeclarator())
+ .getParameterDeclarations()[0]).getDeclarators()[1].getName();
+ IASTName list3 = ((IASTIdExpression) ((IASTArraySubscriptExpression) ((IASTUnaryExpression) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) getinp
+ .getBody()).getStatements()[0]).getExpression()).getOperand1()).getOperand()).getArrayExpression())
+ .getName();
+
+ assertEquals(prompt1.resolveBinding(), prompt2.resolveBinding());
+ assertEquals(list1.resolveBinding(), list2.resolveBinding());
+ assertEquals(list2.resolveBinding(), list3.resolveBinding());
+
+ IASTSimpleDeclaration parm_decl = (IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) getinp.getDeclarator())
+ .getParameterDeclarations()[0];
+ assertTrue(((IASTSimpleDeclSpecifier) parm_decl.getDeclSpecifier()).isConst());
+ assertEquals(((IASTSimpleDeclSpecifier) parm_decl.getDeclSpecifier()).getType(),
+ IASTSimpleDeclSpecifier.t_char);
+ IASTDeclarator prompt = parm_decl.getDeclarators()[0];
+ IASTArrayDeclarator list = (IASTArrayDeclarator) parm_decl.getDeclarators()[1];
+ assertEquals(prompt.getName().toString(), "prompt"); //$NON-NLS-1$
+ assertEquals(prompt.getPointerOperators().length, 1);
+ assertEquals(list.getName().toString(), "list"); //$NON-NLS-1$
+ assertEquals(list.getArrayModifiers().length, 1);
+ assertNull(list.getArrayModifiers()[0].getConstantExpression());
+ assertEquals(list.getPointerOperators().length, 1);
+
// test tu.getDeclarationsInAST(IBinding)
- IASTName[] decls = tu.getDeclarationsInAST(list3.resolveBinding());
+ IASTName[] decls = tu.getDeclarationsInAST(list3.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], list2);
-
- decls = tu.getDeclarationsInAST(prompt1.resolveBinding());
+
+ decls = tu.getDeclarationsInAST(prompt1.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], prompt2);
- }
-
- 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);
-
- IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
- ICASTKnRFunctionDeclarator f_decltor = (ICASTKnRFunctionDeclarator) f.getDeclarator();
- IFunction f_fun = (IFunction) f_decltor.getName().resolveBinding();
- IParameter[] f_parms = f_fun.getParameters();
- assertEquals(f_parms.length, 2);
- assertEquals(((CParameter) f_parms[0]).getName(), "a"); //$NON-NLS-1$
- assertEquals(((CParameter) f_parms[1]).getName(), "b"); //$NON-NLS-1$
- }
-
- public void testKRC_Ethereal_1() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("struct symbol {\n"); //$NON-NLS-1$
- buffer.append("int lambda;\n};\n"); //$NON-NLS-1$
- buffer.append("struct lemon {\n"); //$NON-NLS-1$
- buffer.append("struct symbol **symbols;\n"); //$NON-NLS-1$
- buffer.append("int errorcnt;\n};\n"); //$NON-NLS-1$
- buffer.append("void f(lemp)\n"); //$NON-NLS-1$
- 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);
-
- IASTSimpleDeclaration symbol_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTSimpleDeclaration lemon_decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
- IASTFunctionDefinition f_def = (IASTFunctionDefinition) tu.getDeclarations()[2];
-
- IASTName symbol_name1 = ((IASTCompositeTypeSpecifier) symbol_decl.getDeclSpecifier()).getName();
- IASTName lambda_name1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) symbol_decl.getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
- IASTName lemon_name1 = ((IASTCompositeTypeSpecifier) lemon_decl.getDeclSpecifier()).getName();
- IASTName symbol_name2 = ((IASTElaboratedTypeSpecifier) ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) lemon_decl.getDeclSpecifier()).getMembers()[0]).getDeclSpecifier()).getName();
- IASTName symbols_name1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) lemon_decl.getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
- IASTName errorcnt_name1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) lemon_decl.getDeclSpecifier()).getMembers()[1]).getDeclarators()[0].getName();
- IASTName lemp_name1 = ((ICASTKnRFunctionDeclarator) f_def.getDeclarator()).getParameterNames()[0];
- IASTName lemon_name2 = ((IASTElaboratedTypeSpecifier) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f_def.getDeclarator()).getParameterDeclarations()[0]).getDeclSpecifier()).getName();
- IASTName lemp_name2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f_def.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName();
- IASTName lemp_name3 = ((IASTIdExpression) ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def.getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldOwner()).getArrayExpression()).getFieldOwner()).getName();
- IASTName symbols_name2 = ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def.getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldOwner()).getArrayExpression()).getFieldName();
- IASTName lambda_name2 = ((IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def.getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldName();
-
- IASTName lemp_name4 = ((IASTIdExpression) ((IASTFieldReference) ((IASTUnaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def.getBody()).getStatements()[1]).getExpression()).getOperand()).getFieldOwner()).getName();
- IASTName errorcnt_name2 = ((IASTFieldReference) ((IASTUnaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def.getBody()).getStatements()[1]).getExpression()).getOperand()).getFieldName();
-
- assertEquals(symbol_name1.resolveBinding(), symbol_name2.resolveBinding());
- assertEquals(lambda_name1.resolveBinding(), lambda_name2.resolveBinding());
- assertEquals(lemon_name1.resolveBinding(), lemon_name2.resolveBinding());
- assertEquals(symbols_name1.resolveBinding(), symbols_name2.resolveBinding());
- assertEquals(errorcnt_name1.resolveBinding(), errorcnt_name2.resolveBinding());
- assertEquals(lemp_name1.resolveBinding(), lemp_name2.resolveBinding());
- assertEquals(lemp_name2.resolveBinding(), lemp_name3.resolveBinding());
- assertEquals(lemp_name3.resolveBinding(), lemp_name4.resolveBinding());
- }
-
- public void testBug97447() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("void f(a) int a; {} \n"); //$NON-NLS-1$
- buffer.append("void f(int); \n"); //$NON-NLS-1$
-
+ }
+
+ 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);
+
+ IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ ICASTKnRFunctionDeclarator f_decltor = (ICASTKnRFunctionDeclarator) f.getDeclarator();
+ IFunction f_fun = (IFunction) f_decltor.getName().resolveBinding();
+ IParameter[] f_parms = f_fun.getParameters();
+ assertEquals(f_parms.length, 2);
+ assertEquals(((CParameter) f_parms[0]).getName(), "a"); //$NON-NLS-1$
+ assertEquals(((CParameter) f_parms[1]).getName(), "b"); //$NON-NLS-1$
+ }
+
+ public void testKRC_Ethereal_1() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("struct symbol {\n"); //$NON-NLS-1$
+ buffer.append("int lambda;\n};\n"); //$NON-NLS-1$
+ buffer.append("struct lemon {\n"); //$NON-NLS-1$
+ buffer.append("struct symbol **symbols;\n"); //$NON-NLS-1$
+ buffer.append("int errorcnt;\n};\n"); //$NON-NLS-1$
+ buffer.append("void f(lemp)\n"); //$NON-NLS-1$
+ 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);
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- IFunction def = (IFunction) col.getName(0).resolveBinding();
- IFunction f1 = (IFunction) col.getName(3).resolveBinding();
- IParameter a = (IParameter) col.getName(4).resolveBinding();
- }
-
- public void testBug100104() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("typedef int ush;\n"); //$NON-NLS-1$
- buffer.append("int f()\n"); //$NON-NLS-1$
- buffer.append("{\n"); //$NON-NLS-1$
- buffer.append("int a=1;\n"); //$NON-NLS-1$
- buffer.append("((ush) (a)*(ush) (a) * a);\n"); //$NON-NLS-1$
- buffer.append("{\n"); //$NON-NLS-1$
- buffer.append("};\n"); //$NON-NLS-1$
- buffer.append("}\n"); //$NON-NLS-1$
-
+
+ IASTSimpleDeclaration symbol_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTSimpleDeclaration lemon_decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
+ IASTFunctionDefinition f_def = (IASTFunctionDefinition) tu.getDeclarations()[2];
+
+ IASTName symbol_name1 = ((IASTCompositeTypeSpecifier) symbol_decl.getDeclSpecifier()).getName();
+ IASTName lambda_name1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) symbol_decl.getDeclSpecifier())
+ .getMembers()[0]).getDeclarators()[0].getName();
+ IASTName lemon_name1 = ((IASTCompositeTypeSpecifier) lemon_decl.getDeclSpecifier()).getName();
+ IASTName symbol_name2 = ((IASTElaboratedTypeSpecifier) ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) lemon_decl
+ .getDeclSpecifier()).getMembers()[0]).getDeclSpecifier()).getName();
+ IASTName symbols_name1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) lemon_decl.getDeclSpecifier())
+ .getMembers()[0]).getDeclarators()[0].getName();
+ IASTName errorcnt_name1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) lemon_decl.getDeclSpecifier())
+ .getMembers()[1]).getDeclarators()[0].getName();
+ IASTName lemp_name1 = ((ICASTKnRFunctionDeclarator) f_def.getDeclarator()).getParameterNames()[0];
+ IASTName lemon_name2 = ((IASTElaboratedTypeSpecifier) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f_def
+ .getDeclarator()).getParameterDeclarations()[0]).getDeclSpecifier()).getName();
+ IASTName lemp_name2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f_def.getDeclarator())
+ .getParameterDeclarations()[0]).getDeclarators()[0].getName();
+ IASTName lemp_name3 = ((IASTIdExpression) ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def
+ .getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldOwner()).getArrayExpression())
+ .getFieldOwner()).getName();
+ IASTName symbols_name2 = ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def
+ .getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldOwner()).getArrayExpression())
+ .getFieldName();
+ IASTName lambda_name2 = ((IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def
+ .getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldName();
+
+ IASTName lemp_name4 = ((IASTIdExpression) ((IASTFieldReference) ((IASTUnaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def
+ .getBody()).getStatements()[1]).getExpression()).getOperand()).getFieldOwner()).getName();
+ IASTName errorcnt_name2 = ((IASTFieldReference) ((IASTUnaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def
+ .getBody()).getStatements()[1]).getExpression()).getOperand()).getFieldName();
+
+ assertEquals(symbol_name1.resolveBinding(), symbol_name2.resolveBinding());
+ assertEquals(lambda_name1.resolveBinding(), lambda_name2.resolveBinding());
+ assertEquals(lemon_name1.resolveBinding(), lemon_name2.resolveBinding());
+ assertEquals(symbols_name1.resolveBinding(), symbols_name2.resolveBinding());
+ assertEquals(errorcnt_name1.resolveBinding(), errorcnt_name2.resolveBinding());
+ assertEquals(lemp_name1.resolveBinding(), lemp_name2.resolveBinding());
+ assertEquals(lemp_name2.resolveBinding(), lemp_name3.resolveBinding());
+ assertEquals(lemp_name3.resolveBinding(), lemp_name4.resolveBinding());
+ }
+
+ public void testBug97447() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ 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);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ IFunction def = (IFunction) col.getName(0).resolveBinding();
+ IFunction f1 = (IFunction) col.getName(3).resolveBinding();
+ IParameter a = (IParameter) col.getName(4).resolveBinding();
+ }
+
+ public void testBug100104() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("typedef int ush;\n"); //$NON-NLS-1$
+ buffer.append("int f()\n"); //$NON-NLS-1$
+ buffer.append("{\n"); //$NON-NLS-1$
+ buffer.append("int a=1;\n"); //$NON-NLS-1$
+ buffer.append("((ush) (a)*(ush) (a) * a);\n"); //$NON-NLS-1$
+ buffer.append("{\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, true);
- assertTrue(tu.getDeclarations()[0] instanceof IASTSimpleDeclaration);
- assertTrue(tu.getDeclarations()[1] instanceof IASTFunctionDefinition);
- IASTStatement[] stmts = ((IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[1]).getBody()).getStatements();
- assertTrue(stmts[0] instanceof IASTDeclarationStatement);
- assertTrue(stmts[1] instanceof IASTExpressionStatement);
- assertTrue(stmts[2] instanceof IASTCompoundStatement);
- assertTrue(stmts[3] instanceof IASTNullStatement);
- }
-
+ assertTrue(tu.getDeclarations()[0] instanceof IASTSimpleDeclaration);
+ assertTrue(tu.getDeclarations()[1] instanceof IASTFunctionDefinition);
+ IASTStatement[] stmts = ((IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[1]).getBody())
+ .getStatements();
+ assertTrue(stmts[0] instanceof IASTDeclarationStatement);
+ assertTrue(stmts[1] instanceof IASTExpressionStatement);
+ assertTrue(stmts[2] instanceof IASTCompoundStatement);
+ assertTrue(stmts[3] instanceof IASTNullStatement);
+ }
+
// typedef long time_t;
//
// void (foo)(timep)
@@ -656,33 +747,34 @@ public class AST2KnRTests extends AST2TestBase {
// {
// return 0;
// }
- public void testBug203050() throws Exception {
+ public void testBug203050() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true, true);
- assertTrue(tu.getDeclarations()[0] instanceof IASTSimpleDeclaration);
- assertTrue(tu.getDeclarations()[1] instanceof IASTFunctionDefinition);
- assertTrue(tu.getDeclarations()[2] instanceof IASTFunctionDefinition);
- IASTStatement[] stmts = ((IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[1]).getBody()).getStatements();
- assertTrue(stmts[0] instanceof IASTDeclarationStatement);
- assertTrue(stmts[1] instanceof IASTExpressionStatement);
- IASTExpression expr= ((IASTExpressionStatement) stmts[1]).getExpression();
- assertTrue(expr instanceof IASTFunctionCallExpression);
- IASTIdExpression fnameExpr= (IASTIdExpression) ((IASTFunctionCallExpression) expr).getFunctionNameExpression();
- fnameExpr.getName().resolveBinding();
-
- IASTName fname= ((IASTFunctionDefinition) tu.getDeclarations()[2]).getDeclarator().getName();
- try {
- fname.resolveBinding();
- } catch (StackOverflowError e) {
- fail(e.getMessage());
- }
- }
-
- // void push_constant (in_char, conv_base)
- // char (*in_char)(void);
- // int conv_base;
- // {}
- public void testFunctionPtrParameter_378614() throws Exception {
- String code= getAboveComment();
- parseAndCheckBindings(code, ParserLanguage.C, true);
- }
+ assertTrue(tu.getDeclarations()[0] instanceof IASTSimpleDeclaration);
+ assertTrue(tu.getDeclarations()[1] instanceof IASTFunctionDefinition);
+ assertTrue(tu.getDeclarations()[2] instanceof IASTFunctionDefinition);
+ IASTStatement[] stmts = ((IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[1]).getBody())
+ .getStatements();
+ assertTrue(stmts[0] instanceof IASTDeclarationStatement);
+ assertTrue(stmts[1] instanceof IASTExpressionStatement);
+ IASTExpression expr = ((IASTExpressionStatement) stmts[1]).getExpression();
+ assertTrue(expr instanceof IASTFunctionCallExpression);
+ IASTIdExpression fnameExpr = (IASTIdExpression) ((IASTFunctionCallExpression) expr).getFunctionNameExpression();
+ fnameExpr.getName().resolveBinding();
+
+ IASTName fname = ((IASTFunctionDefinition) tu.getDeclarations()[2]).getDeclarator().getName();
+ try {
+ fname.resolveBinding();
+ } catch (StackOverflowError e) {
+ fail(e.getMessage());
+ }
+ }
+
+ // void push_constant (in_char, conv_base)
+ // char (*in_char)(void);
+ // int conv_base;
+ // {}
+ public void testFunctionPtrParameter_378614() throws Exception {
+ String code = getAboveComment();
+ parseAndCheckBindings(code, ParserLanguage.C, true);
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java
index 9250a36af40..87234755799 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java
@@ -64,735 +64,708 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
super(name, AST2SelectionParseTest.class);
}
- public void testBaseCase_VariableReference() throws Exception
- {
+ public void testBaseCase_VariableReference() throws Exception {
String code = "void f() { int x; x=3; }"; //$NON-NLS-1$
- int offset1 = code.indexOf( "x=" ); //$NON-NLS-1$
+ int offset1 = code.indexOf("x="); //$NON-NLS-1$
int length = "x".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, offset1, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, offset1, length).getParent();
assertNotNull(node);
- assertTrue( node instanceof IASTIdExpression );
- assertEquals(((IASTIdExpression)node).getName().toString(), "x"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, offset1, length ).getParent();
+ assertTrue(node instanceof IASTIdExpression);
+ assertEquals(((IASTIdExpression) node).getName().toString(), "x"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, offset1, length).getParent();
assertNotNull(node);
- assertTrue( node instanceof IASTIdExpression );
- assertEquals(((IASTIdExpression)node).getName().toString(), "x"); //$NON-NLS-1$
- IASTName name = ((IASTIdExpression)node).getName();
+ assertTrue(node instanceof IASTIdExpression);
+ assertEquals(((IASTIdExpression) node).getName().toString(), "x"); //$NON-NLS-1$
+ IASTName name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
- assertEquals(((IVariable)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ assertEquals(((IVariable) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
}
- public void testBaseCase_FunctionReference() throws Exception
- {
+ public void testBaseCase_FunctionReference() throws Exception {
String code = "int x(){x( );}"; //$NON-NLS-1$
- int offset1 = code.indexOf( "x( " ); //$NON-NLS-1$
+ int offset1 = code.indexOf("x( "); //$NON-NLS-1$
int length = "x".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, offset1, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, offset1, length).getParent();
assertNotNull(node);
- assertTrue( node instanceof IASTIdExpression );
- assertEquals(((IASTIdExpression)node).getName().toString(), "x"); //$NON-NLS-1$
- IASTName name = ((IASTIdExpression)node).getName();
+ assertTrue(node instanceof IASTIdExpression);
+ assertEquals(((IASTIdExpression) node).getName().toString(), "x"); //$NON-NLS-1$
+ IASTName name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, offset1, length ).getParent();
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, offset1, length).getParent();
assertNotNull(node);
- assertTrue( node instanceof IASTIdExpression );
- assertEquals(((IASTIdExpression)node).getName().toString(), "x"); //$NON-NLS-1$
- name = ((IASTIdExpression)node).getName();
+ assertTrue(node instanceof IASTIdExpression);
+ assertEquals(((IASTIdExpression) node).getName().toString(), "x"); //$NON-NLS-1$
+ name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
}
-
- public void testBaseCase_FunctionDeclaration() throws Exception
- {
+
+ public void testBaseCase_FunctionDeclaration() throws Exception {
String code = "int x(); x( );"; //$NON-NLS-1$
- int offset1 = code.indexOf( "x()" ); //$NON-NLS-1$
+ int offset1 = code.indexOf("x()"); //$NON-NLS-1$
int length = "x".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, offset1, length );
+ IASTNode node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
- assertTrue( node instanceof IASTName );
+ assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "x"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, offset1, length );
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, offset1, length);
assertNotNull(node);
- assertTrue( node instanceof IASTName );
+ assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "x"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
}
-
- public void testBaseCase_FunctionDeclaration2() throws Exception
- {
+
+ public void testBaseCase_FunctionDeclaration2() throws Exception {
String code = "int printf( const char *, ... ); "; //$NON-NLS-1$
- int offset1 = code.indexOf( "printf" ); //$NON-NLS-1$
+ int offset1 = code.indexOf("printf"); //$NON-NLS-1$
int length = "printf".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, offset1, length );
+ IASTNode node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
- assertTrue( node instanceof IASTName );
+ assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "printf"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "printf"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, offset1, length );
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "printf"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, offset1, length);
assertNotNull(node);
- assertTrue( node instanceof IASTName );
+ assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "printf"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "printf"); //$NON-NLS-1$
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "printf"); //$NON-NLS-1$
}
- public void testBaseCase_VariableDeclaration() throws Exception
- {
+ public void testBaseCase_VariableDeclaration() throws Exception {
String code = "int x = 3;"; //$NON-NLS-1$
- int offset1 = code.indexOf( "x" ); //$NON-NLS-1$
+ int offset1 = code.indexOf("x"); //$NON-NLS-1$
int length = "x".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, offset1, length );
+ IASTNode node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
- assertTrue( node instanceof IASTName );
+ assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "x"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
- assertEquals(((IVariable)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, offset1, length );
+ assertEquals(((IVariable) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, offset1, length);
assertNotNull(node);
- assertTrue( node instanceof IASTName );
+ assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "x"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
- assertEquals(((IVariable)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ assertEquals(((IVariable) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
}
-
- public void testBaseCase_Parameter() throws Exception
- {
+
+ public void testBaseCase_Parameter() throws Exception {
String code = "int main( int argc ) { int x = argc; }"; //$NON-NLS-1$
- int offset1 = code.indexOf( "argc;" ); //$NON-NLS-1$
+ int offset1 = code.indexOf("argc;"); //$NON-NLS-1$
int length = "argc".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, offset1, length ).getParent().getParent();
+ IASTNode node = parse(code, ParserLanguage.C, offset1, length).getParent().getParent();
assertNotNull(node);
- assertTrue( node instanceof IASTEqualsInitializer );
- assertEquals( ((IASTIdExpression)((IASTEqualsInitializer)node).getInitializerClause()).getName().toString(), "argc" ); //$NON-NLS-1$
- IASTName name = ((IASTIdExpression)((IASTEqualsInitializer)node).getInitializerClause()).getName();
+ assertTrue(node instanceof IASTEqualsInitializer);
+ assertEquals(((IASTIdExpression) ((IASTEqualsInitializer) node).getInitializerClause()).getName().toString(),
+ "argc"); //$NON-NLS-1$
+ IASTName name = ((IASTIdExpression) ((IASTEqualsInitializer) node).getInitializerClause()).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IParameter);
- assertEquals(((IParameter)name.resolveBinding()).getName(), "argc"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, offset1, length ).getParent().getParent();
+ assertEquals(((IParameter) name.resolveBinding()).getName(), "argc"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, offset1, length).getParent().getParent();
assertNotNull(node);
- assertTrue( node instanceof IASTEqualsInitializer );
- assertEquals( ((IASTIdExpression)((IASTEqualsInitializer)node).getInitializerClause()).getName().toString(), "argc" ); //$NON-NLS-1$
- name = ((IASTIdExpression)((IASTEqualsInitializer)node).getInitializerClause()).getName();
+ assertTrue(node instanceof IASTEqualsInitializer);
+ assertEquals(((IASTIdExpression) ((IASTEqualsInitializer) node).getInitializerClause()).getName().toString(),
+ "argc"); //$NON-NLS-1$
+ name = ((IASTIdExpression) ((IASTEqualsInitializer) node).getInitializerClause()).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IParameter);
- assertEquals(((IParameter)name.resolveBinding()).getName(), "argc"); //$NON-NLS-1$
+ assertEquals(((IParameter) name.resolveBinding()).getName(), "argc"); //$NON-NLS-1$
}
-
- public void testBug57898() throws Exception
- {
+
+ public void testBug57898() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Gonzo { public: void playHorn(); };\n" ); //$NON-NLS-1$
- writer.write( "void Gonzo::playHorn() { return; }\n" ); //$NON-NLS-1$
- writer.write( "int main(int argc, char **argv) { Gonzo gonzo; gonzo.playHorn(); }\n" ); //$NON-NLS-1$
+ writer.write("class Gonzo { public: void playHorn(); };\n"); //$NON-NLS-1$
+ writer.write("void Gonzo::playHorn() { return; }\n"); //$NON-NLS-1$
+ writer.write("int main(int argc, char **argv) { Gonzo gonzo; gonzo.playHorn(); }\n"); //$NON-NLS-1$
String code = writer.toString();
- for( int i = 0; i < 3; ++i )
- {
+ for (int i = 0; i < 3; ++i) {
int start = -1, stop = -1;
- switch( i )
- {
- case 0:
- start = code.indexOf( "void playHorn") + 5; //$NON-NLS-1$
- break;
- case 1:
- start = code.indexOf( "::playHorn") + 2; //$NON-NLS-1$
- break;
- case 2:
- start = code.indexOf( ".playHorn") + 1; //$NON-NLS-1$
- break;
+ switch (i) {
+ case 0:
+ start = code.indexOf("void playHorn") + 5; //$NON-NLS-1$
+ break;
+ case 1:
+ start = code.indexOf("::playHorn") + 2; //$NON-NLS-1$
+ break;
+ case 2:
+ start = code.indexOf(".playHorn") + 1; //$NON-NLS-1$
+ break;
}
stop = 8;
- IASTNode node = parse( code, ParserLanguage.CPP, start, stop );
+ IASTNode node = parse(code, ParserLanguage.CPP, start, stop);
assertNotNull(node);
- assertTrue( node instanceof IASTName );
- assertEquals( node.toString(), "playHorn" ); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ assertTrue(node instanceof IASTName);
+ assertEquals(node.toString(), "playHorn"); //$NON-NLS-1$
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPMethod);
- assertEquals(((ICPPMethod)name.resolveBinding()).getName(), "playHorn"); //$NON-NLS-1$
+ assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "playHorn"); //$NON-NLS-1$
}
}
-
- public void testConstructorDestructorDeclaration() throws Exception
- {
+
+ public void testConstructorDestructorDeclaration() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Gonzo { Gonzo(); ~Gonzo(); };"); //$NON-NLS-1$
+ writer.write("class Gonzo { Gonzo(); ~Gonzo(); };"); //$NON-NLS-1$
String code = writer.toString();
- int offset = code.indexOf( " Gonzo()") + 1; //$NON-NLS-1$
+ int offset = code.indexOf(" Gonzo()") + 1; //$NON-NLS-1$
int length = "Gonzo".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, offset, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, offset, length);
assertNotNull(node);
- assertTrue( node instanceof IASTName );
+ assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Gonzo"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPConstructor);
- assertEquals(((ICPPConstructor)name.resolveBinding()).getName(), "Gonzo"); //$NON-NLS-1$
- offset = code.indexOf( " ~Gonzo") + 1; //$NON-NLS-1$
+ assertEquals(((ICPPConstructor) name.resolveBinding()).getName(), "Gonzo"); //$NON-NLS-1$
+ offset = code.indexOf(" ~Gonzo") + 1; //$NON-NLS-1$
length = "~Gonzo".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, offset, length );
+ node = parse(code, ParserLanguage.CPP, offset, length);
assertNotNull(node);
- assertTrue( node instanceof IASTName );
+ assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "~Gonzo"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPMethod);
- assertEquals(((ICPPMethod)name.resolveBinding()).getName(), "~Gonzo"); //$NON-NLS-1$
+ assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "~Gonzo"); //$NON-NLS-1$
+
+ }
- }
-
- public void testBug60264() throws Exception
- {
+ public void testBug60264() throws Exception {
Writer writer = new StringWriter();
- writer.write( "namespace Muppets { int i; }\n" ); //$NON-NLS-1$
- writer.write( "int main(int argc, char **argv) { Muppets::i = 1; }\n" ); //$NON-NLS-1$
+ writer.write("namespace Muppets { int i; }\n"); //$NON-NLS-1$
+ writer.write("int main(int argc, char **argv) { Muppets::i = 1; }\n"); //$NON-NLS-1$
String code = writer.toString();
- int index = code.indexOf( "Muppets::"); //$NON-NLS-1$
+ int index = code.indexOf("Muppets::"); //$NON-NLS-1$
int length = "Muppets".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, index, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Muppets"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPNamespace);
- assertEquals(((ICPPNamespace)name.resolveBinding()).getName(), "Muppets"); //$NON-NLS-1$
- index = code.indexOf( "e Muppets") + 2; //$NON-NLS-1$
+ assertEquals(((ICPPNamespace) name.resolveBinding()).getName(), "Muppets"); //$NON-NLS-1$
+ index = code.indexOf("e Muppets") + 2; //$NON-NLS-1$
length = "Muppets".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Muppets"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPNamespace);
- assertEquals(((ICPPNamespace)name.resolveBinding()).getName(), "Muppets"); //$NON-NLS-1$
+ assertEquals(((ICPPNamespace) name.resolveBinding()).getName(), "Muppets"); //$NON-NLS-1$
}
-
- public void testBug61613() throws Exception
- {
+
+ public void testBug61613() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Foo { // ** (A) **\n" ); //$NON-NLS-1$
- writer.write( " public:\n" ); //$NON-NLS-1$
- writer.write( "Foo() {};\n" ); //$NON-NLS-1$
- writer.write( "};\n" ); //$NON-NLS-1$
- writer.write( "int \n" ); //$NON-NLS-1$
- writer.write( "main(int argc, char **argv) {\n" ); //$NON-NLS-1$
- writer.write( "Foo foo; // ** (B) **\n" ); //$NON-NLS-1$
- writer.write( "}\n" ); //$NON-NLS-1$
+ writer.write("class Foo { // ** (A) **\n"); //$NON-NLS-1$
+ writer.write(" public:\n"); //$NON-NLS-1$
+ writer.write("Foo() {};\n"); //$NON-NLS-1$
+ writer.write("};\n"); //$NON-NLS-1$
+ writer.write("int \n"); //$NON-NLS-1$
+ writer.write("main(int argc, char **argv) {\n"); //$NON-NLS-1$
+ writer.write("Foo foo; // ** (B) **\n"); //$NON-NLS-1$
+ writer.write("}\n"); //$NON-NLS-1$
String code = writer.toString();
- int index = code.indexOf( "class Foo") + 6; //$NON-NLS-1$
+ int index = code.indexOf("class Foo") + 6; //$NON-NLS-1$
int length = "Foo".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, index, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Foo"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPClassType);
- assertEquals(((ICPPClassType)name.resolveBinding()).getName(), "Foo"); //$NON-NLS-1$
+ assertEquals(((ICPPClassType) name.resolveBinding()).getName(), "Foo"); //$NON-NLS-1$
}
-
- public void testBug60038() throws Exception
- {
+
+ public void testBug60038() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Gonzo {\n"); //$NON-NLS-1$
- writer.write( "public:\n"); //$NON-NLS-1$
- writer.write( "Gonzo( const Gonzo & other ){}\n"); //$NON-NLS-1$
- writer.write( "Gonzo() {}\n"); //$NON-NLS-1$
- writer.write( "~Gonzo(){}\n"); //$NON-NLS-1$
- writer.write( "};\n"); //$NON-NLS-1$
- writer.write( "int main(int argc, char **argv) {\n"); //$NON-NLS-1$
- writer.write( " Gonzo * g = new Gonzo();\n"); //$NON-NLS-1$
- writer.write( " Gonzo * g2 = new Gonzo( *g );\n"); //$NON-NLS-1$
- writer.write( " g->~Gonzo();\n"); //$NON-NLS-1$
- writer.write( " return (int) g2;\n"); //$NON-NLS-1$
- writer.write( "}\n"); //$NON-NLS-1$
+ writer.write("class Gonzo {\n"); //$NON-NLS-1$
+ writer.write("public:\n"); //$NON-NLS-1$
+ writer.write("Gonzo( const Gonzo & other ){}\n"); //$NON-NLS-1$
+ writer.write("Gonzo() {}\n"); //$NON-NLS-1$
+ writer.write("~Gonzo(){}\n"); //$NON-NLS-1$
+ writer.write("};\n"); //$NON-NLS-1$
+ writer.write("int main(int argc, char **argv) {\n"); //$NON-NLS-1$
+ writer.write(" Gonzo * g = new Gonzo();\n"); //$NON-NLS-1$
+ writer.write(" Gonzo * g2 = new Gonzo( *g );\n"); //$NON-NLS-1$
+ writer.write(" g->~Gonzo();\n"); //$NON-NLS-1$
+ writer.write(" return (int) g2;\n"); //$NON-NLS-1$
+ writer.write("}\n"); //$NON-NLS-1$
String code = writer.toString();
- for( int i = 0; i < 3; ++i )
- {
+ for (int i = 0; i < 3; ++i) {
int startOffset = 0, length = 0;
- switch( i )
- {
- case 0:
- startOffset = code.indexOf( "new Gonzo()") + 4; //$NON-NLS-1$
- length = 5;
- break;
- case 1:
- startOffset = code.indexOf( "new Gonzo( ") + 4; //$NON-NLS-1$
- length = 5;
- break;
- default:
- startOffset = code.indexOf( "->~") + 2; //$NON-NLS-1$
- length = 6;
+ switch (i) {
+ case 0:
+ startOffset = code.indexOf("new Gonzo()") + 4; //$NON-NLS-1$
+ length = 5;
+ break;
+ case 1:
+ startOffset = code.indexOf("new Gonzo( ") + 4; //$NON-NLS-1$
+ length = 5;
+ break;
+ default:
+ startOffset = code.indexOf("->~") + 2; //$NON-NLS-1$
+ length = 6;
}
- IASTNode node = parse( code, ParserLanguage.CPP, startOffset, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, startOffset, length);
assertNotNull(node);
IASTName name = null;
- switch( i )
- {
- case 0:
- case 1:
- node= node.getParent().getParent();
- assertTrue(node instanceof IASTTypeId);
- assertEquals(((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName().toString(), "Gonzo"); //$NON-NLS-1$
- name = ((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName();
- name = TestUtil.findImplicitName(name);
- IBinding binding = name.resolveBinding();
- assertTrue(binding instanceof ICPPConstructor);
- assertEquals(((ICPPConstructor)binding).getName(), "Gonzo"); //$NON-NLS-1$
- break;
- default:
- assertTrue(node instanceof IASTName);
- assertEquals(node.toString(), "~Gonzo"); //$NON-NLS-1$
- name = (IASTName)node;
- assertNotNull(name.resolveBinding());
- assertTrue(name.resolveBinding() instanceof ICPPMethod);
- assertEquals(((ICPPMethod)name.resolveBinding()).getName(), "~Gonzo"); //$NON-NLS-1$
- break;
-
+ switch (i) {
+ case 0:
+ case 1:
+ node = node.getParent().getParent();
+ assertTrue(node instanceof IASTTypeId);
+ assertEquals(((IASTNamedTypeSpecifier) ((IASTTypeId) node).getDeclSpecifier()).getName().toString(),
+ "Gonzo"); //$NON-NLS-1$
+ name = ((IASTNamedTypeSpecifier) ((IASTTypeId) node).getDeclSpecifier()).getName();
+ name = TestUtil.findImplicitName(name);
+ IBinding binding = name.resolveBinding();
+ assertTrue(binding instanceof ICPPConstructor);
+ assertEquals(((ICPPConstructor) binding).getName(), "Gonzo"); //$NON-NLS-1$
+ break;
+ default:
+ assertTrue(node instanceof IASTName);
+ assertEquals(node.toString(), "~Gonzo"); //$NON-NLS-1$
+ name = (IASTName) node;
+ assertNotNull(name.resolveBinding());
+ assertTrue(name.resolveBinding() instanceof ICPPMethod);
+ assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "~Gonzo"); //$NON-NLS-1$
+ break;
+
}
}
}
-
- public void testMethodReference() throws Exception
- {
+
+ public void testMethodReference() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Sample { public:\n"); //$NON-NLS-1$
- writer.write( " int getAnswer() const;\n"); //$NON-NLS-1$
- writer.write( "};\n"); //$NON-NLS-1$
- writer.write( "int main(int argc, char **argv) {\n" ); //$NON-NLS-1$
- writer.write( " Sample * s = new Sample();\n" ); //$NON-NLS-1$
- writer.write( " return s->getAnswer();\n" ); //$NON-NLS-1$
- writer.write( "}\n" ); //$NON-NLS-1$
+ writer.write("class Sample { public:\n"); //$NON-NLS-1$
+ writer.write(" int getAnswer() const;\n"); //$NON-NLS-1$
+ writer.write("};\n"); //$NON-NLS-1$
+ writer.write("int main(int argc, char **argv) {\n"); //$NON-NLS-1$
+ writer.write(" Sample * s = new Sample();\n"); //$NON-NLS-1$
+ writer.write(" return s->getAnswer();\n"); //$NON-NLS-1$
+ writer.write("}\n"); //$NON-NLS-1$
String code = writer.toString();
- int startIndex = code.indexOf( "->getAnswer") + 2; //$NON-NLS-1$
+ int startIndex = code.indexOf("->getAnswer") + 2; //$NON-NLS-1$
int length = "getAnswer".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "getAnswer"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPMethod);
- assertEquals(((ICPPMethod)name.resolveBinding()).getName(), "getAnswer"); //$NON-NLS-1$
+ assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "getAnswer"); //$NON-NLS-1$
}
-
- public void testConstructorDefinition() throws Exception
- {
+
+ public void testConstructorDefinition() throws Exception {
String code = "class ABC { public: ABC(); }; ABC::ABC(){}"; //$NON-NLS-1$
- int startIndex = code.indexOf( "::ABC") + 2; //$NON-NLS-1$
+ int startIndex = code.indexOf("::ABC") + 2; //$NON-NLS-1$
int length = "ABC".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertEquals(node.toString(), "ABC"); //$NON-NLS-1$
assertTrue(name.resolveBinding() instanceof ICPPConstructor);
- assertEquals(((ICPPConstructor)name.resolveBinding()).getName(), "ABC"); //$NON-NLS-1$
+ assertEquals(((ICPPConstructor) name.resolveBinding()).getName(), "ABC"); //$NON-NLS-1$
}
-
- public void testBug63966() throws Exception
- {
+
+ public void testBug63966() throws Exception {
Writer writer = new StringWriter();
- writer.write( "void foo(int a) {}\n" ); //$NON-NLS-1$
- writer.write( "void foo(long a) {}\n" ); //$NON-NLS-1$
- writer.write( "int main(int argc, char **argv) {\n" ); //$NON-NLS-1$
- writer.write( "foo(1); \n }" ); //$NON-NLS-1$
+ writer.write("void foo(int a) {}\n"); //$NON-NLS-1$
+ writer.write("void foo(long a) {}\n"); //$NON-NLS-1$
+ writer.write("int main(int argc, char **argv) {\n"); //$NON-NLS-1$
+ writer.write("foo(1); \n }"); //$NON-NLS-1$
String code = writer.toString();
- int startIndex = code.indexOf( "foo(1)"); //$NON-NLS-1$
+ int startIndex = code.indexOf("foo(1)"); //$NON-NLS-1$
int length = "foo".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, startIndex, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, startIndex, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression)node).getName().toString(), "foo"); //$NON-NLS-1$
- IASTName name = ((IASTIdExpression)node).getName();
+ assertEquals(((IASTIdExpression) node).getName().toString(), "foo"); //$NON-NLS-1$
+ IASTName name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "foo"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, startIndex, length ).getParent();
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "foo"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, startIndex, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression)node).getName().toString(), "foo"); //$NON-NLS-1$
- name = ((IASTIdExpression)node).getName();
+ assertEquals(((IASTIdExpression) node).getName().toString(), "foo"); //$NON-NLS-1$
+ name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "foo"); //$NON-NLS-1$
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "foo"); //$NON-NLS-1$
}
-
- public void testBug66744() throws Exception
- {
+
+ public void testBug66744() throws Exception {
Writer writerCPP = new StringWriter();
- writerCPP.write( "enum EColours { RED, GREEN, BLUE }; \n" ); //$NON-NLS-1$
- writerCPP.write( "void foo() { EColours color = GREEN; } \n" ); //$NON-NLS-1$
-
+ writerCPP.write("enum EColours { RED, GREEN, BLUE }; \n"); //$NON-NLS-1$
+ writerCPP.write("void foo() { EColours color = GREEN; } \n"); //$NON-NLS-1$
+
Writer writerC = new StringWriter();
- writerC.write( "enum EColours { RED, GREEN, BLUE }; \n" ); //$NON-NLS-1$
- writerC.write( "void foo() { enum EColours color = GREEN; } \n" ); //$NON-NLS-1$
-
+ writerC.write("enum EColours { RED, GREEN, BLUE }; \n"); //$NON-NLS-1$
+ writerC.write("void foo() { enum EColours color = GREEN; } \n"); //$NON-NLS-1$
+
String codeCPP = writerCPP.toString();
String codeC = writerC.toString();
- int startIndex = codeC.indexOf( "EColours color"); //$NON-NLS-1$
+ int startIndex = codeC.indexOf("EColours color"); //$NON-NLS-1$
int length = "EColours".length(); //$NON-NLS-1$
- IASTNode node = parse( codeC, ParserLanguage.C, startIndex, length );
+ IASTNode node = parse(codeC, ParserLanguage.C, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "EColours"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IEnumeration);
- assertEquals(((IEnumeration)name.resolveBinding()).getName(), "EColours"); //$NON-NLS-1$
- startIndex = codeCPP.indexOf( "EColours color"); //$NON-NLS-1$
- node = parse( codeCPP, ParserLanguage.CPP, startIndex, length ).getParent();
+ assertEquals(((IEnumeration) name.resolveBinding()).getName(), "EColours"); //$NON-NLS-1$
+ startIndex = codeCPP.indexOf("EColours color"); //$NON-NLS-1$
+ node = parse(codeCPP, ParserLanguage.CPP, startIndex, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTNamedTypeSpecifier);
- assertEquals(((IASTNamedTypeSpecifier)node).getName().toString(), "EColours"); //$NON-NLS-1$
- name = ((IASTNamedTypeSpecifier)node).getName();
+ assertEquals(((IASTNamedTypeSpecifier) node).getName().toString(), "EColours"); //$NON-NLS-1$
+ name = ((IASTNamedTypeSpecifier) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IEnumeration);
- assertEquals(((IEnumeration)name.resolveBinding()).getName(), "EColours"); //$NON-NLS-1$
+ assertEquals(((IEnumeration) name.resolveBinding()).getName(), "EColours"); //$NON-NLS-1$
}
-
-
- public void testBug68527() throws Exception
- {
+ public void testBug68527() throws Exception {
Writer writer = new StringWriter();
writer.write("struct X;\n"); //$NON-NLS-1$
writer.write("struct X anA;"); //$NON-NLS-1$
String code = writer.toString();
- int startIndex = code.indexOf( "X anA"); //$NON-NLS-1$
+ int startIndex = code.indexOf("X anA"); //$NON-NLS-1$
int length = "X".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, startIndex, length );
+ IASTNode node = parse(code, ParserLanguage.C, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "X"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICompositeType);
- assertEquals(((ICompositeType)name.resolveBinding()).getName(), "X"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, startIndex, length );
+ assertEquals(((ICompositeType) name.resolveBinding()).getName(), "X"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "X"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICompositeType);
- assertEquals(((ICompositeType)name.resolveBinding()).getName(), "X"); //$NON-NLS-1$
+ assertEquals(((ICompositeType) name.resolveBinding()).getName(), "X"); //$NON-NLS-1$
}
- public void testBug60407() throws Exception
- {
+ public void testBug60407() throws Exception {
Writer writer = new StringWriter();
- writer.write( "struct ZZZ { int x, y, z; };\n" ); //$NON-NLS-1$
- writer.write( "typedef struct ZZZ _FILE;\n" ); //$NON-NLS-1$
- writer.write( "typedef _FILE FILE;\n" ); //$NON-NLS-1$
- writer.write( "static void static_function(FILE * lcd){}\n" ); //$NON-NLS-1$
- writer.write( "int main(int argc, char **argv) {\n" ); //$NON-NLS-1$
- writer.write( "FILE * file = 0;\n" ); //$NON-NLS-1$
- writer.write( "static_function( file );\n" ); //$NON-NLS-1$
- writer.write( "return 0;\n" ); //$NON-NLS-1$
- writer.write( "}\n" ); //$NON-NLS-1$
+ writer.write("struct ZZZ { int x, y, z; };\n"); //$NON-NLS-1$
+ writer.write("typedef struct ZZZ _FILE;\n"); //$NON-NLS-1$
+ writer.write("typedef _FILE FILE;\n"); //$NON-NLS-1$
+ writer.write("static void static_function(FILE * lcd){}\n"); //$NON-NLS-1$
+ writer.write("int main(int argc, char **argv) {\n"); //$NON-NLS-1$
+ writer.write("FILE * file = 0;\n"); //$NON-NLS-1$
+ writer.write("static_function( file );\n"); //$NON-NLS-1$
+ writer.write("return 0;\n"); //$NON-NLS-1$
+ writer.write("}\n"); //$NON-NLS-1$
String code = writer.toString();
- int startIndex = code.indexOf( "static_function( file )"); //$NON-NLS-1$
+ int startIndex = code.indexOf("static_function( file )"); //$NON-NLS-1$
int length = "static_function".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, startIndex, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, startIndex, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression)node).getName().toString(), "static_function"); //$NON-NLS-1$
- IASTName name = ((IASTIdExpression)node).getName();
+ assertEquals(((IASTIdExpression) node).getName().toString(), "static_function"); //$NON-NLS-1$
+ IASTName name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "static_function"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, startIndex, length ).getParent();
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "static_function"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, startIndex, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression)node).getName().toString(), "static_function"); //$NON-NLS-1$
- name = ((IASTIdExpression)node).getName();
+ assertEquals(((IASTIdExpression) node).getName().toString(), "static_function"); //$NON-NLS-1$
+ name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "static_function"); //$NON-NLS-1$
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "static_function"); //$NON-NLS-1$
}
-
- public void testBug61800() throws Exception
- {
+
+ public void testBug61800() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class B {};\n"); //$NON-NLS-1$
- writer.write( "class ABCDEF {\n"); //$NON-NLS-1$
- writer.write( " static B stInt; };\n"); //$NON-NLS-1$
- writer.write( "B ABCDEF::stInt = 5;\n"); //$NON-NLS-1$
+ writer.write("class B {};\n"); //$NON-NLS-1$
+ writer.write("class ABCDEF {\n"); //$NON-NLS-1$
+ writer.write(" static B stInt; };\n"); //$NON-NLS-1$
+ writer.write("B ABCDEF::stInt = 5;\n"); //$NON-NLS-1$
String code = writer.toString();
- int startIndex = code.indexOf( "::stInt") + 2; //$NON-NLS-1$
+ int startIndex = code.indexOf("::stInt") + 2; //$NON-NLS-1$
int length = "stInt".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "stInt"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "stInt"); //$NON-NLS-1$
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "stInt"); //$NON-NLS-1$
}
-
- public void testBug68739() throws Exception
- {
- Writer writer = new StringWriter();
- writer.write( "int fprintf( int *, const char *, ... ); \n" ); //$NON-NLS-1$
- writer.write( "void boo( int * lcd ) { \n" ); //$NON-NLS-1$
- writer.write( " /**/fprintf( lcd, \"%c%s 0x%x\", ' ', \"bbb\", 2 ); \n" ); //$NON-NLS-1$
- writer.write( "} \n" ); //$NON-NLS-1$
-
- String code = writer.toString();
- int startIndex = code.indexOf( "/**/fprintf") + 4; //$NON-NLS-1$
+
+ public void testBug68739() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("int fprintf( int *, const char *, ... ); \n"); //$NON-NLS-1$
+ writer.write("void boo( int * lcd ) { \n"); //$NON-NLS-1$
+ writer.write(" /**/fprintf( lcd, \"%c%s 0x%x\", ' ', \"bbb\", 2 ); \n"); //$NON-NLS-1$
+ writer.write("} \n"); //$NON-NLS-1$
+
+ String code = writer.toString();
+ int startIndex = code.indexOf("/**/fprintf") + 4; //$NON-NLS-1$
int length = "fprintf".length(); //$NON-NLS-1$
-
- IASTNode node = parse( code, ParserLanguage.C, startIndex, length ).getParent();
+
+ IASTNode node = parse(code, ParserLanguage.C, startIndex, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression)node).getName().toString(), "fprintf"); //$NON-NLS-1$
- IASTName name = ((IASTIdExpression)node).getName();
+ assertEquals(((IASTIdExpression) node).getName().toString(), "fprintf"); //$NON-NLS-1$
+ IASTName name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "fprintf"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, startIndex, length ).getParent();
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "fprintf"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, startIndex, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression)node).getName().toString(), "fprintf"); //$NON-NLS-1$
- name = ((IASTIdExpression)node).getName();
+ assertEquals(((IASTIdExpression) node).getName().toString(), "fprintf"); //$NON-NLS-1$
+ name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "fprintf"); //$NON-NLS-1$
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "fprintf"); //$NON-NLS-1$
}
-
- public void testBug72818() throws Exception
- {
+
+ public void testBug72818() throws Exception {
Writer writerCPP = new StringWriter();
- writerCPP.write( "union Squaw { int x; double u; };\n" ); //$NON-NLS-1$
- writerCPP.write( "int main(int argc, char **argv) {\n" ); //$NON-NLS-1$
- writerCPP.write( "return sizeof( Squaw );\n" ); //$NON-NLS-1$
- writerCPP.write( "}\n" ); //$NON-NLS-1$
-
+ writerCPP.write("union Squaw { int x; double u; };\n"); //$NON-NLS-1$
+ writerCPP.write("int main(int argc, char **argv) {\n"); //$NON-NLS-1$
+ writerCPP.write("return sizeof( Squaw );\n"); //$NON-NLS-1$
+ writerCPP.write("}\n"); //$NON-NLS-1$
+
Writer writerC = new StringWriter();
- writerC.write( "union Squaw { int x; double u; };\n" ); //$NON-NLS-1$
- writerC.write( "int main(int argc, char **argv) {\n" ); //$NON-NLS-1$
- writerC.write( "return sizeof( union Squaw );\n" ); //$NON-NLS-1$
- writerC.write( "}\n" ); //$NON-NLS-1$
-
+ writerC.write("union Squaw { int x; double u; };\n"); //$NON-NLS-1$
+ writerC.write("int main(int argc, char **argv) {\n"); //$NON-NLS-1$
+ writerC.write("return sizeof( union Squaw );\n"); //$NON-NLS-1$
+ writerC.write("}\n"); //$NON-NLS-1$
+
String codeC = writerC.toString();
String codeCPP = writerCPP.toString();
- int startIndex = codeC.indexOf( "sizeof( union ") + "sizeof( union ".length(); //$NON-NLS-1$ //$NON-NLS-2$
+ int startIndex = codeC.indexOf("sizeof( union ") + "sizeof( union ".length(); //$NON-NLS-1$ //$NON-NLS-2$
int length = "Squaw".length(); //$NON-NLS-1$
- IASTNode node = parse( codeC, ParserLanguage.C, startIndex, length );
+ IASTNode node = parse(codeC, ParserLanguage.C, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Squaw"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICompositeType);
- assertEquals(((ICompositeType)name.resolveBinding()).getName(), "Squaw"); //$NON-NLS-1$
- startIndex = codeCPP.indexOf( "sizeof( ") + "sizeof( ".length(); //$NON-NLS-1$ //$NON-NLS-2$
- node = parse( codeCPP, ParserLanguage.CPP, startIndex, length ).getParent().getParent();
+ assertEquals(((ICompositeType) name.resolveBinding()).getName(), "Squaw"); //$NON-NLS-1$
+ startIndex = codeCPP.indexOf("sizeof( ") + "sizeof( ".length(); //$NON-NLS-1$ //$NON-NLS-2$
+ node = parse(codeCPP, ParserLanguage.CPP, startIndex, length).getParent().getParent();
assertNotNull(node);
assertTrue(node instanceof IASTTypeId);
- assertEquals(((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName().toString(), "Squaw"); //$NON-NLS-1$
- name = ((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName();
+ assertEquals(((IASTNamedTypeSpecifier) ((IASTTypeId) node).getDeclSpecifier()).getName().toString(), "Squaw"); //$NON-NLS-1$
+ name = ((IASTNamedTypeSpecifier) ((IASTTypeId) node).getDeclSpecifier()).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPClassType);
- assertEquals(((ICPPClassType)name.resolveBinding()).getName(), "Squaw"); //$NON-NLS-1$
+ assertEquals(((ICPPClassType) name.resolveBinding()).getName(), "Squaw"); //$NON-NLS-1$
}
-
- public void test72220() throws Exception
- {
+
+ public void test72220() throws Exception {
Writer writer = new StringWriter();
- writer.write( "const int FOUND_ME = 1;\n" ); //$NON-NLS-1$
- writer.write( "class Test{\n" ); //$NON-NLS-1$
- writer.write( "public:\n" ); //$NON-NLS-1$
- writer.write( "const int findCode() const;\n" ); //$NON-NLS-1$
- writer.write( "};\n" ); //$NON-NLS-1$
- writer.write( "const int Test::findCode() const {\n" ); //$NON-NLS-1$
- writer.write( "return FOUND_ME;\n" ); //$NON-NLS-1$
- writer.write( "}\n" ); //$NON-NLS-1$
+ writer.write("const int FOUND_ME = 1;\n"); //$NON-NLS-1$
+ writer.write("class Test{\n"); //$NON-NLS-1$
+ writer.write("public:\n"); //$NON-NLS-1$
+ writer.write("const int findCode() const;\n"); //$NON-NLS-1$
+ writer.write("};\n"); //$NON-NLS-1$
+ writer.write("const int Test::findCode() const {\n"); //$NON-NLS-1$
+ writer.write("return FOUND_ME;\n"); //$NON-NLS-1$
+ writer.write("}\n"); //$NON-NLS-1$
String code = writer.toString();
- int startIndex = code.indexOf( "return ") + "return ".length(); //$NON-NLS-1$ //$NON-NLS-2$
+ int startIndex = code.indexOf("return ") + "return ".length(); //$NON-NLS-1$ //$NON-NLS-2$
int length = "FOUND_ME".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression)node).getName().toString(), "FOUND_ME"); //$NON-NLS-1$
- IASTName name = ((IASTIdExpression)node).getName();
+ assertEquals(((IASTIdExpression) node).getName().toString(), "FOUND_ME"); //$NON-NLS-1$
+ IASTName name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
- assertEquals(((IVariable)name.resolveBinding()).getName(), "FOUND_ME"); //$NON-NLS-1$
+ assertEquals(((IVariable) name.resolveBinding()).getName(), "FOUND_ME"); //$NON-NLS-1$
}
-
- public void testBug72721() throws Exception{
- Writer writer = new StringWriter();
- writer.write(" class ABC { public: ABC(int); }; \n"); //$NON-NLS-1$
- writer.write("void f() { \n"); //$NON-NLS-1$
- writer.write(" int j = 1; \n"); //$NON-NLS-1$
- writer.write(" new ABC( j + 1 ); \n"); //$NON-NLS-1$
- writer.write("} \n"); //$NON-NLS-1$
-
- String code = writer.toString();
- int startIndex = code.indexOf( "ABC(" ); //$NON-NLS-1$
+
+ public void testBug72721() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write(" class ABC { public: ABC(int); }; \n"); //$NON-NLS-1$
+ writer.write("void f() { \n"); //$NON-NLS-1$
+ writer.write(" int j = 1; \n"); //$NON-NLS-1$
+ writer.write(" new ABC( j + 1 ); \n"); //$NON-NLS-1$
+ writer.write("} \n"); //$NON-NLS-1$
+
+ String code = writer.toString();
+ int startIndex = code.indexOf("ABC("); //$NON-NLS-1$
int length = "ABC".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "ABC"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPConstructor);
- assertEquals(((ICPPConstructor)name.resolveBinding()).getName(), "ABC"); //$NON-NLS-1$
+ assertEquals(((ICPPConstructor) name.resolveBinding()).getName(), "ABC"); //$NON-NLS-1$
}
-
- public void testBug72372() throws Exception{
- Writer writer = new StringWriter();
- writer.write("namespace B { \n"); //$NON-NLS-1$
- writer.write(" class SD_02 { void f_SD(); }; \n"); //$NON-NLS-1$
- writer.write("} \n"); //$NON-NLS-1$
- writer.write("using namespace B; \n"); //$NON-NLS-1$
- writer.write("void SD_02::f_SD(){} \n"); //$NON-NLS-1$
-
- String code = writer.toString();
- int startIndex = code.indexOf( ":f_SD" ) + 1; //$NON-NLS-1$
+
+ public void testBug72372() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("namespace B { \n"); //$NON-NLS-1$
+ writer.write(" class SD_02 { void f_SD(); }; \n"); //$NON-NLS-1$
+ writer.write("} \n"); //$NON-NLS-1$
+ writer.write("using namespace B; \n"); //$NON-NLS-1$
+ writer.write("void SD_02::f_SD(){} \n"); //$NON-NLS-1$
+
+ String code = writer.toString();
+ int startIndex = code.indexOf(":f_SD") + 1; //$NON-NLS-1$
int length = "f_SD".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "f_SD"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPMethod);
- assertEquals(((ICPPMethod)name.resolveBinding()).getName(), "f_SD"); //$NON-NLS-1$
+ assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "f_SD"); //$NON-NLS-1$
}
- public void testBug72372_2() throws Exception{
- Writer writer = new StringWriter();
- writer.write("namespace A { \n"); //$NON-NLS-1$
- writer.write(" namespace B { \n"); //$NON-NLS-1$
- writer.write(" void f_SD(); \n"); //$NON-NLS-1$
- writer.write(" } \n"); //$NON-NLS-1$
- writer.write("} \n"); //$NON-NLS-1$
- writer.write("namespace C { \n"); //$NON-NLS-1$
- writer.write(" using namespace A; \n"); //$NON-NLS-1$
- writer.write("} \n"); //$NON-NLS-1$
- writer.write("void C::B::f_SD(){} \n"); //$NON-NLS-1$
-
- String code = writer.toString();
- int startIndex = code.indexOf( ":f_SD" ) + 1; //$NON-NLS-1$
+
+ public void testBug72372_2() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("namespace A { \n"); //$NON-NLS-1$
+ writer.write(" namespace B { \n"); //$NON-NLS-1$
+ writer.write(" void f_SD(); \n"); //$NON-NLS-1$
+ writer.write(" } \n"); //$NON-NLS-1$
+ writer.write("} \n"); //$NON-NLS-1$
+ writer.write("namespace C { \n"); //$NON-NLS-1$
+ writer.write(" using namespace A; \n"); //$NON-NLS-1$
+ writer.write("} \n"); //$NON-NLS-1$
+ writer.write("void C::B::f_SD(){} \n"); //$NON-NLS-1$
+
+ String code = writer.toString();
+ int startIndex = code.indexOf(":f_SD") + 1; //$NON-NLS-1$
int length = "f_SD".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "f_SD"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "f_SD"); //$NON-NLS-1$
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "f_SD"); //$NON-NLS-1$
}
-
- public void testBug72713() throws Exception{
- Writer writer = new StringWriter();
- writer.write( "class Deck{ void initialize(); }; \n"); //$NON-NLS-1$
- writer.write( "void Deck::initialize(){} \n"); //$NON-NLS-1$
-
- String code = writer.toString();
- int startIndex = code.indexOf( ":initialize" ) + 1; //$NON-NLS-1$
- int length = "initialize".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length );
+
+ public void testBug72713() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class Deck{ void initialize(); }; \n"); //$NON-NLS-1$
+ writer.write("void Deck::initialize(){} \n"); //$NON-NLS-1$
+
+ String code = writer.toString();
+ int startIndex = code.indexOf(":initialize") + 1; //$NON-NLS-1$
+ int length = "initialize".length(); //$NON-NLS-1$
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "initialize"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPMethod);
- assertEquals(((ICPPMethod)name.resolveBinding()).getName(), "initialize"); //$NON-NLS-1$
+ assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "initialize"); //$NON-NLS-1$
}
-
- public void testBug72712() throws Exception{
- Writer writer = new StringWriter();
- writer.write( "class B{ public: B(); }; void f(){ B* b; b = new B(); }" ); //$NON-NLS-1$
-
- String code = writer.toString();
- int startIndex = code.indexOf( "new B" ) + 4; //$NON-NLS-1$
- int length = "B".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length ).getParent().getParent();
+
+ public void testBug72712() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class B{ public: B(); }; void f(){ B* b; b = new B(); }"); //$NON-NLS-1$
+
+ String code = writer.toString();
+ int startIndex = code.indexOf("new B") + 4; //$NON-NLS-1$
+ int length = "B".length(); //$NON-NLS-1$
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length).getParent().getParent();
assertNotNull(node);
assertTrue(node instanceof IASTTypeId);
- assertEquals(((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName().toString(), "B"); //$NON-NLS-1$
- IASTName name = ((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName();
+ assertEquals(((IASTNamedTypeSpecifier) ((IASTTypeId) node).getDeclSpecifier()).getName().toString(), "B"); //$NON-NLS-1$
+ IASTName name = ((IASTNamedTypeSpecifier) ((IASTTypeId) node).getDeclSpecifier()).getName();
name = TestUtil.findImplicitName(name);
- IBinding binding = name.resolveBinding();
- assertTrue(binding instanceof ICPPConstructor);
- assertEquals(((ICPPConstructor)binding).getName(), "B"); //$NON-NLS-1$
+ IBinding binding = name.resolveBinding();
+ assertTrue(binding instanceof ICPPConstructor);
+ assertEquals(((ICPPConstructor) binding).getName(), "B"); //$NON-NLS-1$
}
-
- public void testBug72712_2() throws Exception{
- Writer writer = new StringWriter();
- writer.write( "class A {}; \n"); //$NON-NLS-1$
- writer.write( "class B{ public: B( A* ); }; \n"); //$NON-NLS-1$
- writer.write( "void f(){ B* b; b = new B( (A*)0 ); } \n"); //$NON-NLS-1$
-
- String code = writer.toString();
- int startIndex = code.indexOf( "(A*)" ) + 1; //$NON-NLS-1$
- int length = "A".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length ).getParent();
+
+ public void testBug72712_2() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class A {}; \n"); //$NON-NLS-1$
+ writer.write("class B{ public: B( A* ); }; \n"); //$NON-NLS-1$
+ writer.write("void f(){ B* b; b = new B( (A*)0 ); } \n"); //$NON-NLS-1$
+
+ String code = writer.toString();
+ int startIndex = code.indexOf("(A*)") + 1; //$NON-NLS-1$
+ int length = "A".length(); //$NON-NLS-1$
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTNamedTypeSpecifier);
- assertEquals(((IASTNamedTypeSpecifier)node).getName().toString(), "A"); //$NON-NLS-1$
- IASTName name = ((IASTNamedTypeSpecifier)node).getName();
+ assertEquals(((IASTNamedTypeSpecifier) node).getName().toString(), "A"); //$NON-NLS-1$
+ IASTName name = ((IASTNamedTypeSpecifier) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPClassType);
- assertEquals(((ICPPClassType)name.resolveBinding()).getName(), "A"); //$NON-NLS-1$
+ assertEquals(((ICPPClassType) name.resolveBinding()).getName(), "A"); //$NON-NLS-1$
}
-
- public void testBug72710() throws Exception
- {
+
+ public void testBug72710() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Card{\n" ); //$NON-NLS-1$
- writer.write( " Card( int rank );\n" ); //$NON-NLS-1$
- writer.write( " int rank;\n" ); //$NON-NLS-1$
- writer.write( "};\n" ); //$NON-NLS-1$
- writer.write( "Card::Card( int rank ) {\n" ); //$NON-NLS-1$
- writer.write( "this->rank = rank;\n" ); //$NON-NLS-1$
- writer.write( "}\n" ); //$NON-NLS-1$
+ writer.write("class Card{\n"); //$NON-NLS-1$
+ writer.write(" Card( int rank );\n"); //$NON-NLS-1$
+ writer.write(" int rank;\n"); //$NON-NLS-1$
+ writer.write("};\n"); //$NON-NLS-1$
+ writer.write("Card::Card( int rank ) {\n"); //$NON-NLS-1$
+ writer.write("this->rank = rank;\n"); //$NON-NLS-1$
+ writer.write("}\n"); //$NON-NLS-1$
String code = writer.toString();
- int index = code.indexOf( "this->rank") + 6; //$NON-NLS-1$
+ int index = code.indexOf("this->rank") + 6; //$NON-NLS-1$
int length = "rank".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, index, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
}
-
-
- public void testBug75731() throws Exception
- {
+
+ public void testBug75731() throws Exception {
Writer writer = new StringWriter();
writer.write("int rank() {\n"); //$NON-NLS-1$
writer.write("return 5;\n}\n"); //$NON-NLS-1$
@@ -800,212 +773,212 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
writer.write("private:\n"); //$NON-NLS-1$
writer.write("Card( int rank );\n"); //$NON-NLS-1$
writer.write("int rank;\n"); //$NON-NLS-1$
- writer.write("public:\n"); //$NON-NLS-1$
+ writer.write("public:\n"); //$NON-NLS-1$
writer.write("int getRank();\n};\n"); //$NON-NLS-1$
- writer.write("Card::Card( int rank )\n{\n"); //$NON-NLS-1$
+ writer.write("Card::Card( int rank )\n{\n"); //$NON-NLS-1$
writer.write("this->rank = ::rank();\n"); //$NON-NLS-1$
writer.write("this->rank = this->rank;\n"); //$NON-NLS-1$
writer.write("this->rank = rank;\n"); //$NON-NLS-1$
writer.write("this->rank = Card::rank;\n"); //$NON-NLS-1$
writer.write("this->rank = getRank();\n}\n"); //$NON-NLS-1$
-
+
String code = writer.toString();
- int index = code.indexOf( "int rank() {") + 4; //$NON-NLS-1$
+ int index = code.indexOf("int rank() {") + 4; //$NON-NLS-1$
int length = "rank".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, index, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "class Card{") + 6; //$NON-NLS-1$
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("class Card{") + 6; //$NON-NLS-1$
length = "Card".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Card"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPClassType);
- assertEquals(((ICPPClassType)name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$
-
- index = code.indexOf( "Card( int rank );"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((ICPPClassType) name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$
+
+ index = code.indexOf("Card( int rank );"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Card"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPConstructor);
- assertEquals(((ICPPConstructor)name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$
-
- index = code.indexOf( "Card( int rank );") + 10; //$NON-NLS-1$
+ assertEquals(((ICPPConstructor) name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$
+
+ index = code.indexOf("Card( int rank );") + 10; //$NON-NLS-1$
length = "rank".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length ).getParent();
+ node = parse(code, ParserLanguage.CPP, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "rank"); //$NON-NLS-1$
- name = ((IASTDeclarator)node).getName();
+ assertEquals(((IASTDeclarator) node).getName().toString(), "rank"); //$NON-NLS-1$
+ name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
- assertEquals(((IVariable)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+ assertEquals(((IVariable) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
- index = code.indexOf( "int rank;") + 4; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length ).getParent();
+ index = code.indexOf("int rank;") + 4; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "rank"); //$NON-NLS-1$
- name = ((IASTDeclarator)node).getName();
+ assertEquals(((IASTDeclarator) node).getName().toString(), "rank"); //$NON-NLS-1$
+ name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "int getRank();") + 4; //$NON-NLS-1$
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("int getRank();") + 4; //$NON-NLS-1$
length = "getRank".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "getRank"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPMethod);
- assertEquals(((ICPPMethod)name.resolveBinding()).getName(), "getRank"); //$NON-NLS-1$
-
- index = code.indexOf( "Card::Card( int rank )"); //$NON-NLS-1$
+ assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "getRank"); //$NON-NLS-1$
+
+ index = code.indexOf("Card::Card( int rank )"); //$NON-NLS-1$
length = "Card".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Card"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPClassType);
- assertEquals(((ICPPClassType)name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$
-
- index = code.indexOf( "Card::Card( int rank )") + 6; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((ICPPClassType) name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$
+
+ index = code.indexOf("Card::Card( int rank )") + 6; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Card"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPConstructor);
- assertEquals(((ICPPConstructor)name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$
-
- index = code.indexOf( "Card::Card( int rank )") + 16; //$NON-NLS-1$
+ assertEquals(((ICPPConstructor) name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$
+
+ index = code.indexOf("Card::Card( int rank )") + 16; //$NON-NLS-1$
length = "rank".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length ).getParent();
+ node = parse(code, ParserLanguage.CPP, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "rank"); //$NON-NLS-1$
- name = ((IASTDeclarator)node).getName();
+ assertEquals(((IASTDeclarator) node).getName().toString(), "rank"); //$NON-NLS-1$
+ name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
- assertEquals(((IVariable)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = ::rank();") + 6; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((IVariable) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = ::rank();") + 6; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = ::rank();") + 15; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = ::rank();") + 15; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = this->rank;") + 6; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = this->rank;") + 6; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = this->rank;") + 19; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = this->rank;") + 19; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = rank;") + 6; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = rank;") + 6; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = rank;") + 13; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length ).getParent();
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = rank;") + 13; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression)node).getName().toString(), "rank"); //$NON-NLS-1$
- name = ((IASTIdExpression)node).getName();
+ assertEquals(((IASTIdExpression) node).getName().toString(), "rank"); //$NON-NLS-1$
+ name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
- assertEquals(((IVariable)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = Card::rank;") + 6; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((IVariable) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = Card::rank;") + 6; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = Card::rank;") + 19; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = Card::rank;") + 19; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = getRank();") + 6; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = getRank();") + 6; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = getRank();") + 13; //$NON-NLS-1$
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = getRank();") + 13; //$NON-NLS-1$
length = "getRank".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length ).getParent();
+ node = parse(code, ParserLanguage.CPP, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression)node).getName().toString(), "getRank"); //$NON-NLS-1$
- name = ((IASTIdExpression)node).getName();
+ assertEquals(((IASTIdExpression) node).getName().toString(), "getRank"); //$NON-NLS-1$
+ name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPMethod);
- assertEquals(((ICPPMethod)name.resolveBinding()).getName(), "getRank"); //$NON-NLS-1$
+ assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "getRank"); //$NON-NLS-1$
}
public void testBug77989() throws Exception {
@@ -1014,44 +987,44 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
writer.write("class C{};\n}\n"); //$NON-NLS-1$
writer.write("using namespace N; /* B */\n"); //$NON-NLS-1$
writer.write("N::C c; /* C */\n"); //$NON-NLS-1$
-
+
String code = writer.toString();
- int index = code.indexOf( "using namespace N;") + 16; //$NON-NLS-1$
+ int index = code.indexOf("using namespace N;") + 16; //$NON-NLS-1$
int length = "N".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, index, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "N"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPNamespace);
- assertEquals(((ICPPNamespace)name.resolveBinding()).getName(), "N"); //$NON-NLS-1$
+ assertEquals(((ICPPNamespace) name.resolveBinding()).getName(), "N"); //$NON-NLS-1$
}
public void testBug78435() throws Exception {
Writer writer = new StringWriter();
- writer.write("int itself; //A\n"); //$NON-NLS-1$
+ writer.write("int itself; //A\n"); //$NON-NLS-1$
writer.write("void f(int itself){} //B\n"); //$NON-NLS-1$
-
+
String code = writer.toString();
- int index = code.indexOf( "void f(int itself){}") + 11; //$NON-NLS-1$
+ int index = code.indexOf("void f(int itself){}") + 11; //$NON-NLS-1$
int length = "itself".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, index, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "itself"); //$NON-NLS-1$
- IASTName name = ((IASTDeclarator)node).getName();
+ assertEquals(((IASTDeclarator) node).getName().toString(), "itself"); //$NON-NLS-1$
+ IASTName name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
- assertEquals(((IVariable)name.resolveBinding()).getName(), "itself"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length ).getParent();
+ assertEquals(((IVariable) name.resolveBinding()).getName(), "itself"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "itself"); //$NON-NLS-1$
- name = ((IASTDeclarator)node).getName();
+ assertEquals(((IASTDeclarator) node).getName().toString(), "itself"); //$NON-NLS-1$
+ name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
- assertEquals(((IVariable)name.resolveBinding()).getName(), "itself"); //$NON-NLS-1$
+ assertEquals(((IVariable) name.resolveBinding()).getName(), "itself"); //$NON-NLS-1$
}
public void testBug78231A() throws Exception {
@@ -1059,402 +1032,400 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
writer.write("struct Base {\n"); //$NON-NLS-1$
writer.write("int Data; // 1\n"); //$NON-NLS-1$
writer.write("struct Data; // 2\n};\n"); //$NON-NLS-1$
-
+
String code = writer.toString();
int index = code.indexOf("struct Data;") + 7; //$NON-NLS-1$
int length = "Data".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, index, length );
+ IASTNode node = parse(code, ParserLanguage.C, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Data"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICompositeType);
- assertEquals(((ICompositeType)name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((ICompositeType) name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Data"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICompositeType);
- assertEquals(((ICompositeType)name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$
+ assertEquals(((ICompositeType) name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$
}
-
+
public void testBug78231B() throws Exception {
Writer writer = new StringWriter();
writer.write("int Data;\n"); //$NON-NLS-1$
writer.write("struct Base {\n"); //$NON-NLS-1$
writer.write("int Data; // 1\n"); //$NON-NLS-1$
writer.write("struct Data; // 2\n};\n"); //$NON-NLS-1$
-
+
String code = writer.toString();
int index = code.indexOf("struct Data;") + 7; //$NON-NLS-1$
int length = "Data".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, index, length );
+ IASTNode node = parse(code, ParserLanguage.C, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Data"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICompositeType);
- assertEquals(((ICompositeType)name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((ICompositeType) name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Data"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICompositeType);
- assertEquals(((ICompositeType)name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$
+ assertEquals(((ICompositeType) name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$
}
-
+
public void testSimpleKRCTest1() throws Exception {
StringBuilder buffer = new StringBuilder();
- 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$
-
+ 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$
+
String code = buffer.toString();
int index = code.indexOf("x;"); //$NON-NLS-1$
int length = "x".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, true, true, index, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, true, true, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "x"); //$NON-NLS-1$
- IASTName name = ((IASTDeclarator)node).getName();
+ assertEquals(((IASTDeclarator) node).getName().toString(), "x"); //$NON-NLS-1$
+ IASTName name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IParameter);
- assertEquals(((IParameter)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ assertEquals(((IParameter) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
}
-
+
public void testSimpleKRCTest2() throws Exception {
StringBuilder buffer = new StringBuilder();
- 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$
-
+ 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$
+
String code = buffer.toString();
int index = code.indexOf("x;"); //$NON-NLS-1$
int length = "x".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, true, true, index, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, true, true, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "x"); //$NON-NLS-1$
- IASTName name = ((IASTDeclarator)node).getName();
+ assertEquals(((IASTDeclarator) node).getName().toString(), "x"); //$NON-NLS-1$
+ IASTName name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IParameter);
- assertEquals(((IParameter)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ assertEquals(((IParameter) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
}
-
+
public void testSimpleKRCTest3() throws Exception {
StringBuilder buffer = new StringBuilder();
- 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$
+ 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$
String code = buffer.toString();
int index = code.indexOf("char x;"); //$NON-NLS-1$
int length = "char x;".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, true, true, index, length );
+ IASTNode node = parse(code, ParserLanguage.C, true, true, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTSimpleDeclaration);
- assertEquals( ((IASTSimpleDeclaration)node).getDeclarators()[0].getName().toString(), "x" ); //$NON-NLS-1$
- IASTName name = ((IASTSimpleDeclaration)node).getDeclarators()[0].getName();
+ assertEquals(((IASTSimpleDeclaration) node).getDeclarators()[0].getName().toString(), "x"); //$NON-NLS-1$
+ IASTName name = ((IASTSimpleDeclaration) node).getDeclarators()[0].getName();
assertNotNull(name.resolveBinding());
- assertTrue( name.resolveBinding() instanceof IParameter );
- assertEquals( ((IParameter)name.resolveBinding()).getName(), "x" ); //$NON-NLS-1$
+ assertTrue(name.resolveBinding() instanceof IParameter);
+ assertEquals(((IParameter) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
}
-
+
public void testKRC_1() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "int isroot (x, y) /* comment */ \n" ); //$NON-NLS-1$
- 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$
+ buffer.append("int isroot (x, y) /* comment */ \n"); //$NON-NLS-1$
+ 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$
String code = buffer.toString();
int index = code.indexOf("y;"); //$NON-NLS-1$
int length = "y".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, true, true, index, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, true, true, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "y"); //$NON-NLS-1$
- IASTName name = ((IASTDeclarator)node).getName();
+ assertEquals(((IASTDeclarator) node).getName().toString(), "y"); //$NON-NLS-1$
+ IASTName name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IParameter);
- assertEquals(((IParameter)name.resolveBinding()).getName(), "y"); //$NON-NLS-1$
+ assertEquals(((IParameter) name.resolveBinding()).getName(), "y"); //$NON-NLS-1$
}
-
+
public void testKRCWithTypes() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "typedef char c;\n" ); //$NON-NLS-1$
- buffer.append( "int isroot (c);\n" ); //$NON-NLS-1$
- 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$
+ buffer.append("typedef char c;\n"); //$NON-NLS-1$
+ buffer.append("int isroot (c);\n"); //$NON-NLS-1$
+ 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$
String code = buffer.toString();
int index = code.indexOf("c x;"); //$NON-NLS-1$
int length = "c".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, true, true, index, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, true, true, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTNamedTypeSpecifier);
- assertEquals(((IASTNamedTypeSpecifier)node).getName().toString(), "c"); //$NON-NLS-1$
- IASTName name = ((IASTNamedTypeSpecifier)node).getName();
+ assertEquals(((IASTNamedTypeSpecifier) node).getName().toString(), "c"); //$NON-NLS-1$
+ IASTName name = ((IASTNamedTypeSpecifier) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ITypedef);
- assertEquals(((ITypedef)name.resolveBinding()).getName(), "c"); //$NON-NLS-1$
-
+ assertEquals(((ITypedef) name.resolveBinding()).getName(), "c"); //$NON-NLS-1$
+
index = code.indexOf("x;"); //$NON-NLS-1$
length = "x".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, true, true, index, length ).getParent();
+ node = parse(code, ParserLanguage.C, true, true, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "x"); //$NON-NLS-1$
- name = ((IASTDeclarator)node).getName();
+ assertEquals(((IASTDeclarator) node).getName().toString(), "x"); //$NON-NLS-1$
+ name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IParameter);
- assertEquals(((IParameter)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ assertEquals(((IParameter) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
}
-
+
public void testKRC_monop_cards1() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "#ifdef __STDC__\n" ); //$NON-NLS-1$
- buffer.append( "#define __P(x) x\n" ); //$NON-NLS-1$
- buffer.append( "#else\n" ); //$NON-NLS-1$
- buffer.append( "#define __P(x) ()\n" ); //$NON-NLS-1$
- buffer.append( "#endif\n" ); //$NON-NLS-1$
- buffer.append( "struct A_struct {\n" ); //$NON-NLS-1$
- buffer.append( "int a;\n" ); //$NON-NLS-1$
- buffer.append( "long *c;\n" ); //$NON-NLS-1$
- buffer.append( "};\n" ); //$NON-NLS-1$
- buffer.append( "typedef struct A_struct A;\n" ); //$NON-NLS-1$
- buffer.append( "static void f __P((A *));\n" ); //$NON-NLS-1$
- buffer.append( "static void\n" ); //$NON-NLS-1$
- buffer.append( "f(x)\n" ); //$NON-NLS-1$
- buffer.append( "A *x; {\n" ); //$NON-NLS-1$
- 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$
+ buffer.append("#ifdef __STDC__\n"); //$NON-NLS-1$
+ buffer.append("#define __P(x) x\n"); //$NON-NLS-1$
+ buffer.append("#else\n"); //$NON-NLS-1$
+ buffer.append("#define __P(x) ()\n"); //$NON-NLS-1$
+ buffer.append("#endif\n"); //$NON-NLS-1$
+ buffer.append("struct A_struct {\n"); //$NON-NLS-1$
+ buffer.append("int a;\n"); //$NON-NLS-1$
+ buffer.append("long *c;\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+ buffer.append("typedef struct A_struct A;\n"); //$NON-NLS-1$
+ buffer.append("static void f __P((A *));\n"); //$NON-NLS-1$
+ buffer.append("static void\n"); //$NON-NLS-1$
+ buffer.append("f(x)\n"); //$NON-NLS-1$
+ buffer.append("A *x; {\n"); //$NON-NLS-1$
+ 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$
String code = buffer.toString();
int index = code.indexOf("*c;"); //$NON-NLS-1$
int length = "*".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, index, length );
+ IASTNode node = parse(code, ParserLanguage.C, index, length);
assertNotNull(node);
assertTrue(node instanceof ICASTPointer);
-
-
+
index = code.indexOf("*c;") + 1; //$NON-NLS-1$
length = "c".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, index, length );
+ node = parse(code, ParserLanguage.C, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IField);
- assertEquals(((IField)name.resolveBinding()).getName(), "c"); //$NON-NLS-1$
-
+ assertEquals(((IField) name.resolveBinding()).getName(), "c"); //$NON-NLS-1$
+
index = code.indexOf("c[2]"); //$NON-NLS-1$
length = "c".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, true, true, index, length );
+ node = parse(code, ParserLanguage.C, true, true, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IField);
- assertEquals(((IField)name.resolveBinding()).getName(), "c"); //$NON-NLS-1$
+ assertEquals(((IField) name.resolveBinding()).getName(), "c"); //$NON-NLS-1$
}
-
+
public void testKRC_monop_cards2() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "int\n" ); //$NON-NLS-1$
- 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$
+ buffer.append("int\n"); //$NON-NLS-1$
+ 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$
String code = buffer.toString();
int index = code.indexOf("list[]"); //$NON-NLS-1$
int length = "list".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, true, true, index, length );
+ IASTNode node = parse(code, ParserLanguage.C, true, true, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertEquals(name.toString(), "list"); //$NON-NLS-1$
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IParameter);
- assertEquals(((IParameter)name.resolveBinding()).getName(), "list"); //$NON-NLS-1$
-
+ assertEquals(((IParameter) name.resolveBinding()).getName(), "list"); //$NON-NLS-1$
+
index = code.indexOf("[]"); //$NON-NLS-1$
length = "[]".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, true, true, index, length );
+ node = parse(code, ParserLanguage.C, true, true, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTArrayModifier);
-
+
index = code.indexOf("*const list[]"); //$NON-NLS-1$
length = "*const".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, true, true, index, length );
+ node = parse(code, ParserLanguage.C, true, true, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTPointer);
}
-
-
+
public void testKRC_getParametersOrder() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "int f(a, b) int b,a;{}\n" ); //$NON-NLS-1$
+ buffer.append("int f(a, b) int b,a;{}\n"); //$NON-NLS-1$
String code = buffer.toString();
int index = code.indexOf("b,a"); //$NON-NLS-1$
int length = "b".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, true, true, index, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, true, true, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- IASTName name = ((IASTDeclarator)node).getName();
+ IASTName name = ((IASTDeclarator) node).getName();
assertEquals(name.toString(), "b"); //$NON-NLS-1$
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IParameter);
- assertEquals(((IParameter)name.resolveBinding()).getName(), "b"); //$NON-NLS-1$
+ assertEquals(((IParameter) name.resolveBinding()).getName(), "b"); //$NON-NLS-1$
}
-
+
public void testKRC_Ethereal_1() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "struct symbol {\n" ); //$NON-NLS-1$
- buffer.append( "int lambda;\n};\n" ); //$NON-NLS-1$
- buffer.append( "struct lemon {\n" ); //$NON-NLS-1$
- buffer.append( "struct symbol **symbols;\n" ); //$NON-NLS-1$
- buffer.append( "int errorcnt;\n};\n" ); //$NON-NLS-1$
- buffer.append( "void f(lemp)\n" ); //$NON-NLS-1$
- 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$
+ buffer.append("struct symbol {\n"); //$NON-NLS-1$
+ buffer.append("int lambda;\n};\n"); //$NON-NLS-1$
+ buffer.append("struct lemon {\n"); //$NON-NLS-1$
+ buffer.append("struct symbol **symbols;\n"); //$NON-NLS-1$
+ buffer.append("int errorcnt;\n};\n"); //$NON-NLS-1$
+ buffer.append("void f(lemp)\n"); //$NON-NLS-1$
+ 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$
String code = buffer.toString();
int index = code.indexOf("**symbols"); //$NON-NLS-1$
int length = "*".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, index, length );
+ IASTNode node = parse(code, ParserLanguage.C, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTPointer);
-
+
index = code.indexOf("**symbols") + 1; //$NON-NLS-1$
length = "*".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, index, length );
+ node = parse(code, ParserLanguage.C, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTPointer);
index = code.indexOf("**symbols") + 2; //$NON-NLS-1$
length = "symbols".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, index, length );
+ node = parse(code, ParserLanguage.C, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IField);
- assertEquals(((IField)name.resolveBinding()).getName(), "symbols"); //$NON-NLS-1$
-
+ assertEquals(((IField) name.resolveBinding()).getName(), "symbols"); //$NON-NLS-1$
+
index = code.indexOf("lemp->symbols") + 6; //$NON-NLS-1$
length = "symbols".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, true, true, index, length );
+ node = parse(code, ParserLanguage.C, true, true, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IField);
- assertEquals(((IField)name.resolveBinding()).getName(), "symbols"); //$NON-NLS-1$
+ assertEquals(((IField) name.resolveBinding()).getName(), "symbols"); //$NON-NLS-1$
}
public void testBug86698() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "struct C;\n"); //$NON-NLS-1$
- buffer.append( "void no_opt(C*);\n"); //$NON-NLS-1$
- buffer.append( "struct C {\n"); //$NON-NLS-1$
- buffer.append( "int c;\n"); //$NON-NLS-1$
- buffer.append( "C() : c(0) { no_opt(this); }\n"); //$NON-NLS-1$
- buffer.append( "};\n"); //$NON-NLS-1$
+ buffer.append("struct C;\n"); //$NON-NLS-1$
+ buffer.append("void no_opt(C*);\n"); //$NON-NLS-1$
+ buffer.append("struct C {\n"); //$NON-NLS-1$
+ buffer.append("int c;\n"); //$NON-NLS-1$
+ buffer.append("C() : c(0) { no_opt(this); }\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
String code = buffer.toString();
int index = code.indexOf("c(0)"); //$NON-NLS-1$
int length = "c".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, index, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IField);
- assertEquals(((IField)name.resolveBinding()).getName(), "c"); //$NON-NLS-1$
-
+ assertEquals(((IField) name.resolveBinding()).getName(), "c"); //$NON-NLS-1$
+
}
-
+
public void testLittleThings() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("int a[3];\r\n"); //$NON-NLS-1$
buffer.append("int *b;\r\n"); //$NON-NLS-1$
buffer.append("int &c;\r\n"); //$NON-NLS-1$
buffer.append("char d='e';\r\n"); //$NON-NLS-1$
-
+
String code = buffer.toString();
- int index = 0;
+ int index = 0;
int length = 0;
-
+
IASTNode node = null;
ParserLanguage lang = null;
- for(int i=0; i<2; i++) {
- lang = i==0 ? ParserLanguage.C : ParserLanguage.CPP;
-
+ for (int i = 0; i < 2; i++) {
+ lang = i == 0 ? ParserLanguage.C : ParserLanguage.CPP;
+
index = code.indexOf("[3]"); //$NON-NLS-1$
length = "[3]".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
index = code.indexOf("3"); //$NON-NLS-1$
length = "3".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
index = code.indexOf("*"); //$NON-NLS-1$
length = "*".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
if (lang != ParserLanguage.C) {
index = code.indexOf("&"); //$NON-NLS-1$
length = "&".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
index = code.indexOf("&c"); //$NON-NLS-1$
length = "&c".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
}
-
+
index = code.indexOf("int a"); //$NON-NLS-1$
length = "int".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
index = code.indexOf("int a[3];"); //$NON-NLS-1$
length = "int a[3];".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
index = code.indexOf("a[3]"); //$NON-NLS-1$
length = "a[3]".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
index = code.indexOf("*b"); //$NON-NLS-1$
length = "*b".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
index = code.indexOf("'e'"); //$NON-NLS-1$
length = "'e'".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
}
}
-
+
public void testSimpleWindowsPreprocessorSelections() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("#define ONE 1\r\n"); //$NON-NLS-1$
@@ -1463,44 +1434,44 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
buffer.append("#else\r\n"); //$NON-NLS-1$
buffer.append("char c='c';\r\n"); //$NON-NLS-1$
buffer.append("#endif\r\n"); //$NON-NLS-1$
-
+
String code = buffer.toString();
- int index = 0;
+ int index = 0;
int length = 0;
-
+
IASTNode node = null;
ParserLanguage lang = null;
- for(int i=0; i<2; i++) {
- lang = i==0 ? ParserLanguage.C : ParserLanguage.CPP;
-
+ for (int i = 0; i < 2; i++) {
+ lang = i == 0 ? ParserLanguage.C : ParserLanguage.CPP;
+
index = code.indexOf("#define ONE 1"); //$NON-NLS-1$
length = "#define ONE 1".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
// TODO bug 87179
-// index = code.indexOf("#ifdef ONE"); //$NON-NLS-1$
-// length = "#ifdef ONE".length(); //$NON-NLS-1$
-// node = parse( code, lang, index, length );
-// assertNotNull(node);
-
+ // index = code.indexOf("#ifdef ONE"); //$NON-NLS-1$
+ // length = "#ifdef ONE".length(); //$NON-NLS-1$
+ // node = parse( code, lang, index, length );
+ // assertNotNull(node);
+
index = code.indexOf("int x=0;"); //$NON-NLS-1$
length = "int x=0;".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
index = code.indexOf("#else"); //$NON-NLS-1$
length = "#else".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
index = code.indexOf("#endif"); //$NON-NLS-1$
length = "#endif".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
}
}
-
+
public void testBug86993() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("#define _BEGIN_STD_C extern \"C\" {\r\n"); //$NON-NLS-1$
@@ -1508,24 +1479,24 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
buffer.append("_BEGIN_STD_C\r\n"); //$NON-NLS-1$
buffer.append("char c;\r\n"); //$NON-NLS-1$
buffer.append("_END_STD_C\r\n"); //$NON-NLS-1$
-
+
String code = buffer.toString();
- int index = 0;
+ int index = 0;
int length = 0;
-
+
IASTNode node = null;
-
+
index = code.indexOf("c;"); //$NON-NLS-1$
length = "c".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length ).getParent();
+ node = parse(code, ParserLanguage.CPP, index, length).getParent();
assertNotNull(node);
- assertTrue( node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "c"); //$NON-NLS-1$
- IASTName name = ((IASTDeclarator)node).getName();
+ assertTrue(node instanceof IASTDeclarator);
+ assertEquals(((IASTDeclarator) node).getName().toString(), "c"); //$NON-NLS-1$
+ IASTName name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
}
-
+
public void testBug86870() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("#if VERSION == 1\r\n"); //$NON-NLS-1$
@@ -1535,47 +1506,46 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
buffer.append("#else\r\n"); //$NON-NLS-1$
buffer.append("#define INCFILE \"versN.h\"\r\n"); //$NON-NLS-1$
buffer.append("#endif\r\n"); //$NON-NLS-1$
-
+
String code = buffer.toString();
- int offset1 = code.indexOf( "#if VERSION == 1" ); //$NON-NLS-1$
+ int offset1 = code.indexOf("#if VERSION == 1"); //$NON-NLS-1$
int length = "#if VERSION == 1".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, offset1, length );
+ IASTNode node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
- assertEquals( ((ASTNode)node).getLength(), length);
-
- offset1 = code.indexOf( "#elif VERSION == 2" ); //$NON-NLS-1$
+ assertEquals(((ASTNode) node).getLength(), length);
+
+ offset1 = code.indexOf("#elif VERSION == 2"); //$NON-NLS-1$
length = "#elif VERSION == 2".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, offset1, length );
+ node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
- assertEquals( ((ASTNode)node).getLength(), length);
-
- offset1 = code.indexOf( "#else" ); //$NON-NLS-1$
+ assertEquals(((ASTNode) node).getLength(), length);
+
+ offset1 = code.indexOf("#else"); //$NON-NLS-1$
length = "#else".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, offset1, length );
+ node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
- assertEquals( ((ASTNode)node).getLength(), length);
+ assertEquals(((ASTNode) node).getLength(), length);
- offset1 = code.indexOf( "#define INCFILE \"versN.h\"" ); //$NON-NLS-1$
+ offset1 = code.indexOf("#define INCFILE \"versN.h\""); //$NON-NLS-1$
length = "#define INCFILE \"versN.h\"".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, offset1, length );
+ node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
- assertEquals( ((ASTNode)node).getLength(), length);
-
- offset1 = code.indexOf( "INCFILE \"versN.h\"" ); //$NON-NLS-1$
+ assertEquals(((ASTNode) node).getLength(), length);
+
+ offset1 = code.indexOf("INCFILE \"versN.h\""); //$NON-NLS-1$
length = "INCFILE".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, offset1, length );
+ node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
- assertEquals( ((ASTNode)node).getLength(), length);
-
- offset1 = code.indexOf( "#endif" ); //$NON-NLS-1$
+ assertEquals(((ASTNode) node).getLength(), length);
+
+ offset1 = code.indexOf("#endif"); //$NON-NLS-1$
length = "#endif".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, offset1, length );
+ node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
- assertEquals( ((ASTNode)node).getLength(), length);
+ assertEquals(((ASTNode) node).getLength(), length);
}
-
- public void testBug87179() throws Exception
- {
+
+ public void testBug87179() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("#define ONE 1\r\n"); //$NON-NLS-1$
buffer.append("#ifdef ONE\r\n"); //$NON-NLS-1$
@@ -1583,26 +1553,26 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
buffer.append("#else\r\n"); //$NON-NLS-1$
buffer.append("char c='c';\r\n"); //$NON-NLS-1$
buffer.append("#endif\r\n"); //$NON-NLS-1$
-
+
String code = buffer.toString();
- int offset1 = code.indexOf( "#ifdef ONE" ); //$NON-NLS-1$
+ int offset1 = code.indexOf("#ifdef ONE"); //$NON-NLS-1$
int length = "#ifdef ONE".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, offset1, length );
+ IASTNode node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
}
public void testBug96702() throws Exception {
importFile("test.h", "int x;\n"); //$NON-NLS-1$ //$NON-NLS-2$
String code = "#include \"test.h\" // comment \nvoid f(); // comment \n"; //$NON-NLS-1$
-
- int offset = code.indexOf( "f()" ); //$NON-NLS-1$
+
+ int offset = code.indexOf("f()"); //$NON-NLS-1$
IFile file = importFile("blah.c", code);
- IASTNode node = parse( file, ParserLanguage.C, offset, 1 ); // select f();
+ IASTNode node = parse(file, ParserLanguage.C, offset, 1); // select f();
assertTrue(node instanceof IASTName);
- assertEquals(((ASTNode)node).getOffset(), 44);
- assertEquals(((ASTNode)node).getLength(), 1);
+ assertEquals(((ASTNode) node).getOffset(), 44);
+ assertEquals(((ASTNode) node).getLength(), 1);
}
-
+
public void testBug97301() throws Exception {
StringBuilder buffer = new StringBuilder();
// test2.h:
@@ -1621,8 +1591,7 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
buffer.append("#endif\r\n"); //$NON-NLS-1$
String test2_h = buffer.toString();
importFile("test2.h", test2_h); //$NON-NLS-1$
-
-
+
// test1.h:
buffer = new StringBuilder();
buffer.append("#ifdef RC_INVOKED\r\n"); //$NON-NLS-1$
@@ -1632,35 +1601,34 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
buffer.append("#endif\r\n"); //$NON-NLS-1$
buffer.append("#endif\r\n"); //$NON-NLS-1$
importFile("test1.h", buffer.toString()); //$NON-NLS-1$
-
+
// test.c:
IFile file = importFile("test.c", "#include \"test1.h\""); //$NON-NLS-1$ //$NON-NLS-2$
-
+
IASTTranslationUnit tu = parse(file, ParserLanguage.CPP, false, true);
IASTPreprocessorStatement[] stmts = tu.getAllPreprocessorStatements();
IASTFileLocation fileLoc = stmts[5].getFileLocation();
int fileOffset = test2_h.indexOf("#ifndef _WINGDI_H");
- int fileLocOffset = fileLoc.getNodeOffset();
+ int fileLocOffset = fileLoc.getNodeOffset();
assertEquals(fileOffset, fileLocOffset);
}
-
+
public void testBug86126() throws Exception {
- String header= "foo"+System.currentTimeMillis()+".h";
- String source= "blah"+System.currentTimeMillis()+".c";
- importFile(header, "int x;\r\n"); //$NON-NLS-1$
- String code = "#include \""+header+"\"\r\n"; //$NON-NLS-1$
+ String header = "foo" + System.currentTimeMillis() + ".h";
+ String source = "blah" + System.currentTimeMillis() + ".c";
+ importFile(header, "int x;\r\n"); //$NON-NLS-1$
+ String code = "#include \"" + header + "\"\r\n"; //$NON-NLS-1$
IFile file = importFile(source, code);
- int offset1 = code.indexOf( "#include \""+header+"\"" ); //$NON-NLS-1$
- int length = ("#include \""+header+"\"").length(); //$NON-NLS-1$
- IASTNode node = parse( file, ParserLanguage.C, offset1, length );
+ int offset1 = code.indexOf("#include \"" + header + "\""); //$NON-NLS-1$
+ int length = ("#include \"" + header + "\"").length(); //$NON-NLS-1$
+ IASTNode node = parse(file, ParserLanguage.C, offset1, length);
assertNotNull(node);
}
-
- public void testBug98806() throws Exception {
- String code = "template <class T> class A { typedef typename T::B _B;};";
- IASTNode node = parse( code, ParserLanguage.CPP, code.indexOf( "T::B"), "T::B".length() );
- assertNotNull( node );
- assertTrue( node instanceof IASTName );
- }
+ public void testBug98806() throws Exception {
+ String code = "template <class T> class A { typedef typename T::B _B;};";
+ IASTNode node = parse(code, ParserLanguage.CPP, code.indexOf("T::B"), "T::B".length());
+ assertNotNull(node);
+ assertTrue(node instanceof IASTName);
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTestBase.java
index 0ebfebbaca1..1b3c460d146 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTestBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTestBase.java
@@ -45,7 +45,7 @@ import org.eclipse.core.resources.IFile;
*/
public class AST2SelectionParseTestBase extends FileBasePluginTestCase {
- public AST2SelectionParseTestBase() {
+ public AST2SelectionParseTestBase() {
}
public AST2SelectionParseTestBase(String name) {
@@ -53,7 +53,7 @@ public class AST2SelectionParseTestBase extends FileBasePluginTestCase {
}
private static final IParserLogService NULL_LOG = new NullLogService();
-
+
public AST2SelectionParseTestBase(String name, Class className) {
super(name, className);
}
@@ -61,81 +61,85 @@ public class AST2SelectionParseTestBase extends FileBasePluginTestCase {
protected IASTNode parse(String code, ParserLanguage lang, int offset, int length) throws ParserException {
return parse(code, lang, false, false, offset, length);
}
-
+
protected IASTNode parse(IFile file, ParserLanguage lang, int offset, int length) throws ParserException {
IASTTranslationUnit tu = parse(file, lang, false, false);
return tu.getNodeSelector(null).findNode(offset, length);
}
-
- protected IASTNode parse(String code, ParserLanguage lang, int offset, int length, boolean expectedToPass) throws ParserException {
+
+ protected IASTNode parse(String code, ParserLanguage lang, int offset, int length, boolean expectedToPass)
+ throws ParserException {
return parse(code, lang, false, expectedToPass, offset, length);
}
-
- protected IASTNode parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems, int offset, int length) throws ParserException {
+
+ protected IASTNode parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems,
+ int offset, int length) throws ParserException {
IASTTranslationUnit tu = parse(code, lang, useGNUExtensions, expectNoProblems);
return tu.getNodeSelector(null).findNode(offset, length);
- }
+ }
- protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems) throws ParserException {
+ protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
+ boolean expectNoProblems) throws ParserException {
FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
- ScannerInfo scannerInfo = new ScannerInfo();
- IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
-
- ISourceCodeParser parser2 = null;
- if (lang == ParserLanguage.CPP) {
- ICPPParserExtensionConfiguration config = null;
- if (useGNUExtensions)
- config = new GPPParserExtensionConfiguration();
- else
- config = new ANSICPPParserExtensionConfiguration();
- parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
- } else {
- ICParserExtensionConfiguration config = null;
-
- if (useGNUExtensions)
- config = new GCCParserExtensionConfiguration();
- else
- config = new ANSICParserExtensionConfiguration();
-
- parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
- }
-
- IASTTranslationUnit tu = parser2.parse();
-
- if (parser2.encounteredError() && expectNoProblems)
- throw new ParserException("FAILURE"); //$NON-NLS-1$
-
- if (lang == ParserLanguage.C && expectNoProblems) {
- assertEquals(CVisitor.getProblems(tu).length, 0);
- assertEquals(tu.getPreprocessorProblems().length, 0);
- } else if (lang == ParserLanguage.CPP && expectNoProblems) {
- assertEquals(CPPVisitor.getProblems(tu).length, 0);
- assertEquals(tu.getPreprocessorProblems().length, 0);
- }
- if (expectNoProblems)
- assertEquals(0, tu.getPreprocessorProblems().length);
-
- return tu;
- }
-
- protected IASTTranslationUnit parse(IFile file, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems) throws ParserException {
- IASTTranslationUnit tu= null;
+ ScannerInfo scannerInfo = new ScannerInfo();
+ IScanner scanner = AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
+
+ ISourceCodeParser parser2 = null;
+ if (lang == ParserLanguage.CPP) {
+ ICPPParserExtensionConfiguration config = null;
+ if (useGNUExtensions)
+ config = new GPPParserExtensionConfiguration();
+ else
+ config = new ANSICPPParserExtensionConfiguration();
+ parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
+ } else {
+ ICParserExtensionConfiguration config = null;
+
+ if (useGNUExtensions)
+ config = new GCCParserExtensionConfiguration();
+ else
+ config = new ANSICParserExtensionConfiguration();
+
+ parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
+ }
+
+ IASTTranslationUnit tu = parser2.parse();
+
+ if (parser2.encounteredError() && expectNoProblems)
+ throw new ParserException("FAILURE"); //$NON-NLS-1$
+
+ if (lang == ParserLanguage.C && expectNoProblems) {
+ assertEquals(CVisitor.getProblems(tu).length, 0);
+ assertEquals(tu.getPreprocessorProblems().length, 0);
+ } else if (lang == ParserLanguage.CPP && expectNoProblems) {
+ assertEquals(CPPVisitor.getProblems(tu).length, 0);
+ assertEquals(tu.getPreprocessorProblems().length, 0);
+ }
+ if (expectNoProblems)
+ assertEquals(0, tu.getPreprocessorProblems().length);
+
+ return tu;
+ }
+
+ protected IASTTranslationUnit parse(IFile file, ParserLanguage lang, boolean useGNUExtensions,
+ boolean expectNoProblems) throws ParserException {
+ IASTTranslationUnit tu = null;
try {
tu = CDOM.getInstance().getASTService().getTranslationUnit(file);
} catch (UnsupportedDialectException e) {
assertFalse(true); // shouldn't happen
}
- if (lang == ParserLanguage.C && expectNoProblems) {
- assertEquals(CVisitor.getProblems(tu).length, 0);
- assertEquals(tu.getPreprocessorProblems().length, 0);
- } else if (lang == ParserLanguage.CPP && expectNoProblems) {
- assertEquals(CPPVisitor.getProblems(tu).length, 0);
- assertEquals(tu.getPreprocessorProblems().length, 0);
- }
- if (expectNoProblems)
- assertEquals(0, tu.getPreprocessorProblems().length);
-
- return tu;
- }
+ if (lang == ParserLanguage.C && expectNoProblems) {
+ assertEquals(CVisitor.getProblems(tu).length, 0);
+ assertEquals(tu.getPreprocessorProblems().length, 0);
+ } else if (lang == ParserLanguage.CPP && expectNoProblems) {
+ assertEquals(CPPVisitor.getProblems(tu).length, 0);
+ assertEquals(tu.getPreprocessorProblems().length, 0);
+ }
+ if (expectNoProblems)
+ assertEquals(0, tu.getPreprocessorProblems().length);
+
+ return tu;
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecTestBase.java
index 08f1d7150b6..cd08241332b 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecTestBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecTestBase.java
@@ -61,83 +61,86 @@ public class AST2SpecTestBase extends AST2TestBase {
* @param expectedProblemBindings the number of problem bindings you expect to encounter
* @throws ParserException
*/
- protected void parseCandCPP(String code, boolean checkBindings, int expectedProblemBindings) throws ParserException {
+ protected void parseCandCPP(String code, boolean checkBindings, int expectedProblemBindings)
+ throws ParserException {
parse(code, ParserLanguage.C, false, true, checkBindings, expectedProblemBindings, null);
parse(code, ParserLanguage.CPP, false, true, checkBindings, expectedProblemBindings, null);
}
protected IASTTranslationUnit parseWithErrors(String code, ParserLanguage lang) throws ParserException {
- return parse(code, lang, false, false, false, 0, null);
- }
+ return parse(code, lang, false, false, false, 0, null);
+ }
+
+ protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean checkBindings,
+ int expectedProblemBindings) throws ParserException {
+ return parse(code, lang, false, true, checkBindings, expectedProblemBindings, null);
+ }
- protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean checkBindings, int expectedProblemBindings) throws ParserException {
- return parse(code, lang, false, true, checkBindings, expectedProblemBindings, null);
- }
-
protected IASTTranslationUnit parse(String code, ParserLanguage lang, String[] problems) throws ParserException {
- return parse(code, lang, false, true, true, problems.length, problems);
+ return parse(code, lang, false, true, true, problems.length, problems);
}
-
- private IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems,
- boolean checkBindings, int expectedProblemBindings, String[] problems) throws ParserException {
+
+ private IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
+ boolean expectNoProblems, boolean checkBindings, int expectedProblemBindings, String[] problems)
+ throws ParserException {
// TODO beef this up with tests... i.e. run once with \n, and then run again with \r\n replacing \n ... etc
// TODO another example might be to replace all characters with corresponding trigraph/digraph tests...
-
- FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
- return parse(codeReader, lang, useGNUExtensions, expectNoProblems, checkBindings, expectedProblemBindings, problems);
- }
-
-// private IASTTranslationUnit parse(IFile filename, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems) throws ParserException {
-// CodeReader codeReader=null;
-// try {
-// codeReader = new CodeReader(filename.getName(), filename.getContents());
-// } catch (IOException e) {
-// e.printStackTrace();
-// } catch (CoreException e) {
-// e.printStackTrace();
-// }
-//
-// return parse(codeReader, lang, useGNUExtensions, expectNoProblems);
-// }
-
- private IASTTranslationUnit parse(FileContent codeReader, ParserLanguage lang,
- boolean useGNUExtensions, boolean expectNoProblems, boolean checkBindings,
- int expectedProblemBindings, String[] problems) throws ParserException {
- ScannerInfo scannerInfo = new ScannerInfo();
- IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
-
- ISourceCodeParser parser2 = null;
- if (lang == ParserLanguage.CPP) {
- ICPPParserExtensionConfiguration config = null;
- if (useGNUExtensions)
- config = new GPPParserExtensionConfiguration();
- else
- config = new ANSICPPParserExtensionConfiguration();
- parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
- } else {
- ICParserExtensionConfiguration config = null;
-
- if (useGNUExtensions)
- config = new GCCParserExtensionConfiguration();
- else
- config = new ANSICParserExtensionConfiguration();
-
- parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE,
- NULL_LOG, config);
- }
-
- if (expectedProblemBindings > 0)
- CPPASTNameBase.sAllowNameComputation= true;
-
- IASTTranslationUnit tu = parser2.parse();
-
+
+ FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
+ return parse(codeReader, lang, useGNUExtensions, expectNoProblems, checkBindings, expectedProblemBindings,
+ problems);
+ }
+
+ // private IASTTranslationUnit parse(IFile filename, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems) throws ParserException {
+ // CodeReader codeReader=null;
+ // try {
+ // codeReader = new CodeReader(filename.getName(), filename.getContents());
+ // } catch (IOException e) {
+ // e.printStackTrace();
+ // } catch (CoreException e) {
+ // e.printStackTrace();
+ // }
+ //
+ // return parse(codeReader, lang, useGNUExtensions, expectNoProblems);
+ // }
+
+ private IASTTranslationUnit parse(FileContent codeReader, ParserLanguage lang, boolean useGNUExtensions,
+ boolean expectNoProblems, boolean checkBindings, int expectedProblemBindings, String[] problems)
+ throws ParserException {
+ ScannerInfo scannerInfo = new ScannerInfo();
+ IScanner scanner = AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
+
+ ISourceCodeParser parser2 = null;
+ if (lang == ParserLanguage.CPP) {
+ ICPPParserExtensionConfiguration config = null;
+ if (useGNUExtensions)
+ config = new GPPParserExtensionConfiguration();
+ else
+ config = new ANSICPPParserExtensionConfiguration();
+ parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
+ } else {
+ ICParserExtensionConfiguration config = null;
+
+ if (useGNUExtensions)
+ config = new GCCParserExtensionConfiguration();
+ else
+ config = new ANSICParserExtensionConfiguration();
+
+ parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
+ }
+
+ if (expectedProblemBindings > 0)
+ CPPASTNameBase.sAllowNameComputation = true;
+
+ IASTTranslationUnit tu = parser2.parse();
+
// resolve all bindings
if (checkBindings) {
NameResolver res = new NameResolver();
- tu.accept(res);
+ tu.accept(res);
if (res.problemBindings.size() != expectedProblemBindings)
- throw new ParserException("Expected " + expectedProblemBindings +
- " problems, encountered " + res.problemBindings.size());
+ throw new ParserException(
+ "Expected " + expectedProblemBindings + " problems, encountered " + res.problemBindings.size());
if (problems != null) {
for (int i = 0; i < problems.length; i++) {
assertEquals(problems[i], res.problemBindings.get(i));
@@ -145,37 +148,37 @@ public class AST2SpecTestBase extends AST2TestBase {
}
}
- if (parser2.encounteredError() && expectNoProblems)
- throw new ParserException("FAILURE");
-
- if (lang == ParserLanguage.C && expectNoProblems) {
+ if (parser2.encounteredError() && expectNoProblems)
+ throw new ParserException("FAILURE");
+
+ if (lang == ParserLanguage.C && expectNoProblems) {
if (CVisitor.getProblems(tu).length != 0) {
- throw new ParserException("CVisitor has AST Problems");
+ throw new ParserException("CVisitor has AST Problems");
}
if (tu.getPreprocessorProblems().length != 0) {
- throw new ParserException("C TranslationUnit has Preprocessor Problems");
+ throw new ParserException("C TranslationUnit has Preprocessor Problems");
}
- } else if (lang == ParserLanguage.CPP && expectNoProblems) {
+ } else if (lang == ParserLanguage.CPP && expectNoProblems) {
if (CPPVisitor.getProblems(tu).length != 0) {
- throw new ParserException("CPPVisitor has AST Problems");
+ throw new ParserException("CPPVisitor has AST Problems");
}
if (tu.getPreprocessorProblems().length != 0) {
- throw new ParserException("CPP TranslationUnit has Preprocessor Problems");
+ throw new ParserException("CPP TranslationUnit has Preprocessor Problems");
}
- }
-
- return tu;
+ }
+
+ return tu;
}
-
+
static protected class NameResolver extends ASTVisitor {
{
shouldVisitNames = true;
}
-
+
public List<IASTName> nameList = new ArrayList<IASTName>();
public List<String> problemBindings = new ArrayList<String>();
public int numNullBindings = 0;
-
+
@Override
public int visit(IASTName name) {
nameList.add(name);
@@ -186,15 +189,15 @@ public class AST2SpecTestBase extends AST2TestBase {
numNullBindings++;
return PROCESS_CONTINUE;
}
-
+
public IASTName getName(int idx) {
if (idx < 0 || idx >= nameList.size())
return null;
return nameList.get(idx);
}
-
- public int size() {
- return nameList.size();
+
+ public int size() {
+ return nameList.size();
}
}
}
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 292a165d23f..42e967458c5 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
@@ -183,7 +183,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertSame(A_int, a.getType());
assertTrue(A_int instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A_int).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A_int).getTemplateDefinition(), A);
ICPPClassScope A_int_Scope = (ICPPClassScope) A_int.getCompositeScope();
assertNotSame(A_int_Scope, ((ICompositeType) A).getCompositeScope());
@@ -228,7 +228,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A_int = (ICPPClassType) col.getName(7).resolveBinding();
assertTrue(A_int instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A_int).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A_int).getTemplateDefinition(), A);
ICPPMethod f_int = (ICPPMethod) col.getName(11).resolveBinding();
assertTrue(f_int instanceof ICPPSpecialization);
@@ -303,9 +303,11 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPTemplateParameter T1 = (ICPPTemplateParameter) col.getName(0).resolveBinding();
ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding();
ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(2).resolveBinding();
- ICPPClassTemplatePartialSpecialization A2 = (ICPPClassTemplatePartialSpecialization) col.getName(3).resolveBinding();
+ ICPPClassTemplatePartialSpecialization A2 = (ICPPClassTemplatePartialSpecialization) col.getName(3)
+ .resolveBinding();
ICPPTemplateParameter T3 = (ICPPTemplateParameter) col.getName(5).resolveBinding();
- ICPPClassTemplatePartialSpecialization A3 = (ICPPClassTemplatePartialSpecialization) col.getName(7).resolveBinding();
+ ICPPClassTemplatePartialSpecialization A3 = (ICPPClassTemplatePartialSpecialization) col.getName(7)
+ .resolveBinding();
ICPPTemplateParameter T4 = (ICPPTemplateParameter) col.getName(6).resolveBinding();
assertSame(A2.getPrimaryClassTemplate(), A1);
@@ -385,7 +387,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// const int *p;
// f(p); //calls f(const T *) , 3 is more specialized than 1 or 2
// }
- public void test14_5_5_2s5_OrderingFunctionTemplates_a() throws Exception{
+ public void test14_5_5_2s5_OrderingFunctionTemplates_a() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -409,7 +411,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// float x;
// f(x); //ambiguous 1 or 2
// }
- public void test14_5_5_2s5_OrderingFunctionTemplates_b() throws Exception{
+ public void test14_5_5_2s5_OrderingFunctionTemplates_b() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -492,7 +494,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// A <int, char*, 5> a3; //uses #4, T is char
// A <int, char*, 1> a4; //uses #5, T is int, T2 is char, I is1
// A <int*, int*, 2> a5; //ambiguous, matches #3 & #5.
- public void test14_5_4_1s2_MatchingTemplateSpecializations() throws Exception{
+ public void test14_5_4_1s2_MatchingTemplateSpecializations() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -504,7 +506,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassTemplate A5 = (ICPPClassTemplate) col.getName(26).resolveBinding();
assertTrue(A3 instanceof ICPPClassTemplatePartialSpecialization);
- assertSame(((ICPPClassTemplatePartialSpecialization)A3).getPrimaryClassTemplate(), A1);
+ assertSame(((ICPPClassTemplatePartialSpecialization) A3).getPrimaryClassTemplate(), A1);
ICPPTemplateTypeParameter T1 = (ICPPTemplateTypeParameter) col.getName(11).resolveBinding();
ICPPTemplateTypeParameter T2 = (ICPPTemplateTypeParameter) col.getName(12).resolveBinding();
@@ -820,7 +822,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A1 = (ICPPClassType) col.getName(7).resolveBinding();
assertTrue(A1 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A1).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A1).getTemplateDefinition(), A);
ICPPField u2 = (ICPPField) col.getName(11).resolveBinding();
assertTrue(u2 instanceof ICPPSpecialization);
@@ -846,7 +848,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertSame(A1, A2);
assertTrue(A1 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A1).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A1).getTemplateDefinition(), A);
}
// template <class T> void f(T);
@@ -886,7 +888,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertSame(A1, A2);
assertTrue(A1 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A1).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A1).getTemplateDefinition(), A);
ICPPClassType AI = (ICPPClassType) col.getName(10).resolveBinding();
ICPPMethod f2 = (ICPPMethod) col.getName(14).resolveBinding();
@@ -935,7 +937,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A2 = (ICPPClassType) col.getName(9).resolveBinding();
assertTrue(A2 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A2).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A2).getTemplateDefinition(), A);
ICPPMethod f2_2 = (ICPPMethod) col.getName(16).resolveBinding();
assertTrue(f2_2 instanceof ICPPSpecialization);
@@ -972,7 +974,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A2 = (ICPPClassType) col.getName(2).resolveBinding();
assertTrue(A2 instanceof ICPPSpecialization);
- assertSame(((ICPPSpecialization)A2).getSpecializedBinding(), A1);
+ assertSame(((ICPPSpecialization) A2).getSpecializedBinding(), A1);
ICPPClassType r1 = (ICPPClassType) col.getName(4).resolveBinding();
ICPPClassType r2 = (ICPPClassType) col.getName(7).resolveBinding();
@@ -1005,7 +1007,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A2 = (ICPPClassType) col.getName(5).resolveBinding();
assertTrue(A2 instanceof ICPPSpecialization);
- assertSame(((ICPPSpecialization)A2).getSpecializedBinding(), A1);
+ assertSame(((ICPPSpecialization) A2).getSpecializedBinding(), A1);
ICPPMethod f2 = (ICPPMethod) col.getName(7).resolveBinding();
assertNotSame(f1, f2);
@@ -1044,13 +1046,13 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A1 = (ICPPClassType) col.getName(11).resolveBinding();
assertTrue(A1 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A1).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A1).getTemplateDefinition(), A);
ICPPClassType B1 = (ICPPClassType) col.getName(13).resolveBinding();
assertTrue(B1 instanceof ICPPTemplateInstance);
- ICPPClassType B2 = (ICPPClassType) ((ICPPTemplateInstance)B1).getTemplateDefinition();
+ ICPPClassType B2 = (ICPPClassType) ((ICPPTemplateInstance) B1).getTemplateDefinition();
assertTrue(B2 instanceof ICPPSpecialization);
- assertSame(((ICPPSpecialization)B2).getSpecializedBinding(), B);
+ assertSame(((ICPPSpecialization) B2).getSpecializedBinding(), B);
ICPPMethod f1 = (ICPPMethod) col.getName(20).resolveBinding();
assertTrue(f1 instanceof ICPPSpecialization);
@@ -1080,11 +1082,12 @@ public class AST2TemplateTests extends AST2CPPTestBase {
tu.accept(col);
ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(3).resolveBinding();
- ICPPClassTemplatePartialSpecialization A2 = (ICPPClassTemplatePartialSpecialization) col.getName(9).resolveBinding();
+ ICPPClassTemplatePartialSpecialization A2 = (ICPPClassTemplatePartialSpecialization) col.getName(9)
+ .resolveBinding();
ICPPClassType A3 = (ICPPClassType) col.getName(13).resolveBinding();
assertTrue(A3 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A3).getTemplateDefinition(), A2);
+ assertSame(((ICPPTemplateInstance) A3).getTemplateDefinition(), A2);
ICPPClassTemplate A4 = (ICPPClassTemplate) col.getName(14).resolveBinding();
assertSame(A4, A1);
@@ -1111,7 +1114,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding();
ICPPField x1 = (ICPPField) col.getName(2).resolveBinding();
- ICPPClassTemplatePartialSpecialization A2 = (ICPPClassTemplatePartialSpecialization) col.getName(4).resolveBinding();
+ ICPPClassTemplatePartialSpecialization A2 = (ICPPClassTemplatePartialSpecialization) col.getName(4)
+ .resolveBinding();
ICPPField x2 = (ICPPField) col.getName(7).resolveBinding();
ICPPClassTemplate C = (ICPPClassTemplate) col.getName(10).resolveBinding();
@@ -1120,7 +1124,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType C1 = (ICPPClassType) col.getName(18).resolveBinding();
assertTrue(C1 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)C1).getTemplateDefinition(), C);
+ assertSame(((ICPPTemplateInstance) C1).getTemplateDefinition(), C);
ICPPField y2 = (ICPPField) col.getName(23).resolveBinding();
assertTrue(y2 instanceof ICPPSpecialization);
@@ -1250,9 +1254,9 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType Acb = (ICPPClassType) col.getName(14).resolveBinding();
assertTrue(Acb instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)Acb).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) Acb).getTemplateDefinition(), A);
- ICPPField s2 = (ICPPField) col.getName(21).resolveBinding();
+ ICPPField s2 = (ICPPField) col.getName(21).resolveBinding();
assertTrue(s2 instanceof ICPPSpecialization);
assertSame(((ICPPSpecialization) s2).getSpecializedBinding(), s);
@@ -1290,7 +1294,6 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A3 = (ICPPClassType) col.getName(9).resolveBinding();
assertSame(A, A3);
-
ICPPTemplateParameter U2 = (ICPPTemplateParameter) col.getName(13).resolveBinding();
assertSame(U, U2);
assertSame(T, U);
@@ -1335,13 +1338,13 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// A<B> ab;
// A<C> ac;
public void testEnclosingScopes_a() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPSpecialization b0= ba.assertNonProblem("A<B>", 4, ICPPSpecialization.class, ICPPClassType.class);
- ICPPTemplateInstance b1= ba.assertNonProblem("A<C>", 4, ICPPTemplateInstance.class, ICPPClassType.class);
+ ICPPSpecialization b0 = ba.assertNonProblem("A<B>", 4, ICPPSpecialization.class, ICPPClassType.class);
+ ICPPTemplateInstance b1 = ba.assertNonProblem("A<C>", 4, ICPPTemplateInstance.class, ICPPClassType.class);
- ICPPClassType sc0= assertInstance(b0.getSpecializedBinding(), ICPPClassType.class);
- ICPPClassType sc1= assertInstance(b1.getSpecializedBinding(), ICPPClassType.class);
+ ICPPClassType sc0 = assertInstance(b0.getSpecializedBinding(), ICPPClassType.class);
+ ICPPClassType sc1 = assertInstance(b1.getSpecializedBinding(), ICPPClassType.class);
assertTrue(sc0.isSameType(sc1));
assertInstance(b0, ICPPSpecialization.class);
@@ -1349,8 +1352,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertInstance(b0.getScope(), ICPPTemplateScope.class);
- IScope ts0= ((ICPPClassType) b0.getSpecializedBinding()).getScope();
- IScope ts1= ((ICPPClassType) b1.getSpecializedBinding()).getScope();
+ IScope ts0 = ((ICPPClassType) b0.getSpecializedBinding()).getScope();
+ IScope ts1 = ((ICPPClassType) b1.getSpecializedBinding()).getScope();
assertInstance(ts0, ICPPTemplateScope.class);
@@ -1376,18 +1379,18 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// A<D>::B adb;
// }
public void testEnclosingScopes_b() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPClassType b0= ba.assertNonProblem("B acb", 1, ICPPClassType.class);
- ICPPClassType b1= ba.assertNonProblem("B adb", 1, ICPPClassType.class, ICPPSpecialization.class);
- ICPPClassType b2= ba.assertNonProblem("A<C>", 4, ICPPClassType.class, ICPPSpecialization.class);
- ICPPClassType b3= ba.assertNonProblem("A {", 1, ICPPClassType.class, ICPPTemplateDefinition.class);
- ICPPClassType b4= ba.assertNonProblem("B {}", 1, ICPPClassType.class);
+ ICPPClassType b0 = ba.assertNonProblem("B acb", 1, ICPPClassType.class);
+ ICPPClassType b1 = ba.assertNonProblem("B adb", 1, ICPPClassType.class, ICPPSpecialization.class);
+ ICPPClassType b2 = ba.assertNonProblem("A<C>", 4, ICPPClassType.class, ICPPSpecialization.class);
+ ICPPClassType b3 = ba.assertNonProblem("A {", 1, ICPPClassType.class, ICPPTemplateDefinition.class);
+ ICPPClassType b4 = ba.assertNonProblem("B {}", 1, ICPPClassType.class);
assertFalse(b0 instanceof ICPPSpecialization);
assertSame(b0.getScope(), b2.getCompositeScope());
- ICPPClassScope cs1= assertInstance(b1.getScope(), ICPPClassScope.class);
+ ICPPClassScope cs1 = assertInstance(b1.getScope(), ICPPClassScope.class);
assertInstance(cs1.getClassType(), ICPPTemplateInstance.class);
assertSame(b4.getScope(), b3.getCompositeScope());
}
@@ -1403,15 +1406,15 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// X<A>::Y::Z xayz;
public void testEnclosingScopes_c() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPClassType b0= ba.assertNonProblem("Y::Z x", 1, ICPPClassType.class);
- ICPPClassType b1= ba.assertNonProblem("Z xayz", 1, ICPPClassType.class);
+ ICPPClassType b0 = ba.assertNonProblem("Y::Z x", 1, ICPPClassType.class);
+ ICPPClassType b1 = ba.assertNonProblem("Z xayz", 1, ICPPClassType.class);
- ICPPClassScope cs0= assertInstance(b0.getScope(), ICPPClassScope.class);
+ ICPPClassScope cs0 = assertInstance(b0.getScope(), ICPPClassScope.class);
assertInstance(cs0.getClassType(), ICPPSpecialization.class);
- ICPPClassScope cs1= assertInstance(b1.getScope(), ICPPClassScope.class);
+ ICPPClassScope cs1 = assertInstance(b1.getScope(), ICPPClassScope.class);
assertInstance(cs1.getClassType(), ICPPSpecialization.class);
}
@@ -1427,18 +1430,18 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// X<B,A>::N n;
public void testEnclosingScopes_d() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPClassType b0= ba.assertNonProblem("N n", 1, ICPPClassType.class);
- ICPPClassType b1= ba.assertNonProblem("N {", 1, ICPPClassType.class);
+ ICPPClassType b0 = ba.assertNonProblem("N n", 1, ICPPClassType.class);
+ ICPPClassType b1 = ba.assertNonProblem("N {", 1, ICPPClassType.class);
- ICPPClassScope s0= assertInstance(b0.getScope(), ICPPClassScope.class);
+ ICPPClassScope s0 = assertInstance(b0.getScope(), ICPPClassScope.class);
assertInstance(s0.getClassType(), ICPPTemplateInstance.class);
- ICPPClassScope s1= assertInstance(b1.getScope(), ICPPClassScope.class);
+ ICPPClassScope s1 = assertInstance(b1.getScope(), ICPPClassScope.class);
assertInstance(s1.getClassType(), ICPPTemplateDefinition.class);
- ICPPTemplateScope s2= assertInstance(s1.getClassType().getScope(), ICPPTemplateScope.class);
+ ICPPTemplateScope s2 = assertInstance(s1.getClassType().getScope(), ICPPTemplateScope.class);
}
// template<class T> struct A {
@@ -1476,7 +1479,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A2 = (ICPPClassType) col.getName(15).resolveBinding();
assertTrue(A2 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A2).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A2).getTemplateDefinition(), A);
ICPPMethod f2 = (ICPPMethod) col.getName(17).resolveBinding();
assertTrue(f2 instanceof ICPPSpecialization);
assertSame(((ICPPSpecialization) f2).getSpecializedBinding(), f);
@@ -1557,7 +1560,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A2 = (ICPPClassType) col.getName(4).resolveBinding();
assertTrue(A2 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A2).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A2).getTemplateDefinition(), A);
ICPPFunction s2 = (ICPPFunction) col.getName(8).resolveBinding();
assertTrue(s2 instanceof ICPPTemplateInstance);
@@ -1565,7 +1568,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A3 = (ICPPClassType) col.getName(10).resolveBinding();
assertTrue(A3 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A3).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A3).getTemplateDefinition(), A);
assertNotSame(A2, A3);
}
@@ -1581,7 +1584,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding();
ICPPClassType A2 = (ICPPClassType) col.getName(2).resolveBinding();
assertTrue(A2 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A2).getTemplateDefinition(), A1);
+ assertSame(((ICPPTemplateInstance) A2).getTemplateDefinition(), A1);
ICPPFunctionTemplate s1 = (ICPPFunctionTemplate) col.getName(5).resolveBinding();
ICPPFunction s2 = (ICPPFunction) col.getName(10).resolveBinding();
@@ -1605,7 +1608,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
IASTName f = col.getName(6);
IASTFunctionDefinition fdef = (IASTFunctionDefinition) f.getParent().getParent();
- IASTExpressionStatement statement = (IASTExpressionStatement) ((IASTCompoundStatement) fdef.getBody()).getStatements()[0];
+ IASTExpressionStatement statement = (IASTExpressionStatement) ((IASTCompoundStatement) fdef.getBody())
+ .getStatements()[0];
IType type = statement.getExpression().getExpressionType();
assertTrue(type.isSameType(p.getType()));
@@ -1729,7 +1733,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f(A<int>(1));
// }
public void testBug99254a() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
ICPPConstructor ctor = bh.assertNonProblem("A(T t)", "A", ICPPConstructor.class);
ICPPSpecialization spec = bh.assertNonProblem("A<int>(1)", "A<int>", ICPPSpecialization.class);
assertSame(ctor.getOwner(), spec.getSpecializedBinding());
@@ -1755,12 +1759,13 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// b->add(core::A<int>(10, 2));
// }
public void testBug99254b() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
ICPPConstructor ctor = bh.assertNonProblem("A(T x, T y)", "A", ICPPConstructor.class);
ICPPSpecialization spec = bh.assertNonProblem("A<int>(10, 2)", "A<int>", ICPPSpecialization.class);
assertSame(ctor.getOwner(), spec.getSpecializedBinding());
IASTName name = bh.findName("A<int>(10, 2)", "A<int>");
- IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) name.getParent().getParent().getParent()).getImplicitNames();
+ IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) name.getParent().getParent().getParent())
+ .getImplicitNames();
assertEquals(1, implicitNames.length);
ICPPSpecialization ctor2 = (ICPPSpecialization) implicitNames[0].getBinding();
assertSame(ctor, ctor2.getSpecializedBinding());
@@ -1778,7 +1783,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// b->add(A<int>(10));
// }
public void testBug99254c() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
ICPPConstructor ctor = bh.assertNonProblem("A(T)", "A", ICPPConstructor.class);
ICPPSpecialization spec = bh.assertNonProblem("A<int>(10)", "A<int>", ICPPSpecialization.class);
assertSame(ctor.getOwner(), spec.getSpecializedBinding());
@@ -1793,7 +1798,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
}
public void testBug98666() throws Exception {
- CPPASTNameBase.sAllowNameComputation= true;
+ CPPASTNameBase.sAllowNameComputation = true;
IASTTranslationUnit tu = parse("A::template B<T> b;", CPP);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -1828,14 +1833,15 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertSame(T, col.getName(10).resolveBinding());
assertSame(T2ofPartialSpec, col.getName(14).resolveBinding());
- ICPPClassTemplatePartialSpecialization spec = (ICPPClassTemplatePartialSpecialization) col.getName(12).resolveBinding();
+ ICPPClassTemplatePartialSpecialization spec = (ICPPClassTemplatePartialSpecialization) col.getName(12)
+ .resolveBinding();
assertSame(spec.getPrimaryClassTemplate(), B);
ICPPClassType BI = (ICPPClassType) col.getName(19).resolveBinding();
assertTrue(BI instanceof ICPPTemplateInstance);
- final IBinding partialSpecSpec = ((ICPPTemplateInstance)BI).getSpecializedBinding();
+ final IBinding partialSpecSpec = ((ICPPTemplateInstance) BI).getSpecializedBinding();
assertTrue(partialSpecSpec instanceof ICPPSpecialization);
- IBinding partialSpec= ((ICPPSpecialization) partialSpecSpec).getSpecializedBinding();
+ IBinding partialSpec = ((ICPPSpecialization) partialSpecSpec).getSpecializedBinding();
assertSame(partialSpec, spec);
}
@@ -1844,7 +1850,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// int k = f(1); // uses #2
// int l = f<>(1); // uses #1
public void testBug95208() throws Exception {
- String content= getAboveComment();
+ String content = getAboveComment();
IASTTranslationUnit tu = parse(content, CPP);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -1859,8 +1865,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertSame(((ICPPTemplateInstance) b).getSpecializedBinding(), f1);
assertSame(f1, col.getName(10).resolveBinding());
-
- tu = parse(content,CPP);
+ tu = parse(content, CPP);
col = new NameCollector();
tu.accept(col);
@@ -1952,11 +1957,11 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ITypedef myType = (ITypedef) col.getName(31).resolveBinding();
ICPPClassType A = (ICPPClassType) myType.getType();
- ICPPClassTemplatePartialSpecialization Aspec =
- (ICPPClassTemplatePartialSpecialization) col.getName(10).resolveBinding();
+ ICPPClassTemplatePartialSpecialization Aspec = (ICPPClassTemplatePartialSpecialization) col.getName(10)
+ .resolveBinding();
assertTrue(A instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A).getTemplateDefinition(), Aspec);
+ assertSame(((ICPPTemplateInstance) A).getTemplateDefinition(), Aspec);
}
// template<class T>
@@ -2043,8 +2048,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// }
// };
public void testBug201204() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPFunction fn= bh.assertNonProblem("makeClosure(this", 11, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPFunction fn = bh.assertNonProblem("makeClosure(this", 11, ICPPFunction.class);
}
// template <class R, class T, class P1, class P2, class P3, class P4>
@@ -2069,9 +2074,9 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// func(d, &C::m2);
// }
public void testBug233889() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPFunction fn1= bh.assertNonProblem("func(c", 4, ICPPFunction.class);
- ICPPFunction fn2= bh.assertNonProblem("func(d", 4, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPFunction fn1 = bh.assertNonProblem("func(c", 4, ICPPFunction.class);
+ ICPPFunction fn2 = bh.assertNonProblem("func(d", 4, ICPPFunction.class);
assertNotSame(fn1, fn2);
}
@@ -2092,7 +2097,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// GetPair(x, 1);
// }
public void testBug229917a() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
ICPPFunction fn = bh.assertNonProblem("GetPair(x", 7, ICPPFunction.class);
}
@@ -2109,7 +2114,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// template <class _C>
// typename _C::value_type GetPair(_C& collection, typename _C::value_type::first_type key);
public void testBug229917b() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
IBinding b0 = bh.assertNonProblem("value_type GetPair", 10, IBinding.class);
}
@@ -2128,7 +2133,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// str.m();
// }
public void testBug232086() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
ICPPFunction b0 = bh.assertNonProblem("m();", 1, ICPPFunction.class);
}
@@ -2151,15 +2156,15 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// bar(ca);
// }
public void testBug214646() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
- IBinding b0= bh.assertNonProblem("foo(a)", 3);
- IBinding b1= bh.assertNonProblem("bar(ca)", 3);
+ IBinding b0 = bh.assertNonProblem("foo(a)", 3);
+ IBinding b1 = bh.assertNonProblem("bar(ca)", 3);
assertInstance(b0, ICPPFunction.class);
assertInstance(b1, ICPPFunction.class);
- ICPPFunction f0= (ICPPFunction) b0, f1= (ICPPFunction) b1;
+ ICPPFunction f0 = (ICPPFunction) b0, f1 = (ICPPFunction) b1;
assertEquals(1, f0.getParameters().length);
assertEquals(1, f1.getParameters().length);
@@ -2183,10 +2188,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// func(a2);
// }
public void testFunctionTemplate_245049a() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPFunction b0= bh.assertNonProblem("func(a1)", 4, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPFunction b0 = bh.assertNonProblem("func(a1)", 4, ICPPFunction.class);
assertInstance(b0, ICPPTemplateInstance.class);
- ICPPFunction b1= bh.assertNonProblem("func(a2)", 4, ICPPFunction.class);
+ ICPPFunction b1 = bh.assertNonProblem("func(a2)", 4, ICPPFunction.class);
assertSame(b0, b1);
}
@@ -2206,10 +2211,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// func(a2);
// }
public void testFunctionTemplate_245049b() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPFunction b0= bh.assertNonProblem("func(a1)", 4, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPFunction b0 = bh.assertNonProblem("func(a1)", 4, ICPPFunction.class);
assertInstance(b0, ICPPTemplateInstance.class);
- ICPPFunction b1= bh.assertNonProblem("func(a2)", 4, ICPPFunction.class);
+ ICPPFunction b1 = bh.assertNonProblem("func(a2)", 4, ICPPFunction.class);
assertNotSame(b0, b1);
}
@@ -2229,7 +2234,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// using ns::make_pair;
// pair<int, int> p = make_pair(1, 2);
public void testFunctionTemplateWithUsing() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("make_pair(1", 9, ICPPFunction.class);
}
@@ -2276,7 +2281,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f(a(x));
// }
public void testFunctionTemplate_264963() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("f(a(x));", 1, ICPPFunction.class);
}
@@ -2291,7 +2296,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f(&A::m);
// }
public void testFunctionTemplate_266532() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("f(&A::m);", 1, ICPPFunction.class);
}
@@ -2362,7 +2367,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f1(x, &f2);
// }
public void testFunctionTemplateWithFunctionPointer_281783() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("f1(x, &f2);", 2, ICPPFunction.class);
}
@@ -2393,14 +2398,14 @@ public class AST2TemplateTests extends AST2CPPTestBase {
NameCollector col = new NameCollector(true);
tu.accept(col);
- IASTImplicitName tid= (IASTImplicitName) col.getName(20);
- IASTName cn= col.getName(22);
+ IASTImplicitName tid = (IASTImplicitName) col.getName(20);
+ IASTName cn = col.getName(22);
assertInstance(cn.resolveBinding(), ICPPClassTemplate.class); // *D*<int>(5, 6)
assertInstance(cn.resolveBinding(), ICPPClassType.class); // *D*<int>(5, 6)
assertInstance(tid.resolveBinding(), ICPPTemplateInstance.class); // *D<int>*(5, 6)
assertInstance(tid.resolveBinding(), ICPPConstructor.class); // *D<int>*(5, 6)
- IBinding tidSpc= ((ICPPTemplateInstance) tid.resolveBinding()).getSpecializedBinding();
+ IBinding tidSpc = ((ICPPTemplateInstance) tid.resolveBinding()).getSpecializedBinding();
assertInstance(tidSpc, ICPPConstructor.class);
assertInstance(tidSpc, ICPPSpecialization.class);
assertInstance(tidSpc, ICPPFunctionTemplate.class);
@@ -2421,27 +2426,27 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertFalse(name.resolveBinding() instanceof IProblemBinding);
}
- name= col.nameList.get(0);
+ name = col.nameList.get(0);
assertTrue(name.resolveBinding() instanceof ICPPTemplateParameter);
- name= col.nameList.get(1);
+ name = col.nameList.get(1);
assertTrue(name.resolveBinding() instanceof ICPPTemplateParameter);
- name= col.nameList.get(2);
+ name = col.nameList.get(2);
assertTrue(name.resolveBinding() instanceof ICPPFunction);
- name= col.nameList.get(3);
+ name = col.nameList.get(3);
assertTrue(name.resolveBinding() instanceof ICPPTemplateParameter);
- name= col.nameList.get(4);
+ name = col.nameList.get(4);
assertTrue(name.resolveBinding() instanceof IParameter);
- name= col.nameList.get(5);
+ name = col.nameList.get(5);
assertTrue(name.resolveBinding() instanceof ICPPTemplateParameter);
- name= col.nameList.get(6);
+ name = col.nameList.get(6);
assertTrue(name.resolveBinding() instanceof IParameter);
- name= col.nameList.get(7);
+ name = col.nameList.get(7);
assertTrue(name.resolveBinding() instanceof IParameter);
- name= col.nameList.get(8);
+ name = col.nameList.get(8);
assertTrue(name.resolveBinding() instanceof IParameter);
- name= col.nameList.get(9);
+ name = col.nameList.get(9);
assertTrue(name.resolveBinding() instanceof IParameter);
- name= col.nameList.get(10);
+ name = col.nameList.get(10);
assertTrue(name.resolveBinding() instanceof IParameter);
}
@@ -2459,7 +2464,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// void f(B<int>::tb r) {}
public void testTemplateTypedef_214447() throws Exception {
- CPPASTNameBase.sAllowNameComputation= true;
+ CPPASTNameBase.sAllowNameComputation = true;
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
NameCollector col = new NameCollector();
@@ -2493,7 +2498,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// void f(Vec<int>::reference r) {}
public void testRebindPattern_214447a() throws Exception {
- CPPASTNameBase.sAllowNameComputation= true;
+ CPPASTNameBase.sAllowNameComputation = true;
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
NameCollector col = new NameCollector();
@@ -2533,7 +2538,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// void f(Vec<int>::reference r) {}
public void testRebindPattern_214447b() throws Exception {
- CPPASTNameBase.sAllowNameComputation= true;
+ CPPASTNameBase.sAllowNameComputation = true;
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
NameCollector col = new NameCollector();
@@ -2572,7 +2577,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// void f(map<int>::value_type r) {}
public void testRebindPattern_236197() throws Exception {
- CPPASTNameBase.sAllowNameComputation= true;
+ CPPASTNameBase.sAllowNameComputation = true;
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -2604,7 +2609,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// void main(Iter<int*>::iter_reference r);
public void testSpecializationSelection_229218() throws Exception {
- CPPASTNameBase.sAllowNameComputation= true;
+ CPPASTNameBase.sAllowNameComputation = true;
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -2734,7 +2739,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// B<int>::b::a x;
public void testDefaultTemplateParameter() throws Exception {
- CPPASTNameBase.sAllowNameComputation= true;
+ CPPASTNameBase.sAllowNameComputation = true;
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
NameCollector col = new NameCollector();
@@ -2784,8 +2789,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// foo(d);
// }
public void testUserDefinedConversions_224364() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPFunction fn= bh.assertNonProblem("foo(d)", 3, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPFunction fn = bh.assertNonProblem("foo(d)", 3, ICPPFunction.class);
}
// class B {};
@@ -2804,8 +2809,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// foo(d);
// }
public void testUserDefinedConversions_224364a() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPFunction fn= bh.assertNonProblem("foo(d)", 3, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPFunction fn = bh.assertNonProblem("foo(d)", 3, ICPPFunction.class);
}
// class Z {};
@@ -2827,8 +2832,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// Z z= foo(*new E<Z>());
public void testUserDefinedConversions_224364b() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPFunction fn= bh.assertNonProblem("foo(*new", 3, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPFunction fn = bh.assertNonProblem("foo(*new", 3, ICPPFunction.class);
}
// class X {}; class B {};
@@ -2851,8 +2856,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// foo(cx);
// }
public void testUserDefinedConversions_226231() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPFunction fn= bh.assertNonProblem("foo(cx", 3, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPFunction fn = bh.assertNonProblem("foo(cx", 3, ICPPFunction.class);
}
// class A;
@@ -2870,7 +2875,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// return foo(c);
// }
public void testUserDefinedConversions_239023() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
ba.assertNonProblem("foo(c);", 3);
}
@@ -2893,7 +2898,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// class A {};
//
// void foo() {
- // A<i> a1;
+ // A<i> a1;
// }
//
// const int i= 1;
@@ -2971,7 +2976,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// return at;
// }
public void testTypeIdAsTemplateArgumentIsTypeId_229942a() throws Exception {
- BindingAssertionHelper ba=new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
ba.assertNonProblem("T> at) {", 1);
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
@@ -3010,13 +3015,13 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// template<> class Alias<td const *> {
// };
public void testNonAmbiguityCase_229942() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(), CPP);
- NameCollector col= new NameCollector();
+ IASTTranslationUnit tu = parse(getAboveComment(), CPP);
+ NameCollector col = new NameCollector();
tu.accept(col);
// 2 is Alias
- ICPPASTTemplateId tid= assertInstance(col.getName(2).getParent(), ICPPASTTemplateId.class);
- IASTNode[] args= tid.getTemplateArguments();
+ ICPPASTTemplateId tid = assertInstance(col.getName(2).getParent(), ICPPASTTemplateId.class);
+ IASTNode[] args = tid.getTemplateArguments();
assertEquals(1, args.length);
assertInstance(args[0], IASTTypeId.class);
}
@@ -3036,7 +3041,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// C c1;
// C<> c2; // ok - default args
public void testMissingTemplateArgumentLists() throws Exception {
- BindingAssertionHelper ba=new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
ba.assertProblem("B b1", 1);
ba.assertNonProblem("B<> b2", 1, ICPPTemplateDefinition.class, ICPPClassType.class);
ba.assertProblem("B<> b2", 3);
@@ -3053,11 +3058,11 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// member1 = 0;
// }
public void testDefinitionOfClassTemplateWithNonTypeParameter() throws Exception {
- BindingAssertionHelper ba=new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPMethod f1= ba.assertNonProblem("fun1(void);", 4, ICPPMethod.class);
- ICPPField m1= ba.assertNonProblem("member1;", 7, ICPPField.class);
- ICPPMethod f2= ba.assertNonProblem("fun1(void) {", 4, ICPPMethod.class);
- ICPPField m2= ba.assertNonProblem("member1 =", 7, ICPPField.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPMethod f1 = ba.assertNonProblem("fun1(void);", 4, ICPPMethod.class);
+ ICPPField m1 = ba.assertNonProblem("member1;", 7, ICPPField.class);
+ ICPPMethod f2 = ba.assertNonProblem("fun1(void) {", 4, ICPPMethod.class);
+ ICPPField m2 = ba.assertNonProblem("member1 =", 7, ICPPField.class);
assertSame(m1, m2);
assertSame(f1, f2);
}
@@ -3078,11 +3083,11 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// void ref() {
// A<short>::B<> b;
// }
- public void testNestedTemplateDefinitionParameter() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPTemplateTypeParameter T3a= ba.assertNonProblem("T3 f", 2, ICPPTemplateTypeParameter.class);
- ICPPTemplateTypeParameter T3b= ba.assertNonProblem("T3)", 2, ICPPTemplateTypeParameter.class);
- ICPPClassType b= ba.assertNonProblem("B<>", 3, ICPPClassType.class, ICPPTemplateInstance.class);
+ public void testNestedTemplateDefinitionParameter() throws Exception {
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPTemplateTypeParameter T3a = ba.assertNonProblem("T3 f", 2, ICPPTemplateTypeParameter.class);
+ ICPPTemplateTypeParameter T3b = ba.assertNonProblem("T3)", 2, ICPPTemplateTypeParameter.class);
+ ICPPClassType b = ba.assertNonProblem("B<>", 3, ICPPClassType.class, ICPPTemplateInstance.class);
}
// template<class T, int x> class A {public: class X {};};
@@ -3095,18 +3100,18 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// A<B, 1>::Y y;
// A<B, 2>::Z z;
public void testNonTypeArgumentDisambiguation_233460() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPClassType b2= ba.assertNonProblem("A<B, 0>", 7, ICPPClassType.class, ICPPTemplateInstance.class);
- ICPPClassType b3= ba.assertNonProblem("A<B, 1>", 7, ICPPClassType.class, ICPPTemplateInstance.class);
- ICPPClassType b4= ba.assertNonProblem("A<B, 2>", 7, ICPPClassType.class, ICPPTemplateInstance.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPClassType b2 = ba.assertNonProblem("A<B, 0>", 7, ICPPClassType.class, ICPPTemplateInstance.class);
+ ICPPClassType b3 = ba.assertNonProblem("A<B, 1>", 7, ICPPClassType.class, ICPPTemplateInstance.class);
+ ICPPClassType b4 = ba.assertNonProblem("A<B, 2>", 7, ICPPClassType.class, ICPPTemplateInstance.class);
assertTrue(!b2.isSameType(b3));
assertTrue(!b3.isSameType(b4));
assertTrue(!b4.isSameType(b2));
- ICPPClassType X= ba.assertNonProblem("X x", 1, ICPPClassType.class);
- ICPPClassType Y= ba.assertNonProblem("Y y", 1, ICPPClassType.class);
- ICPPClassType Z= ba.assertNonProblem("Z z", 1, ICPPClassType.class);
+ ICPPClassType X = ba.assertNonProblem("X x", 1, ICPPClassType.class);
+ ICPPClassType Y = ba.assertNonProblem("Y y", 1, ICPPClassType.class);
+ ICPPClassType Z = ba.assertNonProblem("Z z", 1, ICPPClassType.class);
assertTrue(!X.isSameType(Y));
assertTrue(!Y.isSameType(Z));
@@ -3124,10 +3129,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// A<B, true>::X x; //3 should be an error
// A<B, false>::Y y; //4 should be an error
public void testNonTypeBooleanArgumentDisambiguation() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPClassType X= ba.assertNonProblem("X x; //1", 1, ICPPClassType.class);
- ICPPClassType Y= ba.assertNonProblem("Y y; //2", 1, ICPPClassType.class);
+ ICPPClassType X = ba.assertNonProblem("X x; //1", 1, ICPPClassType.class);
+ ICPPClassType Y = ba.assertNonProblem("Y y; //2", 1, ICPPClassType.class);
ba.assertProblem("X x; //3", 1);
ba.assertProblem("Y y; //4", 1);
@@ -3155,21 +3160,21 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// baz();
// }
public void testBug207871() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPVariable _256= ba.assertNonProblem("_256=0x100", 4, ICPPVariable.class);
- IQualifierType qt1= assertInstance(_256.getType(), IQualifierType.class);
- ICPPBasicType bt1= assertInstance(qt1.getType(), ICPPBasicType.class);
+ ICPPVariable _256 = ba.assertNonProblem("_256=0x100", 4, ICPPVariable.class);
+ IQualifierType qt1 = assertInstance(_256.getType(), IQualifierType.class);
+ ICPPBasicType bt1 = assertInstance(qt1.getType(), ICPPBasicType.class);
assertConstantValue(256, _256);
- ICPPVariable t= ba.assertNonProblem("t;", 1, ICPPVariable.class);
- ICPPTemplateInstance ci1= assertInstance(t.getType(), ICPPTemplateInstance.class, ICPPClassType.class);
- ICPPTemplateParameterMap args1= ci1.getTemplateParameterMap();
+ ICPPVariable t = ba.assertNonProblem("t;", 1, ICPPVariable.class);
+ ICPPTemplateInstance ci1 = assertInstance(t.getType(), ICPPTemplateInstance.class, ICPPClassType.class);
+ ICPPTemplateParameterMap args1 = ci1.getTemplateParameterMap();
assertEquals(1, args1.getAllParameterPositions().length);
assertEquals(256, args1.getArgument(0).getNonTypeValue().numberValue().intValue());
- ICPPTemplateInstance ct= ba.assertNonProblem("C<_256> ", 7, ICPPTemplateInstance.class, ICPPClassType.class);
- ICPPTemplateParameterMap args= ct.getTemplateParameterMap();
+ ICPPTemplateInstance ct = ba.assertNonProblem("C<_256> ", 7, ICPPTemplateInstance.class, ICPPClassType.class);
+ ICPPTemplateParameterMap args = ct.getTemplateParameterMap();
assertEquals(1, args.getAllParameterPositions().length);
assertEquals(256, args.getArgument(0).getNonTypeValue().numberValue().intValue());
@@ -3186,9 +3191,9 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// C<y> go();
// };
public void testDeferredNonTypeArgument() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPDeferredClassInstance ci= ba.assertNonProblem("C<y>", 4, ICPPDeferredClassInstance.class);
- ICPPTemplateArgument[] args= ci.getTemplateArguments();
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPDeferredClassInstance ci = ba.assertNonProblem("C<y>", 4, ICPPDeferredClassInstance.class);
+ ICPPTemplateArgument[] args = ci.getTemplateArguments();
assertEquals(1, args.length);
assertEquals(0, IntegralValue.isTemplateParameter(args[0].getNonTypeValue()));
}
@@ -3198,7 +3203,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// A<int> aint; // should be an error
public void testTypeArgumentToNonTypeParameter() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
ba.assertProblem("A<int>", 6);
}
@@ -3218,18 +3223,18 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// inline This<I>::This() : That<I>(I) {
// }
public void testParameterReferenceInChainInitializer_a() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
// These intermediate assertions will not hold until deferred non-type arguments are
// correctly modelled
- ICPPClassType tid= ba.assertNonProblem("This<I>::T", 7, ICPPClassType.class);
+ ICPPClassType tid = ba.assertNonProblem("This<I>::T", 7, ICPPClassType.class);
assertFalse(tid instanceof ICPPSpecialization);
- ICPPConstructor th1sCtor= ba.assertNonProblem("This() :", 4, ICPPConstructor.class);
+ ICPPConstructor th1sCtor = ba.assertNonProblem("This() :", 4, ICPPConstructor.class);
assertFalse(th1sCtor instanceof ICPPSpecialization);
ICPPTemplateNonTypeParameter np = ba.assertNonProblem("I>(I)", 1, ICPPTemplateNonTypeParameter.class);
- ICPPConstructor clazz= ba.assertNonProblem("That<I>(I)", 4, ICPPConstructor.class);
- ICPPConstructor ctor= ba.assertNonProblem("That<I>(I)", 7, ICPPConstructor.class);
+ ICPPConstructor clazz = ba.assertNonProblem("That<I>(I)", 4, ICPPConstructor.class);
+ ICPPConstructor ctor = ba.assertNonProblem("That<I>(I)", 7, ICPPConstructor.class);
ICPPTemplateNonTypeParameter np1 = ba.assertNonProblem("I)", 1, ICPPTemplateNonTypeParameter.class);
assertSame(np, np1);
@@ -3251,16 +3256,16 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// inline This<I>::This() : That<I>() {
// }
public void testParameterReferenceInChainInitializer_b() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPClassType tid= ba.assertNonProblem("This<I>::T", 7, ICPPClassType.class);
+ ICPPClassType tid = ba.assertNonProblem("This<I>::T", 7, ICPPClassType.class);
assertFalse(tid instanceof ICPPSpecialization);
- ICPPConstructor th1sCtor= ba.assertNonProblem("This() :", 4, ICPPConstructor.class);
+ ICPPConstructor th1sCtor = ba.assertNonProblem("This() :", 4, ICPPConstructor.class);
assertFalse(th1sCtor instanceof ICPPSpecialization);
- ICPPTemplateTypeParameter np= ba.assertNonProblem("I>()", 1, ICPPTemplateTypeParameter.class);
- ICPPConstructor clazz= ba.assertNonProblem("That<I>()", 4, ICPPConstructor.class);
- ICPPConstructor ctor= ba.assertNonProblem("That<I>()", 7, ICPPConstructor.class);
+ ICPPTemplateTypeParameter np = ba.assertNonProblem("I>()", 1, ICPPTemplateTypeParameter.class);
+ ICPPConstructor clazz = ba.assertNonProblem("That<I>()", 4, ICPPConstructor.class);
+ ICPPConstructor ctor = ba.assertNonProblem("That<I>()", 7, ICPPConstructor.class);
}
// template<typename T, int I>
@@ -3273,8 +3278,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// C<A,5L> ca5L;
public void testIntegralConversionInPartialSpecializationMatching_237914() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPTemplateInstance ctps= ba.assertNonProblem("C<A,5L>", 7, ICPPTemplateInstance.class, ICPPClassType.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPTemplateInstance ctps = ba.assertNonProblem("C<A,5L>", 7, ICPPTemplateInstance.class, ICPPClassType.class);
assertInstance(ctps.getTemplateDefinition(), ICPPClassTemplatePartialSpecialization.class);
}
@@ -3293,8 +3298,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// ca5L.test= 0;
// }
public void testIntegralConversionInSpecializationMatching_237914() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPSpecialization ctps= ba.assertNonProblem("C<A,5L>", 7, ICPPSpecialization.class, ICPPClassType.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPSpecialization ctps = ba.assertNonProblem("C<A,5L>", 7, ICPPSpecialization.class, ICPPClassType.class);
ba.assertNonProblem("test=", 4, ICPPField.class);
}
@@ -3361,7 +3366,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// B(const B<T>& other) : A(other) {}
// };
public void testChainInitializerLookupThroughDeferredClassBase() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
ba.assertNonProblem("A(other", 1);
}
@@ -3394,7 +3399,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// }
// };
public void testMemberLookupThroughDeferredClassBase() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
ba.assertNonProblem("foo(s", 3);
}
@@ -3470,7 +3475,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// return foo();
// }
public void testMemberReferenceFromTemplatedMethodDefinition_238232() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
ba.assertNonProblem("foo();", 3);
}
@@ -3515,14 +3520,15 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// } // detail
public void testBug238180_ClassCast() throws Exception {
// the code above used to trigger a ClassCastException
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPClassType p= ba.assertNonProblem("str<true, true, false, A, B>", 0, ICPPClassType.class);
- ICPPConstructor con= p.getConstructors()[1];
- ICPPReferenceType reftype= (ICPPReferenceType) con.getType().getParameterTypes()[0];
- IQualifierType qt= (IQualifierType) reftype.getType();
- ICPPDeferredClassInstance dcl= (ICPPDeferredClassInstance) qt.getType();
- ICPPClassTemplatePartialSpecialization spec= (ICPPClassTemplatePartialSpecialization) dcl.getSpecializedBinding();
- ICPPTemplateTypeParameter tp= (ICPPTemplateTypeParameter) spec.getTemplateParameters()[0];
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPClassType p = ba.assertNonProblem("str<true, true, false, A, B>", 0, ICPPClassType.class);
+ ICPPConstructor con = p.getConstructors()[1];
+ ICPPReferenceType reftype = (ICPPReferenceType) con.getType().getParameterTypes()[0];
+ IQualifierType qt = (IQualifierType) reftype.getType();
+ ICPPDeferredClassInstance dcl = (ICPPDeferredClassInstance) qt.getType();
+ ICPPClassTemplatePartialSpecialization spec = (ICPPClassTemplatePartialSpecialization) dcl
+ .getSpecializedBinding();
+ ICPPTemplateTypeParameter tp = (ICPPTemplateTypeParameter) spec.getTemplateParameters()[0];
assertNull(tp.getDefault());
}
@@ -3543,10 +3549,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// };
// template<typename T> int CT<T>::x = sizeof(T);
public void testUsingTemplParamInInitializerOfStaticField() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPTemplateTypeParameter t= ba.assertNonProblem("T)", 1, ICPPTemplateTypeParameter.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPTemplateTypeParameter t = ba.assertNonProblem("T)", 1, ICPPTemplateTypeParameter.class);
}
-
+
// template <typename T>
// constexpr T id(T a) {
// return a;
@@ -3613,11 +3619,11 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// func(cb);
// }
public void testTemplateMetaProgramming_245027() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPMethod method= ba.assertNonProblem("method();", 6, ICPPMethod.class);
- ICPPVariable a= ba.assertNonProblem("a =", 1, ICPPVariable.class);
- ICPPVariable b= ba.assertNonProblem("b =", 1, ICPPVariable.class);
- ICPPFunction func= ba.assertNonProblem("func(cb)", 4, ICPPFunction.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPMethod method = ba.assertNonProblem("method();", 6, ICPPMethod.class);
+ ICPPVariable a = ba.assertNonProblem("a =", 1, ICPPVariable.class);
+ ICPPVariable b = ba.assertNonProblem("b =", 1, ICPPVariable.class);
+ ICPPFunction func = ba.assertNonProblem("func(cb)", 4, ICPPFunction.class);
}
// class Incomplete;
@@ -3639,7 +3645,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// ns1::A<(sizeof(probe(x)) == 1)>::m(x);
// }
public void testNonTypeTemplateParameter_252108() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
ba.assertNonProblem("x))", 1, ICPPVariable.class);
}
@@ -3659,14 +3665,14 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// > > > > >
// type;
public void testNestedArguments_246079() throws Throwable {
- final Throwable[] th= {null};
- Thread t= new Thread() {
+ final Throwable[] th = { null };
+ Thread t = new Thread() {
@Override
public void run() {
try {
- parseAndCheckBindings(getAboveComment(), CPP);
+ parseAndCheckBindings(getAboveComment(), CPP);
} catch (Throwable e) {
- th[0]= e;
+ th[0] = e;
}
}
};
@@ -3684,10 +3690,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// };
// template<class T> void A<T, int>::foo(T t) {}
public void testBug177418() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true );
+ IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
NameCollector col = new NameCollector();
- tu.accept( col );
+ tu.accept(col);
ICPPTemplateParameter T1 = (ICPPTemplateParameter) col.getName(0).resolveBinding();
ICPPTemplateParameter U = (ICPPTemplateParameter) col.getName(1).resolveBinding();
@@ -3696,7 +3702,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(3).resolveBinding();
assertNotSame(T1, T2);
- ICPPClassTemplatePartialSpecialization A2 = (ICPPClassTemplatePartialSpecialization) col.getName(4).resolveBinding();
+ ICPPClassTemplatePartialSpecialization A2 = (ICPPClassTemplatePartialSpecialization) col.getName(4)
+ .resolveBinding();
assertSame(A2.getPrimaryClassTemplate(), A);
assertSame(A, col.getName(5).resolveBinding());
assertSame(T2, col.getName(6).resolveBinding());
@@ -3731,11 +3738,11 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testFunctionSpecializationAsFriend() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPFunctionTemplate f= bh.assertNonProblem("f(T)", 1);
- IFunction fref1= bh.assertNonProblem("f<>", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPFunctionTemplate f = bh.assertNonProblem("f(T)", 1);
+ IFunction fref1 = bh.assertNonProblem("f<>", 1);
assertSame(fref1, f);
- IFunction fref2= bh.assertNonProblem("f<>", 3);
+ IFunction fref2 = bh.assertNonProblem("f<>", 3);
assertInstance(fref2, ICPPTemplateInstance.class);
assertSame(f, ((ICPPTemplateInstance) fref2).getSpecializedBinding());
}
@@ -3758,15 +3765,15 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testMethodImplWithNonDeferredType() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPMethod m1= bh.assertNonProblem("m1();", 2);
- ICPPMethod m2= bh.assertNonProblem("m1() ", 2);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPMethod m1 = bh.assertNonProblem("m1();", 2);
+ ICPPMethod m2 = bh.assertNonProblem("m1() ", 2);
assertSame(m1, m2);
- m1= bh.assertNonProblem("m2();", 2);
- m2= bh.assertNonProblem("m2() ", 2);
+ m1 = bh.assertNonProblem("m2();", 2);
+ m2 = bh.assertNonProblem("m2() ", 2);
assertSame(m1, m2);
- m1= bh.assertNonProblem("m3();", 2);
- m2= bh.assertNonProblem("m3() ", 2);
+ m1 = bh.assertNonProblem("m3();", 2);
+ m2 = bh.assertNonProblem("m3() ", 2);
assertSame(m1, m2);
}
@@ -3783,16 +3790,16 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testClassTemplateMemberFunctionTemplate_104262() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
- ICPPClassTemplate A1= bh.assertNonProblem("A1", 2);
- ICPPMethod method= bh.assertNonProblem("A1<float>::f1", 13);
- IBinding owner= method.getOwner();
+ ICPPClassTemplate A1 = bh.assertNonProblem("A1", 2);
+ ICPPMethod method = bh.assertNonProblem("A1<float>::f1", 13);
+ IBinding owner = method.getOwner();
assertInstance(owner, ICPPClassSpecialization.class);
assertSame(A1, ((ICPPClassSpecialization) owner).getSpecializedBinding());
- ICPPClassSpecialization special= bh.assertNonProblem("A<float>", 8);
- method= bh.assertNonProblem("A<float>::f", 11);
+ ICPPClassSpecialization special = bh.assertNonProblem("A<float>", 8);
+ method = bh.assertNonProblem("A<float>::f", 11);
assertSame(method.getOwner(), special);
}
@@ -3806,10 +3813,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testQualifiedMethodTemplate() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
- ICPPMethod mt1= bh.assertNonProblem("m(V);", 1);
- ICPPMethod mt2= bh.assertNonProblem("m(V) ", 1);
+ ICPPMethod mt1 = bh.assertNonProblem("m(V);", 1);
+ ICPPMethod mt2 = bh.assertNonProblem("m(V) ", 1);
assertSame(mt1, mt2);
assertInstance(mt1, ICPPFunctionTemplate.class);
}
@@ -3878,10 +3885,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testFieldReference_257186() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
- IBinding a1= bh.assertNonProblem("a;", 1);
- IBinding a2= bh.assertNonProblem("a=", 1);
+ IBinding a1 = bh.assertNonProblem("a;", 1);
+ IBinding a2 = bh.assertNonProblem("a=", 1);
assertInstance(a1, ICPPField.class);
assertSame(a1, a2);
}
@@ -3900,7 +3907,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testUnknownReferences_257194() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("func();", 4, ICPPUnknownBinding.class);
bh.assertNonProblem("var;", 3, ICPPUnknownBinding.class);
@@ -3923,7 +3930,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testTypeOfUnknownReferences_257194a() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("b.c", 1, ICPPUnknownBinding.class);
bh.assertNonProblem("c;", 1, ICPPUnknownBinding.class);
@@ -3948,7 +3955,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testTypeOfUnknownReferences_257194b() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("b->c", 1, ICPPUnknownBinding.class);
bh.assertNonProblem("c;", 1, ICPPUnknownBinding.class);
@@ -3973,23 +3980,23 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testTypeVsExpressionInArgsOfDependentTemplateID_257194() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
- ICPPUnknownBinding b= bh.assertNonProblem("a>", 1);
+ ICPPUnknownBinding b = bh.assertNonProblem("a>", 1);
assertFalse(b instanceof IType);
- b= bh.assertNonProblem("A>", 1);
+ b = bh.assertNonProblem("A>", 1);
assertTrue(b instanceof IType);
- ICPPUsingDeclaration ud= bh.assertNonProblem("b;", 1);
- b= (ICPPUnknownBinding) ud.getDelegates()[0];
+ ICPPUsingDeclaration ud = bh.assertNonProblem("b;", 1);
+ b = (ICPPUnknownBinding) ud.getDelegates()[0];
assertFalse(b instanceof IType);
- ud= bh.assertNonProblem("B;", 1);
- b= (ICPPUnknownBinding) ud.getDelegates()[0];
+ ud = bh.assertNonProblem("B;", 1);
+ b = (ICPPUnknownBinding) ud.getDelegates()[0];
assertTrue(b instanceof IType);
- b= bh.assertNonProblem("f();", 1);
+ b = bh.assertNonProblem("f();", 1);
assertFalse(b instanceof IType);
- b= bh.assertNonProblem("F();", 1);
+ b = bh.assertNonProblem("F();", 1);
assertTrue(b instanceof IType);
}
@@ -4009,7 +4016,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// func(p);
// }
public void testTypedefReference_259871() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("func(p)", 4, ICPPFunction.class);
}
@@ -4052,7 +4059,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// auto s3 = s2.append("foo");
// }
public void testTypedefPreservation_380498a() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ICPPVariable s1 = ba.assertNonProblem("s1");
assertTrue(s1.getType() instanceof ITypedef);
assertEquals("string", ((ITypedef) s1.getType()).getName());
@@ -4076,7 +4083,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// auto it = v.begin();
// }
public void testTypedefPreservation_380498b() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ICPPVariable it = ba.assertNonProblem("it =", "it", ICPPVariable.class);
assertTrue(it.getType() instanceof ITypedef);
assertEquals("vector<Element>::const_iterator", ASTTypeUtil.getType(it.getType(), false));
@@ -4117,7 +4124,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// }
// }
public void testTypedefPreservation_380498c() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ICPPVariable s = ba.assertNonProblem("s :", "s", ICPPVariable.class);
assertInstance(s.getType(), ITypedef.class);
assertEquals("string", ASTTypeUtil.getType(s.getType(), false));
@@ -4158,7 +4165,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// }
// };
public void testNestedTemplates_259872a() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("A<B, int>", 9, ICPPClassType.class);
}
@@ -4183,7 +4190,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// }
// };
public void testNestedTemplates_259872b() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("A<B, int>", 9, ICPPClassType.class);
}
@@ -4202,9 +4209,9 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testCtorWithTemplateID_259600() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPConstructor ctor= bh.assertNonProblem("DumbPtr/**/", 7);
- ICPPMethod dtor= bh.assertNonProblem("~DumbPtr/**/", 8);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPConstructor ctor = bh.assertNonProblem("DumbPtr/**/", 7);
+ ICPPMethod dtor = bh.assertNonProblem("~DumbPtr/**/", 8);
}
// template <class T> class XT {
@@ -4217,9 +4224,9 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testCtorTemplateWithTemplateID_259600() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPConstructor ctor= bh.assertNonProblem("XT/**/", 2);
- ctor= bh.assertNonProblem("XT<T>/**/", 5);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPConstructor ctor = bh.assertNonProblem("XT/**/", 2);
+ ctor = bh.assertNonProblem("XT<T>/**/", 5);
}
// template <typename T> class XT {
@@ -4241,12 +4248,12 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testResolutionOfUnknownBindings_262163() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- IVariable x= bh.assertNonProblem("x;", 1);
- ITypedef Nested= bh.assertNonProblem("Nested;", 6);
- IType t= x.getType();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ IVariable x = bh.assertNonProblem("x;", 1);
+ ITypedef Nested = bh.assertNonProblem("Nested;", 6);
+ IType t = x.getType();
assertInstance(t, ITypedef.class);
- t= ((ITypedef) t).getType();
+ t = ((ITypedef) t).getType();
assertSame(t, Nested);
}
@@ -4273,7 +4280,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// s.substr(0);
// }
public void testResolutionOfUnknownBindings_262328() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("substr(0)", 6, ICPPMethod.class);
}
@@ -4311,10 +4318,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// x.append(3, 'c');
// }
public void testConflictInTemplateArgumentDeduction() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPMethod m= bh.assertNonProblem("append(3", 6);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPMethod m = bh.assertNonProblem("append(3", 6);
assertFalse(m instanceof ICPPTemplateInstance);
}
@@ -4332,8 +4339,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// p.m();
// }
public void testConversionSequence_263159() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPMethod m= bh.assertNonProblem("m();", 1, ICPPMethod.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPMethod m = bh.assertNonProblem("m();", 1, ICPPMethod.class);
}
// template <class C> class A;
@@ -4352,7 +4359,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// return A<C>(p);
// }
public void testForwardDeclarations_264109() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("A<C> make_A(C* p) {", 4, ICPPTemplateInstance.class);
parseAndCheckBindings(getAboveComment());
}
@@ -4415,7 +4422,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// getline2(i);
// }
public void testAmbiguousDeclaratorInFunctionTemplate_265342() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("getline2(i)", 8, ICPPTemplateInstance.class);
parseAndCheckBindings(getAboveComment());
}
@@ -4433,21 +4440,21 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// };
// };
public void testOwnerOfFriendTemplate_265671() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- IFunction f= bh.assertNonProblem("f1(", 2, IFunction.class);
- IBinding owner= f.getOwner();
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ IFunction f = bh.assertNonProblem("f1(", 2, IFunction.class);
+ IBinding owner = f.getOwner();
assertNull(owner);
- ICPPFunctionTemplate ft= bh.assertNonProblem("f2(", 2, ICPPFunctionTemplate.class);
- owner= f.getOwner();
+ ICPPFunctionTemplate ft = bh.assertNonProblem("f2(", 2, ICPPFunctionTemplate.class);
+ owner = f.getOwner();
assertNull(owner);
- ICPPTemplateParameter tpar= ft.getTemplateParameters()[0];
+ ICPPTemplateParameter tpar = ft.getTemplateParameters()[0];
assertEquals(0, tpar.getTemplateNestingLevel());
- tpar= bh.assertNonProblem("T1", 2, ICPPTemplateParameter.class);
+ tpar = bh.assertNonProblem("T1", 2, ICPPTemplateParameter.class);
assertEquals(0, tpar.getTemplateNestingLevel());
- tpar= bh.assertNonProblem("T2", 2, ICPPTemplateParameter.class);
+ tpar = bh.assertNonProblem("T2", 2, ICPPTemplateParameter.class);
assertEquals(1, tpar.getTemplateNestingLevel());
- tpar= bh.assertNonProblem("T3", 2, ICPPTemplateParameter.class);
+ tpar = bh.assertNonProblem("T3", 2, ICPPTemplateParameter.class);
assertEquals(2, tpar.getTemplateNestingLevel());
parseAndCheckBindings(getAboveComment());
@@ -4478,10 +4485,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// }
// template <typename T> void g(T t) {}
public void testDependentNameReferencingLaterDeclaration_265926a() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- IFunction gref= bh.assertNonProblem("g(t)", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ IFunction gref = bh.assertNonProblem("g(t)", 1);
assertInstance(gref, ICPPUnknownBinding.class);
- IFunction gdecl= bh.assertNonProblem("g(T t)", 1);
+ IFunction gdecl = bh.assertNonProblem("g(T t)", 1);
parseAndCheckBindings(getAboveComment());
}
@@ -4704,8 +4711,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// }
public void testInlineFriendFunction_287409() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPFunction func= bh.assertNonProblem("f(x)", 1, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPFunction func = bh.assertNonProblem("f(x)", 1, ICPPFunction.class);
assertFalse(func instanceof ICPPUnknownBinding);
}
@@ -4736,8 +4743,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// };
public void testResolutionOfNonDependentNames_293052() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPFunction func= bh.assertNonProblem("m();", 1, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPFunction func = bh.assertNonProblem("m();", 1, ICPPFunction.class);
assertFalse(func instanceof ICPPUnknownBinding);
bh.assertProblem("n();", 1);
}
@@ -4761,7 +4768,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// }
public void testArgumentDeduction_293409() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("f1(d);", 2, ICPPFunction.class);
bh.assertNonProblem("f2(&d);", 2, ICPPFunction.class);
bh.assertNonProblem("f2(&cd);", 2, ICPPFunction.class);
@@ -4882,10 +4889,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// return a;
// }
public void testClosingAngleBrackets2_261268() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
IASTTranslationUnit tu = parse(code, CPP, true, false);
- IASTFunctionDefinition fdef= getDeclaration(tu, 2);
- IASTProblemStatement p1= getStatement(fdef, 1);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 2);
+ IASTProblemStatement p1 = getStatement(fdef, 1);
}
// template<typename T> class CT {};
@@ -4920,24 +4927,24 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// X<const int&&> x2; // X<const int&&>::f has the parameter type const int&
// // X<const int&&>::g has the parameter type const int&&
public void testRValueReferences_294730() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
- ICPPClassType type= bh.assertNonProblem("X<int&>", 7);
- ICPPMethod[] ms= ClassTypeHelper.getMethods(type);
- int i= ms[0].getName().equals("f") ? 0 : 1;
- ICPPMethod m= ms[i];
+ ICPPClassType type = bh.assertNonProblem("X<int&>", 7);
+ ICPPMethod[] ms = ClassTypeHelper.getMethods(type);
+ int i = ms[0].getName().equals("f") ? 0 : 1;
+ ICPPMethod m = ms[i];
assertEquals("int &", ASTTypeUtil.getType(m.getType().getParameterTypes()[0]));
- m= ms[1 - i];
+ m = ms[1 - i];
assertEquals("int &", ASTTypeUtil.getType(m.getType().getParameterTypes()[0]));
- type= bh.assertNonProblem("X<const int&&>", 14);
- ms= ClassTypeHelper.getMethods(type);
- i= ms[0].getName().equals("f") ? 0 : 1;
- m= ms[i];
+ type = bh.assertNonProblem("X<const int&&>", 14);
+ ms = ClassTypeHelper.getMethods(type);
+ i = ms[0].getName().equals("f") ? 0 : 1;
+ m = ms[i];
assertEquals("const int &", ASTTypeUtil.getType(m.getType().getParameterTypes()[0]));
- m= ms[1 - i];
+ m = ms[1 - i];
assertEquals("const int &&", ASTTypeUtil.getType(m.getType().getParameterTypes()[0]));
}
@@ -4949,28 +4956,28 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// template<typename NonPack> void f6(NonPack ...);
// template<typename... T> void f7() throw(T...);
public void testFunctionParameterPacks_280909() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPFunctionTemplate f= bh.assertNonProblem("f1", 2);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPFunctionTemplate f = bh.assertNonProblem("f1", 2);
assertEquals("void (int (*)(#0(...) ...))", ASTTypeUtil.getType(f.getType(), true));
assertFalse(f.getParameters()[0].isParameterPack());
- f= bh.assertNonProblem("f2", 2);
+ f = bh.assertNonProblem("f2", 2);
assertEquals("void (int (* ...)(#0(...), int))", ASTTypeUtil.getType(f.getType(), true));
assertTrue(f.getParameters()[0].isParameterPack());
- f= bh.assertNonProblem("f3", 2);
+ f = bh.assertNonProblem("f3", 2);
assertEquals("void (#0(...) (* ...)())", ASTTypeUtil.getType(f.getType(), true));
assertTrue(f.getParameters()[0].isParameterPack());
- f= bh.assertNonProblem("f4", 2);
+ f = bh.assertNonProblem("f4", 2);
assertEquals("void (int (& ...)[3 *0 0])", ASTTypeUtil.getType(f.getType(), true));
assertTrue(f.getParameters()[0].isParameterPack());
- f= bh.assertNonProblem("f5", 2);
+ f = bh.assertNonProblem("f5", 2);
assertEquals("void (#0(...) ...)", ASTTypeUtil.getType(f.getType(), true));
assertTrue(f.getParameters()[0].isParameterPack());
- f= bh.assertNonProblem("f6", 2);
+ f = bh.assertNonProblem("f6", 2);
assertEquals("void (#0, ...)", ASTTypeUtil.getType(f.getType(), true));
assertFalse(f.getParameters()[0].isParameterPack());
- f= bh.assertNonProblem("f7", 2);
+ f = bh.assertNonProblem("f7", 2);
assertEquals("#0(...) ...", ASTTypeUtil.getType(f.getExceptionSpecification()[0], true));
}
@@ -4978,19 +4985,19 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// template<template<typename... NP> class... Pack> class C2 {};
// template<int... Pack> class C3 {};
public void testTemplateParameterPacks_280909() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPClassTemplate ct= bh.assertNonProblem("C1", 2);
- ICPPTemplateParameter tp= ct.getTemplateParameters()[0];
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPClassTemplate ct = bh.assertNonProblem("C1", 2);
+ ICPPTemplateParameter tp = ct.getTemplateParameters()[0];
assertTrue(tp.isParameterPack());
- ct= bh.assertNonProblem("C2", 2);
- tp= ct.getTemplateParameters()[0];
+ ct = bh.assertNonProblem("C2", 2);
+ tp = ct.getTemplateParameters()[0];
assertTrue(tp.isParameterPack());
- ct= bh.assertNonProblem("C3", 2);
- tp= ct.getTemplateParameters()[0];
+ ct = bh.assertNonProblem("C3", 2);
+ tp = ct.getTemplateParameters()[0];
assertTrue(tp.isParameterPack());
}
@@ -5007,14 +5014,14 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// c.mem();
// }
public void testParameterPackExpansions_280909() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPField field= bh.assertNonProblem("a= 1", 1);
- field= bh.assertNonProblem("b= 1", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPField field = bh.assertNonProblem("a= 1", 1);
+ field = bh.assertNonProblem("b= 1", 1);
- ICPPMethod meth= bh.assertNonProblem("mem();", 3);
- IType[] spec= meth.getExceptionSpecification();
+ ICPPMethod meth = bh.assertNonProblem("mem();", 3);
+ IType[] spec = meth.getExceptionSpecification();
assertEquals(2, spec.length);
assertEquals("A", ASTTypeUtil.getType(spec[0]));
assertEquals("B", ASTTypeUtil.getType(spec[1]));
@@ -5023,15 +5030,15 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// template<typename... T> void f1(T*...);
// template<typename T> void f2(T*...);
public void testTemplateParameterPacksAmbiguity_280909() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPFunctionTemplate ft= bh.assertNonProblem("f1", 2);
- ICPPTemplateParameter tp= ft.getTemplateParameters()[0];
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPFunctionTemplate ft = bh.assertNonProblem("f1", 2);
+ ICPPTemplateParameter tp = ft.getTemplateParameters()[0];
assertTrue(tp.isParameterPack());
- ft= bh.assertNonProblem("f2", 2);
- tp= ft.getTemplateParameters()[0];
+ ft = bh.assertNonProblem("f2", 2);
+ tp = ft.getTemplateParameters()[0];
assertFalse(tp.isParameterPack());
}
@@ -5084,8 +5091,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// Tuple<>* t; // OK: Elements is empty
// Tuple* u; // syntax error
public void testVariadicTemplateExamples_280909e() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("String<>", 6);
bh.assertProblem("String*", 6);
bh.assertNonProblem("Tuple<>", 5);
@@ -5104,8 +5111,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// Y<B> yb; // okay
// Y<C> yc; // okay
public void testVariadicTemplateExamples_280909f() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("X<A>", 4);
bh.assertProblem("X<B>", 4);
bh.assertProblem("X<C>", 4);
@@ -5127,8 +5134,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// template<class... Types> void B<Types...>::f3() {} // OK
// template<class... Types> void B<Types>::f4() {} // error
public void testVariadicTemplateExamples_280909g() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("f1() {}", 2);
bh.assertProblem("f2() {}", 2);
bh.assertNonProblem("f3() {}", 2);
@@ -5148,8 +5155,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f<void>(g<int, bool>); // Y for outer f deduced to be
// } // int (*)(bool), Z is deduced to an empty sequence
public void testVariadicTemplateExamples_280909h() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("f<int>(5.6)", 6);
bh.assertProblem("f(5.6)", 1);
bh.assertNonProblem("f<void>(f<int, bool>)", 7);
@@ -5169,8 +5176,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f2<char, short, int, long>(); // okay
// }
public void testVariadicTemplateExamples_280909i() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("f<int,char*,double>", 0);
bh.assertNonProblem("f<int,char*>", 0);
bh.assertNonProblem("f<int>", 0);
@@ -5222,8 +5229,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// Tuple<0> error; // Error: 0 is not a type
// }
public void testVariadicTemplateExamples_280909p() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("Tuple<>", 0);
bh.assertNonProblem("Tuple<int>", 0);
bh.assertNonProblem("Tuple<int, float>", 0);
@@ -5269,20 +5276,21 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f(h(args...) + args...); // okay: first 'args' expanded within h, second 'args' expanded within f.
// }
public void testVariadicTemplateExamples_280909s() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ITypedef td= bh.assertNonProblem("T1;", 2);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ITypedef td = bh.assertNonProblem("T1;", 2);
IType type = getNestedType(td, TDEF);
- assertEquals("Tuple<Pair<short int,unsigned short int>,Pair<int,unsigned int>>", ASTTypeUtil.getType(type, false));
- td= bh.assertNonProblem("zip<short>::with<unsigned short, unsigned>::type", 0);
+ assertEquals("Tuple<Pair<short int,unsigned short int>,Pair<int,unsigned int>>",
+ ASTTypeUtil.getType(type, false));
+ td = bh.assertNonProblem("zip<short>::with<unsigned short, unsigned>::type", 0);
type = getNestedType(td, TDEF);
assertTrue(type instanceof IProblemBinding);
ICPPUnknownBinding ub;
- ub= bh.assertNonProblem("f(const_cast<const Args*>(&args)...)", 1);
- ub= bh.assertNonProblem("f(5 ...)", 1); // no diagnostics in CDT, treated as unknown function.
- ub= bh.assertNonProblem("f(args)", 1); // no diagnostics in CDT
- ub= bh.assertNonProblem("f(h(args...) + args...)", 1);
+ ub = bh.assertNonProblem("f(const_cast<const Args*>(&args)...)", 1);
+ ub = bh.assertNonProblem("f(5 ...)", 1); // no diagnostics in CDT, treated as unknown function.
+ ub = bh.assertNonProblem("f(args)", 1); // no diagnostics in CDT
+ ub = bh.assertNonProblem("f(h(args...) + args...)", 1);
}
// template <typename... Args>
@@ -5336,26 +5344,26 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f<int,char>(); // f<int,char>(0,0)
// }
public void testDefaultTemplateArgsForFunctionTemplates_294730() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
- ICPPTemplateInstance f= bh.assertNonProblem("f(1, 'c');", 1);
+ ICPPTemplateInstance f = bh.assertNonProblem("f(1, 'c');", 1);
assertEquals("<int,char>", ASTTypeUtil.getArgumentListString(f.getTemplateArguments(), true));
- f= bh.assertNonProblem("f(1);", 1);
+ f = bh.assertNonProblem("f(1);", 1);
assertEquals("<int,double>", ASTTypeUtil.getArgumentListString(f.getTemplateArguments(), true));
bh.assertProblem("f();", 1);
- f= bh.assertNonProblem("f<int>();", -3);
+ f = bh.assertNonProblem("f<int>();", -3);
assertEquals("<int,double>", ASTTypeUtil.getArgumentListString(f.getTemplateArguments(), true));
- f= bh.assertNonProblem("f<int,char>();", -3);
+ f = bh.assertNonProblem("f<int,char>();", -3);
assertEquals("<int,char>", ASTTypeUtil.getArgumentListString(f.getTemplateArguments(), true));
}
// template<typename T> class CT {};
// extern template class CT<int>;
public void testExternTemplates_294730() throws Exception {
- final String code= getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code);
- ICPPASTExplicitTemplateInstantiation ti= getDeclaration(tu, 1);
+ final String code = getAboveComment();
+ IASTTranslationUnit tu = parseAndCheckBindings(code);
+ ICPPASTExplicitTemplateInstantiation ti = getDeclaration(tu, 1);
assertEquals(ICPPASTExplicitTemplateInstantiation.EXTERN, ti.getModifier());
}
@@ -5374,24 +5382,24 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// eval<D<int, 17>> eD; // error: D does not match TT in partial specialization
// eval<E<int, float>> eE; // error: E does not match TT in partial specialization
public void testExtendingVariadicTemplateTemplateParameters_302282() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPClassTemplate ct= bh.assertNonProblem("eval;", -1);
- ICPPClassTemplatePartialSpecialization pspec= bh.assertNonProblem("eval<TT<T1, Rest...>>", 0);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPClassTemplate ct = bh.assertNonProblem("eval;", -1);
+ ICPPClassTemplatePartialSpecialization pspec = bh.assertNonProblem("eval<TT<T1, Rest...>>", 0);
- ICPPTemplateInstance inst= bh.assertNonProblem("eval<A<int>>", 0);
+ ICPPTemplateInstance inst = bh.assertNonProblem("eval<A<int>>", 0);
assertSame(pspec, inst.getSpecializedBinding());
- inst= bh.assertNonProblem("eval<B<int, float>>", 0);
+ inst = bh.assertNonProblem("eval<B<int, float>>", 0);
assertSame(pspec, inst.getSpecializedBinding());
- inst= bh.assertNonProblem("eval<C<17>>", 0);
+ inst = bh.assertNonProblem("eval<C<17>>", 0);
assertSame(ct, inst.getSpecializedBinding());
- inst= bh.assertNonProblem("eval<D<int, 17>>", 0);
+ inst = bh.assertNonProblem("eval<D<int, 17>>", 0);
assertSame(ct, inst.getSpecializedBinding());
- inst= bh.assertNonProblem("eval<E<int, float>>", 0);
+ inst = bh.assertNonProblem("eval<E<int, float>>", 0);
assertSame(ct, inst.getSpecializedBinding());
}
@@ -5408,11 +5416,11 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// g(1);
// }
public void testExplicitSpecializations_296427() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("X<int>", 0);
+ inst = bh.assertNonProblem("X<int>", 0);
assertFalse(inst.isExplicitSpecialization());
inst = bh.assertNonProblem("Y<int> y;", 6);
assertTrue(inst.isExplicitSpecialization());
@@ -5447,8 +5455,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// func<int>(1);
// }
public void testBug306213a() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("func<int>", 0);
parseAndCheckBindings(code);
}
@@ -5463,9 +5471,9 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// func<int*>(1);
// }
public void testBug306213b() throws Exception {
- CPPASTNameBase.sAllowRecursionBindings= true;
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ CPPASTNameBase.sAllowRecursionBindings = true;
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertProblem("func<int*>", 0);
}
@@ -5488,27 +5496,27 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// template<> class CT<int,char> {};
// template<> class CT<char,char> {};
public void testBug311164() throws Exception {
- CPPASTNameBase.sAllowNameComputation= true;
- final String code= getAboveComment();
+ CPPASTNameBase.sAllowNameComputation = true;
+ final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
final IASTTranslationUnit tu = bh.getTranslationUnit();
- IBinding b= bh.assertNonProblem("CT {", 2);
+ IBinding b = bh.assertNonProblem("CT {", 2);
IName[] names = tu.getDeclarationsInAST(b);
assertEquals(1, names.length);
assertEquals("CT", names[0].toString());
- names= tu.getReferences(b);
+ names = tu.getReferences(b);
assertEquals(2, names.length);
assertEquals("CT", names[0].toString());
assertEquals("CT", names[1].toString());
- b= bh.assertNonProblem("CT<int,char>", 0);
+ b = bh.assertNonProblem("CT<int,char>", 0);
names = tu.getDeclarationsInAST(b);
assertEquals(1, names.length);
assertEquals("CT<int, char>", names[0].toString());
- b= bh.assertNonProblem("CT<char,char>", 0);
+ b = bh.assertNonProblem("CT<char,char>", 0);
names = tu.getDeclarationsInAST(b);
assertEquals(1, names.length);
assertEquals("CT<char, char>", names[0].toString());
@@ -5518,7 +5526,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// if any methods that were added during the refactoring need
// to be added to ASTComparer.methodsToIgnore.
public void testBug316704() throws Exception {
- StringBuilder code= new StringBuilder("typedef if_< bool,");
+ StringBuilder code = new StringBuilder("typedef if_< bool,");
for (int i = 0; i < 50; i++) {
code.append('\n').append("if_<bool,");
}
@@ -5527,7 +5535,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
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, true, true);
tu = validateCopy(tu);
assertEquals(1, tu.getDeclarations().length);
}
@@ -5563,24 +5571,24 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testInlineNamespaces_305980() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPFunctionTemplate ft= bh.assertNonProblem("f(T&)", 1);
- ICPPNamespace M= (ICPPNamespace) ft.getOwner();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPFunctionTemplate ft = bh.assertNonProblem("f(T&)", 1);
+ ICPPNamespace M = (ICPPNamespace) ft.getOwner();
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f<char>", 0);
+ inst = bh.assertNonProblem("f<char>", 0);
assertSame(ft, inst.getTemplateDefinition());
assertSame(M, inst.getOwner());
- inst= bh.assertNonProblem("f<short>", 0);
+ inst = bh.assertNonProblem("f<short>", 0);
assertSame(ft, inst.getTemplateDefinition());
assertSame(M, inst.getOwner());
- inst= bh.assertNonProblem("f<int>", 0);
+ inst = bh.assertNonProblem("f<int>", 0);
assertSame(ft, inst.getTemplateDefinition());
assertSame(M, inst.getOwner());
- inst= bh.assertNonProblem("f<long>", 0);
+ inst = bh.assertNonProblem("f<long>", 0);
assertSame(ft, inst.getTemplateDefinition());
assertSame(M, inst.getOwner());
}
@@ -5667,11 +5675,11 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// out << endl;
// }
public void testInstantiationOfEndl_297457() throws Exception {
- final String code= getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code);
+ final String code = getAboveComment();
+ IASTTranslationUnit tu = parseAndCheckBindings(code);
final IASTNodeSelector nodeSelector = tu.getNodeSelector(null);
- IASTName methodName= nodeSelector.findEnclosingName(code.indexOf("operator<<"), 1);
+ IASTName methodName = nodeSelector.findEnclosingName(code.indexOf("operator<<"), 1);
IASTImplicitName name = nodeSelector.findImplicitName(code.indexOf("<< endl"), 2);
final IBinding method = methodName.resolveBinding();
@@ -5721,23 +5729,23 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f(g, 1);
// }
public void testInstantiationOfFunctionTemplateWithOverloadedFunctionSetArgument_326492() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPFunctionTemplate f1= bh.assertNonProblem("f(T (*)(int), char)", 1);
- ICPPFunctionTemplate f2= bh.assertNonProblem("f(int (*)(T), int)", 1);
- IFunction g1= bh.assertNonProblem("g(char)", 1);
- IFunction g2= bh.assertNonProblem("g(int)", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPFunctionTemplate f1 = bh.assertNonProblem("f(T (*)(int), char)", 1);
+ ICPPFunctionTemplate f2 = bh.assertNonProblem("f(int (*)(T), int)", 1);
+ IFunction g1 = bh.assertNonProblem("g(char)", 1);
+ IFunction g2 = bh.assertNonProblem("g(int)", 1);
ICPPTemplateInstance t;
- t= bh.assertNonProblem("f(g, '1')", 1);
+ t = bh.assertNonProblem("f(g, '1')", 1);
assertSame(f1, t.getTemplateDefinition());
- t= bh.assertNonProblem("f(g, 1)", 1);
+ t = bh.assertNonProblem("f(g, 1)", 1);
assertSame(f2, t.getTemplateDefinition());
ICPPFunction g;
- g= bh.assertNonProblem("g, '1')", 1);
+ g = bh.assertNonProblem("g, '1')", 1);
assertSame(g2, g);
- g= bh.assertNonProblem("g, 1)", 1);
+ g = bh.assertNonProblem("g, 1)", 1);
assertSame(g1, g);
}
@@ -5789,10 +5797,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// l.m().foo = 1;
// }
public void testNestedTypedefSpecialization_329795() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPField f1= bh.assertNonProblem("foo;", 3);
- IBinding f2= bh.assertNonProblem("foo =", 3);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPField f1 = bh.assertNonProblem("foo;", 3);
+ IBinding f2 = bh.assertNonProblem("foo =", 3);
assertSame(f1, f2);
}
@@ -6032,20 +6040,20 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// s<1 && 2>::f(); // f is global
// }
public void testTemplateIDAmbiguity_341747a() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings();
- IASTFunctionDefinition fdef= getDeclaration(tu, 4);
+ IASTTranslationUnit tu = parseAndCheckBindings();
+ IASTFunctionDefinition fdef = getDeclaration(tu, 4);
IASTExpressionStatement stmt;
- stmt= getStatement(fdef, 0);
+ stmt = getStatement(fdef, 0);
assertTrue(stmt.getExpression() instanceof IASTBinaryExpression);
- stmt= getStatement(fdef, 1);
+ stmt = getStatement(fdef, 1);
assertTrue(stmt.getExpression() instanceof IASTFunctionCallExpression);
- stmt= getStatement(fdef, 2);
+ stmt = getStatement(fdef, 2);
assertTrue(stmt.getExpression() instanceof IASTFunctionCallExpression);
- stmt= getStatement(fdef, 0);
+ stmt = getStatement(fdef, 0);
assertTrue(stmt.getExpression() instanceof IASTBinaryExpression);
}
@@ -6162,9 +6170,9 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// }
public void testArgumentDeductionFromReturnTypeOfExplicitSpecialization_355304() throws Exception {
parseAndCheckBindings();
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPFunctionTemplate template= bh.assertNonProblem("f();", 1);
- ICPPTemplateInstance inst= bh.assertNonProblem("f() {", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPFunctionTemplate template = bh.assertNonProblem("f();", 1);
+ ICPPTemplateInstance inst = bh.assertNonProblem("f() {", 1);
assertSame(template, inst.getTemplateDefinition());
}
@@ -6354,8 +6362,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// B<int>::pointer a;
public void testDependentExpressions_b() throws Exception {
parseAndCheckBindings();
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPVariable var= bh.assertNonProblem("a;", 1, ICPPVariable.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPVariable var = bh.assertNonProblem("a;", 1, ICPPVariable.class);
IType type = var.getType();
type = SemanticUtil.getNestedType(type, TDEF);
assertEquals("int *", type.toString());
@@ -6554,8 +6562,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// };
public void testTemplateShortNameInQualifiedName_367607() throws Exception {
parseAndCheckBindings();
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPDeferredClassInstance shortHand= bh.assertNonProblem("derived:", -1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPDeferredClassInstance shortHand = bh.assertNonProblem("derived:", -1);
assertTrue(shortHand.getClassTemplate() instanceof ICPPClassTemplatePartialSpecialization);
}
@@ -6601,8 +6609,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// e.x; // ERROR HERE: "Field 'x' could not be resolved"
// }
public void testAutoTypeWithTypedef_368311() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- IVariable v= bh.assertNonProblem("cur = r.begin()", 3);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ IVariable v = bh.assertNonProblem("cur = r.begin()", 3);
assertEquals("A<S>::iterator_t", ASTTypeUtil.getType(v.getType(), true));
parseAndCheckBindings();
}
@@ -6921,16 +6929,16 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// };
public void testNestedAliasDeclarationNestingLevel() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPAliasTemplate templateParameterAlias = bh.assertNonProblem("Alias=", "Alias", ICPPAliasTemplate.class);
- ICPPTemplateParameter aliasParameterT= templateParameterAlias.getTemplateParameters()[0];
+ ICPPTemplateParameter aliasParameterT = templateParameterAlias.getTemplateParameters()[0];
assertEquals(1, aliasParameterT.getTemplateNestingLevel());
ICPPAliasTemplateInstance aliasIntInstance = bh.assertNonProblem("Alias<int>");
IType typeOfAliasIntInstance = aliasIntInstance.getType();
assertTrue(typeOfAliasIntInstance instanceof ICPPBasicType);
- assertEquals(((ICPPBasicType)typeOfAliasIntInstance).getKind(), IBasicType.Kind.eInt);
+ assertEquals(((ICPPBasicType) typeOfAliasIntInstance).getKind(), IBasicType.Kind.eInt);
parseAndCheckBindings(code);
}
@@ -6942,7 +6950,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// };
public void testAliasDeclarationNestingLevel() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPAliasTemplate templateParameterAlias = bh.assertNonProblem("Alias=", "Alias", ICPPAliasTemplate.class);
ICPPTemplateParameter aliasParameterT = templateParameterAlias.getTemplateParameters()[0];
@@ -6975,7 +6983,6 @@ public class AST2TemplateTests extends AST2CPPTestBase {
IFunction foo = assertionHelper.assertNonProblem("void foo() {", "foo", IFunction.class);
IVariable myA = assertionHelper.assertNonProblem("Alias myA", "myA", IVariable.class);
-
assertInstances(collector, S, 2);
assertInstances(collector, x, 2);
assertInstances(collector, Alias, 2);
@@ -7004,7 +7011,6 @@ public class AST2TemplateTests extends AST2CPPTestBase {
IVariable myA = assertionHelper.assertNonProblem("Alias myA;", "myA", IVariable.class);
ICPPSpecialization xRef = assertionHelper.assertNonProblem("myA.x = 42;", "x", ICPPSpecialization.class);
-
assertInstances(collector, S, 2);
assertInstances(collector, Alias, 2);
assertInstances(collector, myA, 2);
@@ -7023,8 +7029,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
NameCollector collector = getNameCollector(assertionHelper.getTranslationUnit());
- ICPPAliasTemplate Alias = assertionHelper.assertNonProblem("using Alias = int;", "Alias", ICPPAliasTemplate.class);
- ICPPAliasTemplateInstance aliasFloatInstance = assertionHelper.assertNonProblem("Alias<float> myA;", "Alias<float>", ICPPAliasTemplateInstance.class);
+ ICPPAliasTemplate Alias = assertionHelper.assertNonProblem("using Alias = int;", "Alias",
+ ICPPAliasTemplate.class);
+ ICPPAliasTemplateInstance aliasFloatInstance = assertionHelper.assertNonProblem("Alias<float> myA;",
+ "Alias<float>", ICPPAliasTemplateInstance.class);
assertInstances(collector, Alias, 2);
assertSameType(aliasFloatInstance, new CPPBasicType(IBasicType.Kind.eInt, 0));
@@ -7048,9 +7056,12 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType S = assertionHelper.assertNonProblem("struct S {", "S", ICPPClassType.class);
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
- ICPPTemplateParameter T = assertionHelper.assertNonProblem("template<typename _T>", "_T", ICPPTemplateParameter.class);
- ICPPTemplateParameter TRef = assertionHelper.assertNonProblem("using TAlias = S<_T>;", "_T", ICPPTemplateParameter.class);
- ICPPAliasTemplate TAlias = assertionHelper.assertNonProblem("using TAlias = S<_T>;", "TAlias", ICPPAliasTemplate.class);
+ ICPPTemplateParameter T = assertionHelper.assertNonProblem("template<typename _T>", "_T",
+ ICPPTemplateParameter.class);
+ ICPPTemplateParameter TRef = assertionHelper.assertNonProblem("using TAlias = S<_T>;", "_T",
+ ICPPTemplateParameter.class);
+ ICPPAliasTemplate TAlias = assertionHelper.assertNonProblem("using TAlias = S<_T>;", "TAlias",
+ ICPPAliasTemplate.class);
ICPPVariable myA = assertionHelper.assertNonProblem("TAlias<int> myA;", "myA", ICPPVariable.class);
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = 42;", "t", ICPPSpecialization.class);
@@ -7087,13 +7098,18 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPField t2 = assertionHelper.assertNonProblem("T2 t2;", "t2", ICPPField.class);
ICPPField t3 = assertionHelper.assertNonProblem("T3 t3;", "t3", ICPPField.class);
- ICPPTemplateParameter P1 = assertionHelper.assertNonProblem("template<typename P1, typename P2>", "P1", ICPPTemplateParameter.class);
- ICPPTemplateParameter P2 = assertionHelper.assertNonProblem("template<typename P1, typename P2>", "P2", ICPPTemplateParameter.class);
+ ICPPTemplateParameter P1 = assertionHelper.assertNonProblem("template<typename P1, typename P2>", "P1",
+ ICPPTemplateParameter.class);
+ ICPPTemplateParameter P2 = assertionHelper.assertNonProblem("template<typename P1, typename P2>", "P2",
+ ICPPTemplateParameter.class);
- ICPPTemplateParameter P1Ref = assertionHelper.assertNonProblem("using TAlias = S<int, P2, P1>;", "P1", ICPPTemplateParameter.class);
- ICPPTemplateParameter P2Ref = assertionHelper.assertNonProblem("using TAlias = S<int, P2, P1>;", "P2", ICPPTemplateParameter.class);
+ ICPPTemplateParameter P1Ref = assertionHelper.assertNonProblem("using TAlias = S<int, P2, P1>;", "P1",
+ ICPPTemplateParameter.class);
+ ICPPTemplateParameter P2Ref = assertionHelper.assertNonProblem("using TAlias = S<int, P2, P1>;", "P2",
+ ICPPTemplateParameter.class);
- ICPPAliasTemplateInstance TAliasInstance = assertionHelper.assertNonProblem("TAlias<bool, float> myA;", "TAlias<bool, float>", ICPPAliasTemplateInstance.class);
+ ICPPAliasTemplateInstance TAliasInstance = assertionHelper.assertNonProblem("TAlias<bool, float> myA;",
+ "TAlias<bool, float>", ICPPAliasTemplateInstance.class);
ICPPTemplateInstance aliasedTypeInstance = (ICPPTemplateInstance) TAliasInstance.getType();
ICPPSpecialization t1Ref = assertionHelper.assertNonProblem("myA.t1 = 42;", "t1", ICPPSpecialization.class);
@@ -7106,9 +7122,12 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertEquals(t1, t1Ref.getSpecializedBinding());
assertEquals(t2, t2Ref.getSpecializedBinding());
assertEquals(t3, t3Ref.getSpecializedBinding());
- assertSameType(new CPPBasicType(IBasicType.Kind.eInt, 0), aliasedTypeInstance.getTemplateArguments()[0].getTypeValue());
- assertSameType(new CPPBasicType(IBasicType.Kind.eFloat, 0), aliasedTypeInstance.getTemplateArguments()[1].getTypeValue());
- assertSameType(new CPPBasicType(IBasicType.Kind.eBoolean, 0), aliasedTypeInstance.getTemplateArguments()[2].getTypeValue());
+ assertSameType(new CPPBasicType(IBasicType.Kind.eInt, 0),
+ aliasedTypeInstance.getTemplateArguments()[0].getTypeValue());
+ assertSameType(new CPPBasicType(IBasicType.Kind.eFloat, 0),
+ aliasedTypeInstance.getTemplateArguments()[1].getTypeValue());
+ assertSameType(new CPPBasicType(IBasicType.Kind.eBoolean, 0),
+ aliasedTypeInstance.getTemplateArguments()[2].getTypeValue());
}
// template<typename T>
@@ -7127,11 +7146,12 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
- ICPPAliasTemplateInstance TAliasSInt = assertionHelper.assertNonProblem("TAlias<S<int>> myA;", "TAlias<S<int>>", ICPPAliasTemplateInstance.class);
+ ICPPAliasTemplateInstance TAliasSInt = assertionHelper.assertNonProblem("TAlias<S<int>> myA;", "TAlias<S<int>>",
+ ICPPAliasTemplateInstance.class);
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = S<int>()", "t", ICPPSpecialization.class);
assertEquals(t, tRef.getSpecializedBinding());
- assertSameType(TAliasSInt, (IType)tRef.getOwner());
+ assertSameType(TAliasSInt, (IType) tRef.getOwner());
}
// template<typename T>
@@ -7150,7 +7170,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
- ICPPTemplateInstance STAliasInt = assertionHelper.assertNonProblem("S<TAlias<int>> myA;", "S<TAlias<int>>", ICPPTemplateInstance.class);
+ ICPPTemplateInstance STAliasInt = assertionHelper.assertNonProblem("S<TAlias<int>> myA;", "S<TAlias<int>>",
+ ICPPTemplateInstance.class);
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = S<int>();", "t", ICPPSpecialization.class);
assertEquals(t, tRef.getSpecializedBinding());
@@ -7173,11 +7194,12 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
ICPPField buff = assertionHelper.assertNonProblem("int buff [Size];", "buff", ICPPField.class);
- ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff", ICPPSpecialization.class);
+ ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff",
+ ICPPSpecialization.class);
assertEquals(buff, buffRef.getSpecializedBinding());
- assertEquals(Long.valueOf(4),buffRef.getTemplateParameterMap().getArgument(0).getNonTypeValue().numberValue());
- assertEquals(Long.valueOf(5),buffRef.getTemplateParameterMap().getArgument(1).getNonTypeValue().numberValue());
+ assertEquals(Long.valueOf(4), buffRef.getTemplateParameterMap().getArgument(0).getNonTypeValue().numberValue());
+ assertEquals(Long.valueOf(5), buffRef.getTemplateParameterMap().getArgument(1).getNonTypeValue().numberValue());
}
// template<typename T, int Size>
@@ -7196,12 +7218,15 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
ICPPField buff = assertionHelper.assertNonProblem("T buff [Size];", "buff", ICPPField.class);
- ICPPAliasTemplateInstance myA = assertionHelper.assertNonProblem("TAlias<> myA;", "TAlias<>", ICPPAliasTemplateInstance.class);
- ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff", ICPPSpecialization.class);
+ ICPPAliasTemplateInstance myA = assertionHelper.assertNonProblem("TAlias<> myA;", "TAlias<>",
+ ICPPAliasTemplateInstance.class);
+ ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff",
+ ICPPSpecialization.class);
assertEquals(buff, buffRef.getSpecializedBinding());
- assertSameType(buffRef.getTemplateParameterMap().getArgument(0).getTypeValue(), new CPPBasicType(IBasicType.Kind.eInt, 0));
- assertEquals(Long.valueOf(5),buffRef.getTemplateParameterMap().getArgument(1).getNonTypeValue().numberValue());
+ assertSameType(buffRef.getTemplateParameterMap().getArgument(0).getTypeValue(),
+ new CPPBasicType(IBasicType.Kind.eInt, 0));
+ assertEquals(Long.valueOf(5), buffRef.getTemplateParameterMap().getArgument(1).getNonTypeValue().numberValue());
}
// template<typename T>
@@ -7221,7 +7246,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
ICPPSpecialization tRef = assertionHelper.assertNonProblem(" myA.t = S<int>();", "t", ICPPSpecialization.class);
- ICPPClassSpecialization Sint = assertionHelper.assertNonProblem("myA.t = S<int>();", "S<int>", ICPPClassSpecialization.class);
+ ICPPClassSpecialization Sint = assertionHelper.assertNonProblem("myA.t = S<int>();", "S<int>",
+ ICPPClassSpecialization.class);
assertEquals(t, tRef.getSpecializedBinding());
assertSameType(tRef.getTemplateParameterMap().getArgument(0).getTypeValue(), Sint);
@@ -7247,7 +7273,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
ICPPFunction bar = assertionHelper.assertNonProblem("void bar(TAlias<int> arg){", "bar", ICPPFunction.class);
- ICPPFunction barRefAlias = assertionHelper.assertNonProblem("bar(myA);", "bar", ICPPFunction.class);
+ ICPPFunction barRefAlias = assertionHelper.assertNonProblem("bar(myA);", "bar", ICPPFunction.class);
ICPPFunction barRefSInt = assertionHelper.assertNonProblem("bar(myS);", "bar", ICPPFunction.class);
assertEquals(bar, barRefAlias);
@@ -7288,7 +7314,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// void bar(TAlias<int> arg){
// }
public void testTemplatedAliasRedefinitionOfSameFunction() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
bh.assertNonProblem("bar(S", "bar", ICPPFunction.class);
bh.assertProblem("bar(TAlias", "bar", ISemanticProblem.BINDING_INVALID_REDEFINITION);
}
@@ -7306,7 +7332,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f(v);
// }
public void testTemplatedAliasDeduction() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
bh.assertNonProblem("g(v)", "g", ICPPFunction.class);
bh.assertProblem("f(v)", "f", ISemanticProblem.BINDING_NOT_FOUND);
}
@@ -7321,12 +7347,13 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
NameCollector collector = getNameCollector(assertionHelper.getTranslationUnit());
- ITypedef function = assertionHelper.assertNonProblem("using function = void (&)(int)", "function", ITypedef.class);
+ ITypedef function = assertionHelper.assertNonProblem("using function = void (&)(int)", "function",
+ ITypedef.class);
ICPPFunction foo = assertionHelper.assertNonProblem("void foo(int)", "foo", ICPPFunction.class);
assertInstances(collector, function, 2);
assertInstances(collector, foo, 2);
- assertSameType(((ICPPReferenceType)function.getType()).getType(), foo.getType());
+ assertSameType(((ICPPReferenceType) function.getType()).getType(), foo.getType());
}
// template<typename T>
@@ -7345,8 +7372,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
- ICPPClassSpecialization SInt = assertionHelper.assertNonProblem("S<int> myS;", "S<int>", ICPPClassSpecialization.class);
- ICPPAliasTemplateInstance TAliasInt = assertionHelper.assertNonProblem("TAlias<int> myA = myS;", "TAlias<int>", ICPPAliasTemplateInstance.class);
+ ICPPClassSpecialization SInt = assertionHelper.assertNonProblem("S<int> myS;", "S<int>",
+ ICPPClassSpecialization.class);
+ ICPPAliasTemplateInstance TAliasInt = assertionHelper.assertNonProblem("TAlias<int> myA = myS;", "TAlias<int>",
+ ICPPAliasTemplateInstance.class);
assertSameType(new CPPReferenceType(SInt, false), TAliasInt);
}
@@ -7362,13 +7391,15 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
NameCollector collector = getNameCollector(assertionHelper.getTranslationUnit());
- ICPPAliasTemplate function = assertionHelper.assertNonProblem("using function = void (int)", "function", ICPPAliasTemplate.class);
- ICPPFunction foo = assertionHelper.assertNonProblem("void foo(int) {", "foo", ICPPFunction.class);
- ICPPAliasTemplateInstance functionInt = assertionHelper.assertNonProblem("function<int> f = &foo;", "function<int>", ICPPAliasTemplateInstance.class);
+ ICPPAliasTemplate function = assertionHelper.assertNonProblem("using function = void (int)", "function",
+ ICPPAliasTemplate.class);
+ ICPPFunction foo = assertionHelper.assertNonProblem("void foo(int) {", "foo", ICPPFunction.class);
+ ICPPAliasTemplateInstance functionInt = assertionHelper.assertNonProblem("function<int> f = &foo;",
+ "function<int>", ICPPAliasTemplateInstance.class);
assertInstances(collector, function, 2);
assertInstances(collector, foo, 2);
- assertSameType(foo.getType(),functionInt);
+ assertSameType(foo.getType(), functionInt);
}
// template<typename T>
@@ -7382,13 +7413,15 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
NameCollector collector = getNameCollector(assertionHelper.getTranslationUnit());
- ICPPAliasTemplate function = assertionHelper.assertNonProblem("using function = void (&)(int)", "function", ICPPAliasTemplate.class);
+ ICPPAliasTemplate function = assertionHelper.assertNonProblem("using function = void (&)(int)", "function",
+ ICPPAliasTemplate.class);
ICPPFunction foo = assertionHelper.assertNonProblem("void foo(int) {", "foo", ICPPFunction.class);
- ICPPAliasTemplateInstance functionInt = assertionHelper.assertNonProblem("function<int> f = &foo;", "function<int>", ICPPAliasTemplateInstance.class);
+ ICPPAliasTemplateInstance functionInt = assertionHelper.assertNonProblem("function<int> f = &foo;",
+ "function<int>", ICPPAliasTemplateInstance.class);
assertInstances(collector, function, 2);
assertInstances(collector, foo, 2);
- assertSameType(new CPPReferenceType(foo.getType(), false),functionInt.getType());
+ assertSameType(new CPPReferenceType(foo.getType(), false), functionInt.getType());
}
// template<typename T>
@@ -7408,7 +7441,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = S<int>();", "t", ICPPSpecialization.class);
- ICPPClassSpecialization Sint = assertionHelper.assertNonProblem("myA.t = S<int>();", "S<int>", ICPPClassSpecialization.class);
+ ICPPClassSpecialization Sint = assertionHelper.assertNonProblem("myA.t = S<int>();", "S<int>",
+ ICPPClassSpecialization.class);
assertEquals(t, tRef.getSpecializedBinding());
assertSameType(tRef.getTemplateParameterMap().getArgument(0).getTypeValue(), Sint);
@@ -7454,8 +7488,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
- ICPPAliasTemplateInstance AliasInt =
- assertionHelper.assertNonProblem("Alias<int> intAlias;", "Alias<int>", ICPPAliasTemplateInstance.class);
+ ICPPAliasTemplateInstance AliasInt = assertionHelper.assertNonProblem("Alias<int> intAlias;", "Alias<int>",
+ ICPPAliasTemplateInstance.class);
assertEquals("Alias", AliasInt.getName());
assertEquals("NS", AliasInt.getQualifiedName()[0]);
assertEquals("Alias", AliasInt.getQualifiedName()[1]);
@@ -7463,7 +7497,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertInstance(aliasedType, ICPPTemplateInstance.class);
ICPPTemplateArgument[] args = ((ICPPTemplateInstance) aliasedType).getTemplateArguments();
assertEquals(1, args.length);
- assertSameType(CommonCPPTypes.int_, args[0].getTypeValue());
+ assertSameType(CommonCPPTypes.int_, args[0].getTypeValue());
ICPPNamespace namespaceNS = assertionHelper.assertNonProblem("using namespace NS;", "NS", ICPPNamespace.class);
assertEquals(namespaceNS, AliasInt.getOwner());
@@ -7854,7 +7888,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testConstexprFunctionCallInTemplateArgument_332829() throws Exception {
parseAndCheckBindings();
}
-
+
// struct IntConvertible {
// constexpr operator int() const { return 42; }
// };
@@ -7866,7 +7900,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testUniformInitializationInTemplateArgument_510010() throws Exception {
parseAndCheckBindings();
}
-
+
// int f() {
// int i = 0;
// if(i < 1){
@@ -8314,26 +8348,26 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertEquals(1, num.longValue());
}
- // template <int>
+ // template <int>
// struct A {
// void waldo();
// };
- //
- // template <typename>
+ //
+ // template <typename>
// struct traits {
// enum {
// E = 1,
// };
// };
//
- // template <typename T>
+ // template <typename T>
// struct L {
- // enum {
+ // enum {
// X = traits<T>::E & 1
// };
// };
- //
- // template <typename T>
+ //
+ // template <typename T>
// struct B : A<L<T>::X> {
// using A<L<T>::X>::waldo;
// };
@@ -8627,7 +8661,6 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertVariableValue(answer, 1);
}
-
// template <template <class> class ... Mixins>
// struct C : Mixins<int>... {};
//
@@ -9020,7 +9053,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testDecltypeInPackExpansion_486425b() throws Exception {
parseAndCheckBindings();
}
-
+
// template <typename T>
// T __declval();
//
@@ -9034,8 +9067,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testDeclvalDeclaration_540957() throws Exception {
parseAndCheckBindings();
}
-
- // template <typename T>
+
+ // template <typename T>
// class meta {
// typedef T type;
// };
@@ -9052,7 +9085,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testDependentPackExpansionInFunctionType_526684() throws Exception {
parseAndCheckBindings();
}
-
+
// template <int> struct __make;
// template <> struct __make<2> { typedef int type; };
//
@@ -9070,7 +9103,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ITypedef waldo = helper.assertNonProblem("Waldo");
assertSameType(CommonCPPTypes.int_, waldo);
}
-
+
// template <int, class>
// struct A {};
//
@@ -9220,7 +9253,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testUnqualifiedFunctionCallInTemplate_402498d() throws Exception {
parseAndCheckBindings();
}
-
+
// void bar();
//
// template <typename T>
@@ -9605,12 +9638,12 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPVariable waldo = helper.assertNonProblem("waldo");
assertConstantValue(0, waldo);
}
-
+
// template <typename T>
// struct traits {
// static constexpr int Flags = 1;
// };
- //
+ //
// template <typename T>
// struct S {
// static constexpr int a = traits<T>::Flags;
@@ -9792,7 +9825,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
IVariable var2 = helper.assertNonProblem("var2");
assertSameType(var1.getType(), var2.getType());
}
-
+
// template <typename T>
// void foo() {
// typedef decltype(T::member) C;
@@ -9937,7 +9970,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testAmbiguityResolutionInNestedClassMethodBody_485388() throws Exception {
parseAndCheckBindings();
}
-
+
// template <typename...>
// struct Voider {
// using type = void;
@@ -10104,7 +10137,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
IVariable waldo = helper.assertNonProblem("waldo");
helper.assertVariableValue("waldo", -13);
}
-
+
// template<int P, int Q>
// struct gcd : gcd<Q, P % Q> {};
//
@@ -10131,7 +10164,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// template<typename R1, typename R2>
// struct ratio_multiply {
- // static constexpr int div = gcd<1, R1::den>::value;
+ // static constexpr int div = gcd<1, R1::den>::value;
// typedef ratio<1, R1::den / div> type;
// };
//
@@ -10141,8 +10174,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// Just check that resolution does not throw an exception.
helper.findName("waldo").resolveBinding();
}
-
- // template <typename Ty>
+
+ // template <typename Ty>
// struct has_rbegin_impl {
// typedef char yes[1];
// typedef char no[2];
@@ -10176,7 +10209,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testSFINAEInEvalIdWithFieldOwner_510834() throws Exception {
parseAndCheckBindings();
}
-
+
// class C {};
//
// void aux(C);
@@ -10194,7 +10227,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testSFINAEInDecltype_516291a() throws Exception {
parseAndCheckBindings();
}
-
+
// class C {};
//
// void aux(C);
@@ -10212,8 +10245,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testSFINAEInDecltype_516291b() throws Exception {
parseAndCheckBindings();
}
-
- // template <typename>
+
+ // template <typename>
// using void_t = void;
//
// template <typename T, typename = void>
@@ -10228,7 +10261,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testSFINAEInAliasTemplateArgs_516338() throws Exception {
parseAndCheckBindings();
}
-
+
// template <typename, typename>
// struct is_same {
// static constexpr bool value = false;
@@ -10264,7 +10297,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testInstantiationOfEvalIdWithFieldOwner_511108() throws Exception {
parseAndCheckBindings();
}
-
+
// class C {};
// typedef C D;
//
@@ -10280,7 +10313,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testDependentDestructorName_511122() throws Exception {
parseAndCheckBindings();
}
-
+
// template <class T>
// using alias = T;
//
@@ -10299,6 +10332,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testNoexceptSpecifierInTypeTemplateArgument_511186() throws Exception {
parseAndCheckBindings();
}
+
// namespace ns {
//
// template <typename T>
@@ -10318,7 +10352,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testFriendFunctionDeclarationInNamespace_513681() throws Exception {
parseAndCheckBindings();
}
-
+
// template<class T, unsigned long Size = sizeof(T)>
// class foobar {};
//
@@ -10332,7 +10366,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testDependentSizeofInDefaultArgument_513430() throws Exception {
parseAndCheckBindings();
}
-
+
// struct S {
// int& foo();
// };
@@ -10348,7 +10382,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testDependentMemberAccess_516290() throws Exception {
parseAndCheckBindings();
}
-
+
// template <typename>
// struct A;
//
@@ -10360,7 +10394,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testDelegatingConstructorInPartialSpecialization_512932() throws Exception {
parseAndCheckBindings();
}
-
+
// enum class E { F };
//
// template <unsigned char>
@@ -10375,7 +10409,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testOverloadingOnTypeOfNonTypeTemplateParameter_512932() throws Exception {
parseAndCheckBindings();
}
-
+
// template <typename T>
// void waldo(T&);
//
@@ -10388,7 +10422,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testReferenceBinding_Regression_516284() throws Exception {
parseAndCheckBindings();
}
-
+
// // Declare a constexpr function that turns int and int& into different values.
// template <typename T> constexpr int foo();
// template <> constexpr int foo<int>() { return 42; };
@@ -10410,7 +10444,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// Check that the TypeOfDependentExpression instantiated to the correct type.
helper.assertVariableValue("waldo", 42);
}
-
+
// template <int N>
// struct Model {
// static constexpr int getFamily() {
@@ -10427,7 +10461,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableValue("waldo", 1300);
}
-
+
// template <int N>
// struct constant {
// static constexpr int value = N;
@@ -10448,7 +10482,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableValue("waldo", 1300);
}
-
+
// template <class>
// struct A {
// template <class>
@@ -10465,7 +10499,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testMemberOfUnknownMemberClass_519819() throws Exception {
parseAndCheckBindings();
}
-
+
// template <class> class any {};
// typedef any<any<any<any<any<any<any<any<any<any<any<any<any<any<any<any<
// any<any<any<any<any<any<any<any<any<any<any<any<any<any<any<
@@ -10512,7 +10546,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertNotNull(problem);
assertEquals(IProblem.TEMPLATE_ARGUMENT_NESTING_DEPTH_LIMIT_EXCEEDED, problem.getID());
}
-
+
// template<class... Ts>
// struct infinite;
//
@@ -10542,7 +10576,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertProblem("generate<400>", "generate<400>");
}
-
+
// template <typename T> T declval();
//
// template <class T>
@@ -10554,13 +10588,13 @@ public class AST2TemplateTests extends AST2CPPTestBase {
IType waldo = helper.assertNonProblem("Waldo");
assertSameType(CommonCPPTypes.void_, waldo);
}
-
+
// template <int, int, int, int, int, int, int, int> int constant8f();
//
// template <int i0, int i1, int i2, int i3>
// void foo() {
// constant8f<
- // i0 < 0, i0 < 0,
+ // i0 < 0, i0 < 0,
// i1 < 0, i1 < 0,
// i2 < 0, i2 < 0,
// i3 < 0, i3 < 0>();
@@ -10568,7 +10602,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testTemplateIdAmbiguity_529696() throws Exception {
parseAndCheckBindings();
}
-
+
// template <int...>
// using index_sequence = int;
//
@@ -10577,7 +10611,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testTemplateAliasWithVariadicNonTypeArgs_530086a() throws Exception {
parseAndCheckBindings();
}
-
+
// template <int...>
// struct integer_sequence {};
//
@@ -10586,14 +10620,14 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// template <typename, int... I>
// void bar(index_sequence<I...>);
- //
+ //
// void foo() {
// bar<int>(integer_sequence<0>{});
// }
public void testTemplateAliasWithVariadicArgs_530086b() throws Exception {
parseAndCheckBindings();
}
-
+
// template<bool, typename _Tp = void>
// struct enable_if {};
//
@@ -10812,7 +10846,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableValue("waldo", 42);
}
-
+
// namespace std {
// template <class E>
// struct initializer_list {
@@ -10843,7 +10877,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testOverloadResolutionWithInitializerList_531322() throws Exception {
parseAndCheckBindings();
}
-
+
// using size_t = decltype(sizeof(int));
//
// template <class Fn, class... Ts>
@@ -10937,7 +10971,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// // Make it long enough to be sure that if the runtime is exponential
// // in the length of the list, the test suite times out.
// TypeList<int, short, void, float, double, long, char
- // int*, short*, void*, float*, double*, long*, char*>,
+ // int*, short*, void*, float*, double*, long*, char*>,
// Empty,
// MetaFlip<Fn>>;
//
@@ -10951,7 +10985,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testMetaprogrammingWithAliasTemplates_534126() throws Exception {
parseAndCheckBindings();
}
-
+
// template <class>
// struct hhh {
// using type = int;
@@ -11038,7 +11072,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// template <typename> struct B;
// using C = B<A>;
public void testInvalidAliasTemplateWithTemplateTemplateParameter_540676() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertProblem("B<A>", 4);
}
}
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 9d9f2370519..569c4fbdede 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
@@ -101,13 +101,13 @@ import junit.framework.AssertionFailedError;
public class AST2TestBase extends SemanticTestBase {
public final static String TEST_CODE = "<testcode>";
protected static final IParserLogService NULL_LOG = new NullLogService();
- protected static boolean sValidateCopy;
+ protected static boolean sValidateCopy;
- private static final ScannerInfo GNU_SCANNER_INFO = new ScannerInfo(getGnuMap());
+ private static final ScannerInfo GNU_SCANNER_INFO = new ScannerInfo(getGnuMap());
private static final ScannerInfo SCANNER_INFO = new ScannerInfo(getStdMap());
private static Map<String, String> getGnuMap() {
- Map<String, String> map= new HashMap<>();
+ Map<String, String> map = new HashMap<>();
map.put("__GNUC__", Integer.toString(GCC_MAJOR_VERSION_FOR_TESTS));
map.put("__GNUC_MINOR__", Integer.toString(GCC_MINOR_VERSION_FOR_TESTS));
map.put("__SIZEOF_SHORT__", "2");
@@ -119,7 +119,7 @@ public class AST2TestBase extends SemanticTestBase {
}
private static Map<String, String> getStdMap() {
- Map<String, String> map= new HashMap<>();
+ Map<String, String> map = new HashMap<>();
map.put("__SIZEOF_SHORT__", "2");
map.put("__SIZEOF_INT__", "4");
map.put("__SIZEOF_LONG__", "8");
@@ -128,80 +128,81 @@ public class AST2TestBase extends SemanticTestBase {
return map;
}
- public AST2TestBase() {
- super();
- }
+ public AST2TestBase() {
+ super();
+ }
public AST2TestBase(String name) {
- super(name);
- }
+ super(name);
+ }
- @Override
+ @Override
protected void setUp() throws Exception {
- sValidateCopy= true;
+ sValidateCopy = true;
super.setUp();
}
protected IASTTranslationUnit parse(String code, ParserLanguage lang) throws ParserException {
- return parse(code, lang, false, true);
- }
-
- protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions) throws ParserException {
- return parse(code, lang, useGNUExtensions, true);
- }
-
- protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
- boolean expectNoProblems) throws ParserException {
- return parse(code, lang, useGNUExtensions, expectNoProblems, Integer.MAX_VALUE);
- }
-
- protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
- boolean expectNoProblems, int limitTrivialInitializers) throws ParserException {
- IScanner scanner = createScanner(FileContent.create(TEST_CODE, code.toCharArray()), lang, ParserMode.COMPLETE_PARSE,
- createScannerInfo(useGNUExtensions));
- configureScanner(scanner);
- AbstractGNUSourceCodeParser parser = null;
- if (lang == ParserLanguage.CPP) {
- ICPPParserExtensionConfiguration config = null;
- if (useGNUExtensions) {
- config = new GPPParserExtensionConfiguration();
- } else {
- config = new ANSICPPParserExtensionConfiguration();
- }
- parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null);
- } else {
- ICParserExtensionConfiguration config = null;
-
- if (useGNUExtensions) {
- config = new GCCParserExtensionConfiguration();
- } else {
- config = new ANSICParserExtensionConfiguration();
- }
-
- parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null);
- }
- parser.setMaximumTrivialExpressionsInAggregateInitializers(limitTrivialInitializers);
-
- IASTTranslationUnit tu = parser.parse();
- assertTrue(tu.isFrozen());
- if (sValidateCopy)
- validateCopy(tu);
-
- if (parser.encounteredError() && expectNoProblems)
- throw new ParserException("FAILURE"); //$NON-NLS-1$
-
- if (lang == ParserLanguage.C && expectNoProblems) {
- assertEquals(CVisitor.getProblems(tu).length, 0);
- assertEquals(tu.getPreprocessorProblems().length, 0);
- } else if (lang == ParserLanguage.CPP && expectNoProblems) {
- assertEquals(CPPVisitor.getProblems(tu).length, 0);
- assertEquals(0, tu.getPreprocessorProblems().length);
- }
- if (expectNoProblems)
- assertEquals(0, tu.getPreprocessorProblems().length);
-
- return tu;
- }
+ return parse(code, lang, false, true);
+ }
+
+ protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions)
+ throws ParserException {
+ return parse(code, lang, useGNUExtensions, true);
+ }
+
+ protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
+ boolean expectNoProblems) throws ParserException {
+ return parse(code, lang, useGNUExtensions, expectNoProblems, Integer.MAX_VALUE);
+ }
+
+ protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
+ boolean expectNoProblems, int limitTrivialInitializers) throws ParserException {
+ IScanner scanner = createScanner(FileContent.create(TEST_CODE, code.toCharArray()), lang,
+ ParserMode.COMPLETE_PARSE, createScannerInfo(useGNUExtensions));
+ configureScanner(scanner);
+ AbstractGNUSourceCodeParser parser = null;
+ if (lang == ParserLanguage.CPP) {
+ ICPPParserExtensionConfiguration config = null;
+ if (useGNUExtensions) {
+ config = new GPPParserExtensionConfiguration();
+ } else {
+ config = new ANSICPPParserExtensionConfiguration();
+ }
+ parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null);
+ } else {
+ ICParserExtensionConfiguration config = null;
+
+ if (useGNUExtensions) {
+ config = new GCCParserExtensionConfiguration();
+ } else {
+ config = new ANSICParserExtensionConfiguration();
+ }
+
+ parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null);
+ }
+ parser.setMaximumTrivialExpressionsInAggregateInitializers(limitTrivialInitializers);
+
+ IASTTranslationUnit tu = parser.parse();
+ assertTrue(tu.isFrozen());
+ if (sValidateCopy)
+ validateCopy(tu);
+
+ if (parser.encounteredError() && expectNoProblems)
+ throw new ParserException("FAILURE"); //$NON-NLS-1$
+
+ if (lang == ParserLanguage.C && expectNoProblems) {
+ assertEquals(CVisitor.getProblems(tu).length, 0);
+ assertEquals(tu.getPreprocessorProblems().length, 0);
+ } else if (lang == ParserLanguage.CPP && expectNoProblems) {
+ assertEquals(CPPVisitor.getProblems(tu).length, 0);
+ assertEquals(0, tu.getPreprocessorProblems().length);
+ }
+ if (expectNoProblems)
+ assertEquals(0, tu.getPreprocessorProblems().length);
+
+ return tu;
+ }
public ScannerInfo createScannerInfo(boolean useGnu) {
if (useGnu)
@@ -215,134 +216,137 @@ public class AST2TestBase extends SemanticTestBase {
public static IScanner createScanner(FileContent codeReader, ParserLanguage lang, ParserMode mode,
IScannerInfo scannerInfo) {
IScannerExtensionConfiguration configuration = null;
- if (lang == ParserLanguage.C) {
- configuration= GCCScannerExtensionConfiguration.getInstance(scannerInfo);
- } else {
- configuration= GPPScannerExtensionConfiguration.getInstance(scannerInfo);
- }
- IScanner scanner;
- scanner= new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration,
- IncludeFileContentProvider.getSavedFilesProvider());
+ if (lang == ParserLanguage.C) {
+ configuration = GCCScannerExtensionConfiguration.getInstance(scannerInfo);
+ } else {
+ configuration = GPPScannerExtensionConfiguration.getInstance(scannerInfo);
+ }
+ IScanner scanner;
+ scanner = new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration,
+ IncludeFileContentProvider.getSavedFilesProvider());
return scanner;
}
- protected void validateSimplePostfixInitializerExpressionC(String code) throws ParserException {
- ICASTTypeIdInitializerExpression e = (ICASTTypeIdInitializerExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
- assertNotNull(e);
- assertNotNull(e.getTypeId());
- assertNotNull(e.getInitializer());
- }
-
- protected void validateSimpleUnaryTypeIdExpression(String code, int op) throws ParserException {
- IASTCastExpression e = (IASTCastExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
- assertNotNull(e);
- assertEquals(e.getOperator(), op);
- assertNotNull(e.getTypeId());
- IASTIdExpression x = (IASTIdExpression) e.getOperand();
- assertEquals(x.getName().toString(), "x"); //$NON-NLS-1$
- }
-
- protected void validateSimpleTypeIdExpressionC(String code, int op) throws ParserException {
- IASTTypeIdExpression e = (IASTTypeIdExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
- assertNotNull(e);
- assertEquals(e.getOperator(), op);
- assertNotNull(e.getTypeId());
- }
-
- protected void validateSimpleUnaryExpressionC(String code, int operator) throws ParserException {
- IASTUnaryExpression e = (IASTUnaryExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
- assertNotNull(e);
- assertEquals(e.getOperator(), operator);
- IASTIdExpression x = (IASTIdExpression) e.getOperand();
- assertEquals(x.getName().toString(), "x"); //$NON-NLS-1$
- }
-
- protected void validateConditionalExpressionC(String code) throws ParserException {
- IASTConditionalExpression e = (IASTConditionalExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
- assertNotNull(e);
- IASTIdExpression x = (IASTIdExpression) e.getLogicalConditionExpression();
- assertEquals(x.getName().toString(), "x"); //$NON-NLS-1$
- IASTIdExpression y = (IASTIdExpression) e.getPositiveResultExpression();
- assertEquals(y.getName().toString(), "y"); //$NON-NLS-1$
- IASTIdExpression x2 = (IASTIdExpression) e.getNegativeResultExpression();
- assertEquals(x.getName().toString(), x2.getName().toString());
- }
-
- protected void validateSimpleBinaryExpressionC(String code, int operand) throws ParserException {
- IASTBinaryExpression e = (IASTBinaryExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
- assertNotNull(e);
- assertEquals(e.getOperator(), operand);
- 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 IASTExpression getExpressionFromStatementInCode(String code, ParserLanguage language) 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);
- IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement cs = (IASTCompoundStatement) f.getBody();
- IASTExpressionStatement s = (IASTExpressionStatement) cs.getStatements()[1];
- return s.getExpression();
- }
-
- protected <T extends IASTNode> T validateCopy(T tu) {
+ protected void validateSimplePostfixInitializerExpressionC(String code) throws ParserException {
+ ICASTTypeIdInitializerExpression e = (ICASTTypeIdInitializerExpression) getExpressionFromStatementInCode(code,
+ ParserLanguage.C);
+ assertNotNull(e);
+ assertNotNull(e.getTypeId());
+ assertNotNull(e.getInitializer());
+ }
+
+ protected void validateSimpleUnaryTypeIdExpression(String code, int op) throws ParserException {
+ IASTCastExpression e = (IASTCastExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
+ assertNotNull(e);
+ assertEquals(e.getOperator(), op);
+ assertNotNull(e.getTypeId());
+ IASTIdExpression x = (IASTIdExpression) e.getOperand();
+ assertEquals(x.getName().toString(), "x"); //$NON-NLS-1$
+ }
+
+ protected void validateSimpleTypeIdExpressionC(String code, int op) throws ParserException {
+ IASTTypeIdExpression e = (IASTTypeIdExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
+ assertNotNull(e);
+ assertEquals(e.getOperator(), op);
+ assertNotNull(e.getTypeId());
+ }
+
+ protected void validateSimpleUnaryExpressionC(String code, int operator) throws ParserException {
+ IASTUnaryExpression e = (IASTUnaryExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
+ assertNotNull(e);
+ assertEquals(e.getOperator(), operator);
+ IASTIdExpression x = (IASTIdExpression) e.getOperand();
+ assertEquals(x.getName().toString(), "x"); //$NON-NLS-1$
+ }
+
+ protected void validateConditionalExpressionC(String code) throws ParserException {
+ IASTConditionalExpression e = (IASTConditionalExpression) getExpressionFromStatementInCode(code,
+ ParserLanguage.C);
+ assertNotNull(e);
+ IASTIdExpression x = (IASTIdExpression) e.getLogicalConditionExpression();
+ assertEquals(x.getName().toString(), "x"); //$NON-NLS-1$
+ IASTIdExpression y = (IASTIdExpression) e.getPositiveResultExpression();
+ assertEquals(y.getName().toString(), "y"); //$NON-NLS-1$
+ IASTIdExpression x2 = (IASTIdExpression) e.getNegativeResultExpression();
+ assertEquals(x.getName().toString(), x2.getName().toString());
+ }
+
+ protected void validateSimpleBinaryExpressionC(String code, int operand) throws ParserException {
+ IASTBinaryExpression e = (IASTBinaryExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
+ assertNotNull(e);
+ assertEquals(e.getOperator(), operand);
+ 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 IASTExpression getExpressionFromStatementInCode(String code, ParserLanguage language)
+ 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);
+ IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement cs = (IASTCompoundStatement) f.getBody();
+ IASTExpressionStatement s = (IASTExpressionStatement) cs.getStatements()[1];
+ return s.getExpression();
+ }
+
+ protected <T extends IASTNode> T validateCopy(T tu) {
IASTNode copy = tu.copy();
assertFalse(copy.isFrozen());
ASTComparer.assertCopy(tu, copy);
return (T) copy;
}
- static protected class NameCollector extends ASTVisitor {
- public NameCollector() {
- this(false); // don't visit implicit names by default
- }
+ static protected class NameCollector extends ASTVisitor {
+ public NameCollector() {
+ this(false); // don't visit implicit names by default
+ }
- public NameCollector(boolean shouldVisitImplicitNames) {
- this.shouldVisitNames = true;
- this.shouldVisitImplicitNames = shouldVisitImplicitNames;
- }
+ public NameCollector(boolean shouldVisitImplicitNames) {
+ this.shouldVisitNames = true;
+ this.shouldVisitImplicitNames = shouldVisitImplicitNames;
+ }
- public List<IASTName> nameList = new ArrayList<>();
+ public List<IASTName> nameList = new ArrayList<>();
- @Override
+ @Override
public int visit(IASTName name) {
- nameList.add(name);
- return PROCESS_CONTINUE;
- }
-
- public IASTName getName(int idx) {
- if (idx < 0 || idx >= nameList.size())
- return null;
- return nameList.get(idx);
- }
-
- public int size() {
- return nameList.size();
- }
-
- public void dump() {
- for (int i= 0; i < size(); i++) {
- IASTName name= getName(i);
- String parent= name.getParent() != null ? name.getParent().getRawSignature() : "";
- System.out.println(i + ": #" + name.getRawSignature() + "# " + parent);
- }
- }
- }
-
- protected void assertInstances(NameCollector collector, IBinding binding, int num) throws Exception {
- int count = 0;
- for (int i = 0; i < collector.size(); i++) {
- if (collector.getName(i).resolveBinding() == binding)
- count++;
- }
-
- assertEquals(num, count);
- }
+ nameList.add(name);
+ return PROCESS_CONTINUE;
+ }
+
+ public IASTName getName(int idx) {
+ if (idx < 0 || idx >= nameList.size())
+ return null;
+ return nameList.get(idx);
+ }
+
+ public int size() {
+ return nameList.size();
+ }
+
+ public void dump() {
+ for (int i = 0; i < size(); i++) {
+ IASTName name = getName(i);
+ String parent = name.getParent() != null ? name.getParent().getRawSignature() : "";
+ System.out.println(i + ": #" + name.getRawSignature() + "# " + parent);
+ }
+ }
+ }
+
+ protected void assertInstances(NameCollector collector, IBinding binding, int num) throws Exception {
+ int count = 0;
+ for (int i = 0; i < collector.size(); i++) {
+ if (collector.getName(i).resolveBinding() == binding)
+ count++;
+ }
+
+ assertEquals(num, count);
+ }
protected void isExpressionStringEqual(IASTInitializerClause exp, String str) {
String expressionString = ASTStringUtil.getExpressionString((IASTExpression) exp);
@@ -361,7 +365,7 @@ public class AST2TestBase extends SemanticTestBase {
}
protected void isSignatureEqual(IASTDeclarator declarator, String expected) {
- String signature= ASTStringUtil.getSignatureString(declarator);
+ String signature = ASTStringUtil.getSignatureString(declarator);
assertEquals(expected, signature);
}
@@ -461,11 +465,11 @@ public class AST2TestBase extends SemanticTestBase {
}
protected static void assertField(IBinding binding, String fieldName, String ownerName) {
- assertInstance(binding, IField.class);
- assertEquals(fieldName, binding.getName());
- ICompositeType struct = ((IField) binding).getCompositeTypeOwner();
- assertEquals(ownerName, struct.getName());
- }
+ assertInstance(binding, IField.class);
+ assertEquals(fieldName, binding.getName());
+ ICompositeType struct = ((IField) binding).getCompositeTypeOwner();
+ assertEquals(ownerName, struct.getName());
+ }
protected static void assertConstantValue(long expected, IVariable constant) {
IValue value = constant.getInitialValue();
@@ -478,13 +482,13 @@ public class AST2TestBase extends SemanticTestBase {
protected class AST2AssertionHelper extends BindingAssertionHelper {
protected boolean isCPP;
- public AST2AssertionHelper(String contents, boolean isCPP) throws ParserException {
- this(contents, isCPP ? ParserLanguage.CPP : ParserLanguage.C);
+ public AST2AssertionHelper(String contents, boolean isCPP) throws ParserException {
+ this(contents, isCPP ? ParserLanguage.CPP : ParserLanguage.C);
}
- public AST2AssertionHelper(String contents, ParserLanguage lang) throws ParserException {
- super(contents, parse(contents, lang, true, false));
- this.isCPP= lang.isCPP();
+ public AST2AssertionHelper(String contents, ParserLanguage lang) throws ParserException {
+ super(contents, parse(contents, lang, true, false));
+ this.isCPP = lang.isCPP();
}
}
@@ -492,19 +496,20 @@ public class AST2TestBase extends SemanticTestBase {
return parseAndCheckBindings(code, lang, false);
}
- final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang, boolean useGnuExtensions) throws Exception {
+ 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, boolean useGnuExtensions,
- int limitTrivialInitializers) throws Exception {
+ final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang,
+ boolean useGnuExtensions, int limitTrivialInitializers) throws Exception {
IASTTranslationUnit tu = parse(code, lang, useGnuExtensions, true, limitTrivialInitializers);
NameCollector col = new NameCollector();
tu.accept(col);
assertNoProblemBindings(col);
return tu;
}
-
+
final protected IASTTranslationUnit parseAndCheckImplicitNameBindings() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP, false, true);
NameCollector col = new NameCollector(true /* Visit implicit names */);
@@ -514,7 +519,7 @@ public class AST2TestBase extends SemanticTestBase {
}
protected BindingAssertionHelper getAssertionHelper(ParserLanguage lang) throws ParserException, IOException {
- String code= getAboveComment();
+ String code = getAboveComment();
return new AST2AssertionHelper(code, lang);
}
@@ -535,34 +540,34 @@ public class AST2TestBase extends SemanticTestBase {
final protected <T extends IASTDeclaration> T getDeclaration(IASTTranslationUnit tu, int i_decl) {
Class<T> tclass;
- IASTDeclaration[] decls= tu.getDeclarations();
+ IASTDeclaration[] decls = tu.getDeclarations();
assertTrue(decls.length > i_decl);
return (T) decls[i_decl];
}
final protected <T extends IASTDeclaration> T getDeclaration(ICPPASTNamespaceDefinition ns, int i_decl) {
Class<T> tclass;
- IASTDeclaration[] decls= ns.getDeclarations();
+ IASTDeclaration[] decls = ns.getDeclarations();
assertTrue(decls.length > i_decl);
return (T) decls[i_decl];
}
final protected <T extends IASTDeclaration> T getDeclaration(ICPPASTLinkageSpecification ls, int i_decl) {
Class<T> tclass;
- IASTDeclaration[] decls= ls.getDeclarations();
+ IASTDeclaration[] decls = ls.getDeclarations();
assertTrue(decls.length > i_decl);
return (T) decls[i_decl];
}
final protected <T extends IASTDeclaration> T getDeclaration(IASTCompositeTypeSpecifier ct, int i_decl) {
Class<T> tclass;
- IASTDeclaration[] decls= ct.getMembers();
+ IASTDeclaration[] decls = ct.getMembers();
assertTrue(decls.length > i_decl);
return (T) decls[i_decl];
}
final protected <T extends IASTCompositeTypeSpecifier> T getCompositeType(IASTTranslationUnit tu, int i_decl) {
- IASTSimpleDeclaration sdecl= getDeclaration(tu, i_decl);
+ IASTSimpleDeclaration sdecl = getDeclaration(tu, i_decl);
return (T) sdecl.getDeclSpecifier();
}
@@ -571,17 +576,17 @@ public class AST2TestBase extends SemanticTestBase {
}
final protected <T extends IASTStatement> T getStatement(IASTCompoundStatement compound, int i_stmt) {
- IASTStatement[] stmts= compound.getStatements();
+ IASTStatement[] stmts = compound.getStatements();
assertTrue(stmts.length > i_stmt);
return (T) stmts[i_stmt];
}
final protected <T extends IASTExpression> T getExpressionOfStatement(IASTFunctionDefinition fdef, int i) {
- IASTStatement stmt= getStatement(fdef, i);
+ IASTStatement stmt = getStatement(fdef, i);
assertInstance(stmt, IASTExpressionStatement.class);
return (T) ((IASTExpressionStatement) stmt).getExpression();
}
-
+
/**
* Sort the given array of AST names lexicographically.
*/
@@ -590,6 +595,7 @@ public class AST2TestBase extends SemanticTestBase {
@Override
public int compare(IASTName a, IASTName b) {
return a.toString().compareTo(b.toString());
- }});
+ }
+ });
}
}
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 86c625f9d1d..3f42935de6f 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
@@ -160,7 +160,7 @@ public class AST2Tests extends AST2TestBase {
}
private void parseAndCheckBindings(boolean useGnuExtensions) throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code, C, useGnuExtensions);
parseAndCheckBindings(code, CPP, useGnuExtensions);
}
@@ -235,8 +235,7 @@ public class AST2Tests extends AST2TestBase {
// function - void f()
IASTFunctionDefinition funcdef_f = (IASTFunctionDefinition) declarations[1];
- IASTSimpleDeclSpecifier declspec_f =
- (IASTSimpleDeclSpecifier) funcdef_f.getDeclSpecifier();
+ IASTSimpleDeclSpecifier declspec_f = (IASTSimpleDeclSpecifier) funcdef_f.getDeclSpecifier();
assertEquals(IASTSimpleDeclSpecifier.t_void, declspec_f.getType());
IASTFunctionDeclarator declor_f = funcdef_f.getDeclarator();
IASTName name_f = declor_f.getName();
@@ -244,8 +243,7 @@ public class AST2Tests extends AST2TestBase {
// parameter - int y
assertTrue(declor_f instanceof IASTStandardFunctionDeclarator);
- IASTParameterDeclaration decl_y =
- ((IASTStandardFunctionDeclarator) declor_f).getParameters()[0];
+ IASTParameterDeclaration decl_y = ((IASTStandardFunctionDeclarator) declor_f).getParameters()[0];
IASTSimpleDeclSpecifier declspec_y = (IASTSimpleDeclSpecifier) decl_y.getDeclSpecifier();
assertEquals(IASTSimpleDeclSpecifier.t_int, declspec_y.getType());
IASTDeclarator declor_y = decl_y.getDeclarator();
@@ -254,11 +252,9 @@ public class AST2Tests extends AST2TestBase {
// int z
IASTCompoundStatement body_f = (IASTCompoundStatement) funcdef_f.getBody();
- IASTDeclarationStatement declstmt_z =
- (IASTDeclarationStatement) body_f.getStatements()[0];
+ IASTDeclarationStatement declstmt_z = (IASTDeclarationStatement) body_f.getStatements()[0];
IASTSimpleDeclaration decl_z = (IASTSimpleDeclaration) declstmt_z.getDeclaration();
- IASTSimpleDeclSpecifier declspec_z =
- (IASTSimpleDeclSpecifier) decl_z.getDeclSpecifier();
+ IASTSimpleDeclSpecifier declspec_z = (IASTSimpleDeclSpecifier) decl_z.getDeclSpecifier();
assertEquals(IASTSimpleDeclSpecifier.t_int, declspec_z.getType());
IASTDeclarator declor_z = decl_z.getDeclarators()[0];
IASTName name_z = declor_z.getName();
@@ -283,8 +279,7 @@ public class AST2Tests extends AST2TestBase {
IFunction func_f = (IFunction) name_f.resolveBinding();
assertEquals(globalScope, func_f.getScope());
IParameter var_y = (IParameter) name_y.resolveBinding();
- assertEquals(((IASTCompoundStatement) funcdef_f.getBody()).getScope(),
- var_y.getScope());
+ assertEquals(((IASTCompoundStatement) funcdef_f.getBody()).getScope(), var_y.getScope());
IVariable var_z = (IVariable) name_z.resolveBinding();
assertEquals(((ICFunctionScope) func_f.getFunctionScope()).getBodyScope(), var_z.getScope());
@@ -472,63 +467,40 @@ public class AST2Tests extends AST2TestBase {
validateSimpleUnaryExpressionC("~x", IASTUnaryExpression.op_tilde); //$NON-NLS-1$
validateSimpleUnaryExpressionC("*x", IASTUnaryExpression.op_star); //$NON-NLS-1$
validateSimpleUnaryExpressionC("&x", IASTUnaryExpression.op_amper); //$NON-NLS-1$
- validateSimpleUnaryExpressionC(
- "sizeof x", IASTUnaryExpression.op_sizeof); //$NON-NLS-1$
- validateSimpleTypeIdExpressionC(
- "sizeof(int)", IASTTypeIdExpression.op_sizeof); //$NON-NLS-1$
- validateSimpleUnaryTypeIdExpression(
- "(int)x", IASTCastExpression.op_cast); //$NON-NLS-1$
+ validateSimpleUnaryExpressionC("sizeof x", IASTUnaryExpression.op_sizeof); //$NON-NLS-1$
+ validateSimpleTypeIdExpressionC("sizeof(int)", IASTTypeIdExpression.op_sizeof); //$NON-NLS-1$
+ validateSimpleUnaryTypeIdExpression("(int)x", IASTCastExpression.op_cast); //$NON-NLS-1$
validateSimplePostfixInitializerExpressionC("(int) { 5 }"); //$NON-NLS-1$
validateSimplePostfixInitializerExpressionC("(int) { 5, }"); //$NON-NLS-1$
validateSimpleBinaryExpressionC("x=y", IASTBinaryExpression.op_assign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x*=y", IASTBinaryExpression.op_multiplyAssign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x/=y", IASTBinaryExpression.op_divideAssign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x%=y", IASTBinaryExpression.op_moduloAssign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x+=y", IASTBinaryExpression.op_plusAssign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x-=y", IASTBinaryExpression.op_minusAssign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x<<=y", IASTBinaryExpression.op_shiftLeftAssign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x>>=y", IASTBinaryExpression.op_shiftRightAssign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x&=y", IASTBinaryExpression.op_binaryAndAssign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x^=y", IASTBinaryExpression.op_binaryXorAssign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x|=y", IASTBinaryExpression.op_binaryOrAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x*=y", IASTBinaryExpression.op_multiplyAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x/=y", IASTBinaryExpression.op_divideAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x%=y", IASTBinaryExpression.op_moduloAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x+=y", IASTBinaryExpression.op_plusAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x-=y", IASTBinaryExpression.op_minusAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x<<=y", IASTBinaryExpression.op_shiftLeftAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x>>=y", IASTBinaryExpression.op_shiftRightAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x&=y", IASTBinaryExpression.op_binaryAndAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x^=y", IASTBinaryExpression.op_binaryXorAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x|=y", IASTBinaryExpression.op_binaryOrAssign); //$NON-NLS-1$
validateSimpleBinaryExpressionC("x-y", IASTBinaryExpression.op_minus); //$NON-NLS-1$
validateSimpleBinaryExpressionC("x+y", IASTBinaryExpression.op_plus); //$NON-NLS-1$
validateSimpleBinaryExpressionC("x/y", IASTBinaryExpression.op_divide); //$NON-NLS-1$
validateSimpleBinaryExpressionC("x*y", IASTBinaryExpression.op_multiply); //$NON-NLS-1$
validateSimpleBinaryExpressionC("x%y", IASTBinaryExpression.op_modulo); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x<<y", IASTBinaryExpression.op_shiftLeft); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x>>y", IASTBinaryExpression.op_shiftRight); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x<<y", IASTBinaryExpression.op_shiftLeft); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x>>y", IASTBinaryExpression.op_shiftRight); //$NON-NLS-1$
validateSimpleBinaryExpressionC("x<y", IASTBinaryExpression.op_lessThan); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x>y", IASTBinaryExpression.op_greaterThan); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x<=y", IASTBinaryExpression.op_lessEqual); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x>=y", IASTBinaryExpression.op_greaterEqual); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x>y", IASTBinaryExpression.op_greaterThan); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x<=y", IASTBinaryExpression.op_lessEqual); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x>=y", IASTBinaryExpression.op_greaterEqual); //$NON-NLS-1$
validateSimpleBinaryExpressionC("x==y", IASTBinaryExpression.op_equals); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x!=y", IASTBinaryExpression.op_notequals); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x&y", IASTBinaryExpression.op_binaryAnd); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x^y", IASTBinaryExpression.op_binaryXor); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x!=y", IASTBinaryExpression.op_notequals); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x&y", IASTBinaryExpression.op_binaryAnd); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x^y", IASTBinaryExpression.op_binaryXor); //$NON-NLS-1$
validateSimpleBinaryExpressionC("x|y", IASTBinaryExpression.op_binaryOr); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x&&y", IASTBinaryExpression.op_logicalAnd); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x||y", IASTBinaryExpression.op_logicalOr); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x&&y", IASTBinaryExpression.op_logicalAnd); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x||y", IASTBinaryExpression.op_logicalOr); //$NON-NLS-1$
validateConditionalExpressionC("x ? y : x"); //$NON-NLS-1$
}
@@ -1154,8 +1126,7 @@ public class AST2Tests extends AST2TestBase {
IASTForStatement for_stmt = (IASTForStatement) compound.getStatements()[0];
// int i = 0;
- IASTDeclarationStatement declStatement =
- (IASTDeclarationStatement) for_stmt.getInitializerStatement();
+ IASTDeclarationStatement declStatement = (IASTDeclarationStatement) for_stmt.getInitializerStatement();
IASTSimpleDeclaration initDecl = (IASTSimpleDeclaration) declStatement.getDeclaration();
IASTDeclarator dtor = initDecl.getDeclarators()[0];
IASTName name_i = dtor.getName();
@@ -1250,9 +1221,10 @@ public class AST2Tests extends AST2TestBase {
assertEquals(decls[0], fdef.getDeclarator().getName());
fieldRef = (IASTFieldReference) expStatement.getExpression();
- IASTCastExpression castExpression =
- (IASTCastExpression) ((IASTUnaryExpression) fieldRef.getFieldOwner()).getOperand();
- IASTElaboratedTypeSpecifier elaboratedTypeSpecifier = ((IASTElaboratedTypeSpecifier) castExpression.getTypeId().getDeclSpecifier());
+ IASTCastExpression castExpression = (IASTCastExpression) ((IASTUnaryExpression) fieldRef.getFieldOwner())
+ .getOperand();
+ IASTElaboratedTypeSpecifier elaboratedTypeSpecifier = ((IASTElaboratedTypeSpecifier) castExpression
+ .getTypeId().getDeclSpecifier());
decls = tu.getDeclarationsInAST(elaboratedTypeSpecifier.getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], compType.getName());
@@ -1315,10 +1287,8 @@ public class AST2Tests extends AST2TestBase {
IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) tu.getDeclarations()[1];
IASTName name_X1 = decl1.getDeclarators()[0].getName();
IASTName name_f = decl2.getDeclarators()[0].getName();
- IASTStandardFunctionDeclarator functionDecl =
- (IASTStandardFunctionDeclarator) decl2.getDeclarators()[0];
- IASTName name_X2 =
- ((IASTNamedTypeSpecifier) functionDecl.getParameters()[0].getDeclSpecifier()).getName();
+ IASTStandardFunctionDeclarator functionDecl = (IASTStandardFunctionDeclarator) decl2.getDeclarators()[0];
+ IASTName name_X2 = ((IASTNamedTypeSpecifier) functionDecl.getParameters()[0].getDeclSpecifier()).getName();
IASTName name_x = functionDecl.getParameters()[0].getDeclarator().getName();
IASTName[] decls = tu.getDeclarationsInAST(name_X1.resolveBinding());
@@ -1627,10 +1597,14 @@ public class AST2Tests extends AST2TestBase {
public void testBug270275_int_is_equivalent_to_signed_int() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), C);
IASTDeclaration[] declarations = tu.getDeclarations();
- IType plainInt = ((IVariable)((IASTSimpleDeclaration) declarations[0]).getDeclarators()[0].getName().resolveBinding()).getType();
- IType signedInt = ((IVariable)((IASTSimpleDeclaration) declarations[1]).getDeclarators()[0].getName().resolveBinding()).getType();
- IType unsignedInt = ((IVariable)((IASTSimpleDeclaration) declarations[2]).getDeclarators()[0].getName().resolveBinding()).getType();
- IType noSpec = ((IVariable)((IASTSimpleDeclaration) declarations[3]).getDeclarators()[0].getName().resolveBinding()).getType();
+ IType plainInt = ((IVariable) ((IASTSimpleDeclaration) declarations[0]).getDeclarators()[0].getName()
+ .resolveBinding()).getType();
+ IType signedInt = ((IVariable) ((IASTSimpleDeclaration) declarations[1]).getDeclarators()[0].getName()
+ .resolveBinding()).getType();
+ IType unsignedInt = ((IVariable) ((IASTSimpleDeclaration) declarations[2]).getDeclarators()[0].getName()
+ .resolveBinding()).getType();
+ IType noSpec = ((IVariable) ((IASTSimpleDeclaration) declarations[3]).getDeclarators()[0].getName()
+ .resolveBinding()).getType();
assertTrue(plainInt.isSameType(signedInt));
assertFalse(plainInt.isSameType(unsignedInt));
assertFalse(signedInt.isSameType(unsignedInt));
@@ -1812,20 +1786,25 @@ public class AST2Tests extends AST2TestBase {
decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
IFunction f = (IFunction) decl.getDeclarators()[0].getName().resolveBinding();
IASTName name_f = decl.getDeclarators()[0].getName();
- IASTName name_i = ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getParameters()[0].getDeclarator().getName();
- IASTName name_c = ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getParameters()[1].getDeclarator().getName();
+ IASTName name_i = ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getParameters()[0]
+ .getDeclarator().getName();
+ IASTName name_c = ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getParameters()[1]
+ .getDeclarator().getName();
decl = (IASTSimpleDeclaration) tu.getDeclarations()[2];
IVariable g = (IVariable) decl.getDeclarators()[0].getNestedDeclarator().getName().resolveBinding();
IASTName name_g = decl.getDeclarators()[0].getNestedDeclarator().getName();
- IASTName name_A2 = ((IASTElaboratedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getParameters()[0].getDeclSpecifier()).getName();
+ IASTName name_A2 = ((IASTElaboratedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl
+ .getDeclarators()[0]).getParameters()[0].getDeclSpecifier()).getName();
decl = (IASTSimpleDeclaration) tu.getDeclarations()[3];
- IVariable h = (IVariable) decl.getDeclarators()[0].getNestedDeclarator().getNestedDeclarator().getName().resolveBinding();
+ IVariable h = (IVariable) decl.getDeclarators()[0].getNestedDeclarator().getNestedDeclarator().getName()
+ .resolveBinding();
IASTName name_h = decl.getDeclarators()[0].getNestedDeclarator().getNestedDeclarator().getName();
- IASTName name_A3 = ((IASTElaboratedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0].getNestedDeclarator()).getParameters()[0]
- .getDeclSpecifier()).getName();
- IASTName name_d = ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getParameters()[0].getDeclarator().getName();
+ IASTName name_A3 = ((IASTElaboratedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]
+ .getNestedDeclarator()).getParameters()[0].getDeclSpecifier()).getName();
+ IASTName name_d = ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getParameters()[0]
+ .getDeclarator().getName();
IFunctionType t_f = f.getType();
IType t_f_return = t_f.getReturnType();
@@ -1907,7 +1886,7 @@ public class AST2Tests extends AST2TestBase {
assertEquals(decls.length, 1);
assertEquals(decls[0], name_A1);
- assertNull("Expected null, got "+name_d.resolveBinding(), name_d.resolveBinding());
+ assertNull("Expected null, got " + name_d.resolveBinding(), name_d.resolveBinding());
tu = validateCopy(tu);
}
@@ -1933,34 +1912,47 @@ public class AST2Tests extends AST2TestBase {
assertNotNull(tu);
IASTDeclaration[] declarations = tu.getDeclarations();
IASTName name_Coord = ((IASTSimpleDeclaration) declarations[0]).getDeclarators()[0].getName();
- IASTName name_x = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[0]).getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
- IASTName name_y = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[0]).getDeclSpecifier()).getMembers()[1]).getDeclarators()[0].getName();
+ IASTName name_x = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[0])
+ .getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
+ IASTName name_y = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[0])
+ .getDeclSpecifier()).getMembers()[1]).getDeclarators()[0].getName();
IASTName name_Point = ((IASTSimpleDeclaration) declarations[1]).getDeclarators()[0].getName();
- IASTName name_pos = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[1]).getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
- IASTName name_width = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[1]).getDeclSpecifier()).getMembers()[1]).getDeclarators()[0].getName();
+ IASTName name_pos = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[1])
+ .getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
+ IASTName name_width = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[1])
+ .getDeclSpecifier()).getMembers()[1]).getDeclarators()[0].getName();
IASTFunctionDefinition main = (IASTFunctionDefinition) declarations[2];
IASTStatement[] statements = ((IASTCompoundStatement) main.getBody()).getStatements();
- IASTSimpleDeclaration xy = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statements[0]).getDeclaration();
+ IASTSimpleDeclaration xy = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statements[0])
+ .getDeclaration();
IASTName name_Coord2 = ((IASTNamedTypeSpecifier) xy.getDeclSpecifier()).getName();
IASTName name_xy = xy.getDeclarators()[0].getName();
IASTDeclarator declarator_xy = xy.getDeclarators()[0];
- IASTInitializer[] initializers1 = ((IASTInitializerList) ((IASTEqualsInitializer) declarator_xy.getInitializer()).getInitializerClause()).getInitializers();
- IASTName name_y2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers1[0]).getDesignators()[0]).getName();
+ IASTInitializer[] initializers1 = ((IASTInitializerList) ((IASTEqualsInitializer) declarator_xy
+ .getInitializer()).getInitializerClause()).getInitializers();
+ IASTName name_y2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers1[0])
+ .getDesignators()[0]).getName();
// test bug 87649
assertEquals(((ASTNode) (ICASTDesignatedInitializer) initializers1[0]).getLength(), 7);
- IASTName name_x2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers1[1]).getDesignators()[0]).getName();
+ IASTName name_x2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers1[1])
+ .getDesignators()[0]).getName();
- IASTSimpleDeclaration point = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statements[1]).getDeclaration();
+ IASTSimpleDeclaration point = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statements[1])
+ .getDeclaration();
IASTName name_Point2 = ((IASTNamedTypeSpecifier) point.getDeclSpecifier()).getName();
IASTName name_point = point.getDeclarators()[0].getName();
IASTDeclarator declarator_point = point.getDeclarators()[0];
- IASTInitializer[] initializers2 = ((IASTInitializerList) ((IASTEqualsInitializer) declarator_point.getInitializer()).getInitializerClause()).getInitializers();
- IASTName name_width2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers2[0]).getDesignators()[0]).getName();
- IASTName name_pos2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers2[1]).getDesignators()[0]).getName();
- IASTName name_xy2 = ((IASTIdExpression) ((IASTUnaryExpression) ((IASTEqualsInitializer) ((ICASTDesignatedInitializer) initializers2[1]).getOperandInitializer()).getInitializerClause()).getOperand()).getName();
+ IASTInitializer[] initializers2 = ((IASTInitializerList) ((IASTEqualsInitializer) declarator_point
+ .getInitializer()).getInitializerClause()).getInitializers();
+ IASTName name_width2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers2[0])
+ .getDesignators()[0]).getName();
+ IASTName name_pos2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers2[1])
+ .getDesignators()[0]).getName();
+ IASTName name_xy2 = ((IASTIdExpression) ((IASTUnaryExpression) ((IASTEqualsInitializer) ((ICASTDesignatedInitializer) initializers2[1])
+ .getOperandInitializer()).getInitializerClause()).getOperand()).getName();
for (int j = 0; j < 2; ++j) {
ICASTDesignatedInitializer designatedInitializer = (ICASTDesignatedInitializer) initializers1[j];
@@ -2024,12 +2016,18 @@ public class AST2Tests extends AST2TestBase {
IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTFunctionDefinition f_def = (IASTFunctionDefinition) tu.getDeclarations()[1];
- IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
- IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier()).getMembers()[1]).getDeclarators()[0].getName();
- final IASTDeclarator dtor = ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) f_def.getBody()).getStatements()[0]).getDeclaration()).getDeclarators()[0];
- final IASTInitializerList initializerList = (IASTInitializerList) ((IASTEqualsInitializer) dtor.getInitializer()).getInitializerClause();
- IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[0]).getDesignators()[0]).getName();
- IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[1]).getDesignators()[0]).getName();
+ IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier())
+ .getMembers()[0]).getDeclarators()[0].getName();
+ IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier())
+ .getMembers()[1]).getDeclarators()[0].getName();
+ final IASTDeclarator dtor = ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) f_def
+ .getBody()).getStatements()[0]).getDeclaration()).getDeclarators()[0];
+ final IASTInitializerList initializerList = (IASTInitializerList) ((IASTEqualsInitializer) dtor
+ .getInitializer()).getInitializerClause();
+ IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[0])
+ .getDesignators()[0]).getName();
+ IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[1])
+ .getDesignators()[0]).getName();
assertEquals(a1.resolveBinding(), a2.resolveBinding());
assertEquals(b1.resolveBinding(), b2.resolveBinding());
@@ -2056,11 +2054,16 @@ public class AST2Tests extends AST2TestBase {
for (int i = 0; i < NUM_TESTS; i++) {
IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
- IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier()).getMembers()[1]).getDeclarators()[0].getName();
- final IASTInitializer[] initializers = ((IASTInitializerList) ((IASTEqualsInitializer) S_decl.getDeclarators()[0].getInitializer()).getInitializerClause()).getInitializers();
- IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers[0]).getDesignators()[0]).getName();
- IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers[1]).getDesignators()[0]).getName();
+ IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier())
+ .getMembers()[0]).getDeclarators()[0].getName();
+ IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier())
+ .getMembers()[1]).getDeclarators()[0].getName();
+ final IASTInitializer[] initializers = ((IASTInitializerList) ((IASTEqualsInitializer) S_decl
+ .getDeclarators()[0].getInitializer()).getInitializerClause()).getInitializers();
+ IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers[0]).getDesignators()[0])
+ .getName();
+ IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers[1]).getDesignators()[0])
+ .getName();
assertEquals(a1.resolveBinding(), a2.resolveBinding());
assertEquals(b1.resolveBinding(), b2.resolveBinding());
@@ -2091,12 +2094,16 @@ public class AST2Tests extends AST2TestBase {
IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTSimpleDeclaration x_decl = (IASTSimpleDeclaration) tu.getDeclarations()[3];
- IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
- IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier()).getMembers()[1]).getDeclarators()[0].getName();
+ IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier())
+ .getMembers()[0]).getDeclarators()[0].getName();
+ IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier())
+ .getMembers()[1]).getDeclarators()[0].getName();
IASTInitializer initializer = x_decl.getDeclarators()[0].getInitializer();
- initializer= (IASTInitializer) ((IASTEqualsInitializer) initializer).getInitializerClause();
- IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) initializer).getInitializers()[0]).getDesignators()[0]).getName();
- IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) initializer).getInitializers()[1]).getDesignators()[0]).getName();
+ initializer = (IASTInitializer) ((IASTEqualsInitializer) initializer).getInitializerClause();
+ IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) initializer)
+ .getInitializers()[0]).getDesignators()[0]).getName();
+ IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) initializer)
+ .getInitializers()[1]).getDesignators()[0]).getName();
assertEquals(a1.resolveBinding(), a2.resolveBinding());
assertEquals(b1.resolveBinding(), b2.resolveBinding());
@@ -2114,8 +2121,7 @@ public class AST2Tests extends AST2TestBase {
}
public void testFnReturningPtrToFn() throws Exception {
- IASTTranslationUnit tu = parse(
- "void (* f(int))() {}", C); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse("void (* f(int))() {}", C); //$NON-NLS-1$
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[0];
@@ -2142,8 +2148,7 @@ public class AST2Tests extends AST2TestBase {
// [ and ] of the
// array type derivation.
public void testArrayTypeToQualifiedPointerTypeParm() throws Exception {
- IASTTranslationUnit tu = parse(
- "void f(int parm[const 3]);", C); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse("void f(int parm[const 3]);", C); //$NON-NLS-1$
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
IASTSimpleDeclaration def = (IASTSimpleDeclaration) tu.getDeclarations()[0];
@@ -2154,7 +2159,8 @@ public class AST2Tests extends AST2TestBase {
assertTrue(((IPointerType) ft.getParameterTypes()[0]).isConst());
// test tu.getDeclarationsInAST(IBinding)
- IASTName name_parm = ((IASTStandardFunctionDeclarator) def.getDeclarators()[0]).getParameters()[0].getDeclarator().getName();
+ IASTName name_parm = ((IASTStandardFunctionDeclarator) def.getDeclarators()[0]).getParameters()[0]
+ .getDeclarator().getName();
IASTName[] decls = tu.getDeclarationsInAST(name_parm.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_parm);
@@ -2169,11 +2175,11 @@ public class AST2Tests extends AST2TestBase {
// func(&a);
// }
public void testArrayPointer_261417() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper baC= new AST2AssertionHelper(code, false);
- baC.assertNonProblem("func(&a)", 4, IFunction.class);
- BindingAssertionHelper baCpp= new AST2AssertionHelper(code, true);
- baCpp.assertNonProblem("func(&a)", 4, ICPPFunction.class);
+ String code = getAboveComment();
+ BindingAssertionHelper baC = new AST2AssertionHelper(code, false);
+ baC.assertNonProblem("func(&a)", 4, IFunction.class);
+ BindingAssertionHelper baCpp = new AST2AssertionHelper(code, true);
+ baCpp.assertNonProblem("func(&a)", 4, ICPPFunction.class);
}
// int f() {}
@@ -2200,8 +2206,8 @@ public class AST2Tests extends AST2TestBase {
assertTrue(((IPointerType) ft2.getReturnType()).getType() instanceof IBasicType);
assertTrue(ft3.getReturnType() instanceof IPointerType);
assertTrue(((IPointerType) ft3.getReturnType()).getType() instanceof IFunctionType);
- assertTrue(((IFunctionType) ((IPointerType) ft3.getReturnType()).getType()).getReturnType()
- instanceof IBasicType);
+ assertTrue(((IFunctionType) ((IPointerType) ft3.getReturnType()).getType())
+ .getReturnType() instanceof IBasicType);
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(def1.getDeclarator().getName().resolveBinding());
@@ -2242,9 +2248,10 @@ public class AST2Tests extends AST2TestBase {
// test tu.getDeclarationsInAST(IBinding)
assertTrue(def.getDeclarator() instanceof IASTStandardFunctionDeclarator);
- IASTName name_g = ((IASTStandardFunctionDeclarator) def.getDeclarator()).getParameters()[0].getDeclarator().getName();
- IASTName name_g_call =
- ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTReturnStatement) ((IASTCompoundStatement) def.getBody()).getStatements()[0]).getReturnValue()).getFunctionNameExpression()).getName();
+ IASTName name_g = ((IASTStandardFunctionDeclarator) def.getDeclarator()).getParameters()[0].getDeclarator()
+ .getName();
+ IASTName name_g_call = ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTReturnStatement) ((IASTCompoundStatement) def
+ .getBody()).getStatements()[0]).getReturnValue()).getFunctionNameExpression()).getName();
IASTName[] decls = tu.getDeclarationsInAST(name_g_call.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_g);
@@ -2259,7 +2266,8 @@ public class AST2Tests extends AST2TestBase {
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IVariable v = (IVariable) ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getNestedDeclarator().getName().resolveBinding();
+ IVariable v = (IVariable) ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getNestedDeclarator()
+ .getName().resolveBinding();
IType vt_1 = v.getType();
assertTrue(vt_1 instanceof IArrayType);
@@ -2283,9 +2291,11 @@ public class AST2Tests extends AST2TestBase {
assertEquals(((IBasicType) vpt_2_2).getType(), IBasicType.t_int);
// test tu.getDeclarationsInAST(IBinding)
- IASTName[] decls = tu.getDeclarationsInAST(((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getNestedDeclarator().getName().resolveBinding());
+ IASTName[] decls = tu.getDeclarationsInAST(((IASTStandardFunctionDeclarator) decl.getDeclarators()[0])
+ .getNestedDeclarator().getName().resolveBinding());
assertEquals(decls.length, 1);
- assertEquals(decls[0], ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getNestedDeclarator().getName());
+ assertEquals(decls[0],
+ ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getNestedDeclarator().getName());
tu = validateCopy(tu);
}
@@ -2332,11 +2342,13 @@ public class AST2Tests extends AST2TestBase {
assertEquals(decls.length, 1);
assertEquals(decls[0], name_DWORD);
- decls = tu.getDeclarationsInAST(((IASTNamedTypeSpecifier) decl2.getDeclSpecifier()).getName().resolveBinding());
+ decls = tu.getDeclarationsInAST(
+ ((IASTNamedTypeSpecifier) decl2.getDeclSpecifier()).getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_DWORD);
- decls = tu.getDeclarationsInAST(((IASTNamedTypeSpecifier) decl3.getDeclSpecifier()).getName().resolveBinding());
+ decls = tu.getDeclarationsInAST(
+ ((IASTNamedTypeSpecifier) decl3.getDeclSpecifier()).getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_v);
@@ -2386,7 +2398,7 @@ public class AST2Tests extends AST2TestBase {
assertTrue(signal_ret_ret_1 instanceof ITypedef);
IType signal_ret_ret_2 = ((ITypedef) signal_ret_ret_1).getType();
assertTrue(signal_ret_ret_2 instanceof IBasicType);
- assertEquals(((IBasicType) signal_ret_ret_2).getType(), IBasicType.t_void);
+ assertEquals(((IBasicType) signal_ret_ret_2).getType(), IBasicType.t_void);
assertTrue(((ITypedef) signal_ret_ret_1).getName().equals("DWORD")); //$NON-NLS-1$
IType signal_parm_t1 = signal_t.getParameterTypes()[0];
@@ -2402,15 +2414,14 @@ public class AST2Tests extends AST2TestBase {
assertTrue(signal_parm_t2_ret_1 instanceof ITypedef);
IType signal_parm_t2_ret_2 = ((ITypedef) signal_parm_t2_ret_1).getType();
assertTrue(signal_parm_t2_ret_2 instanceof IBasicType);
- assertEquals(((IBasicType) signal_parm_t2_ret_2).getType(),
- IBasicType.t_void);
+ assertEquals(((IBasicType) signal_parm_t2_ret_2).getType(), IBasicType.t_void);
assertTrue(((ITypedef) signal_parm_t2_ret_1).getName().equals("DWORD")); //$NON-NLS-1$
// test tu.getDeclarationsInAST(IBinding)
IASTName name_pfv = decl2.getDeclarators()[0].getNestedDeclarator().getName();
IASTName name_pfv1 = ((IASTNamedTypeSpecifier) decl3.getDeclSpecifier()).getName();
- IASTName name_pfv2 = ((IASTNamedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl3
- .getDeclarators()[0]).getParameters()[1].getDeclSpecifier()).getName();
+ IASTName name_pfv2 = ((IASTNamedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl3.getDeclarators()[0])
+ .getParameters()[1].getDeclSpecifier()).getName();
IASTName[] decls = tu.getDeclarationsInAST(name_pfv1.resolveBinding());
assertEquals(decls.length, 1);
@@ -2439,16 +2450,15 @@ public class AST2Tests extends AST2TestBase {
ITypedef pfv = (ITypedef) declarators[1].getNestedDeclarator().getName().resolveBinding();
IType fv_t = fv.getType();
- assertEquals(((IBasicType) ((IFunctionType) fv_t).getReturnType()).getType(),
- IBasicType.t_void);
- assertEquals(((IBasicType) ((IFunctionType) fv_t).getParameterTypes()[0]).getType(),
- IBasicType.t_int);
+ assertEquals(((IBasicType) ((IFunctionType) fv_t).getReturnType()).getType(), IBasicType.t_void);
+ assertEquals(((IBasicType) ((IFunctionType) fv_t).getParameterTypes()[0]).getType(), IBasicType.t_int);
IType pfv_t = pfv.getType();
- assertEquals(((IBasicType) ((IFunctionType) ((IPointerType) pfv_t)
- .getType()).getReturnType()).getType(), IBasicType.t_void);
- assertEquals(((IBasicType) ((IFunctionType) ((IPointerType) pfv
- .getType()).getType()).getParameterTypes()[0]).getType(),
+ assertEquals(((IBasicType) ((IFunctionType) ((IPointerType) pfv_t).getType()).getReturnType()).getType(),
+ IBasicType.t_void);
+ assertEquals(
+ ((IBasicType) ((IFunctionType) ((IPointerType) pfv.getType()).getType()).getParameterTypes()[0])
+ .getType(),
IBasicType.t_int);
decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
@@ -2466,50 +2476,41 @@ public class AST2Tests extends AST2TestBase {
IFunction signal3 = (IFunction) declarators[0].getName().resolveBinding();
IType signal3_t = signal3.getType();
+ assertEquals(((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t).getReturnType())
+ .getType()).getReturnType()).getType(), IBasicType.t_void);
+ assertEquals(((IBasicType) ((IFunctionType) signal1_t).getParameterTypes()[0]).getType(), IBasicType.t_int);
assertEquals(
- ((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t)
- .getReturnType()).getType()).getReturnType()).getType(),
- IBasicType.t_void);
- assertEquals(((IBasicType) ((IFunctionType) signal1_t)
- .getParameterTypes()[0]).getType(), IBasicType.t_int);
- assertEquals(
- ((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t)
- .getParameterTypes()[1]).getType()).getReturnType())
- .getType(), IBasicType.t_void);
- assertEquals(
- ((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t)
- .getParameterTypes()[1]).getType()).getParameterTypes()[0])
- .getType(), IBasicType.t_int);
-
+ ((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t).getParameterTypes()[1])
+ .getType()).getReturnType()).getType(),
+ IBasicType.t_void);
assertEquals(
- ((IBasicType) ((IFunctionType) ((ITypedef) ((IPointerType) ((IFunctionType) signal2_t)
- .getReturnType()).getType()).getType()).getReturnType())
- .getType(), IBasicType.t_void);
- assertEquals(((IBasicType) ((IFunctionType) signal2_t).getParameterTypes()[0]).getType(),
+ ((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t).getParameterTypes()[1])
+ .getType()).getParameterTypes()[0]).getType(),
IBasicType.t_int);
+
+ assertEquals(((IBasicType) ((IFunctionType) ((ITypedef) ((IPointerType) ((IFunctionType) signal2_t)
+ .getReturnType()).getType()).getType()).getReturnType()).getType(), IBasicType.t_void);
+ assertEquals(((IBasicType) ((IFunctionType) signal2_t).getParameterTypes()[0]).getType(), IBasicType.t_int);
assertEquals(
((IBasicType) ((IFunctionType) ((ITypedef) ((IPointerType) ((IFunctionType) signal2_t)
- .getParameterTypes()[1]).getType()).getType())
- .getReturnType()).getType(), IBasicType.t_void);
+ .getParameterTypes()[1]).getType()).getType()).getReturnType()).getType(),
+ IBasicType.t_void);
assertEquals(
((IBasicType) ((IFunctionType) ((ITypedef) ((IPointerType) ((IFunctionType) signal2_t)
- .getParameterTypes()[1]).getType()).getType())
- .getParameterTypes()[0]).getType(), IBasicType.t_int);
+ .getParameterTypes()[1]).getType()).getType()).getParameterTypes()[0]).getType(),
+ IBasicType.t_int);
+ assertEquals(((IBasicType) ((IFunctionType) ((IPointerType) ((ITypedef) ((IFunctionType) signal3_t)
+ .getReturnType()).getType()).getType()).getReturnType()).getType(), IBasicType.t_void);
+ assertEquals(((IBasicType) ((IFunctionType) signal3_t).getParameterTypes()[0]).getType(), IBasicType.t_int);
assertEquals(
((IBasicType) ((IFunctionType) ((IPointerType) ((ITypedef) ((IFunctionType) signal3_t)
- .getReturnType()).getType()).getType()).getReturnType())
- .getType(), IBasicType.t_void);
- assertEquals(((IBasicType) ((IFunctionType) signal3_t)
- .getParameterTypes()[0]).getType(), IBasicType.t_int);
- assertEquals(
- ((IBasicType) ((IFunctionType) ((IPointerType) ((ITypedef) ((IFunctionType) signal3_t)
- .getParameterTypes()[1]).getType()).getType())
- .getReturnType()).getType(), IBasicType.t_void);
+ .getParameterTypes()[1]).getType()).getType()).getReturnType()).getType(),
+ IBasicType.t_void);
assertEquals(
((IBasicType) ((IFunctionType) ((IPointerType) ((ITypedef) ((IFunctionType) signal3_t)
- .getParameterTypes()[1]).getType()).getType())
- .getParameterTypes()[0]).getType(), IBasicType.t_int);
+ .getParameterTypes()[1]).getType()).getType()).getParameterTypes()[0]).getType(),
+ IBasicType.t_int);
tu = validateCopy(tu);
}
@@ -2519,8 +2520,7 @@ public class AST2Tests extends AST2TestBase {
// int y [ const static x ];
public void testBug80992() throws Exception {
ICASTArrayModifier mod = (ICASTArrayModifier) ((IASTArrayDeclarator) ((IASTSimpleDeclaration) parse(
- getAboveComment(), C).getDeclarations()[1])
- .getDeclarators()[0]).getArrayModifiers()[0];
+ getAboveComment(), C).getDeclarations()[1]).getDeclarators()[0]).getArrayModifiers()[0];
assertTrue(mod.isConst());
assertTrue(mod.isStatic());
assertFalse(mod.isRestrict());
@@ -2528,13 +2528,11 @@ public class AST2Tests extends AST2TestBase {
assertFalse(mod.isVariableSized());
}
-
// int y (int [ const *]);
public void testBug80978() throws Exception {
ICASTArrayModifier mod = (ICASTArrayModifier) ((IASTArrayDeclarator) ((IASTStandardFunctionDeclarator) ((IASTSimpleDeclaration) parse(
- getAboveComment(), C).getDeclarations()[0])
- .getDeclarators()[0]).getParameters()[0].getDeclarator())
- .getArrayModifiers()[0];
+ getAboveComment(), C).getDeclarations()[0]).getDeclarators()[0]).getParameters()[0].getDeclarator())
+ .getArrayModifiers()[0];
assertTrue(mod.isConst());
assertTrue(mod.isVariableSized());
assertFalse(mod.isStatic());
@@ -2649,18 +2647,13 @@ public class AST2Tests extends AST2TestBase {
for (int i = 0; i < NUM_TESTS; i++) {
IASTIfStatement if_statement = (IASTIfStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
.getDeclarations()[0]).getBody()).getStatements()[0];
- assertEquals(((IASTBinaryExpression) if_statement
- .getConditionExpression()).getOperator(),
+ assertEquals(((IASTBinaryExpression) if_statement.getConditionExpression()).getOperator(),
IASTBinaryExpression.op_equals);
- IASTIfStatement second_if_statement = (IASTIfStatement) if_statement
- .getElseClause();
- assertEquals(((IASTBinaryExpression) second_if_statement
- .getConditionExpression()).getOperator(),
+ IASTIfStatement second_if_statement = (IASTIfStatement) if_statement.getElseClause();
+ assertEquals(((IASTBinaryExpression) second_if_statement.getConditionExpression()).getOperator(),
IASTBinaryExpression.op_lessThan);
- IASTIfStatement third_if_statement = (IASTIfStatement) second_if_statement
- .getElseClause();
- assertEquals(((IASTBinaryExpression) third_if_statement
- .getConditionExpression()).getOperator(),
+ IASTIfStatement third_if_statement = (IASTIfStatement) second_if_statement.getElseClause();
+ assertEquals(((IASTBinaryExpression) third_if_statement.getConditionExpression()).getOperator(),
IASTBinaryExpression.op_greaterThan);
tu = validateCopy(tu);
@@ -2712,8 +2705,7 @@ public class AST2Tests extends AST2TestBase {
}
public void testBug84096_FieldDesignatorRef() throws Exception {
- IASTTranslationUnit tu = parse(
- "struct s { int a; } ss = { .a = 1 }; \n", C); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse("struct s { int a; } ss = { .a = 1 }; \n", C); //$NON-NLS-1$
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
NameCollector collector = new NameCollector();
@@ -2731,8 +2723,7 @@ public class AST2Tests extends AST2TestBase {
}
public void testProblems() throws Exception {
- IASTTranslationUnit tu = parse(
- " a += ;", C, true, false); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(" a += ;", C, true, false); //$NON-NLS-1$
IASTProblem[] ps = CVisitor.getProblems(tu);
assertEquals(1, ps.length);
ps[0].getMessage();
@@ -2853,7 +2844,8 @@ public class AST2Tests extends AST2TestBase {
public void testBug84250() throws Exception {
assertTrue(((IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) parse(
- "void f() { int (*p) [2]; }", C).getDeclarations()[0]).getBody()).getStatements()[0]).getDeclaration() instanceof IASTSimpleDeclaration); //$NON-NLS-1$
+ "void f() { int (*p) [2]; }", C).getDeclarations()[0]).getBody()).getStatements()[0]) //$NON-NLS-1$
+ .getDeclaration() instanceof IASTSimpleDeclaration);
}
// struct s1 { struct s2 *s2p; /* ... */ }; // D1
@@ -2870,7 +2862,6 @@ public class AST2Tests extends AST2TestBase {
ICompositeType s_decl = (ICompositeType) col.getName(3).resolveBinding();
assertSame(s_ref, s_decl);
-
tu = parse(code, lang);
col = new NameCollector();
tu.accept(col);
@@ -2940,10 +2931,8 @@ public class AST2Tests extends AST2TestBase {
public void testBug84236() throws Exception {
String code = "double maximum(double a[ ][*]);"; //$NON-NLS-1$
- IASTSimpleDeclaration d = (IASTSimpleDeclaration) parse(code,
- C).getDeclarations()[0];
- IASTStandardFunctionDeclarator fd = (IASTStandardFunctionDeclarator) d
- .getDeclarators()[0];
+ IASTSimpleDeclaration d = (IASTSimpleDeclaration) parse(code, C).getDeclarations()[0];
+ IASTStandardFunctionDeclarator fd = (IASTStandardFunctionDeclarator) d.getDeclarators()[0];
IASTParameterDeclaration p = fd.getParameters()[0];
IASTArrayDeclarator a = (IASTArrayDeclarator) p.getDeclarator();
ICASTArrayModifier star = (ICASTArrayModifier) a.getArrayModifiers()[1];
@@ -2961,28 +2950,24 @@ public class AST2Tests extends AST2TestBase {
IASTCompoundStatement body = (IASTCompoundStatement) g.getBody();
final IASTStatement statement = body.getStatements()[0];
assertTrue(statement instanceof IASTDeclarationStatement);
- IASTSimpleDeclaration bp = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statement)
- .getDeclaration();
+ IASTSimpleDeclaration bp = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statement).getDeclaration();
assertTrue(bp.getDeclarators()[0].getName().resolveBinding() instanceof IVariable);
}
public void testBug86766() throws Exception {
- IASTTranslationUnit tu = parse(
- "char foo; void foo() {}", C); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse("char foo; void foo() {}", C); //$NON-NLS-1$
NameCollector col = new NameCollector();
tu.accept(col);
IVariable foo = (IVariable) col.getName(0).resolveBinding();
- IProblemBinding prob = (IProblemBinding) col.getName(1)
- .resolveBinding();
+ IProblemBinding prob = (IProblemBinding) col.getName(1).resolveBinding();
assertEquals(prob.getID(), IProblemBinding.SEMANTIC_INVALID_OVERLOAD);
assertNotNull(foo);
}
public void testBug88338_C() throws Exception {
- IASTTranslationUnit tu = parse(
- "struct A; struct A* a;", C); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse("struct A; struct A* a;", C); //$NON-NLS-1$
NameCollector col = new NameCollector();
tu.accept(col);
@@ -3022,7 +3007,7 @@ public class AST2Tests extends AST2TestBase {
IParameter p = (IParameter) col.getName(1).resolveBinding();
IVariable v1 = (IVariable) col.getName(2).resolveBinding();
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
IScope scope = ((IASTCompoundStatement) fdef.getBody()).getScope();
IBinding[] bs = scope.find("par", tu); //$NON-NLS-1$
@@ -3053,7 +3038,7 @@ public class AST2Tests extends AST2TestBase {
IVariable S3 = (IVariable) col.getName(3).resolveBinding();
ILabel S4 = (ILabel) col.getName(4).resolveBinding();
- IASTFunctionDefinition fdef= getDeclaration(tu, 2);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 2);
IScope scope = ((IASTCompoundStatement) fdef.getBody()).getScope();
IBinding[] bs = scope.find("S", tu); //$NON-NLS-1$
@@ -3066,15 +3051,13 @@ public class AST2Tests extends AST2TestBase {
}
public void test92791() throws Exception {
- IASTTranslationUnit tu = parse(
- "void f() { int x, y; x * y; }", C); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse("void f() { int x, y; x * y; }", C); //$NON-NLS-1$
NameCollector col = new NameCollector();
tu.accept(col);
for (int i = 0; i < col.size(); ++i)
assertFalse(col.getName(i).resolveBinding() instanceof IProblemBinding);
- tu = parse(
- "int y; void f() { typedef int x; x * y; }", C); //$NON-NLS-1$
+ tu = parse("int y; void f() { typedef int x; x * y; }", C); //$NON-NLS-1$
col = new NameCollector();
tu.accept(col);
for (int i = 0; i < col.size(); ++i)
@@ -3082,8 +3065,7 @@ public class AST2Tests extends AST2TestBase {
}
public void testBug85786() throws Exception {
- IASTTranslationUnit tu = parse(
- "void f(int); void foo () { void * p = &f; ((void (*) (int)) p) (1); }", C); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse("void f(int); void foo () { void * p = &f; ((void (*) (int)) p) (1); }", C); //$NON-NLS-1$
NameCollector nameResolver = new NameCollector();
tu.accept(nameResolver);
assertNoProblemBindings(nameResolver);
@@ -3123,10 +3105,9 @@ public class AST2Tests extends AST2TestBase {
assertEquals(declarations.length, 1);
assertNotNull(declarations[0]);
assertTrue(declarations[0] instanceof IASTFunctionDefinition);
- assertEquals(((IASTFunctionDefinition) declarations[0]).getDeclarator()
- .getName().toString(), "main"); //$NON-NLS-1$
- assertTrue(((IASTCompoundStatement) ((IASTFunctionDefinition) declarations[0])
- .getBody()).getStatements()[0] instanceof IASTNullStatement);
+ assertEquals(((IASTFunctionDefinition) declarations[0]).getDeclarator().getName().toString(), "main"); //$NON-NLS-1$
+ assertTrue(((IASTCompoundStatement) ((IASTFunctionDefinition) declarations[0]).getBody())
+ .getStatements()[0] instanceof IASTNullStatement);
}
// #define MACRO(a)
@@ -3139,10 +3120,9 @@ public class AST2Tests extends AST2TestBase {
assertEquals(declarations.length, 1);
assertNotNull(declarations[0]);
assertTrue(declarations[0] instanceof IASTFunctionDefinition);
- assertEquals(((IASTFunctionDefinition) declarations[0]).getDeclarator()
- .getName().toString(), "main"); //$NON-NLS-1$
- assertTrue(((IASTCompoundStatement) ((IASTFunctionDefinition) declarations[0])
- .getBody()).getStatements()[0] instanceof IASTNullStatement);
+ assertEquals(((IASTFunctionDefinition) declarations[0]).getDeclarator().getName().toString(), "main"); //$NON-NLS-1$
+ assertTrue(((IASTCompoundStatement) ((IASTFunctionDefinition) declarations[0]).getBody())
+ .getStatements()[0] instanceof IASTNullStatement);
}
// typedef long _TYPE;
@@ -3158,10 +3138,12 @@ public class AST2Tests extends AST2TestBase {
IASTTranslationUnit tu = parse(getAboveComment(), C, true, true);
IASTDeclaration[] decls = tu.getDeclarations();
- assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).isComplex());
- assertEquals(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
- assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[1]).getDeclSpecifier()).isComplex());
- assertEquals(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
+ assertTrue(((ICASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).isComplex());
+ assertEquals(((ICASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).getType(),
+ IASTSimpleDeclSpecifier.t_float);
+ assertTrue(((ICASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[1]).getDeclSpecifier()).isComplex());
+ assertEquals(((ICASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[1]).getDeclSpecifier()).getType(),
+ IASTSimpleDeclSpecifier.t_double);
}
// int foo();
@@ -3223,7 +3205,7 @@ public class AST2Tests extends AST2TestBase {
// f1(__null);
// }
public void testBug240567() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), false);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), false);
bh.assertNonProblem("f1(__null", 2, IFunction.class);
}
@@ -3245,7 +3227,7 @@ public class AST2Tests extends AST2TestBase {
}
public void testBug100408() throws Exception {
- IASTTranslationUnit tu = parse("int foo() { int x=1; (x)*3; }", C); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse("int foo() { int x=1; (x)*3; }", C); //$NON-NLS-1$
NameCollector col = new NameCollector();
tu.accept(col);
assertNoProblemBindings(col);
@@ -3266,7 +3248,7 @@ public class AST2Tests extends AST2TestBase {
tu.accept(col);
IFunction free = (IFunction) col.getName(4).resolveBinding();
- IParameter [] ps = free.getParameters();
+ IParameter[] ps = free.getParameters();
assertEquals(ps.length, 1);
assertSame(free, col.getName(6).resolveBinding());
@@ -3324,7 +3306,7 @@ public class AST2Tests extends AST2TestBase {
public void test1043290() throws Exception {
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment());
IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[0];
- IASTStatement [] statements = ((IASTCompoundStatement) fd.getBody()).getStatements();
+ IASTStatement[] statements = ((IASTCompoundStatement) fd.getBody()).getStatements();
IASTWhileStatement whileStmt = (IASTWhileStatement) statements[1];
IASTLabelStatement labelStmt = (IASTLabelStatement) whileStmt.getBody();
assertTrue(labelStmt.getNestedStatement() instanceof IASTExpressionStatement);
@@ -3385,9 +3367,9 @@ public class AST2Tests extends AST2TestBase {
buffer.append("((int arg1)) {\n"); //$NON-NLS-1$
buffer.append("return 0;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- tu= parse(buffer.toString(), C);
+ tu = parse(buffer.toString(), C);
assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration);
- tu= parse(buffer.toString(), CPP);
+ tu = parse(buffer.toString(), CPP);
assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration);
}
@@ -3401,7 +3383,7 @@ public class AST2Tests extends AST2TestBase {
buffer.append("((int arg1)) {\r\n"); //$NON-NLS-1$
buffer.append("return 0;\r\n"); //$NON-NLS-1$
buffer.append("}\r\n"); //$NON-NLS-1$
- IASTTranslationUnit tu= parse(buffer.toString(), C);
+ IASTTranslationUnit tu = parse(buffer.toString(), C);
assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration);
tu = parse(buffer.toString(), CPP);
@@ -3478,17 +3460,17 @@ public class AST2Tests extends AST2TestBase {
// z= (a)%z;
// }
public void testBracketAroundIdentifier_168924() throws IOException, ParserException {
- String content= getAboveComment();
- IASTTranslationUnit tu= parse(content, C, true, true);
- IASTFunctionDefinition func= (IASTFunctionDefinition) tu.getDeclarations()[0];
- IASTParameterDeclaration[] params= ((IASTStandardFunctionDeclarator) func.getDeclarator()).getParameters();
- IBinding binding= params[0].getDeclarator().getName().resolveBinding();
+ String content = getAboveComment();
+ IASTTranslationUnit tu = parse(content, C, true, 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);
- func= (IASTFunctionDefinition) tu.getDeclarations()[0];
- params= ((IASTStandardFunctionDeclarator) func.getDeclarator()).getParameters();
- binding= params[0].getDeclarator().getName().resolveBinding();
+ tu = parse(content, CPP, true, true);
+ func = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ params = ((IASTStandardFunctionDeclarator) func.getDeclarator()).getParameters();
+ binding = params[0].getDeclarator().getName().resolveBinding();
assertEquals(7, tu.getReferences(binding).length);
}
@@ -3506,34 +3488,19 @@ public class AST2Tests extends AST2TestBase {
*/
public void testMacroCommentsBug_177154() throws Exception {
// simple case
- 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";
+ 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);
// actual reduced test case, plus extra cases
- String text =
- "#define KBOOT 1 //0x00000002\r\n" +
- "#define KBOOT2 /* value */ 1 /* another */ //0x00000002\r\n" +
- "#define KBOOT3 /* value \r\n" +
- " multi line\r\n"+
- " comment */ 1 \\\r\n"+
- "/* another */ + \\\r\n"+
- "2 //0x00000002\r\n" +
- "#define DEBUGNUM(x) (KDebugNum(x))\r\n" +
- "bool KDebugNum(int aBitNum);\r\n" +
- "#define __KTRACE_OPT(a,p) {if ((DEBUGNUM(a)))p;}\r\n" +
- "void fail();\r\n"+
- "void test() {\r\n"+
- "__KTRACE_OPT(KBOOT,fail());\r\n" +
- "__KTRACE_OPT(KBOOT2,fail());\r\n" +
- "}\r\n"
- ;
+ String text = "#define KBOOT 1 //0x00000002\r\n"
+ + "#define KBOOT2 /* value */ 1 /* another */ //0x00000002\r\n"
+ + "#define KBOOT3 /* value \r\n" + " multi line\r\n" + " comment */ 1 \\\r\n"
+ + "/* another */ + \\\r\n" + "2 //0x00000002\r\n" + "#define DEBUGNUM(x) (KDebugNum(x))\r\n"
+ + "bool KDebugNum(int aBitNum);\r\n" + "#define __KTRACE_OPT(a,p) {if ((DEBUGNUM(a)))p;}\r\n"
+ + "void fail();\r\n" + "void test() {\r\n" + "__KTRACE_OPT(KBOOT,fail());\r\n"
+ + "__KTRACE_OPT(KBOOT2,fail());\r\n" + "}\r\n";
// essential test: this code should be parseable
tu = parse(text, CPP, true, true);
@@ -3544,7 +3511,7 @@ public class AST2Tests extends AST2TestBase {
assertEquals("1", macroDefinitions[0].getExpansion());
assertEquals("1", macroDefinitions[1].getExpansion());
// regression test for #64268 and #71733 which also handle comments
- String expectExpansion= "1 + 2";
+ String expectExpansion = "1 + 2";
assertEquals(expectExpansion, macroDefinitions[2].getExpansion());
assertEquals("(KDebugNum(x))", macroDefinitions[3].getExpansion());
assertEquals("{if ((DEBUGNUM(a)))p;}", macroDefinitions[4].getExpansion());
@@ -3562,12 +3529,12 @@ public class AST2Tests extends AST2TestBase {
// check class
IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[1];
- IASTCompoundStatement comp_stmt= (IASTCompoundStatement) fd.getBody();
- IASTExpressionStatement expr_stmt= (IASTExpressionStatement) comp_stmt.getStatements()[0];
- IASTFunctionCallExpression expr= (IASTFunctionCallExpression) expr_stmt.getExpression();
- IASTIdExpression idExpr= (IASTIdExpression) expr.getFunctionNameExpression();
- IBinding binding= idExpr.getName().resolveBinding();
- assertTrue(lang.toString(), binding instanceof IFunction);
+ IASTCompoundStatement comp_stmt = (IASTCompoundStatement) fd.getBody();
+ IASTExpressionStatement expr_stmt = (IASTExpressionStatement) comp_stmt.getStatements()[0];
+ IASTFunctionCallExpression expr = (IASTFunctionCallExpression) expr_stmt.getExpression();
+ IASTIdExpression idExpr = (IASTIdExpression) expr.getFunctionNameExpression();
+ IBinding binding = idExpr.getName().resolveBinding();
+ assertTrue(lang.toString(), binding instanceof IFunction);
assertFalse(lang.toString(), binding instanceof IProblemBinding);
assertEquals(binding.getName(), "decl");
}
@@ -3583,22 +3550,19 @@ public class AST2Tests extends AST2TestBase {
// check class
IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[1];
- IASTCompoundStatement comp_stmt= (IASTCompoundStatement) fd.getBody();
- IASTExpressionStatement expr_stmt= (IASTExpressionStatement) comp_stmt.getStatements()[0];
- IASTFunctionCallExpression expr= (IASTFunctionCallExpression) expr_stmt.getExpression();
- IASTIdExpression idExpr= (IASTIdExpression) expr.getFunctionNameExpression();
- IBinding binding= idExpr.getName().resolveBinding();
- assertTrue(lang.toString(), binding instanceof IVariable);
+ IASTCompoundStatement comp_stmt = (IASTCompoundStatement) fd.getBody();
+ IASTExpressionStatement expr_stmt = (IASTExpressionStatement) comp_stmt.getStatements()[0];
+ IASTFunctionCallExpression expr = (IASTFunctionCallExpression) expr_stmt.getExpression();
+ IASTIdExpression idExpr = (IASTIdExpression) expr.getFunctionNameExpression();
+ IBinding binding = idExpr.getName().resolveBinding();
+ assertTrue(lang.toString(), binding instanceof IVariable);
assertFalse(lang.toString(), binding instanceof IProblemBinding);
}
}
public void testBug181735() throws Exception {
- String code=
- "int (*f)(int);\n"
- + "int g(int n) {return n;}\n"
- + "int g(int n, int m) {return n;}\n"
- + "void foo() { f=g; }";
+ String code = "int (*f)(int);\n" + "int g(int n) {return n;}\n" + "int g(int n, int m) {return n;}\n"
+ + "void foo() { f=g; }";
for (ParserLanguage lang : ParserLanguage.values())
parseAndCheckBindings(code, lang);
@@ -3613,24 +3577,19 @@ public class AST2Tests extends AST2TestBase {
}
public void testMacroCommentsBug_177154_2() throws Exception {
- String noCommentMacro =
- "#define Sonar16G(x) ((Sonr16G(x)<<16)|0xff000000L)\r\n";
- String commentMacro =
- "#define Sonar16G(x) ((Sonr16G(x)<<16)|0xff000000L) // add the varf value\r\n";
-
- String textTail = "\r\n" +
- "const int snd16SonarR[32] = {\r\n" +
- " 0xFF000000L, Sonar16G(0x01), Sonar16G(0x02), Sonar16G(0x03),\r\n" +
- " Sonar16G(0x04), Sonar16G(0x05), Sonar16G(0x06), Sonar16G(0x07),\r\n" +
- " Sonar16G(0x08), Sonar16G(0x09), Sonar16G(0x0A), Sonar16G(0x0B),\r\n" +
- " Sonar16G(0x0C), Sonar16G(0x0D), Sonar16G(0x0E), Sonar16G(0x0F),\r\n" +
- " Sonar16G(0x10), Sonar16G(0x11), Sonar16G(0x12), Sonar16G(0x13),\r\n" +
- " Sonar16G(0x14), Sonar16G(0x15), Sonar16G(0x16), Sonar16G(0x17),\r\n" +
- " Sonar16G(0x18), Sonar16G(0x19), Sonar16G(0x1A), Sonar16G(0x1B),\r\n" +
- " Sonar16G(0x1C), Sonar16G(0x1D), Sonar16G(0x1E), Sonar16G(0x1F),\r\n" +
- " };\r\n" +
- "\r\n" +
- "";
+ String noCommentMacro = "#define Sonar16G(x) ((Sonr16G(x)<<16)|0xff000000L)\r\n";
+ String commentMacro = "#define Sonar16G(x) ((Sonr16G(x)<<16)|0xff000000L) // add the varf value\r\n";
+
+ String textTail = "\r\n" + "const int snd16SonarR[32] = {\r\n"
+ + " 0xFF000000L, Sonar16G(0x01), Sonar16G(0x02), Sonar16G(0x03),\r\n"
+ + " Sonar16G(0x04), Sonar16G(0x05), Sonar16G(0x06), Sonar16G(0x07),\r\n"
+ + " Sonar16G(0x08), Sonar16G(0x09), Sonar16G(0x0A), Sonar16G(0x0B),\r\n"
+ + " Sonar16G(0x0C), Sonar16G(0x0D), Sonar16G(0x0E), Sonar16G(0x0F),\r\n"
+ + " Sonar16G(0x10), Sonar16G(0x11), Sonar16G(0x12), Sonar16G(0x13),\r\n"
+ + " Sonar16G(0x14), Sonar16G(0x15), Sonar16G(0x16), Sonar16G(0x17),\r\n"
+ + " Sonar16G(0x18), Sonar16G(0x19), Sonar16G(0x1A), Sonar16G(0x1B),\r\n"
+ + " Sonar16G(0x1C), Sonar16G(0x1D), Sonar16G(0x1E), Sonar16G(0x1F),\r\n" + " };\r\n" + "\r\n"
+ + "";
// this should work
String textNoComment = noCommentMacro + textTail;
@@ -3649,14 +3608,8 @@ public class AST2Tests extends AST2TestBase {
}
public void testBug186018() throws Exception {
- String code =
- "int main() { \n" +
- " switch(1) { \n" +
- " case 1 : \n" +
- " case 2 : \n" +
- " printf(\"pantera rules\"); \n" +
- " } \n" +
- "}\n";
+ String code = "int main() { \n" + " switch(1) { \n" + " case 1 : \n" + " case 2 : \n"
+ + " printf(\"pantera rules\"); \n" + " } \n" + "}\n";
parseAndCheckBindings(code, C);
}
@@ -3686,13 +3639,13 @@ public class AST2Tests extends AST2TestBase {
// }
// };
public void test186736() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP);
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), CPP);
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
NameCollector col = new NameCollector();
tu.accept(col);
- IBinding methodb= col.getName(27).resolveBinding();
- IBinding methodc= col.getName(30).resolveBinding();
+ IBinding methodb = col.getName(27).resolveBinding();
+ IBinding methodc = col.getName(30).resolveBinding();
assertEquals("method", methodb.getName());
assertEquals("method", methodc.getName());
assertInstance(methodb, ICPPMethod.class);
@@ -3738,13 +3691,13 @@ public class AST2Tests extends AST2TestBase {
// }
// };
public void test186736_variant1() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP);
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), CPP);
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
NameCollector col = new NameCollector();
tu.accept(col);
- IBinding methodA= col.getName(30).resolveBinding();
- IBinding methodAA= col.getName(33).resolveBinding();
+ IBinding methodA = col.getName(30).resolveBinding();
+ IBinding methodAA = col.getName(33).resolveBinding();
assertEquals("method", methodA.getName());
assertEquals("method", methodAA.getName());
assertInstance(methodA, ICPPMethod.class);
@@ -3776,7 +3729,7 @@ public class AST2Tests extends AST2TestBase {
// (&a)->foo();
// }
public void test186736_variant2() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP);
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), CPP);
validateCopy(tu);
}
@@ -3848,17 +3801,17 @@ public class AST2Tests extends AST2TestBase {
}
public void test195943() throws Exception {
- final int depth= 100;
+ final int depth = 100;
StringBuilder buffer = new StringBuilder();
buffer.append("#define M0 1\n");
for (int i = 1; i < depth; i++) {
- buffer.append("#define M").append(i).append(" (M").append(i-1).append("+1)\n");
+ buffer.append("#define M").append(i).append(" (M").append(i - 1).append("+1)\n");
}
- buffer.append("int a= M").append(depth-1).append(";\n");
- long time= System.currentTimeMillis();
+ buffer.append("int a= M").append(depth - 1).append(";\n");
+ long time = System.currentTimeMillis();
parse(buffer.toString(), CPP);
parse(buffer.toString(), C);
- assertTrue(System.currentTimeMillis()-time < 2000);
+ assertTrue(System.currentTimeMillis() - time < 2000);
}
// int array[12]= {};
@@ -3903,7 +3856,7 @@ public class AST2Tests extends AST2TestBase {
// namespace NameClash2 {};
// class NameClash2 {};
public void testBug202271_nameClash() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP, true);
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), CPP, true);
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
NameCollector col = new NameCollector();
@@ -3922,21 +3875,21 @@ public class AST2Tests extends AST2TestBase {
// int a= MACRO;
// int b= WRAP(MACRO);
public void testBug94673_refsForMacrosAsArguments() throws Exception {
- String content= getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(content, CPP, true);
- IASTPreprocessorMacroDefinition[] defs= tu.getMacroDefinitions();
+ String content = getAboveComment();
+ IASTTranslationUnit tu = parseAndCheckBindings(content, CPP, true);
+ IASTPreprocessorMacroDefinition[] defs = tu.getMacroDefinitions();
assertEquals(2, defs.length);
- IASTPreprocessorMacroDefinition md= defs[1];
+ IASTPreprocessorMacroDefinition md = defs[1];
assertEquals("MACRO", md.getName().toString());
- IMacroBinding binding= (IMacroBinding) md.getName().resolveBinding();
+ IMacroBinding binding = (IMacroBinding) md.getName().resolveBinding();
assertNotNull(binding);
- IASTName[] refs= tu.getReferences(binding);
+ IASTName[] refs = tu.getReferences(binding);
assertEquals(2, refs.length);
- IASTFileLocation loc= refs[1].getFileLocation();
+ IASTFileLocation loc = refs[1].getFileLocation();
final int idx = content.indexOf("WRAP(MACRO)");
assertEquals(idx, loc.getNodeOffset());
- IASTImageLocation iloc= refs[1].getImageLocation();
- assertEquals(idx+5, iloc.getNodeOffset());
+ IASTImageLocation iloc = refs[1].getImageLocation();
+ assertEquals(idx + 5, iloc.getNodeOffset());
}
// void OSi_Panic(const char *file, int line) {};
@@ -3988,7 +3941,6 @@ public class AST2Tests extends AST2TestBase {
parse(content2, C);
}
-
// typedef struct Point {
// int x;
// int y;
@@ -4030,7 +3982,7 @@ public class AST2Tests extends AST2TestBase {
assertField(col.getName(27).resolveBinding(), "tag", "Tag");
// Line l2
- assertField(col.getName(30).resolveBinding(), "t", "Line");
+ assertField(col.getName(30).resolveBinding(), "t", "Line");
assertField(col.getName(31).resolveBinding(), "tag", "Tag");
assertField(col.getName(32).resolveBinding(), "p1", "Line");
assertField(col.getName(33).resolveBinding(), "x", "Point");
@@ -4048,7 +4000,6 @@ public class AST2Tests extends AST2TestBase {
assertField(col.getName(45).resolveBinding(), "y", "Point");
}
-
// struct S1 {
// int i;
// float f;
@@ -4164,13 +4115,13 @@ public class AST2Tests extends AST2TestBase {
// foux = (foux) - bhar1;
// }
public void testBug100641_106279_castAmbiguity() throws Exception {
- boolean cpp= false;
+ boolean cpp = false;
do {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), cpp);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), cpp);
ba.assertNonProblem("field)", 5);
ba.assertNonProblem("bit))", 3);
ba.assertNonProblem("foux)", 4);
- cpp= !cpp;
+ cpp = !cpp;
} while (cpp);
}
@@ -4206,26 +4157,26 @@ public class AST2Tests extends AST2TestBase {
// f4(cvi);
// }
public void testBug222418_a() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
- ba.assertNonProblem("f1(i)",2);
- ba.assertProblem("f1(ci)", 2);
- ba.assertProblem("f1(vi)", 2);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
+ ba.assertNonProblem("f1(i)", 2);
+ ba.assertProblem("f1(ci)", 2);
+ ba.assertProblem("f1(vi)", 2);
ba.assertProblem("f1(cvi)", 2);
ba.assertNonProblem("f2(i)", 2);
- ba.assertNonProblem("f2(ci)",2);
- ba.assertProblem("f2(vi)", 2);
- ba.assertProblem("f2(cvi)", 2);
+ ba.assertNonProblem("f2(ci)", 2);
+ ba.assertProblem("f2(vi)", 2);
+ ba.assertProblem("f2(cvi)", 2);
ba.assertNonProblem("f3(i)", 2);
- ba.assertProblem("f3(ci)", 2);
- ba.assertNonProblem("f3(vi)",2);
- ba.assertProblem("f3(cvi)", 2);
+ ba.assertProblem("f3(ci)", 2);
+ ba.assertNonProblem("f3(vi)", 2);
+ ba.assertProblem("f3(cvi)", 2);
- ba.assertNonProblem("f4(i)", 2);
+ ba.assertNonProblem("f4(i)", 2);
ba.assertNonProblem("f4(ci)", 2);
ba.assertNonProblem("f4(vi)", 2);
- ba.assertNonProblem("f4(cvi)",2);
+ ba.assertNonProblem("f4(cvi)", 2);
}
// void f1(int& r) {} // 1
@@ -4245,12 +4196,12 @@ public class AST2Tests extends AST2TestBase {
// f1(cvi); // (4)
// }
public void testBug222418_b() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
- ICPPFunction f1_1= ba.assertNonProblem("f1(i)", 2, ICPPFunction.class);
- ICPPFunction f1_2= ba.assertNonProblem("f1(ci)", 2, ICPPFunction.class);
- ICPPFunction f1_3= ba.assertNonProblem("f1(vi)", 2, ICPPFunction.class);
- ICPPFunction f1_4= ba.assertNonProblem("f1(cvi)",2, ICPPFunction.class);
+ ICPPFunction f1_1 = ba.assertNonProblem("f1(i)", 2, ICPPFunction.class);
+ ICPPFunction f1_2 = ba.assertNonProblem("f1(ci)", 2, ICPPFunction.class);
+ ICPPFunction f1_3 = ba.assertNonProblem("f1(vi)", 2, ICPPFunction.class);
+ ICPPFunction f1_4 = ba.assertNonProblem("f1(cvi)", 2, ICPPFunction.class);
assertEquals(ASTTypeUtil.getParameterTypeString(f1_1.getType()), "(int &)");
assertEquals(ASTTypeUtil.getParameterTypeString(f1_2.getType()), "(const int &)");
@@ -4263,11 +4214,11 @@ public class AST2Tests extends AST2TestBase {
// void f1(volatile int r) {} // 3
// void f1(const volatile int r) {} // 4
public void testBug222418_b_regression() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
- ba.assertNonProblem("f1(int", 2, ICPPFunction.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
+ ba.assertNonProblem("f1(int", 2, ICPPFunction.class);
ba.assertProblem("f1(const i", 2);
ba.assertProblem("f1(vol", 2);
- ba.assertProblem("f1(const v",2);
+ ba.assertProblem("f1(const v", 2);
}
// void fa(int& r) {}
@@ -4289,20 +4240,20 @@ public class AST2Tests extends AST2TestBase {
// fd(five()); // should be an error
// }
public void testBug222418_c() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
- ICPPFunction fn= ba.assertNonProblem("five() {", 4, ICPPFunction.class);
+ ICPPFunction fn = ba.assertNonProblem("five() {", 4, ICPPFunction.class);
assertFalse(fn.getType().getReturnType() instanceof IProblemBinding);
- ba.assertProblem("fa(5", 2);
- ICPPFunction fb= ba.assertNonProblem("fb(5", 2, ICPPFunction.class);
+ ba.assertProblem("fa(5", 2);
+ ICPPFunction fb = ba.assertNonProblem("fb(5", 2, ICPPFunction.class);
ba.assertProblem("fc(5", 2);
- ba.assertProblem("fd(5",2);
+ ba.assertProblem("fd(5", 2);
- ICPPFunction fb2= ba.assertNonProblem("fb(f", 2, ICPPFunction.class);
- ba.assertProblem("fa(f",2);
- ba.assertProblem("fc(f",2);
- ba.assertProblem("fd(f",2);
+ ICPPFunction fb2 = ba.assertNonProblem("fb(f", 2, ICPPFunction.class);
+ ba.assertProblem("fa(f", 2);
+ ba.assertProblem("fc(f", 2);
+ ba.assertProblem("fd(f", 2);
assertEquals(ASTTypeUtil.getParameterTypeString(fb.getType()), "(const int &)");
assertEquals(ASTTypeUtil.getParameterTypeString(fb2.getType()), "(const int &)");
@@ -4321,9 +4272,9 @@ public class AST2Tests extends AST2TestBase {
// f_nonconst(2); // should be an error
// }
public void testBug222418_d() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
- ba.assertNonProblem("f_const(2", 7, ICPPFunction.class);
- ba.assertProblem("f_nonconst(2", 10);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
+ ba.assertNonProblem("f_const(2", 7, ICPPFunction.class);
+ ba.assertProblem("f_nonconst(2", 10);
}
// class A {};
@@ -4360,26 +4311,26 @@ public class AST2Tests extends AST2TestBase {
// f4(cvi);
// }
public void testBug222418_e() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
- ba.assertNonProblem("f1(i)",2);
- ba.assertProblem("f1(ci)", 2);
- ba.assertProblem("f1(vi)", 2);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
+ ba.assertNonProblem("f1(i)", 2);
+ ba.assertProblem("f1(ci)", 2);
+ ba.assertProblem("f1(vi)", 2);
ba.assertProblem("f1(cvi)", 2);
ba.assertNonProblem("f2(i)", 2);
- ba.assertNonProblem("f2(ci)",2);
- ba.assertProblem("f2(vi)", 2);
- ba.assertProblem("f2(cvi)", 2);
+ ba.assertNonProblem("f2(ci)", 2);
+ ba.assertProblem("f2(vi)", 2);
+ ba.assertProblem("f2(cvi)", 2);
ba.assertNonProblem("f3(i)", 2);
- ba.assertProblem("f3(ci)", 2);
- ba.assertNonProblem("f3(vi)",2);
- ba.assertProblem("f3(cvi)", 2);
+ ba.assertProblem("f3(ci)", 2);
+ ba.assertNonProblem("f3(vi)", 2);
+ ba.assertProblem("f3(cvi)", 2);
- ba.assertNonProblem("f4(i)", 2);
+ ba.assertNonProblem("f4(i)", 2);
ba.assertNonProblem("f4(ci)", 2);
ba.assertNonProblem("f4(vi)", 2);
- ba.assertNonProblem("f4(cvi)",2);
+ ba.assertNonProblem("f4(cvi)", 2);
}
// class B {};
@@ -4435,7 +4386,7 @@ public class AST2Tests extends AST2TestBase {
// return 0;
// }
public void testBug222418_f() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
ba.assertNonProblem("foo1(a)", 4);
ba.assertNonProblem("foo2(a)", 4);
ba.assertNonProblem("foo1(3)", 4);
@@ -4450,7 +4401,6 @@ public class AST2Tests extends AST2TestBase {
ba.assertProblem("foo2(b)", 4);
}
-
// class A {};
// class B : public A {};
//
@@ -4461,7 +4411,7 @@ public class AST2Tests extends AST2TestBase {
// f(b2);
// }
public void testBug222418_g_regression() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
ba.assertNonProblem("f(b2)", 1);
}
@@ -4472,7 +4422,7 @@ public class AST2Tests extends AST2TestBase {
// f(r);
// }
public void testBug222418_h_regression() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
ba.assertNonProblem("f(r)", 1);
}
@@ -4485,7 +4435,7 @@ public class AST2Tests extends AST2TestBase {
// f(b2);
// }
public void testBug222418_i_regression() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
ba.assertNonProblem("f(b2)", 1);
}
@@ -4524,7 +4474,7 @@ public class AST2Tests extends AST2TestBase {
// return ri;
// }
public void testBug222418_j() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
ba.assertNonProblem("fi(ri)", 2);
ba.assertNonProblem("fp(&rwi)", 2);
@@ -4563,7 +4513,7 @@ public class AST2Tests extends AST2TestBase {
// a.foo();
// }
public void testBug222418_k_regression() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
ba.assertNonProblem("foo();", 3);
}
@@ -4584,9 +4534,9 @@ public class AST2Tests extends AST2TestBase {
// foo(c);
// }
public void testBug222444_a() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
- ICPPFunction foo1= ba.assertNonProblem("foo(b", 3, ICPPFunction.class);
- ICPPFunction foo2= ba.assertNonProblem("foo(c", 3, ICPPFunction.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
+ ICPPFunction foo1 = ba.assertNonProblem("foo(b", 3, ICPPFunction.class);
+ ICPPFunction foo2 = ba.assertNonProblem("foo(c", 3, ICPPFunction.class);
}
// class A {};
@@ -4605,8 +4555,8 @@ public class AST2Tests extends AST2TestBase {
// foo(c);
// }
public void testBug222444_b() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
- ICPPFunction foo2= ba.assertNonProblem("foo(c", 3, ICPPFunction.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
+ ICPPFunction foo2 = ba.assertNonProblem("foo(c", 3, ICPPFunction.class);
}
// class A {};
@@ -4625,8 +4575,8 @@ public class AST2Tests extends AST2TestBase {
// foo(c);
// }
public void testBug222444_c() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
- ICPPFunction foo2= ba.assertNonProblem("foo(c", 3, ICPPFunction.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
+ ICPPFunction foo2 = ba.assertNonProblem("foo(c", 3, ICPPFunction.class);
}
// int a, b, c;
@@ -4703,7 +4653,7 @@ public class AST2Tests extends AST2TestBase {
parseAndCheckBindings(code, C, true);
parseAndCheckBindings(code, CPP, true);
}
-
+
// struct test {
// int field;
// };
@@ -4713,9 +4663,9 @@ public class AST2Tests extends AST2TestBase {
// const typeof(t) x;
// x.field;
// }
- public void testTypeofInsideQualifier_471907() throws Exception {
- parseAndCheckBindings(getAboveComment(), C);
- }
+ public void testTypeofInsideQualifier_471907() throws Exception {
+ parseAndCheckBindings(getAboveComment(), C);
+ }
// void test(int count) {
// switch(count) {
@@ -4726,9 +4676,11 @@ public class AST2Tests extends AST2TestBase {
final String code = getAboveComment();
{
IASTTranslationUnit tu = parseAndCheckBindings(code, C, true);
- IASTCompoundStatement body = (IASTCompoundStatement)((IASTFunctionDefinition) tu.getDeclarations()[0]).getBody();
+ IASTCompoundStatement body = (IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[0])
+ .getBody();
IASTSwitchStatement switchStmt = (IASTSwitchStatement) body.getStatements()[0];
- IASTCaseStatement caseStmt = (IASTCaseStatement)((IASTCompoundStatement) switchStmt.getBody()).getStatements()[0];
+ IASTCaseStatement caseStmt = (IASTCaseStatement) ((IASTCompoundStatement) switchStmt.getBody())
+ .getStatements()[0];
IASTBinaryExpression binExpr = (IASTBinaryExpression) caseStmt.getExpression();
assertTrue(binExpr.getOperator() == IASTBinaryExpression.op_ellipses);
assertTrue(binExpr.getOperand1() instanceof IASTLiteralExpression);
@@ -4736,9 +4688,11 @@ public class AST2Tests extends AST2TestBase {
}
{
IASTTranslationUnit tu = parseAndCheckBindings(code, CPP, true);
- IASTCompoundStatement body = (IASTCompoundStatement)((IASTFunctionDefinition) tu.getDeclarations()[0]).getBody();
+ IASTCompoundStatement body = (IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[0])
+ .getBody();
IASTSwitchStatement switchStmt = (IASTSwitchStatement) body.getStatements()[0];
- IASTCaseStatement caseStmt = (IASTCaseStatement)((IASTCompoundStatement) switchStmt.getBody()).getStatements()[0];
+ IASTCaseStatement caseStmt = (IASTCaseStatement) ((IASTCompoundStatement) switchStmt.getBody())
+ .getStatements()[0];
IASTBinaryExpression binExpr = (IASTBinaryExpression) caseStmt.getExpression();
assertTrue(binExpr.getOperator() == IASTBinaryExpression.op_ellipses);
assertTrue(binExpr.getOperand1() instanceof IASTLiteralExpression);
@@ -4750,7 +4704,7 @@ public class AST2Tests extends AST2TestBase {
// int x(int (int * a));
// int x(int(TIntPtr));
public void testInfiniteRecursion_269052() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code, C, true);
parseAndCheckBindings(code, CPP, true);
}
@@ -4801,539 +4755,540 @@ public class AST2Tests extends AST2TestBase {
parseAndCheckBindings(code, CPP);
}
- // int f(x) {
- // return 0;
- // }
- public void testBug228422_noKnrParam() throws Exception {
- CharSequence buffer = getContents(1)[0];
- parse(buffer.toString(), C, false);
- }
-
- // struct {
- // char foo;
- // } myStruct, *myStructPointer;
- //
- // union {
- // char foo;
- // } myUnion, *myUnionPointer;
- //
- // void test() {
- // myStruct.foo=1;
- // myStructPointer->foo=2;
- // myUnion.foo=3;
- // myUnionPointer->foo=4;
- //
- // myStruct.bar=1;
- // myStructPointer->bar=2;
- // myUnion.bar=3;
- // myUnionPointer->bar=4;
- // }
- public void testBug228504_nonExistingMembers() throws Exception {
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), lang);
- for (int i= 1; i < 5; i++) {
+ // int f(x) {
+ // return 0;
+ // }
+ public void testBug228422_noKnrParam() throws Exception {
+ CharSequence buffer = getContents(1)[0];
+ parse(buffer.toString(), C, false);
+ }
+
+ // struct {
+ // char foo;
+ // } myStruct, *myStructPointer;
+ //
+ // union {
+ // char foo;
+ // } myUnion, *myUnionPointer;
+ //
+ // void test() {
+ // myStruct.foo=1;
+ // myStructPointer->foo=2;
+ // myUnion.foo=3;
+ // myUnionPointer->foo=4;
+ //
+ // myStruct.bar=1;
+ // myStructPointer->bar=2;
+ // myUnion.bar=3;
+ // myUnionPointer->bar=4;
+ // }
+ public void testBug228504_nonExistingMembers() throws Exception {
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), lang);
+ for (int i = 1; i < 5; i++) {
ba.assertNonProblem("foo=" + i, 3);
ba.assertProblem("bar=" + i, 3);
}
}
- }
-
- // struct S {
- // int value;
- // };
- // typedef struct S *PtrS;
- // struct T {
- // PtrS ptrS;
- // };
- //
- // void testint(int x);
- // void testptr(struct T* x);
- //
- // void test() {
- // struct T* t;
- // t->ptrS->value;
- // (t->ptrS+1)->value;
- // testptr(t-0);
- // testint(t-t);
- // testint(0-t);
- // }
- public void testTypeOfPointerOperations() throws Exception {
- String code= getAboveComment();
- parseAndCheckBindings(code, C);
- parseAndCheckBindings(code, CPP);
- }
-
- // int globalArray[4] = {1,2,3,4};
- // void function1(); // decl
- //
- // void function1() {
- // getArray()[0] = 1;
- // }
- //
- // void function2() {
- // function1(); // ref
- // }
- public void testOutOfOrderResolution_232300() throws Exception {
- String code= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(code, lang);
- IBinding b1= ba.assertNonProblem("function1(); // decl", 9);
- IBinding b2= ba.assertNonProblem("function1() {", 9);
- IBinding b3= ba.assertNonProblem("function1(); // ref", 9);
- assertSame(b1, b2);
- assertSame(b2, b3);
- }
- }
-
- // #define foo __typeof__((int*)0 - (int*)0)
- // typedef foo ptrdiff_t;
- public void testRedefinePtrdiff_230895() throws Exception {
- String code= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(code, lang);
- IBinding b1= ba.assertNonProblem("ptrdiff_t", 9);
- assertInstance(b1, ITypedef.class);
- ITypedef td= (ITypedef) b1;
- IType t= td.getType();
- assertFalse(t instanceof ITypedef);
- }
- }
-
- // int a;
- // int b= a; // ref
- // struct S;
- // typedef struct S S; // td
- public void testRedefineStructInScopeThatIsFullyResolved() throws Exception {
- String code= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(code, lang);
- ba.assertNonProblem("a; // ref", 1);
- // now scope is fully resolved
- ICompositeType ct= ba.assertNonProblem("S;", 1, ICompositeType.class);
- ITypedef td= ba.assertNonProblem("S; // td", 1, ITypedef.class);
- IType t= td.getType();
- assertFalse(t instanceof IProblemBinding);
- assertSame(t, ct);
- }
- }
-
- // void checkLong(long);
- // void test() {
- // checkLong(__builtin_expect(1, 1));
- // }
- public void testReturnTypeOfBuiltin_234309() throws Exception {
- String code= getAboveComment();
- parseAndCheckBindings(code, C, true);
- parseAndCheckBindings(code, CPP, true);
- }
-
- // typedef void VOID;
- // VOID func(void) {
- // }
- public void testTypedefVoid_221567() throws Exception {
- String code= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(code, lang);
- ITypedef td= ba.assertNonProblem("VOID;", 4, ITypedef.class);
-
- IFunction func= ba.assertNonProblem("func", 4, IFunction.class);
- IFunctionType ft= func.getType();
- IType rt= ft.getReturnType();
- IType[] pts= ft.getParameterTypes();
- assertEquals(0, pts.length);
+ }
+
+ // struct S {
+ // int value;
+ // };
+ // typedef struct S *PtrS;
+ // struct T {
+ // PtrS ptrS;
+ // };
+ //
+ // void testint(int x);
+ // void testptr(struct T* x);
+ //
+ // void test() {
+ // struct T* t;
+ // t->ptrS->value;
+ // (t->ptrS+1)->value;
+ // testptr(t-0);
+ // testint(t-t);
+ // testint(0-t);
+ // }
+ public void testTypeOfPointerOperations() throws Exception {
+ String code = getAboveComment();
+ parseAndCheckBindings(code, C);
+ parseAndCheckBindings(code, CPP);
+ }
+
+ // int globalArray[4] = {1,2,3,4};
+ // void function1(); // decl
+ //
+ // void function1() {
+ // getArray()[0] = 1;
+ // }
+ //
+ // void function2() {
+ // function1(); // ref
+ // }
+ public void testOutOfOrderResolution_232300() throws Exception {
+ String code = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, lang);
+ IBinding b1 = ba.assertNonProblem("function1(); // decl", 9);
+ IBinding b2 = ba.assertNonProblem("function1() {", 9);
+ IBinding b3 = ba.assertNonProblem("function1(); // ref", 9);
+ assertSame(b1, b2);
+ assertSame(b2, b3);
+ }
+ }
+
+ // #define foo __typeof__((int*)0 - (int*)0)
+ // typedef foo ptrdiff_t;
+ public void testRedefinePtrdiff_230895() throws Exception {
+ String code = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, lang);
+ IBinding b1 = ba.assertNonProblem("ptrdiff_t", 9);
+ assertInstance(b1, ITypedef.class);
+ ITypedef td = (ITypedef) b1;
+ IType t = td.getType();
+ assertFalse(t instanceof ITypedef);
+ }
+ }
+
+ // int a;
+ // int b= a; // ref
+ // struct S;
+ // typedef struct S S; // td
+ public void testRedefineStructInScopeThatIsFullyResolved() throws Exception {
+ String code = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, lang);
+ ba.assertNonProblem("a; // ref", 1);
+ // now scope is fully resolved
+ ICompositeType ct = ba.assertNonProblem("S;", 1, ICompositeType.class);
+ ITypedef td = ba.assertNonProblem("S; // td", 1, ITypedef.class);
+ IType t = td.getType();
+ assertFalse(t instanceof IProblemBinding);
+ assertSame(t, ct);
+ }
+ }
+
+ // void checkLong(long);
+ // void test() {
+ // checkLong(__builtin_expect(1, 1));
+ // }
+ public void testReturnTypeOfBuiltin_234309() throws Exception {
+ String code = getAboveComment();
+ parseAndCheckBindings(code, C, true);
+ parseAndCheckBindings(code, CPP, true);
+ }
+
+ // typedef void VOID;
+ // VOID func(void) {
+ // }
+ public void testTypedefVoid_221567() throws Exception {
+ String code = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, lang);
+ ITypedef td = ba.assertNonProblem("VOID;", 4, ITypedef.class);
+
+ IFunction func = ba.assertNonProblem("func", 4, IFunction.class);
+ IFunctionType ft = func.getType();
+ IType rt = ft.getReturnType();
+ IType[] pts = ft.getParameterTypes();
+ assertEquals(0, pts.length);
assertInstance(rt, ITypedef.class);
- rt= ((ITypedef) rt).getType();
+ rt = ((ITypedef) rt).getType();
assertTrue(rt instanceof IBasicType);
- assertEquals(IBasicType.Kind.eVoid, ((IBasicType) rt).getKind());
- }
- }
-
- // #define str(s) # s
- //
- // void foo() {
- // printf(str(this is a // this should go away
- // string));
- // }
- public void testCommentInExpansion_84276() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment());
- IASTFunctionDefinition func= (IASTFunctionDefinition) tu.getDeclarations()[0];
-
- IASTFunctionCallExpression fcall= (IASTFunctionCallExpression) ((IASTExpressionStatement)((IASTCompoundStatement) func.getBody()).getStatements()[0]).getExpression();
- IASTLiteralExpression lit= (IASTLiteralExpression) fcall.getArguments()[0];
- assertEquals("\"this is a string\"", lit.toString());
- }
-
- // typedef int tint;
- // tint f1(tint (tint));
- // int f2(int (int));
- // int f3(int (tint));
- // int f4(int (identifier));
- // int f5(int *(tint[10]));
- public void testParamWithFunctionType_84242() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(comment, lang);
-
- IFunction f= ba.assertNonProblem("f1", 2, IFunction.class);
- isTypeEqual(f.getType(), "int (int (*)(int))");
-
- f= ba.assertNonProblem("f2", 2, IFunction.class);
- isTypeEqual(f.getType(), "int (int (*)(int))");
-
- f= ba.assertNonProblem("f3", 2, IFunction.class);
- isTypeEqual(f.getType(), "int (int (*)(int))");
-
- f= ba.assertNonProblem("f4", 2, IFunction.class);
- isTypeEqual(f.getType(), "int (int)");
-
- f= ba.assertNonProblem("f5", 2, IFunction.class);
- isTypeEqual(f.getType(), "int (int * (*)(int *))");
- }
- }
-
- // class C { };
- // void f1(int(C)) { }
- public void testParamWithFunctionTypeCpp_84242() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
-
- IFunction f= ba.assertNonProblem("f1", 2, IFunction.class);
- isTypeEqual(f.getType(), "void (int (*)(C))");
- }
-
- // int (*f1(int par))[5] {};
- // int (*f1 (int par))[5];
- public void testFunctionReturningPtrToArray_216609() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), lang);
-
- IFunction f= ba.assertNonProblem("f1", 2, IFunction.class);
- isTypeEqual(f.getType(), "int (* (int))[5]");
-
- f= ba.assertNonProblem("f1 ", 2, IFunction.class);
- isTypeEqual(f.getType(), "int (* (int))[5]");
- }
- }
-
- // void f1() {}
- // void (f2)() {}
- // void (f3()) {}
- // void ((f4)()) {}
- // void f1();
- // void (f2)();
- // void (f3());
- // void ((f4)());
- public void testNestedFunctionDeclarators() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- IASTTranslationUnit tu= parseAndCheckBindings(comment, lang);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTDeclarator dtor= fdef.getDeclarator();
- assertNull(dtor.getNestedDeclarator());
- assertInstance(dtor.getParent(), IASTFunctionDefinition.class);
- assertInstance(dtor.getName().resolveBinding(), IFunction.class);
-
- fdef= getDeclaration(tu, 1);
- dtor= fdef.getDeclarator();
- assertNotNull(dtor.getNestedDeclarator());
- assertInstance(dtor.getParent(), IASTFunctionDefinition.class);
- assertInstance(dtor.getNestedDeclarator().getName().resolveBinding(), IFunction.class);
-
- fdef= getDeclaration(tu, 2);
- dtor= fdef.getDeclarator();
- assertNull(dtor.getNestedDeclarator());
- assertInstance(dtor.getParent().getParent(), IASTFunctionDefinition.class);
- assertInstance(dtor.getName().resolveBinding(), IFunction.class);
-
- fdef= getDeclaration(tu, 3);
- dtor= fdef.getDeclarator();
- assertNotNull(dtor.getNestedDeclarator());
- assertInstance(dtor.getParent().getParent(), IASTFunctionDefinition.class);
- assertInstance(dtor.getNestedDeclarator().getName().resolveBinding(), IFunction.class);
-
- IASTSimpleDeclaration sdef= getDeclaration(tu, 4);
- IBinding binding= sdef.getDeclarators()[0].getName().resolveBinding();
- assertInstance(binding, IFunction.class);
- assertEquals(2, tu.getDeclarationsInAST(binding).length);
-
- sdef= getDeclaration(tu, 5);
- binding= sdef.getDeclarators()[0].getNestedDeclarator().getName().resolveBinding();
- assertInstance(binding, IFunction.class);
- assertEquals(2, tu.getDeclarationsInAST(binding).length);
-
- sdef= getDeclaration(tu, 6);
- binding= sdef.getDeclarators()[0].getNestedDeclarator().getName().resolveBinding();
- assertInstance(binding, IFunction.class);
- assertEquals(2, tu.getDeclarationsInAST(binding).length);
-
- sdef= getDeclaration(tu, 7);
- binding= sdef.getDeclarators()[0].getNestedDeclarator().getNestedDeclarator().getName().resolveBinding();
- assertInstance(binding, IFunction.class);
- assertEquals(2, tu.getDeclarationsInAST(binding).length);
- }
- }
-
- // void f() {
- // int a,b;
- // { b; a; int a; }
- // }
- public void testLocalVariableResolution_235831() throws Exception {
- final String comment= getAboveComment();
- final boolean[] isCpps= {false, true};
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(comment, lang);
-
- ba.assertNonProblem("b; a", 1, IVariable.class); // fill cache of inner block
- IVariable v3= ba.assertNonProblem("a; }", 1, IVariable.class);
- IVariable v2= ba.assertNonProblem("a; int", 1, IVariable.class);
- IVariable v1= ba.assertNonProblem("a,", 1, IVariable.class);
- assertSame(v1, v2);
- assertNotSame(v2, v3);
- }
- }
-
- // int foo(int (*ptr) (int, int));
- public void testComplexParameterBinding_214482() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(comment, lang);
- IParameter p= ba.assertNonProblem("ptr", 3, IParameter.class);
- assertEquals("ptr", p.getName());
- }
- }
-
- // void test() {}
- // +
- public void testTrailingSyntaxErrorInTU() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTDeclaration decl= getDeclaration(tu, 0);
- IASTProblemDeclaration pdecl= getDeclaration(tu, 1);
- assertEquals("+", pdecl.getRawSignature());
- }
- }
-
- // struct X {
- // int test;
- // +
- // };
- public void testTrailingSyntaxErrorInCompositeType() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTCompositeTypeSpecifier ct= getCompositeType(tu, 0);
- IASTDeclaration decl= getDeclaration(ct, 0);
- IASTProblemDeclaration pdecl= getDeclaration(ct, 1);
- assertEquals("+", pdecl.getRawSignature());
- }
- }
-
- // void func() {
- // {
- // int test;
- // +
- // }
- // }
- public void testTrailingSyntaxErrorInCompoundStatements() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTFunctionDefinition def= getDeclaration(tu, 0);
- IASTCompoundStatement compStmt= getStatement(def, 0);
- IASTDeclarationStatement dstmt= getStatement(compStmt, 0);
- IASTProblemStatement pstmt= getStatement(compStmt, 1);
- assertEquals("+", pstmt.getRawSignature());
- }
- }
-
- // struct X {
- // ;
- // };
- // ;
- public void testEmptyDeclarations() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTCompositeTypeSpecifier ct= getCompositeType(tu, 0);
- IASTDeclaration empty= getDeclaration(ct, 0);
- assertEquals(";", empty.getRawSignature());
- empty= getDeclaration(tu, 1);
- assertEquals(";", empty.getRawSignature());
- }
- }
-
- // void test() {
- // int foux = 3;
- // switch(foux) // no brace!
- // case 0:
- // case 1:
- // foux= 0;
- // foux= 1;
- // }
- public void testSwitchWithoutCompound_105334() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTSwitchStatement sw= getStatement(fdef, 1);
- IASTStatement stmt= getStatement(fdef, 2);
- assertEquals("foux= 1;", stmt.getRawSignature());
- }
- }
-
- // typedef int t;
- // int a,b;
- // void test() {
-
- // b* (t)+a *b // b,t,a,unary+,cast,*,b,*
- // b*(a) + a*b // b,a,*,a,b,*,+
- // b* (t)-a *b // b,t,a,unary-,cast,*,b,*
- // b*(a) - a*b // b,a,*,a,b,*,-
- // b* (t)*a *b // b,t,a,unary*,cast,*,b,*
- // b*(a) * a * b // b,a,*,a,*,b,*
- // b == (t)&a < b // b,t,a,unary&,cast,b,<,==
- // b < (t)&a == b // b,t,a,unary&,cast,<,b,==
- // b==(a) & a<b // b,a,==,a,b,<,&
- // +(t)+1 // t,1,unary+,cast,unary+
- // +(a)+1 // a,unary+,1,+
- // sizeof +(t)+1 // t,1,unary+,cast,unary+,sizeof
- // sizeof +(a)+1 // a,unary+,sizeof,1,+
- // b* (t)(t)+a * b // b,t,t,a,unary+,cast,cast,*,b,*
- // b* (t)(a)+a * b // b,t,a,cast,*,a,b,*,+
- // (int)(t)+1 // int,t,1,unary+,cast,cast
- // (int)(a)+1 // int,a,cast,1,+
- // a*a*(t)+a*a*a // a,a,*,t,a,unary+,cast,*,a,*,a,*
- // (typeof a)(t)-a // typeof a,t,a,unary-,cast,cast
- // (typeof a)(a)-a // typeof a,a,cast,a,-
- public void testBinaryVsCastAmbiguities_237057() throws Exception {
- CharSequence[] input= getContents(2);
- String code= input[0].toString();
- String[] samples= input[1].toString().split("\n");
- for (ParserLanguage lang : ParserLanguage.values()) {
- for (String s : samples) {
- final String[] io= s.split("//");
- final String exprStr = io[0].trim();
- final IASTTranslationUnit tu= parse(code + exprStr + ";}", lang);
- final IASTFunctionDefinition fdef= getDeclaration(tu, 2);
- IASTExpression expr= getExpressionOfStatement(fdef, 0);
+ assertEquals(IBasicType.Kind.eVoid, ((IBasicType) rt).getKind());
+ }
+ }
+
+ // #define str(s) # s
+ //
+ // void foo() {
+ // printf(str(this is a // this should go away
+ // string));
+ // }
+ public void testCommentInExpansion_84276() throws Exception {
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment());
+ IASTFunctionDefinition func = (IASTFunctionDefinition) tu.getDeclarations()[0];
+
+ IASTFunctionCallExpression fcall = (IASTFunctionCallExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) func
+ .getBody()).getStatements()[0]).getExpression();
+ IASTLiteralExpression lit = (IASTLiteralExpression) fcall.getArguments()[0];
+ assertEquals("\"this is a string\"", lit.toString());
+ }
+
+ // typedef int tint;
+ // tint f1(tint (tint));
+ // int f2(int (int));
+ // int f3(int (tint));
+ // int f4(int (identifier));
+ // int f5(int *(tint[10]));
+ public void testParamWithFunctionType_84242() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(comment, lang);
+
+ IFunction f = ba.assertNonProblem("f1", 2, IFunction.class);
+ isTypeEqual(f.getType(), "int (int (*)(int))");
+
+ f = ba.assertNonProblem("f2", 2, IFunction.class);
+ isTypeEqual(f.getType(), "int (int (*)(int))");
+
+ f = ba.assertNonProblem("f3", 2, IFunction.class);
+ isTypeEqual(f.getType(), "int (int (*)(int))");
+
+ f = ba.assertNonProblem("f4", 2, IFunction.class);
+ isTypeEqual(f.getType(), "int (int)");
+
+ f = ba.assertNonProblem("f5", 2, IFunction.class);
+ isTypeEqual(f.getType(), "int (int * (*)(int *))");
+ }
+ }
+
+ // class C { };
+ // void f1(int(C)) { }
+ public void testParamWithFunctionTypeCpp_84242() throws Exception {
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
+
+ IFunction f = ba.assertNonProblem("f1", 2, IFunction.class);
+ isTypeEqual(f.getType(), "void (int (*)(C))");
+ }
+
+ // int (*f1(int par))[5] {};
+ // int (*f1 (int par))[5];
+ public void testFunctionReturningPtrToArray_216609() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), lang);
+
+ IFunction f = ba.assertNonProblem("f1", 2, IFunction.class);
+ isTypeEqual(f.getType(), "int (* (int))[5]");
+
+ f = ba.assertNonProblem("f1 ", 2, IFunction.class);
+ isTypeEqual(f.getType(), "int (* (int))[5]");
+ }
+ }
+
+ // void f1() {}
+ // void (f2)() {}
+ // void (f3()) {}
+ // void ((f4)()) {}
+ // void f1();
+ // void (f2)();
+ // void (f3());
+ // void ((f4)());
+ public void testNestedFunctionDeclarators() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parseAndCheckBindings(comment, lang);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTDeclarator dtor = fdef.getDeclarator();
+ assertNull(dtor.getNestedDeclarator());
+ assertInstance(dtor.getParent(), IASTFunctionDefinition.class);
+ assertInstance(dtor.getName().resolveBinding(), IFunction.class);
+
+ fdef = getDeclaration(tu, 1);
+ dtor = fdef.getDeclarator();
+ assertNotNull(dtor.getNestedDeclarator());
+ assertInstance(dtor.getParent(), IASTFunctionDefinition.class);
+ assertInstance(dtor.getNestedDeclarator().getName().resolveBinding(), IFunction.class);
+
+ fdef = getDeclaration(tu, 2);
+ dtor = fdef.getDeclarator();
+ assertNull(dtor.getNestedDeclarator());
+ assertInstance(dtor.getParent().getParent(), IASTFunctionDefinition.class);
+ assertInstance(dtor.getName().resolveBinding(), IFunction.class);
+
+ fdef = getDeclaration(tu, 3);
+ dtor = fdef.getDeclarator();
+ assertNotNull(dtor.getNestedDeclarator());
+ assertInstance(dtor.getParent().getParent(), IASTFunctionDefinition.class);
+ assertInstance(dtor.getNestedDeclarator().getName().resolveBinding(), IFunction.class);
+
+ IASTSimpleDeclaration sdef = getDeclaration(tu, 4);
+ IBinding binding = sdef.getDeclarators()[0].getName().resolveBinding();
+ assertInstance(binding, IFunction.class);
+ assertEquals(2, tu.getDeclarationsInAST(binding).length);
+
+ sdef = getDeclaration(tu, 5);
+ binding = sdef.getDeclarators()[0].getNestedDeclarator().getName().resolveBinding();
+ assertInstance(binding, IFunction.class);
+ assertEquals(2, tu.getDeclarationsInAST(binding).length);
+
+ sdef = getDeclaration(tu, 6);
+ binding = sdef.getDeclarators()[0].getNestedDeclarator().getName().resolveBinding();
+ assertInstance(binding, IFunction.class);
+ assertEquals(2, tu.getDeclarationsInAST(binding).length);
+
+ sdef = getDeclaration(tu, 7);
+ binding = sdef.getDeclarators()[0].getNestedDeclarator().getNestedDeclarator().getName().resolveBinding();
+ assertInstance(binding, IFunction.class);
+ assertEquals(2, tu.getDeclarationsInAST(binding).length);
+ }
+ }
+
+ // void f() {
+ // int a,b;
+ // { b; a; int a; }
+ // }
+ public void testLocalVariableResolution_235831() throws Exception {
+ final String comment = getAboveComment();
+ final boolean[] isCpps = { false, true };
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(comment, lang);
+
+ ba.assertNonProblem("b; a", 1, IVariable.class); // fill cache of inner block
+ IVariable v3 = ba.assertNonProblem("a; }", 1, IVariable.class);
+ IVariable v2 = ba.assertNonProblem("a; int", 1, IVariable.class);
+ IVariable v1 = ba.assertNonProblem("a,", 1, IVariable.class);
+ assertSame(v1, v2);
+ assertNotSame(v2, v3);
+ }
+ }
+
+ // int foo(int (*ptr) (int, int));
+ public void testComplexParameterBinding_214482() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(comment, lang);
+ IParameter p = ba.assertNonProblem("ptr", 3, IParameter.class);
+ assertEquals("ptr", p.getName());
+ }
+ }
+
+ // void test() {}
+ // +
+ public void testTrailingSyntaxErrorInTU() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTDeclaration decl = getDeclaration(tu, 0);
+ IASTProblemDeclaration pdecl = getDeclaration(tu, 1);
+ assertEquals("+", pdecl.getRawSignature());
+ }
+ }
+
+ // struct X {
+ // int test;
+ // +
+ // };
+ public void testTrailingSyntaxErrorInCompositeType() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTCompositeTypeSpecifier ct = getCompositeType(tu, 0);
+ IASTDeclaration decl = getDeclaration(ct, 0);
+ IASTProblemDeclaration pdecl = getDeclaration(ct, 1);
+ assertEquals("+", pdecl.getRawSignature());
+ }
+ }
+
+ // void func() {
+ // {
+ // int test;
+ // +
+ // }
+ // }
+ public void testTrailingSyntaxErrorInCompoundStatements() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTFunctionDefinition def = getDeclaration(tu, 0);
+ IASTCompoundStatement compStmt = getStatement(def, 0);
+ IASTDeclarationStatement dstmt = getStatement(compStmt, 0);
+ IASTProblemStatement pstmt = getStatement(compStmt, 1);
+ assertEquals("+", pstmt.getRawSignature());
+ }
+ }
+
+ // struct X {
+ // ;
+ // };
+ // ;
+ public void testEmptyDeclarations() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTCompositeTypeSpecifier ct = getCompositeType(tu, 0);
+ IASTDeclaration empty = getDeclaration(ct, 0);
+ assertEquals(";", empty.getRawSignature());
+ empty = getDeclaration(tu, 1);
+ assertEquals(";", empty.getRawSignature());
+ }
+ }
+
+ // void test() {
+ // int foux = 3;
+ // switch(foux) // no brace!
+ // case 0:
+ // case 1:
+ // foux= 0;
+ // foux= 1;
+ // }
+ public void testSwitchWithoutCompound_105334() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTSwitchStatement sw = getStatement(fdef, 1);
+ IASTStatement stmt = getStatement(fdef, 2);
+ assertEquals("foux= 1;", stmt.getRawSignature());
+ }
+ }
+
+ // typedef int t;
+ // int a,b;
+ // void test() {
+
+ // b* (t)+a *b // b,t,a,unary+,cast,*,b,*
+ // b*(a) + a*b // b,a,*,a,b,*,+
+ // b* (t)-a *b // b,t,a,unary-,cast,*,b,*
+ // b*(a) - a*b // b,a,*,a,b,*,-
+ // b* (t)*a *b // b,t,a,unary*,cast,*,b,*
+ // b*(a) * a * b // b,a,*,a,*,b,*
+ // b == (t)&a < b // b,t,a,unary&,cast,b,<,==
+ // b < (t)&a == b // b,t,a,unary&,cast,<,b,==
+ // b==(a) & a<b // b,a,==,a,b,<,&
+ // +(t)+1 // t,1,unary+,cast,unary+
+ // +(a)+1 // a,unary+,1,+
+ // sizeof +(t)+1 // t,1,unary+,cast,unary+,sizeof
+ // sizeof +(a)+1 // a,unary+,sizeof,1,+
+ // b* (t)(t)+a * b // b,t,t,a,unary+,cast,cast,*,b,*
+ // b* (t)(a)+a * b // b,t,a,cast,*,a,b,*,+
+ // (int)(t)+1 // int,t,1,unary+,cast,cast
+ // (int)(a)+1 // int,a,cast,1,+
+ // a*a*(t)+a*a*a // a,a,*,t,a,unary+,cast,*,a,*,a,*
+ // (typeof a)(t)-a // typeof a,t,a,unary-,cast,cast
+ // (typeof a)(a)-a // typeof a,a,cast,a,-
+ public void testBinaryVsCastAmbiguities_237057() throws Exception {
+ CharSequence[] input = getContents(2);
+ String code = input[0].toString();
+ String[] samples = input[1].toString().split("\n");
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ for (String s : samples) {
+ final String[] io = s.split("//");
+ final String exprStr = io[0].trim();
+ final IASTTranslationUnit tu = parse(code + exprStr + ";}", lang);
+ final IASTFunctionDefinition fdef = getDeclaration(tu, 2);
+ IASTExpression expr = getExpressionOfStatement(fdef, 0);
assertEquals("expr: " + exprStr, io[1].trim(), polishNotation(expr));
- assertEquals(exprStr, expr.getRawSignature());
- checkOffsets(exprStr, expr);
+ assertEquals(exprStr, expr.getRawSignature());
+ checkOffsets(exprStr, expr);
}
- }
- }
-
- // struct s {int b;};
- // typedef int t;
- // struct s* a;
- // struct s* f(struct s*);
- // void test() {
-
- // (t)(a) // t,a,cast
- // (f)(a) // f,a,()
- // (t)(t)(a) // t,t,a,cast,cast
- // (t)(f)(a) // t,f,a,(),cast
- // (f)(a)(a) // f,a,(),a,()
- // (t)(f)(a)++ // t,f,a,(),++,cast
- // (t)(t)(a)++ // t,t,a,++,cast,cast
- // (t)(f)(a)-- // t,f,a,(),--,cast
- // (t)(t)(a)-- // t,t,a,--,cast,cast
- // (t)(f)(a)[0] // t,f,a,(),0,[],cast
- // (t)(t)(a)[0] // t,t,a,0,[],cast,cast
- // (t)(f)(a)->b // t,f,a,(),b,->,cast
- // (t)(t)(a)->b // t,t,a,b,->,cast,cast
- // (t)(a)+1 // t,a,cast,1,+
- // (f)(a)+1 // f,a,(),1,+
- // (t)(t)+1 // t,t,1,unary+,cast,cast
- public void testCastVsFunctionCallAmbiguities_237057() throws Exception {
- CharSequence[] input= getContents(2);
- String code= input[0].toString();
- String[] samples= input[1].toString().split("\n");
- for (ParserLanguage lang : ParserLanguage.values()) {
- for (String s : samples) {
- final String[] io= s.split("//");
- final String exprStr = io[0].trim();
- final IASTTranslationUnit tu= parse(code + exprStr + ";}", lang);
- final IASTFunctionDefinition fdef= getDeclaration(tu, 4);
- IASTExpression expr= getExpressionOfStatement(fdef, 0);
+ }
+ }
+
+ // struct s {int b;};
+ // typedef int t;
+ // struct s* a;
+ // struct s* f(struct s*);
+ // void test() {
+
+ // (t)(a) // t,a,cast
+ // (f)(a) // f,a,()
+ // (t)(t)(a) // t,t,a,cast,cast
+ // (t)(f)(a) // t,f,a,(),cast
+ // (f)(a)(a) // f,a,(),a,()
+ // (t)(f)(a)++ // t,f,a,(),++,cast
+ // (t)(t)(a)++ // t,t,a,++,cast,cast
+ // (t)(f)(a)-- // t,f,a,(),--,cast
+ // (t)(t)(a)-- // t,t,a,--,cast,cast
+ // (t)(f)(a)[0] // t,f,a,(),0,[],cast
+ // (t)(t)(a)[0] // t,t,a,0,[],cast,cast
+ // (t)(f)(a)->b // t,f,a,(),b,->,cast
+ // (t)(t)(a)->b // t,t,a,b,->,cast,cast
+ // (t)(a)+1 // t,a,cast,1,+
+ // (f)(a)+1 // f,a,(),1,+
+ // (t)(t)+1 // t,t,1,unary+,cast,cast
+ public void testCastVsFunctionCallAmbiguities_237057() throws Exception {
+ CharSequence[] input = getContents(2);
+ String code = input[0].toString();
+ String[] samples = input[1].toString().split("\n");
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ for (String s : samples) {
+ final String[] io = s.split("//");
+ final String exprStr = io[0].trim();
+ final IASTTranslationUnit tu = parse(code + exprStr + ";}", lang);
+ final IASTFunctionDefinition fdef = getDeclaration(tu, 4);
+ IASTExpression expr = getExpressionOfStatement(fdef, 0);
assertEquals("expr: " + exprStr, io[1].trim(), polishNotation(expr));
- assertEquals(exprStr, expr.getRawSignature());
- checkOffsets(exprStr, expr);
+ assertEquals(exprStr, expr.getRawSignature());
+ checkOffsets(exprStr, expr);
}
- }
- }
-
- // int a,b;
- // void test() {
-
- // 1+2+3 // 1,2,+,3,+
- // a=b=1 // a,b,1,=,=
- // 0, a= 1 ? 2,3 : b= 4, 5 // 0,a,1,2,3,,,b,4,=,?,=,5,,
- // 1 ? 2 ? 3 : 4 ? 5 : 6 : 7 // 1,2,3,4,5,6,?,?,7,?
- public void testBinaryExpressionBinding() throws Exception {
- CharSequence[] input= getContents(2);
- String code= input[0].toString();
- String[] samples= input[1].toString().split("\n");
- for (ParserLanguage lang : ParserLanguage.values()) {
- for (String s : samples) {
- final String[] io= s.split("//");
- final String exprStr = io[0].trim();
- final IASTTranslationUnit tu= parse(code + exprStr + ";}", lang);
- final IASTFunctionDefinition fdef= getDeclaration(tu, 1);
- IASTExpression expr= getExpressionOfStatement(fdef, 0);
+ }
+ }
+
+ // int a,b;
+ // void test() {
+
+ // 1+2+3 // 1,2,+,3,+
+ // a=b=1 // a,b,1,=,=
+ // 0, a= 1 ? 2,3 : b= 4, 5 // 0,a,1,2,3,,,b,4,=,?,=,5,,
+ // 1 ? 2 ? 3 : 4 ? 5 : 6 : 7 // 1,2,3,4,5,6,?,?,7,?
+ public void testBinaryExpressionBinding() throws Exception {
+ CharSequence[] input = getContents(2);
+ String code = input[0].toString();
+ String[] samples = input[1].toString().split("\n");
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ for (String s : samples) {
+ final String[] io = s.split("//");
+ final String exprStr = io[0].trim();
+ final IASTTranslationUnit tu = parse(code + exprStr + ";}", lang);
+ final IASTFunctionDefinition fdef = getDeclaration(tu, 1);
+ IASTExpression expr = getExpressionOfStatement(fdef, 0);
assertEquals("expr: " + exprStr, io[1].trim(), polishNotation(expr));
- assertEquals(exprStr, expr.getRawSignature());
- checkOffsets(exprStr, expr);
+ assertEquals(exprStr, expr.getRawSignature());
+ checkOffsets(exprStr, expr);
}
- }
- }
-
- // int a,b;
- // void test(int a=
-
- // 1+2+3 // 1,2,+,3,+
- // a=b=1 // a,b,1,=,=
- // 1 ? 2,3 : b= 4 // 1,2,3,,,b,4,=,?
- // 1 ? 2 ? 3 : 4 ? 5 : 6 : 7 // 1,2,3,4,5,6,?,?,7,?
- public void testConstantExpressionBinding() throws Exception {
- CharSequence[] input= getContents(2);
- String code= input[0].toString();
- String[] samples= input[1].toString().split("\n");
- for (ParserLanguage lang : ParserLanguage.values()) {
- for (String s : samples) {
- final String[] io= s.split("//");
- final String exprStr = io[0].trim();
- final IASTTranslationUnit tu= parse(code + exprStr + "){}", lang);
- final IASTFunctionDefinition fdef= getDeclaration(tu, 1);
- IASTFunctionDeclarator fdtor= fdef.getDeclarator();
- IASTParameterDeclaration pdecl= (IASTParameterDeclaration) fdtor.getChildren()[1];
- IASTExpression expr= (IASTExpression) ((IASTEqualsInitializer) pdecl.getDeclarator().getInitializer()).getInitializerClause();
+ }
+ }
+
+ // int a,b;
+ // void test(int a=
+
+ // 1+2+3 // 1,2,+,3,+
+ // a=b=1 // a,b,1,=,=
+ // 1 ? 2,3 : b= 4 // 1,2,3,,,b,4,=,?
+ // 1 ? 2 ? 3 : 4 ? 5 : 6 : 7 // 1,2,3,4,5,6,?,?,7,?
+ public void testConstantExpressionBinding() throws Exception {
+ CharSequence[] input = getContents(2);
+ String code = input[0].toString();
+ String[] samples = input[1].toString().split("\n");
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ for (String s : samples) {
+ final String[] io = s.split("//");
+ final String exprStr = io[0].trim();
+ final IASTTranslationUnit tu = parse(code + exprStr + "){}", lang);
+ final IASTFunctionDefinition fdef = getDeclaration(tu, 1);
+ IASTFunctionDeclarator fdtor = fdef.getDeclarator();
+ IASTParameterDeclaration pdecl = (IASTParameterDeclaration) fdtor.getChildren()[1];
+ IASTExpression expr = (IASTExpression) ((IASTEqualsInitializer) pdecl.getDeclarator().getInitializer())
+ .getInitializerClause();
assertEquals("expr: " + exprStr, io[1].trim(), polishNotation(expr));
- assertEquals(exprStr, expr.getRawSignature());
- checkOffsets(exprStr, expr);
+ assertEquals(exprStr, expr.getRawSignature());
+ checkOffsets(exprStr, expr);
}
- }
- }
-
+ }
+ }
private void checkOffsets(String exprStr, IASTExpression expr) {
if (expr instanceof IASTBinaryExpression) {
- IASTBinaryExpression bexpr= (IASTBinaryExpression) expr;
+ IASTBinaryExpression bexpr = (IASTBinaryExpression) expr;
checkOffsets(exprStr, bexpr.getOperand1());
checkOffsets(exprStr, bexpr.getOperand2());
assertEquals("in expr: " + exprStr, offset(bexpr), offset(bexpr.getOperand1()));
assertTrue("in expr: " + exprStr, endOffset(bexpr.getOperand1()) < offset(bexpr.getOperand2()));
assertEquals("in expr: " + exprStr, endOffset(bexpr), endOffset(bexpr.getOperand2()));
} else if (expr instanceof IASTCastExpression) {
- IASTCastExpression castExpr= (IASTCastExpression) expr;
+ IASTCastExpression castExpr = (IASTCastExpression) expr;
checkOffsets(exprStr, castExpr.getOperand());
assertTrue("in expr: " + exprStr, offset(castExpr) < offset(castExpr.getTypeId()));
assertTrue("in expr: " + exprStr, endOffset(castExpr.getTypeId()) < offset(castExpr.getOperand()));
assertEquals("in expr: " + exprStr, endOffset(castExpr), endOffset(castExpr.getOperand()));
} else if (expr instanceof IASTUnaryExpression) {
- IASTUnaryExpression unaryExpr= (IASTUnaryExpression) expr;
+ IASTUnaryExpression unaryExpr = (IASTUnaryExpression) expr;
checkOffsets(exprStr, unaryExpr.getOperand());
switch (unaryExpr.getOperator()) {
case IASTUnaryExpression.op_bracketedPrimary:
@@ -5362,14 +5317,14 @@ public class AST2Tests extends AST2TestBase {
}
private String polishNotation(IASTInitializerClause expr) {
- StringBuilder buf= new StringBuilder();
+ StringBuilder buf = new StringBuilder();
polishNotation(expr, buf);
return buf.toString();
}
private void polishNotation(IASTInitializerClause expr, StringBuilder buf) {
if (expr instanceof IASTConditionalExpression) {
- IASTConditionalExpression bexpr= (IASTConditionalExpression) expr;
+ IASTConditionalExpression bexpr = (IASTConditionalExpression) expr;
polishNotation(bexpr.getLogicalConditionExpression(), buf);
buf.append(',');
polishNotation(bexpr.getPositiveResultExpression(), buf);
@@ -5378,7 +5333,7 @@ public class AST2Tests extends AST2TestBase {
buf.append(',');
buf.append('?');
} else if (expr instanceof IASTExpressionList) {
- IASTExpressionList bexpr= (IASTExpressionList) expr;
+ IASTExpressionList bexpr = (IASTExpressionList) expr;
IASTExpression[] args = bexpr.getExpressions();
for (IASTExpression e : args) {
polishNotation(e, buf);
@@ -5386,20 +5341,20 @@ public class AST2Tests extends AST2TestBase {
}
buf.append(',');
} else if (expr instanceof IASTBinaryExpression) {
- IASTBinaryExpression bexpr= (IASTBinaryExpression) expr;
+ IASTBinaryExpression bexpr = (IASTBinaryExpression) expr;
polishNotation(bexpr.getOperand1(), buf);
buf.append(',');
polishNotation(bexpr.getOperand2(), buf);
buf.append(',');
buf.append(ASTStringUtil.getBinaryOperatorString(bexpr));
} else if (expr instanceof IASTCastExpression) {
- IASTCastExpression castExpr= (IASTCastExpression) expr;
+ IASTCastExpression castExpr = (IASTCastExpression) expr;
buf.append(castExpr.getTypeId().getRawSignature());
buf.append(',');
polishNotation(castExpr.getOperand(), buf);
buf.append(",cast");
} else if (expr instanceof IASTFunctionCallExpression) {
- IASTFunctionCallExpression f= (IASTFunctionCallExpression) expr;
+ IASTFunctionCallExpression f = (IASTFunctionCallExpression) expr;
polishNotation(f.getFunctionNameExpression(), buf);
buf.append(',');
for (IASTInitializerClause arg : f.getArguments()) {
@@ -5408,20 +5363,20 @@ public class AST2Tests extends AST2TestBase {
}
buf.append("()");
} else if (expr instanceof IASTArraySubscriptExpression) {
- IASTArraySubscriptExpression f= (IASTArraySubscriptExpression) expr;
+ IASTArraySubscriptExpression f = (IASTArraySubscriptExpression) expr;
polishNotation(f.getArrayExpression(), buf);
buf.append(',');
polishNotation(f.getArgument(), buf);
buf.append(",[]");
} else if (expr instanceof IASTFieldReference) {
- IASTFieldReference f= (IASTFieldReference) expr;
+ IASTFieldReference f = (IASTFieldReference) expr;
polishNotation(f.getFieldOwner(), buf);
buf.append(',');
buf.append(f.getFieldName().toString());
buf.append(',');
buf.append(f.isPointerDereference() ? "->" : ".");
} else if (expr instanceof IASTUnaryExpression) {
- IASTUnaryExpression unaryExpr= (IASTUnaryExpression) expr;
+ IASTUnaryExpression unaryExpr = (IASTUnaryExpression) expr;
polishNotation(unaryExpr.getOperand(), buf);
switch (unaryExpr.getOperator()) {
case IASTUnaryExpression.op_amper:
@@ -5453,13 +5408,13 @@ public class AST2Tests extends AST2TestBase {
// int x;
// } spinlock_t;
// spinlock_t _lock = (spinlock_t) { };
- public void testCompoundInitializer_145387() throws Exception {
+ public void testCompoundInitializer_145387() throws Exception {
// valid in C99, not in C++.
parseAndCheckBindings(getAboveComment(), C, true);
}
// enum __declspec(uuid("uuid")) bla { a, b};
- public void testDeclspecInEnumSpecifier_241203() throws Exception {
+ public void testDeclspecInEnumSpecifier_241203() throws Exception {
for (ParserLanguage lang : ParserLanguage.values()) {
parseAndCheckBindings(getAboveComment(), lang, true);
}
@@ -5474,9 +5429,9 @@ public class AST2Tests extends AST2TestBase {
// o.a1=0; o.a2=0; o.a3=0;
// }
public void testAnonymousUnionMember() throws Exception {
- final boolean[] isCpps= {false, true};
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), lang);
+ final boolean[] isCpps = { false, true };
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), lang);
bh.assertNonProblem("a1=", 2);
bh.assertProblem("a2=", 2);
bh.assertNonProblem("a3=", 2);
@@ -5488,7 +5443,7 @@ public class AST2Tests extends AST2TestBase {
// if (__builtin_types_compatible_p(typeof(p), char[])) {
// }
// }
- public void testBuiltinTypesCompatible_241570() throws Exception {
+ public void testBuiltinTypesCompatible_241570() throws Exception {
for (ParserLanguage lang : ParserLanguage.values()) {
parseAndCheckBindings(getAboveComment(), lang, true);
}
@@ -5529,63 +5484,88 @@ public class AST2Tests extends AST2TestBase {
// #define IF_COND if (1)
// void test() {
public void testLeadingSyntax_250251() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code + "if (1) {};}");
- IASTFunctionDefinition f= getDeclaration(tu, 0);
+ IASTTranslationUnit tu = parseAndCheckBindings(code + "if (1) {};}");
+ IASTFunctionDefinition f = getDeclaration(tu, 0);
IASTIfStatement i = getStatement(f, 0);
- IASTExpression x= i.getConditionExpression();
- IToken syntax= x.getLeadingSyntax();
- checkToken(syntax, "if", -4); syntax= syntax.getNext();
- checkToken(syntax, "(", -1); syntax= syntax.getNext();
+ IASTExpression x = i.getConditionExpression();
+ IToken syntax = x.getLeadingSyntax();
+ checkToken(syntax, "if", -4);
+ syntax = syntax.getNext();
+ checkToken(syntax, "(", -1);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "if( 1) {}}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
- syntax= x.getLeadingSyntax();
- checkToken(syntax, "if", -5); syntax= syntax.getNext();
- checkToken(syntax, "(", -3); syntax= syntax.getNext();
+ tu = parseAndCheckBindings(code + "if( 1) {}}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
+ syntax = x.getLeadingSyntax();
+ checkToken(syntax, "if", -5);
+ syntax = syntax.getNext();
+ checkToken(syntax, "(", -3);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "if(1) ; else ;}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); IASTStatement est= i.getElseClause();
- syntax= est.getLeadingSyntax();
- checkToken(syntax, "else", -5); syntax= syntax.getNext();
+ tu = parseAndCheckBindings(code + "if(1) ; else ;}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ IASTStatement est = i.getElseClause();
+ syntax = est.getLeadingSyntax();
+ checkToken(syntax, "else", -5);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "IF(1) {}}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
- syntax= x.getLeadingSyntax();
- checkToken(syntax, "IF", -3); syntax= syntax.getNext();
- checkToken(syntax, "(", -1); syntax= syntax.getNext();
+ tu = parseAndCheckBindings(code + "IF(1) {}}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
+ syntax = x.getLeadingSyntax();
+ checkToken(syntax, "IF", -3);
+ syntax = syntax.getNext();
+ checkToken(syntax, "(", -1);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "IF_P 1) {}}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
- syntax= x.getLeadingSyntax();
- checkToken(syntax, "IF_P", -5); syntax= syntax.getNext();
+ tu = parseAndCheckBindings(code + "IF_P 1) {}}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
+ syntax = x.getLeadingSyntax();
+ checkToken(syntax, "IF_P", -5);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "IF_P_T) {}}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
+ tu = parseAndCheckBindings(code + "IF_P_T) {}}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
try {
- syntax= x.getLeadingSyntax();
+ syntax = x.getLeadingSyntax();
fail();
- } catch (ExpansionOverlapsBoundaryException e) {}
+ } catch (ExpansionOverlapsBoundaryException e) {
+ }
- tu= parseAndCheckBindings(code + "SEMI_IF (1) {}}");
- f= getDeclaration(tu, 0); i= getStatement(f, 1); x= i.getConditionExpression();
+ tu = parseAndCheckBindings(code + "SEMI_IF (1) {}}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 1);
+ x = i.getConditionExpression();
try {
- syntax= x.getLeadingSyntax();
+ syntax = x.getLeadingSyntax();
fail();
- } catch (ExpansionOverlapsBoundaryException e) {}
+ } catch (ExpansionOverlapsBoundaryException e) {
+ }
- tu= parseAndCheckBindings(code + "IF_COND {}}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
+ tu = parseAndCheckBindings(code + "IF_COND {}}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
try {
- syntax= x.getLeadingSyntax();
+ syntax = x.getLeadingSyntax();
fail();
- } catch (ExpansionOverlapsBoundaryException e) {}
+ } catch (ExpansionOverlapsBoundaryException e) {
+ }
}
// #define P(x) )
@@ -5595,58 +5575,78 @@ public class AST2Tests extends AST2TestBase {
// #define IF_COND if (1)
// void test() {
public void testTrailingSyntax_250251() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code + "if (1) {};}");
- IASTFunctionDefinition f= getDeclaration(tu, 0);
+ IASTTranslationUnit tu = parseAndCheckBindings(code + "if (1) {};}");
+ IASTFunctionDefinition f = getDeclaration(tu, 0);
IASTIfStatement i = getStatement(f, 0);
- IASTExpression x= i.getConditionExpression();
- IToken syntax= x.getTrailingSyntax();
- checkToken(syntax, ")", 0); syntax= syntax.getNext();
+ IASTExpression x = i.getConditionExpression();
+ IToken syntax = x.getTrailingSyntax();
+ checkToken(syntax, ")", 0);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "do {} while(1 );}");
- f= getDeclaration(tu, 0); IASTDoStatement dstmt= getStatement(f, 0); x= dstmt.getCondition();
- syntax= x.getTrailingSyntax();
- checkToken(syntax, ")", 1); syntax= syntax.getNext();
- checkToken(syntax, ";", 2); syntax= syntax.getNext();
+ tu = parseAndCheckBindings(code + "do {} while(1 );}");
+ f = getDeclaration(tu, 0);
+ IASTDoStatement dstmt = getStatement(f, 0);
+ x = dstmt.getCondition();
+ syntax = x.getTrailingSyntax();
+ checkToken(syntax, ")", 1);
+ syntax = syntax.getNext();
+ checkToken(syntax, ";", 2);
+ syntax = syntax.getNext();
assertNull(syntax);
-
- tu= parseAndCheckBindings(code + "if(1 ) BLOCK()}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
- syntax= x.getTrailingSyntax();
- checkToken(syntax, ")", 1); syntax= syntax.getNext();
+ tu = parseAndCheckBindings(code + "if(1 ) BLOCK()}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
+ syntax = x.getTrailingSyntax();
+ checkToken(syntax, ")", 1);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "if(1 P(0) {}}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
- syntax= x.getTrailingSyntax();
- checkToken(syntax, "P", 1); syntax= syntax.getNext();
- checkToken(syntax, "(", 2); syntax= syntax.getNext();
- checkToken(syntax, "0", 3); syntax= syntax.getNext();
- checkToken(syntax, ")", 4); syntax= syntax.getNext();
+ tu = parseAndCheckBindings(code + "if(1 P(0) {}}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
+ syntax = x.getTrailingSyntax();
+ checkToken(syntax, "P", 1);
+ syntax = syntax.getNext();
+ checkToken(syntax, "(", 2);
+ syntax = syntax.getNext();
+ checkToken(syntax, "0", 3);
+ syntax = syntax.getNext();
+ checkToken(syntax, ")", 4);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "if (T_P {}}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
+ tu = parseAndCheckBindings(code + "if (T_P {}}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
try {
- syntax= x.getTrailingSyntax();
+ syntax = x.getTrailingSyntax();
fail();
- } catch (ExpansionOverlapsBoundaryException e) {}
+ } catch (ExpansionOverlapsBoundaryException e) {
+ }
- tu= parseAndCheckBindings(code + "if (1 P_BLOCK }");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
+ tu = parseAndCheckBindings(code + "if (1 P_BLOCK }");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
try {
- syntax= x.getTrailingSyntax();
+ syntax = x.getTrailingSyntax();
fail();
} catch (ExpansionOverlapsBoundaryException e) {
}
- tu= parseAndCheckBindings(code + "IF_COND {}}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
+ tu = parseAndCheckBindings(code + "IF_COND {}}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
try {
- syntax= x.getTrailingSyntax();
+ syntax = x.getTrailingSyntax();
fail();
} catch (ExpansionOverlapsBoundaryException e) {
}
@@ -5659,46 +5659,67 @@ public class AST2Tests extends AST2TestBase {
// #define IF_COND if (1)
// void test() {
public void testSyntax_250251() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code + "if (1) {};}");
- IASTFunctionDefinition f= getDeclaration(tu, 0);
+ IASTTranslationUnit tu = parseAndCheckBindings(code + "if (1) {};}");
+ IASTFunctionDefinition f = getDeclaration(tu, 0);
IASTIfStatement x = getStatement(f, 0);
- IToken syntax= x.getSyntax();
- checkToken(syntax, "if", 0); syntax= syntax.getNext();
- checkToken(syntax, "(", 3); syntax= syntax.getNext();
- checkToken(syntax, "1", 4); syntax= syntax.getNext();
- checkToken(syntax, ")", 5); syntax= syntax.getNext();
- checkToken(syntax, "{", 7); syntax= syntax.getNext();
- checkToken(syntax, "}", 8); syntax= syntax.getNext();
+ IToken syntax = x.getSyntax();
+ checkToken(syntax, "if", 0);
+ syntax = syntax.getNext();
+ checkToken(syntax, "(", 3);
+ syntax = syntax.getNext();
+ checkToken(syntax, "1", 4);
+ syntax = syntax.getNext();
+ checkToken(syntax, ")", 5);
+ syntax = syntax.getNext();
+ checkToken(syntax, "{", 7);
+ syntax = syntax.getNext();
+ checkToken(syntax, "}", 8);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "if( 1) {}}");
- f= getDeclaration(tu, 0); x= getStatement(f, 0);
- syntax= x.getSyntax();
- checkToken(syntax, "if", 0); syntax= syntax.getNext();
- checkToken(syntax, "(", 2); syntax= syntax.getNext();
- checkToken(syntax, "1", 5); syntax= syntax.getNext();
- checkToken(syntax, ")", 6); syntax= syntax.getNext();
- checkToken(syntax, "{", 8); syntax= syntax.getNext();
- checkToken(syntax, "}", 9); syntax= syntax.getNext();
+ tu = parseAndCheckBindings(code + "if( 1) {}}");
+ f = getDeclaration(tu, 0);
+ x = getStatement(f, 0);
+ syntax = x.getSyntax();
+ checkToken(syntax, "if", 0);
+ syntax = syntax.getNext();
+ checkToken(syntax, "(", 2);
+ syntax = syntax.getNext();
+ checkToken(syntax, "1", 5);
+ syntax = syntax.getNext();
+ checkToken(syntax, ")", 6);
+ syntax = syntax.getNext();
+ checkToken(syntax, "{", 8);
+ syntax = syntax.getNext();
+ checkToken(syntax, "}", 9);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "IF(1) {}}");
- f= getDeclaration(tu, 0); x= getStatement(f, 0);
- syntax= x.getSyntax();
- checkToken(syntax, "IF", 0); syntax= syntax.getNext();
- checkToken(syntax, "(", 2); syntax= syntax.getNext();
- checkToken(syntax, "1", 3); syntax= syntax.getNext();
- checkToken(syntax, ")", 4); syntax= syntax.getNext();
- checkToken(syntax, "{", 6); syntax= syntax.getNext();
- checkToken(syntax, "}", 7); syntax= syntax.getNext();
+ tu = parseAndCheckBindings(code + "IF(1) {}}");
+ f = getDeclaration(tu, 0);
+ x = getStatement(f, 0);
+ syntax = x.getSyntax();
+ checkToken(syntax, "IF", 0);
+ syntax = syntax.getNext();
+ checkToken(syntax, "(", 2);
+ syntax = syntax.getNext();
+ checkToken(syntax, "1", 3);
+ syntax = syntax.getNext();
+ checkToken(syntax, ")", 4);
+ syntax = syntax.getNext();
+ checkToken(syntax, "{", 6);
+ syntax = syntax.getNext();
+ checkToken(syntax, "}", 7);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "SEMI_IF (1) {}}");
- f= getDeclaration(tu, 0); x= getStatement(f, 1);
+ tu = parseAndCheckBindings(code + "SEMI_IF (1) {}}");
+ f = getDeclaration(tu, 0);
+ x = getStatement(f, 1);
try {
- syntax= x.getSyntax();
+ syntax = x.getSyntax();
fail();
} catch (ExpansionOverlapsBoundaryException e) {
}
@@ -5717,30 +5738,35 @@ public class AST2Tests extends AST2TestBase {
// y;
// }
public void testSyntaxWithNL_280175() throws Exception {
- String code= getAboveComment();
- int offsetX= code.indexOf('x', code.indexOf('x')+1);
- int offsetShift= code.indexOf('<');
- int offsetY= code.indexOf('y', offsetX);
+ String code = getAboveComment();
+ int offsetX = code.indexOf('x', code.indexOf('x') + 1);
+ int offsetShift = code.indexOf('<');
+ int offsetY = code.indexOf('y', offsetX);
- IASTTranslationUnit tu= parseAndCheckBindings(code);
- IASTFunctionDefinition f= getDeclaration(tu, 0);
+ IASTTranslationUnit tu = parseAndCheckBindings(code);
+ IASTFunctionDefinition f = getDeclaration(tu, 0);
IASTExpressionStatement i = getStatement(f, 1);
final IASTBinaryExpression expr = (IASTBinaryExpression) i.getExpression();
- IASTExpression x= expr.getOperand1();
- IASTExpression y= expr.getOperand2();
+ IASTExpression x = expr.getOperand1();
+ IASTExpression y = expr.getOperand2();
- IToken syntax= x.getTrailingSyntax();
- checkToken(syntax, "<<", offsetShift-offsetX-1); syntax= syntax.getNext();
+ IToken syntax = x.getTrailingSyntax();
+ checkToken(syntax, "<<", offsetShift - offsetX - 1);
+ syntax = syntax.getNext();
assertNull(syntax);
- syntax= y.getLeadingSyntax();
- checkToken(syntax, "<<", offsetShift - offsetY); syntax= syntax.getNext();
+ syntax = y.getLeadingSyntax();
+ checkToken(syntax, "<<", offsetShift - offsetY);
+ syntax = syntax.getNext();
assertNull(syntax);
- syntax= expr.getSyntax();
- checkToken(syntax, "x", 0); syntax= syntax.getNext();
- checkToken(syntax, "<<", offsetShift-offsetX); syntax= syntax.getNext();
- checkToken(syntax, "y", offsetY-offsetX); syntax= syntax.getNext();
+ syntax = expr.getSyntax();
+ checkToken(syntax, "x", 0);
+ syntax = syntax.getNext();
+ checkToken(syntax, "<<", offsetShift - offsetX);
+ syntax = syntax.getNext();
+ checkToken(syntax, "y", offsetY - offsetX);
+ syntax = syntax.getNext();
assertNull(syntax);
}
@@ -5749,25 +5775,25 @@ public class AST2Tests extends AST2TestBase {
// int* c= &b;
// enum X {e0, e4=4, e5, e2=2, e3};
public void testValues() throws Exception {
- final String code= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper bh= new AST2AssertionHelper(code, lang);
- IVariable v= (IVariable) bh.assertNonProblem("a=", 1);
+ final String code = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, lang);
+ IVariable v = (IVariable) bh.assertNonProblem("a=", 1);
checkValue(v.getInitialValue(), -4);
- v= (IVariable) bh.assertNonProblem("b=", 1);
+ v = (IVariable) bh.assertNonProblem("b=", 1);
checkValue(v.getInitialValue(), 0);
- v= (IVariable) bh.assertNonProblem("c=", 1);
+ v = (IVariable) bh.assertNonProblem("c=", 1);
assertNull(v.getInitialValue().numberValue());
- IEnumerator e= (IEnumerator) bh.assertNonProblem("e0", 2);
+ IEnumerator e = (IEnumerator) bh.assertNonProblem("e0", 2);
checkValue(e.getValue(), 0);
- e= (IEnumerator) bh.assertNonProblem("e2", 2);
+ e = (IEnumerator) bh.assertNonProblem("e2", 2);
checkValue(e.getValue(), 2);
- e= (IEnumerator) bh.assertNonProblem("e3", 2);
+ e = (IEnumerator) bh.assertNonProblem("e3", 2);
checkValue(e.getValue(), 3);
- e= (IEnumerator) bh.assertNonProblem("e4", 2);
+ e = (IEnumerator) bh.assertNonProblem("e4", 2);
checkValue(e.getValue(), 4);
- e= (IEnumerator) bh.assertNonProblem("e5", 2);
+ e = (IEnumerator) bh.assertNonProblem("e5", 2);
checkValue(e.getValue(), 5);
}
}
@@ -5787,9 +5813,9 @@ public class AST2Tests extends AST2TestBase {
public void testReferencesInInitializer_251514() throws Exception {
final String code = getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parseAndCheckBindings(code, lang, true);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTName name= fdef.getDeclarator().getName();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, lang, true);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTName name = fdef.getDeclarator().getName();
assertEquals(2, tu.getReferences(name.resolveBinding()).length);
}
}
@@ -5924,7 +5950,7 @@ public class AST2Tests extends AST2TestBase {
*/
private void intermittentTest(RunnableWithException test) throws Exception {
Exception lastException = null;
- for (int i = 0; i < RETRY_INTERMITTENT_COUNT ; i++) {
+ for (int i = 0; i < RETRY_INTERMITTENT_COUNT; i++) {
try {
test.run();
// no exception, success
@@ -5949,26 +5975,26 @@ public class AST2Tests extends AST2TestBase {
*/
private long memoryUsed() throws InterruptedException {
final Runtime runtime = Runtime.getRuntime();
- long mem= runtime.totalMemory()-runtime.freeMemory();
- long newMem= mem;
- int i=0;
+ long mem = runtime.totalMemory() - runtime.freeMemory();
+ long newMem = mem;
+ int i = 0;
do {
Thread.sleep(50);
System.gc();
- mem= newMem;
- newMem= runtime.totalMemory()-runtime.freeMemory();
- } while (newMem < mem && ++i<5);
+ mem = newMem;
+ newMem = runtime.totalMemory() - runtime.freeMemory();
+ } while (newMem < mem && ++i < 5);
return mem;
}
// int n= 0;
// int a[]= {0x00, sizeof(n)};
public void testNonTrivialInitializer_253690() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(code, lang, false, true, 0);
- IASTSimpleDeclaration d= getDeclaration(tu, 0);
- IBinding b= d.getDeclarators()[0].getName().resolveBinding();
+ IASTTranslationUnit tu = parse(code, lang, false, true, 0);
+ IASTSimpleDeclaration d = getDeclaration(tu, 0);
+ IBinding b = d.getDeclarators()[0].getName().resolveBinding();
IASTName[] refs = tu.getReferences(b);
assertEquals(1, refs.length);
}
@@ -5980,34 +6006,34 @@ public class AST2Tests extends AST2TestBase {
public void testGetChildren_256127() throws Exception {
final String code = getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
- IASTNode node= parseAndCheckBindings(code, lang);
+ IASTNode node = parseAndCheckBindings(code, lang);
- IASTNode[] children= node.getChildren();
+ IASTNode[] children = node.getChildren();
assertEquals(1, children.length);
assertInstance(children[0], IASTFunctionDefinition.class);
- children= children[0].getChildren();
+ children = children[0].getChildren();
assertEquals(3, children.length);
assertInstance(children[0], IASTDeclSpecifier.class);
assertInstance(children[1], IASTDeclarator.class);
assertInstance(children[2], IASTCompoundStatement.class);
- children= children[2].getChildren();
+ children = children[2].getChildren();
assertEquals(1, children.length);
assertInstance(children[0], IASTDeclarationStatement.class);
- children= children[0].getChildren()[0].getChildren(); // skip declaration
+ children = children[0].getChildren()[0].getChildren(); // skip declaration
assertEquals(2, children.length);
assertInstance(children[0], IASTDeclSpecifier.class);
assertInstance(children[1], IASTDeclarator.class);
- children= children[1].getChildren();
+ children = children[1].getChildren();
assertEquals(3, children.length);
assertInstance(children[0], IASTPointerOperator.class);
assertInstance(children[1], IASTName.class);
assertInstance(children[2], IASTInitializer.class);
- children= children[2].getChildren()[0].getChildren(); // skip binary expression
+ children = children[2].getChildren()[0].getChildren(); // skip binary expression
assertEquals(2, children.length);
assertInstance(children[0], IASTLiteralExpression.class);
assertInstance(children[1], IASTLiteralExpression.class);
@@ -6024,7 +6050,7 @@ public class AST2Tests extends AST2TestBase {
// v.mem = 1;
// }
public void testNestedDeclarator_257540() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code, C);
parseAndCheckBindings(code, CPP);
}
@@ -6038,7 +6064,7 @@ public class AST2Tests extends AST2TestBase {
// foo = ((cs) {1.2,1});
// }
public void testCompoundLiterals_258496() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code, C);
parseAndCheckBindings(code, CPP);
}
@@ -6047,7 +6073,7 @@ public class AST2Tests extends AST2TestBase {
// static __thread int j;
// extern __thread int k;
public void testThreadLocalVariables_260387() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code, C, true);
parseAndCheckBindings(code, CPP, true);
}
@@ -6057,12 +6083,12 @@ public class AST2Tests extends AST2TestBase {
// if ((a)+b);
// }
public void testAmbiguityResolutionInIfCondition_261043() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parseAndCheckBindings(code, lang, true);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTIfStatement ifstmt= getStatement(fdef, 1);
- IASTExpression expr= ifstmt.getConditionExpression();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, lang, true);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTIfStatement ifstmt = getStatement(fdef, 1);
+ IASTExpression expr = ifstmt.getConditionExpression();
assertInstance(expr, IASTBinaryExpression.class);
}
}
@@ -6073,11 +6099,11 @@ public class AST2Tests extends AST2TestBase {
// const a; // declares a;
// };
public void testAmbiguousDeclaration_259373() throws Exception {
- final String code= getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, C, true);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
- ITypedef td= bh.assertNonProblem("TInt; //", 4);
- IField f= bh.assertNonProblem("a;", 1);
+ final String code = getAboveComment();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, C, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
+ ITypedef td = bh.assertNonProblem("TInt; //", 4);
+ IField f = bh.assertNonProblem("a;", 1);
}
// struct beta {
@@ -6095,9 +6121,9 @@ public class AST2Tests extends AST2TestBase {
// pl->loc= 1;
// }
public void testLocalVsGlobalStruct_255973() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parseAndCheckBindings(code, lang, true);
+ IASTTranslationUnit tu = parseAndCheckBindings(code, lang, true);
}
}
@@ -6105,14 +6131,14 @@ public class AST2Tests extends AST2TestBase {
// struct A; // struct
// struct A* a;
public void testTypedefWithSameName() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parseAndCheckBindings(code, lang, true);
+ IASTTranslationUnit tu = parseAndCheckBindings(code, lang, true);
- BindingAssertionHelper ba= new AST2AssertionHelper(code, lang == CPP);
- ITypedef t= ba.assertNonProblem("A;", 1);
- ICompositeType s1= ba.assertNonProblem("A; // struct", 1);
- ICompositeType s2= ba.assertNonProblem("A*", 1);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, lang == CPP);
+ ITypedef t = ba.assertNonProblem("A;", 1);
+ ICompositeType s1 = ba.assertNonProblem("A; // struct", 1);
+ ICompositeType s2 = ba.assertNonProblem("A*", 1);
assertSame(s1, s2);
assertSame(s1, t.getType());
}
@@ -6120,24 +6146,24 @@ public class AST2Tests extends AST2TestBase {
// typedef long unsigned int size_t;
//
- // size_t a = 0;
- // size_t x = a + 5;
- // size_t y = 2 + a;
- // size_t y = a * 2;
- public void testTypeOfExpressionWithTypedef_380498_1() throws Exception {
- String code= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(code, lang);
- IASTExpression exp = ba.assertNode("a + 5", IASTExpression.class);
- assertTrue(exp.getExpressionType() instanceof ITypedef);
- assertEquals("size_t", ((ITypedef) exp.getExpressionType()).getName());
- exp = ba.assertNode("2 + a", IASTExpression.class);
- assertTrue(exp.getExpressionType() instanceof ITypedef);
- assertEquals("size_t", ((ITypedef) exp.getExpressionType()).getName());
- exp = ba.assertNode("a * 2", IASTExpression.class);
- assertTrue(exp.getExpressionType() instanceof ITypedef);
- assertEquals("size_t", ((ITypedef) exp.getExpressionType()).getName());
- }
+ // size_t a = 0;
+ // size_t x = a + 5;
+ // size_t y = 2 + a;
+ // size_t y = a * 2;
+ public void testTypeOfExpressionWithTypedef_380498_1() throws Exception {
+ String code = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, lang);
+ IASTExpression exp = ba.assertNode("a + 5", IASTExpression.class);
+ assertTrue(exp.getExpressionType() instanceof ITypedef);
+ assertEquals("size_t", ((ITypedef) exp.getExpressionType()).getName());
+ exp = ba.assertNode("2 + a", IASTExpression.class);
+ assertTrue(exp.getExpressionType() instanceof ITypedef);
+ assertEquals("size_t", ((ITypedef) exp.getExpressionType()).getName());
+ exp = ba.assertNode("a * 2", IASTExpression.class);
+ assertTrue(exp.getExpressionType() instanceof ITypedef);
+ assertEquals("size_t", ((ITypedef) exp.getExpressionType()).getName());
+ }
}
// typedef void* VoidPtr;
@@ -6146,64 +6172,65 @@ public class AST2Tests extends AST2TestBase {
// void test(Func f) {
// f();
// }
- public void testTypeOfExpressionWithTypedef_380498_2() throws Exception {
- String code= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(code, lang);
- IASTExpression exp = ba.assertNode("f()", IASTExpression.class);
- assertTrue(exp.getExpressionType() instanceof ITypedef);
- assertEquals("VoidPtr", ((ITypedef) exp.getExpressionType()).getName());
- }
- }
- // typedef int TInt;
- // int a= TInt; //ref
- public void testTypeAsExpressionIsProblem_261175() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ public void testTypeOfExpressionWithTypedef_380498_2() throws Exception {
+ String code = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, lang);
+ IASTExpression exp = ba.assertNode("f()", IASTExpression.class);
+ assertTrue(exp.getExpressionType() instanceof ITypedef);
+ assertEquals("VoidPtr", ((ITypedef) exp.getExpressionType()).getName());
+ }
+ }
+
+ // typedef int TInt;
+ // int a= TInt; //ref
+ public void testTypeAsExpressionIsProblem_261175() throws Exception {
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertProblem("TInt; //ref", 4);
- bh= new AST2AssertionHelper(code, false);
+ bh = new AST2AssertionHelper(code, false);
bh.assertProblem("TInt; //ref", 4);
- }
-
- // typedef int x, y;
- // void func(int c) {
- // c= sizeof(x(y));
- // x(y);
- // }
- public void testSizeofFunctionType_252243() throws Exception {
- final String code= getAboveComment();
+ }
+
+ // typedef int x, y;
+ // void func(int c) {
+ // c= sizeof(x(y));
+ // x(y);
+ // }
+ public void testSizeofFunctionType_252243() throws Exception {
+ final String code = getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(code, lang == CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, lang == CPP);
ba.assertProblem("y));", 1);
- IVariable v= ba.assertNonProblem("y);", 1);
+ IVariable v = ba.assertNonProblem("y);", 1);
}
- }
+ }
- // int* v;
- public void testPointerOperatorsAsChildren_260461() throws Exception {
- final String code= getAboveComment();
+ // int* v;
+ public void testPointerOperatorsAsChildren_260461() throws Exception {
+ final String code = getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parseAndCheckBindings(code, lang, true);
- IASTSimpleDeclaration decl= getDeclaration(tu, 0);
- IASTDeclarator dtor= decl.getDeclarators()[0];
+ IASTTranslationUnit tu = parseAndCheckBindings(code, lang, true);
+ IASTSimpleDeclaration decl = getDeclaration(tu, 0);
+ IASTDeclarator dtor = decl.getDeclarators()[0];
IASTNode[] nodes = dtor.getChildren();
assertEquals(2, nodes.length);
assertInstance(nodes[0], IASTPointerOperator.class);
}
- }
+ }
- // int a = -142;
- // int b = 456L;
- // int c = 100000LL;
- // int d = 0U;
- // int e = 1UL;
- // int f = 9u;
- // int g = 1234l;
- // int h = -123ll;
- // int i = 8888uL;
- public void testBug269705_int_literal() throws Exception {
- final String code= getAboveComment();
+ // int a = -142;
+ // int b = 456L;
+ // int c = 100000LL;
+ // int d = 0U;
+ // int e = 1UL;
+ // int f = 9u;
+ // int g = 1234l;
+ // int h = -123ll;
+ // int i = 8888uL;
+ public void testBug269705_int_literal() throws Exception {
+ final String code = getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
IASTTranslationUnit tu = parseAndCheckBindings(code, lang);
@@ -6211,7 +6238,7 @@ public class AST2Tests extends AST2TestBase {
// int a = -142;
{
- IBasicType t = getTypeForDeclaration(declarations, 0);
+ IBasicType t = getTypeForDeclaration(declarations, 0);
assertTrue(t.getType() == IBasicType.t_int);
assertFalse(t.isUnsigned());
assertFalse(t.isSigned());
@@ -6221,7 +6248,7 @@ public class AST2Tests extends AST2TestBase {
// int b = 456L;
{
- IBasicType t = getTypeForDeclaration(declarations, 1);
+ IBasicType t = getTypeForDeclaration(declarations, 1);
assertTrue(t.getType() == IBasicType.t_int);
assertFalse(t.isUnsigned());
assertFalse(t.isSigned());
@@ -6231,7 +6258,7 @@ public class AST2Tests extends AST2TestBase {
// int c = 100000LL;
{
- IBasicType t = getTypeForDeclaration(declarations, 2);
+ IBasicType t = getTypeForDeclaration(declarations, 2);
assertTrue(t.getType() == IBasicType.t_int);
assertFalse(t.isUnsigned());
assertFalse(t.isSigned());
@@ -6241,7 +6268,7 @@ public class AST2Tests extends AST2TestBase {
// int d = 0U;
{
- IBasicType t = getTypeForDeclaration(declarations, 3);
+ IBasicType t = getTypeForDeclaration(declarations, 3);
assertTrue(t.getType() == IBasicType.t_int);
assertTrue(t.isUnsigned());
assertFalse(t.isSigned());
@@ -6252,7 +6279,7 @@ public class AST2Tests extends AST2TestBase {
// int e = 1UL;
{
- IBasicType t = getTypeForDeclaration(declarations, 4);
+ IBasicType t = getTypeForDeclaration(declarations, 4);
assertTrue(t.getType() == IBasicType.t_int);
assertTrue(t.isUnsigned());
assertFalse(t.isSigned());
@@ -6262,7 +6289,7 @@ public class AST2Tests extends AST2TestBase {
// int f = 9u;
{
- IBasicType t = getTypeForDeclaration(declarations, 5);
+ IBasicType t = getTypeForDeclaration(declarations, 5);
assertTrue(t.getType() == IBasicType.t_int);
assertTrue(t.isUnsigned());
assertFalse(t.isSigned());
@@ -6273,7 +6300,7 @@ public class AST2Tests extends AST2TestBase {
// int g = 1234l;
{
- IBasicType t = getTypeForDeclaration(declarations, 6);
+ IBasicType t = getTypeForDeclaration(declarations, 6);
assertTrue(t.getType() == IBasicType.t_int);
assertFalse(t.isUnsigned());
assertFalse(t.isSigned());
@@ -6283,7 +6310,7 @@ public class AST2Tests extends AST2TestBase {
// int h = -123ll;
{
- IBasicType t = getTypeForDeclaration(declarations, 7);
+ IBasicType t = getTypeForDeclaration(declarations, 7);
assertTrue(t.getType() == IBasicType.t_int);
assertFalse(t.isUnsigned());
assertFalse(t.isSigned());
@@ -6293,7 +6320,7 @@ public class AST2Tests extends AST2TestBase {
// int i = 8888uL;
{
- IBasicType t = getTypeForDeclaration(declarations, 8);
+ IBasicType t = getTypeForDeclaration(declarations, 8);
assertTrue(t.getType() == IBasicType.t_int);
assertTrue(t.isUnsigned());
assertFalse(t.isSigned());
@@ -6301,82 +6328,83 @@ public class AST2Tests extends AST2TestBase {
assertFalse(isLongLong(t));
}
}
- }
-
- // int a = -142.0;
- // int b = 456.1f;
- // int c = 100000.99F;
- // int d = 0.123l;
- // int e = 1.3L;
- public void testBug269705_float_literal() throws Exception {
- final String code= getAboveComment();
-
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu = parseAndCheckBindings(code, lang);
- IASTDeclaration[] declarations = tu.getDeclarations();
-
- // int a = -142.0;
- {
- IBasicType t = getTypeForDeclaration(declarations, 0);
- assertTrue(t.getType() == IBasicType.t_double);
- assertFalse(t.isSigned());
- assertFalse(t.isUnsigned());
- assertFalse(t.isLong());
- assertFalse(isLongLong(t));
- }
-
- // int b = 456.1f;
- {
- IBasicType t = getTypeForDeclaration(declarations, 1);
- assertTrue(t.getType() == IBasicType.t_float);
- assertFalse(t.isSigned());
- assertFalse(t.isUnsigned());
- assertFalse(t.isLong());
- assertFalse(isLongLong(t));
- }
-
- // int c = 100000.99F;
- {
- IBasicType t = getTypeForDeclaration(declarations, 2);
- assertTrue(t.getType() == IBasicType.t_float);
- assertFalse(t.isSigned());
- assertFalse(t.isUnsigned());
- assertFalse(t.isLong());
- assertFalse(isLongLong(t));
- }
-
- // int d = 0.123l;
- {
- IBasicType t = getTypeForDeclaration(declarations, 3);
- assertTrue(t.getType() == IBasicType.t_double);
- assertFalse(t.isSigned());
- assertFalse(t.isUnsigned());
- assertFalse(isLongLong(t));
- assertTrue(t.isLong());
- }
-
- // int e = 1.3L;
- {
- IBasicType t = getTypeForDeclaration(declarations, 4);
- assertTrue(t.getType() == IBasicType.t_double);
- assertFalse(t.isSigned());
- assertFalse(t.isUnsigned());
- assertTrue(t.isLong());
- assertFalse(isLongLong(t));
- }
- }
- }
-
- boolean isLongLong(IType t) {
- if (t instanceof IBasicType) {
- return ((IBasicType) t).isLongLong();
- }
- return false;
- }
+ }
+
+ // int a = -142.0;
+ // int b = 456.1f;
+ // int c = 100000.99F;
+ // int d = 0.123l;
+ // int e = 1.3L;
+ public void testBug269705_float_literal() throws Exception {
+ final String code = getAboveComment();
+
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parseAndCheckBindings(code, lang);
+ IASTDeclaration[] declarations = tu.getDeclarations();
+
+ // int a = -142.0;
+ {
+ IBasicType t = getTypeForDeclaration(declarations, 0);
+ assertTrue(t.getType() == IBasicType.t_double);
+ assertFalse(t.isSigned());
+ assertFalse(t.isUnsigned());
+ assertFalse(t.isLong());
+ assertFalse(isLongLong(t));
+ }
+
+ // int b = 456.1f;
+ {
+ IBasicType t = getTypeForDeclaration(declarations, 1);
+ assertTrue(t.getType() == IBasicType.t_float);
+ assertFalse(t.isSigned());
+ assertFalse(t.isUnsigned());
+ assertFalse(t.isLong());
+ assertFalse(isLongLong(t));
+ }
+
+ // int c = 100000.99F;
+ {
+ IBasicType t = getTypeForDeclaration(declarations, 2);
+ assertTrue(t.getType() == IBasicType.t_float);
+ assertFalse(t.isSigned());
+ assertFalse(t.isUnsigned());
+ assertFalse(t.isLong());
+ assertFalse(isLongLong(t));
+ }
+
+ // int d = 0.123l;
+ {
+ IBasicType t = getTypeForDeclaration(declarations, 3);
+ assertTrue(t.getType() == IBasicType.t_double);
+ assertFalse(t.isSigned());
+ assertFalse(t.isUnsigned());
+ assertFalse(isLongLong(t));
+ assertTrue(t.isLong());
+ }
+
+ // int e = 1.3L;
+ {
+ IBasicType t = getTypeForDeclaration(declarations, 4);
+ assertTrue(t.getType() == IBasicType.t_double);
+ assertFalse(t.isSigned());
+ assertFalse(t.isUnsigned());
+ assertTrue(t.isLong());
+ assertFalse(isLongLong(t));
+ }
+ }
+ }
+
+ boolean isLongLong(IType t) {
+ if (t instanceof IBasicType) {
+ return ((IBasicType) t).isLongLong();
+ }
+ return false;
+ }
private IBasicType getTypeForDeclaration(IASTDeclaration[] declarations, int index) {
IASTInitializer init = ((IASTSimpleDeclaration) declarations[index]).getDeclarators()[0].getInitializer();
- return (IBasicType)((IASTExpression)((IASTEqualsInitializer) init).getInitializerClause()).getExpressionType();
+ return (IBasicType) ((IASTExpression) ((IASTEqualsInitializer) init).getInitializerClause())
+ .getExpressionType();
}
// void test() {
@@ -6900,15 +6928,15 @@ public class AST2Tests extends AST2TestBase {
public void testPromotionInUnaryExpressions() throws Exception {
for (ParserLanguage lang : ParserLanguage.values()) {
IASTTranslationUnit ast = parseAndCheckBindings(getAboveComment(), lang);
- IASTFunctionDefinition fdef= getDeclaration(ast, 1);
- IASTExpression expr= getExpressionOfStatement(fdef, 0);
- IBasicType t= (IBasicType) expr.getExpressionType();
+ IASTFunctionDefinition fdef = getDeclaration(ast, 1);
+ IASTExpression expr = getExpressionOfStatement(fdef, 0);
+ IBasicType t = (IBasicType) expr.getExpressionType();
assertEquals(Kind.eChar, t.getKind());
assertEquals(0, t.getModifiers());
for (int i = 1; i < 4; i++) {
- expr= getExpressionOfStatement(fdef, i);
- t= (IBasicType) expr.getExpressionType();
+ expr = getExpressionOfStatement(fdef, i);
+ t = (IBasicType) expr.getExpressionType();
assertEquals(Kind.eInt, t.getKind()); // promoted to int
assertEquals(0, t.getModifiers());
}
@@ -6943,7 +6971,8 @@ public class AST2Tests extends AST2TestBase {
public void testBug278797() throws Exception {
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), C);
IASTFunctionDefinition func = (IASTFunctionDefinition) tu.getDeclarations()[1];
- IASTExpressionStatement stmt = ((IASTExpressionStatement)((IASTCompoundStatement) func.getBody()).getStatements()[0]);
+ IASTExpressionStatement stmt = ((IASTExpressionStatement) ((IASTCompoundStatement) func.getBody())
+ .getStatements()[0]);
IType t = ((IASTCastExpression) stmt.getExpression()).getOperand().getExpressionType();
assertNotNull(t);
assertTrue(t instanceof IEnumeration);
@@ -6999,12 +7028,12 @@ public class AST2Tests extends AST2TestBase {
//void goo(my_buf in);
//
public void testBug284248() throws Exception {
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
- assertTrue(tu.isFrozen());
- IASTName n = ((IASTSimpleDeclaration) tu.getDeclarations()[1]).getDeclarators()[0].getName();
- assertTrue(((IFunction) n.resolveBinding()).getType().getParameterTypes()[0] instanceof IPointerType);
- }
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
+ assertTrue(tu.isFrozen());
+ IASTName n = ((IASTSimpleDeclaration) tu.getDeclarations()[1]).getDeclarators()[0].getName();
+ assertTrue(((IFunction) n.resolveBinding()).getType().getParameterTypes()[0] instanceof IPointerType);
+ }
}
//
@@ -7018,16 +7047,17 @@ public class AST2Tests extends AST2TestBase {
//};
//
public void testBug295851() throws Exception {
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
- IASTEnumerationSpecifier enumSpec = (IASTEnumerationSpecifier)((IASTSimpleDeclaration) tu.getDeclarations()[0]).getDeclSpecifier();
- IEnumerator enumeratorBinding = (IEnumerator) enumSpec.getEnumerators()[0].getName().resolveBinding();
- IValue value = enumeratorBinding.getValue();
- assertEquals(2, value.numberValue().longValue());
- IEnumerator enumeratorBinding2 = (IEnumerator) enumSpec.getEnumerators()[1].getName().resolveBinding();
- IValue value2 = enumeratorBinding2.getValue();
- assertEquals(1, value2.numberValue().longValue());
- }
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
+ IASTEnumerationSpecifier enumSpec = (IASTEnumerationSpecifier) ((IASTSimpleDeclaration) tu
+ .getDeclarations()[0]).getDeclSpecifier();
+ IEnumerator enumeratorBinding = (IEnumerator) enumSpec.getEnumerators()[0].getName().resolveBinding();
+ IValue value = enumeratorBinding.getValue();
+ assertEquals(2, value.numberValue().longValue());
+ IEnumerator enumeratorBinding2 = (IEnumerator) enumSpec.getEnumerators()[1].getName().resolveBinding();
+ IValue value2 = enumeratorBinding2.getValue();
+ assertEquals(1, value2.numberValue().longValue());
+ }
}
// extern void goo();
@@ -7041,98 +7071,106 @@ public class AST2Tests extends AST2TestBase {
// structure.ptr = goo;
// }
public void testBindingsOnFields() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), C, false);
- IASTCompoundStatement bodyStmt = (IASTCompoundStatement)((IASTFunctionDefinition) tu.getDeclarations()[2]).getBody();
-
- // Get the IFields bindings from the type used in the declaration of structure
- IASTName n = ((IASTSimpleDeclaration)((IASTDeclarationStatement) bodyStmt.getStatements()[0]).getDeclaration()).getDeclarators()[0].getName();
- ICompositeType t = (ICompositeType)((IVariable) n.resolveBinding()).getType();
- IField[] fields = t.getFields();
- assertTrue(fields.length == 2);
-
- // Get the IField for the first assignment
- IASTFieldReference ref1 = (IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement) bodyStmt.getStatements()[1]).getExpression()).getOperand1();
- IBinding field1 = ref1.getFieldName().resolveBinding();
-
- // Get the IField for the second assignment
- IASTFieldReference ref2 = (IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement) bodyStmt.getStatements()[2]).getExpression()).getOperand1();
- IBinding field2 = ref2.getFieldName().resolveBinding();
-
- // Compare the IField from the type and the assignments
- assertEquals(fields[0], field1);
- assertEquals(fields[1], field2); // fails
-
- assertEquals(1, ((ICInternalBinding) field1).getDeclarations().length);
- assertEquals(1, ((ICInternalBinding) field2).getDeclarations().length);
- }
-
- // /*
- // * Check that the type returned by CASTArraySubscriptExpression
- // * handles typedefs correctly.
- // */
- // struct s {
- // int a;
- // };
- // typedef struct s* ptr;
- // typedef struct s array[10];
+ IASTTranslationUnit tu = parse(getAboveComment(), C, false);
+ IASTCompoundStatement bodyStmt = (IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[2])
+ .getBody();
+
+ // Get the IFields bindings from the type used in the declaration of structure
+ IASTName n = ((IASTSimpleDeclaration) ((IASTDeclarationStatement) bodyStmt.getStatements()[0]).getDeclaration())
+ .getDeclarators()[0].getName();
+ ICompositeType t = (ICompositeType) ((IVariable) n.resolveBinding()).getType();
+ IField[] fields = t.getFields();
+ assertTrue(fields.length == 2);
+
+ // Get the IField for the first assignment
+ IASTFieldReference ref1 = (IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) bodyStmt
+ .getStatements()[1]).getExpression()).getOperand1();
+ IBinding field1 = ref1.getFieldName().resolveBinding();
+
+ // Get the IField for the second assignment
+ IASTFieldReference ref2 = (IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) bodyStmt
+ .getStatements()[2]).getExpression()).getOperand1();
+ IBinding field2 = ref2.getFieldName().resolveBinding();
+
+ // Compare the IField from the type and the assignments
+ assertEquals(fields[0], field1);
+ assertEquals(fields[1], field2); // fails
+
+ assertEquals(1, ((ICInternalBinding) field1).getDeclarations().length);
+ assertEquals(1, ((ICInternalBinding) field2).getDeclarations().length);
+ }
+
+ // /*
+ // * Check that the type returned by CASTArraySubscriptExpression
+ // * handles typedefs correctly.
+ // */
+ // struct s {
+ // int a;
+ // };
+ // typedef struct s* ptr;
+ // typedef struct s array[10];
// typedef array newArray;
- // ptr var1;
- // struct s* var2;
- // array var3;
- // struct s var4[10];
- // newArray var5;
- //
- // void foo() {
+ // ptr var1;
+ // struct s* var2;
+ // array var3;
+ // struct s var4[10];
+ // newArray var5;
+ //
+ // void foo() {
// /* The type of the array subscript expression should be struct s
// * each of the following statements
// */
- // var1[1].a = 1;
- // var2[1].a = 1;
- // var3[1].a = 1;
- // var4[1].a = 1;
+ // var1[1].a = 1;
+ // var2[1].a = 1;
+ // var3[1].a = 1;
+ // var4[1].a = 1;
// var5[1].a = 1;
- // }
+ // }
public void testArraySubscriptExpressionGetExpressionType() throws Exception {
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
- assertTrue(tu.isFrozen());
- for (IASTDeclaration d : tu.getDeclarations()) {
- if (d instanceof IASTFunctionDefinition) {
- for (IASTStatement s : ((IASTCompoundStatement) ((IASTFunctionDefinition) d).getBody()).getStatements()) {
- IASTExpression op1 = ((IASTBinaryExpression) ((IASTExpressionStatement) s).getExpression()).getOperand1();
- IASTExpression owner = ((IASTFieldReference) op1).getFieldOwner();
- IType t = owner.getExpressionType();
- assertTrue(t instanceof ICompositeType);
- assertEquals("s", ((ICompositeType) t).getName());
- }
- }
- }
- }
- }
-
- // char array[10];
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
+ assertTrue(tu.isFrozen());
+ for (IASTDeclaration d : tu.getDeclarations()) {
+ if (d instanceof IASTFunctionDefinition) {
+ for (IASTStatement s : ((IASTCompoundStatement) ((IASTFunctionDefinition) d).getBody())
+ .getStatements()) {
+ IASTExpression op1 = ((IASTBinaryExpression) ((IASTExpressionStatement) s).getExpression())
+ .getOperand1();
+ IASTExpression owner = ((IASTFieldReference) op1).getFieldOwner();
+ IType t = owner.getExpressionType();
+ assertTrue(t instanceof ICompositeType);
+ assertEquals("s", ((ICompositeType) t).getName());
+ }
+ }
+ }
+ }
+ }
+
+ // char array[10];
// char* ptr;
- //
- // void test() {
- // array + 1;
- // 1 + array;
- // ptr + 1;
- // 1 + ptr;
- // }
+ //
+ // void test() {
+ // array + 1;
+ // 1 + array;
+ // ptr + 1;
+ // 1 + ptr;
+ // }
public void testPointerExpression_131037() throws Exception {
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
- assertTrue(tu.isFrozen());
- for (IASTDeclaration d : tu.getDeclarations()) {
- if (d instanceof IASTFunctionDefinition) {
- for (IASTStatement s : ((IASTCompoundStatement) ((IASTFunctionDefinition) d).getBody()).getStatements()) {
- IType t = ((IASTBinaryExpression) ((IASTExpressionStatement) s).getExpression()).getExpressionType();
- assertTrue(t instanceof IPointerType || t instanceof IArrayType);
- assertEquals("char", ((IPointerType) t).getType().toString());
- }
- }
- }
- }
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
+ assertTrue(tu.isFrozen());
+ for (IASTDeclaration d : tu.getDeclarations()) {
+ if (d instanceof IASTFunctionDefinition) {
+ for (IASTStatement s : ((IASTCompoundStatement) ((IASTFunctionDefinition) d).getBody())
+ .getStatements()) {
+ IType t = ((IASTBinaryExpression) ((IASTExpressionStatement) s).getExpression())
+ .getExpressionType();
+ assertTrue(t instanceof IPointerType || t instanceof IArrayType);
+ assertEquals("char", ((IPointerType) t).getType().toString());
+ }
+ }
+ }
+ }
}
// extern int a[];
@@ -7147,24 +7185,24 @@ public class AST2Tests extends AST2TestBase {
// void f2(const int* p) {}
public void testDroppingOfStorageDecl_293322() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
- IFunction f= bh.assertNonProblem("f1", 2);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
+ IFunction f = bh.assertNonProblem("f1", 2);
assertEquals("const int *", ASTTypeUtil.getType(f.getParameters()[0].getType()));
- f= bh.assertNonProblem("f2", 2);
+ f = bh.assertNonProblem("f2", 2);
assertEquals("const int *", ASTTypeUtil.getType(f.getParameters()[0].getType()));
}
// typedef int f(int);
// f ff;
public void testFunctionDeclViaTypedef_86495() throws Exception {
- final String code = getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
+ final String code = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
IASTTranslationUnit tu = parseAndCheckBindings(code, lang);
- IASTSimpleDeclaration decl= getDeclaration(tu, 1);
- IFunction ff= (IFunction) decl.getDeclarators()[0].getName().resolveBinding();
+ IASTSimpleDeclaration decl = getDeclaration(tu, 1);
+ IFunction ff = (IFunction) decl.getDeclarators()[0].getName().resolveBinding();
assertNotNull(ff.getType());
assertEquals(1, ff.getParameters().length);
- }
+ }
}
// void f() {
@@ -7172,27 +7210,27 @@ public class AST2Tests extends AST2TestBase {
public void testLargeExpression_294029() throws Exception {
// when running the test in a suite, it cannot handle more than 160 parenthesis.
// run as a single test it does > 500.
- sValidateCopy= false;
- StringBuilder buf= new StringBuilder();
- buf.append(getAboveComment());
- final int depth= 160;
- for (int i = 0; i < depth; i++) {
- buf.append('(');
- }
- buf.append('1');
- for (int i = 0; i < depth; i++) {
- buf.append(")+1");
- }
- buf.append(";}");
- String code= buf.toString();
- for (ParserLanguage lang : ParserLanguage.values()) {
+ sValidateCopy = false;
+ StringBuilder buf = new StringBuilder();
+ buf.append(getAboveComment());
+ final int depth = 160;
+ for (int i = 0; i < depth; i++) {
+ buf.append('(');
+ }
+ buf.append('1');
+ for (int i = 0; i < depth; i++) {
+ buf.append(")+1");
+ }
+ buf.append(";}");
+ String code = buf.toString();
+ for (ParserLanguage lang : ParserLanguage.values()) {
IASTTranslationUnit tu = parseAndCheckBindings(code, lang);
- }
+ }
}
// static a[2]= {0,0};
public void testSkipAggregateInitializer_297550() throws Exception {
- final String code = getAboveComment();
+ final String code = getAboveComment();
IASTTranslationUnit tu = parseAndCheckBindings(code, C, false, 0);
assertTrue(tu.hasNodesOmitted());
}
@@ -7214,42 +7252,42 @@ public class AST2Tests extends AST2TestBase {
// typeof(b(1)) b(int);
public void testRecursiveFunctionType_321856() throws Exception {
- final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
- IFunction f= bh.assertNonProblem("b(1)", 1);
- f= bh.assertNonProblem("b(int)", 1);
- f.getType();
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
+ IFunction f = bh.assertNonProblem("b(1)", 1);
+ f = bh.assertNonProblem("b(int)", 1);
+ f.getType();
}
public void testDeepBinaryExpression_294969() throws Exception {
- sValidateCopy= false;
- StringBuilder buf= new StringBuilder("void f() {0");
+ sValidateCopy = false;
+ StringBuilder buf = new StringBuilder("void f() {0");
for (int i = 0; i < 150000; i++) {
buf.append('+').append(i);
}
buf.append(";}");
- String code= buf.toString();
- for (ParserLanguage lang : ParserLanguage.values()) {
+ String code = buf.toString();
+ for (ParserLanguage lang : ParserLanguage.values()) {
IASTTranslationUnit tu = parseAndCheckBindings(code, lang);
- }
+ }
}
public void testDeepElseif_298455() throws Exception {
- sValidateCopy= false;
- StringBuilder buf= new StringBuilder("void f() {if (0) {}");
+ sValidateCopy = false;
+ StringBuilder buf = new StringBuilder("void f() {if (0) {}");
for (int i = 0; i < 75000; i++) {
buf.append("else if (0) {}");
}
buf.append("}");
- String code= buf.toString();
- for (ParserLanguage lang : ParserLanguage.values()) {
+ String code = buf.toString();
+ for (ParserLanguage lang : ParserLanguage.values()) {
IASTTranslationUnit tu = parseAndCheckBindings(code, lang);
- }
+ }
}
// void f () __attribute__ ((int));
public void testAttributeSyntax_298841() throws Exception {
- final String code = getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code, C, true);
parseAndCheckBindings(code, CPP, true);
}
@@ -7258,13 +7296,13 @@ public class AST2Tests extends AST2TestBase {
// int* obj = 0;
// }
public void testParameterRedeclaration_301779() throws Exception {
- final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- bh.assertNonProblem("obj", 3, IParameter.class);
- bh.assertProblem("obj =", 3);
- bh= new AST2AssertionHelper(code, false);
- bh.assertNonProblem("obj", 3, IParameter.class);
- bh.assertProblem("obj =", 3);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ bh.assertNonProblem("obj", 3, IParameter.class);
+ bh.assertProblem("obj =", 3);
+ bh = new AST2AssertionHelper(code, false);
+ bh.assertNonProblem("obj", 3, IParameter.class);
+ bh.assertProblem("obj =", 3);
}
// #define ONCE() PRAGMA(once)
@@ -7273,21 +7311,21 @@ public class AST2Tests extends AST2TestBase {
// _Pragma ("once")
// ONCE()
public void testPragmaOperator_294730() throws Exception {
- final String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, C);
+ final String code = getAboveComment();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, C);
IASTPreprocessorStatement[] stmts = tu.getAllPreprocessorStatements();
assertEquals(5, stmts.length);
for (int i = 2; i < stmts.length; i++) {
IASTPreprocessorStatement stmt = stmts[i];
assertInstance(stmt, IASTPreprocessorPragmaStatement.class);
- assertEquals(i>2, ((IASTPreprocessorPragmaStatement) stmt).isPragmaOperator());
+ assertEquals(i > 2, ((IASTPreprocessorPragmaStatement) stmt).isPragmaOperator());
}
- tu= parseAndCheckBindings(code, CPP);
+ tu = parseAndCheckBindings(code, CPP);
assertEquals(5, stmts.length);
for (int i = 2; i < stmts.length; i++) {
IASTPreprocessorStatement stmt = stmts[i];
assertInstance(stmt, IASTPreprocessorPragmaStatement.class);
- assertEquals(i>2, ((IASTPreprocessorPragmaStatement) stmt).isPragmaOperator());
+ assertEquals(i > 2, ((IASTPreprocessorPragmaStatement) stmt).isPragmaOperator());
}
}
@@ -7296,7 +7334,7 @@ public class AST2Tests extends AST2TestBase {
// int a= (min)(1, 2);
// }
public void testFunctionNameExpression() throws Exception {
- final String code = getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code, C, true);
parseAndCheckBindings(code, CPP, true);
}
@@ -7306,15 +7344,15 @@ public class AST2Tests extends AST2TestBase {
// }
// MACRO
public void testEmptyTrailingMacro_303152() throws Exception {
- final String code = getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parseAndCheckBindings(code, lang);
- IASTPreprocessorMacroExpansion[] expansions = tu.getMacroExpansions();
- assertEquals(1, expansions.length);
- IToken t= tu.getSyntax();
- while (t.getNext() != null)
- t= t.getNext();
- assertEquals("MACRO", t.getImage());
+ final String code = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parseAndCheckBindings(code, lang);
+ IASTPreprocessorMacroExpansion[] expansions = tu.getMacroExpansions();
+ assertEquals(1, expansions.length);
+ IToken t = tu.getSyntax();
+ while (t.getNext() != null)
+ t = t.getNext();
+ assertEquals("MACRO", t.getImage());
}
}
@@ -7326,7 +7364,7 @@ public class AST2Tests extends AST2TestBase {
// x = va_arg(list, int(*)[3]);
// }
public void testVaArgWithFunctionPtr_311030() throws Exception {
- final String code = getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code, C, true);
parseAndCheckBindings(code, CPP, true);
}
@@ -7335,30 +7373,30 @@ public class AST2Tests extends AST2TestBase {
// __builtin_va_list result;
// }
public void testLocalVariableOfTypeVaList_313270() throws Exception {
- final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
- IBinding var= bh.assertNonProblem("result", 0);
- assertInstance(var, IVariable.class);
- assertTrue(var.getScope().getKind() == EScopeKind.eLocal);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
+ IBinding var = bh.assertNonProblem("result", 0);
+ assertInstance(var, IVariable.class);
+ assertTrue(var.getScope().getKind() == EScopeKind.eLocal);
- bh= new AST2AssertionHelper(code, true);
- var= bh.assertNonProblem("result", 0);
- assertInstance(var, IVariable.class);
- assertTrue(var.getScope().getKind() == EScopeKind.eLocal);
+ bh = new AST2AssertionHelper(code, true);
+ var = bh.assertNonProblem("result", 0);
+ assertInstance(var, IVariable.class);
+ assertTrue(var.getScope().getKind() == EScopeKind.eLocal);
}
// void foo(int i);
// void foo(int j) { }
public void testParameterBindings_316931() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code);
for (ParserLanguage lang : ParserLanguage.values()) {
- BindingAssertionHelper bh= new AST2AssertionHelper(code, lang);
- IParameter i= bh.assertNonProblem("i)", 1);
- IParameter j= bh.assertNonProblem("j)", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, lang);
+ IParameter i = bh.assertNonProblem("i)", 1);
+ IParameter j = bh.assertNonProblem("j)", 1);
assertSame(i, j);
- IASTTranslationUnit tu= bh.getTranslationUnit();
+ IASTTranslationUnit tu = bh.getTranslationUnit();
IASTName[] decls = tu.getDeclarationsInAST(i);
assertEquals(2, decls.length);
decls = tu.getDeclarationsInAST(j);
@@ -7369,21 +7407,21 @@ public class AST2Tests extends AST2TestBase {
// typedef __typeof__((int*)0-(int*)0) ptrdiff_t;
// typedef __typeof__(sizeof(int)) size_t;
public void testPtrDiffRecursion_317004() throws Exception {
- final String comment = getAboveComment();
- String code= comment;
+ final String comment = getAboveComment();
+ String code = comment;
parseAndCheckBindings(code, C, true);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
- ITypedef td= bh.assertNonProblem("ptrdiff_t", 0);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
+ ITypedef td = bh.assertNonProblem("ptrdiff_t", 0);
assertEquals("long int", ASTTypeUtil.getType(td.getType()));
- td= bh.assertNonProblem("size_t", 0);
+ td = bh.assertNonProblem("size_t", 0);
assertEquals("unsigned long int", ASTTypeUtil.getType(td.getType()));
- code= "namespace std {" + comment + "}";
+ code = "namespace std {" + comment + "}";
parseAndCheckBindings(code, CPP, true);
- bh= new AST2AssertionHelper(code, true);
- td= bh.assertNonProblem("ptrdiff_t", 0);
+ bh = new AST2AssertionHelper(code, true);
+ td = bh.assertNonProblem("ptrdiff_t", 0);
assertEquals("long int", ASTTypeUtil.getType(td.getType()));
- td= bh.assertNonProblem("size_t", 0);
+ td = bh.assertNonProblem("size_t", 0);
assertEquals("unsigned long int", ASTTypeUtil.getType(td.getType()));
}
@@ -7394,12 +7432,12 @@ public class AST2Tests extends AST2TestBase {
public void testParameterResolution() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("f(int a)", 1);
bh.assertNonProblem("f(int)", 1);
bh.assertNonProblem("a;", 1);
- bh= new AST2AssertionHelper(code, false);
+ bh = new AST2AssertionHelper(code, false);
bh.assertNonProblem("f(int a)", 1);
bh.assertNonProblem("f(int)", 1);
bh.assertNonProblem("a;", 1);
@@ -7410,8 +7448,8 @@ public class AST2Tests extends AST2TestBase {
// #endif // inactive
// #endif // active
public void testInactivePreprocessingStatements() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment());
- IASTPreprocessorStatement[] stmts= tu.getAllPreprocessorStatements();
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment());
+ IASTPreprocessorStatement[] stmts = tu.getAllPreprocessorStatements();
assertTrue(stmts[0].isActive());
assertFalse(stmts[1].isActive());
assertFalse(stmts[2].isActive());
@@ -7428,18 +7466,18 @@ public class AST2Tests extends AST2TestBase {
// }
public void testTypeOfSizeof_355052() throws Exception {
final String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, CPP);
- IASTFunctionDefinition a= getDeclaration(tu, 0);
- IASTExpressionStatement es= getStatement(a, 1);
+ IASTTranslationUnit tu = parseAndCheckBindings(code, CPP);
+ IASTFunctionDefinition a = getDeclaration(tu, 0);
+ IASTExpressionStatement es = getStatement(a, 1);
assertEquals("unsigned long int", ASTTypeUtil.getType(es.getExpression().getExpressionType()));
- es= getStatement(a, 2);
+ es = getStatement(a, 2);
assertEquals("unsigned long int", ASTTypeUtil.getType(es.getExpression().getExpressionType()));
- tu= parseAndCheckBindings(code, C);
- a= getDeclaration(tu, 0);
- es= getStatement(a, 1);
+ tu = parseAndCheckBindings(code, C);
+ a = getDeclaration(tu, 0);
+ es = getStatement(a, 1);
assertEquals("unsigned long int", ASTTypeUtil.getType(es.getExpression().getExpressionType()));
- es= getStatement(a, 2);
+ es = getStatement(a, 2);
assertEquals("unsigned long int", ASTTypeUtil.getType(es.getExpression().getExpressionType()));
}
@@ -7453,13 +7491,13 @@ public class AST2Tests extends AST2TestBase {
// typedef int T[sizeof(int)];
public void testSizeofExpression_362464() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
for (ParserLanguage l : ParserLanguage.values()) {
- IASTTranslationUnit tu= parseAndCheckBindings(code, l);
- IASTSimpleDeclaration sdecl= getDeclaration(tu, 0);
- ITypedef tdef= (ITypedef) sdecl.getDeclarators()[0].getName().resolveBinding();
- IArrayType at= (IArrayType) tdef.getType();
- IValue v= at.getSize();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, l);
+ IASTSimpleDeclaration sdecl = getDeclaration(tu, 0);
+ ITypedef tdef = (ITypedef) sdecl.getDeclarators()[0].getName().resolveBinding();
+ IArrayType at = (IArrayType) tdef.getType();
+ IValue v = at.getSize();
assertNotNull(v.numberValue());
assertTrue(v.numberValue().longValue() == 4);
}
@@ -7470,8 +7508,8 @@ public class AST2Tests extends AST2TestBase {
// NULL_STATEMENT_MACRO //comment
// }
public void testCommentAfterMacroExpansion_367827() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(), CPP);
- IASTComment comment= tu.getComments()[0];
+ IASTTranslationUnit tu = parse(getAboveComment(), CPP);
+ IASTComment comment = tu.getComments()[0];
assertEquals("//comment", new String(comment.getComment()));
assertEquals("//comment", comment.getRawSignature());
}
@@ -7489,20 +7527,20 @@ public class AST2Tests extends AST2TestBase {
public void testNoRawStringInPlainC_397127() throws Exception {
parseAndCheckBindings(getAboveComment(), C, true);
}
-
- // #define X
+
+ // #define X
// int a=X-1;X
public void testMacroReferences_399394() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment());
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment());
assertEquals(2, countMacroRefs(tu));
-
- IASTSimpleDeclaration decl= getDeclaration(tu, 0);
+
+ IASTSimpleDeclaration decl = getDeclaration(tu, 0);
assertEquals(1, countMacroRefs(decl));
-
- IASTEqualsInitializer init= (IASTEqualsInitializer) decl.getDeclarators()[0].getInitializer();
+
+ IASTEqualsInitializer init = (IASTEqualsInitializer) decl.getDeclarators()[0].getInitializer();
assertEquals(1, countMacroRefs(init));
-
- IASTUnaryExpression expr= (IASTUnaryExpression) init.getInitializerClause();
+
+ IASTUnaryExpression expr = (IASTUnaryExpression) init.getInitializerClause();
assertEquals(0, countMacroRefs(expr));
}
@@ -7514,7 +7552,7 @@ public class AST2Tests extends AST2TestBase {
}
return count;
}
-
+
// typedef struct { int x; } A;
//
// void (*function(A *a))(void) {
@@ -7523,28 +7561,25 @@ public class AST2Tests extends AST2TestBase {
public void testFunctionReturningFunctionPointer_413204() throws Exception {
parseAndCheckBindings();
}
-
+
// double d = 00.9;
public void testOctalFloatingPointLiteral_394048() throws Exception {
parseAndCheckBindings();
}
-
+
public void testMacOS9LineEnding_151329a() throws Exception {
parseAndCheckBindings("int waldo;\r#define bar");
}
-
+
public void testMaxOS9LineEnding_151329b() throws Exception {
// This tests that if there is an \r\n in a macro continuation,
// the \r is not treated as an extra newline. The code
// stringifies the macro expansion and arranges for the string
// length to show up in a template parameter, whose value is
// checked by the test.
- String code = "#define MACRO foo\\\r\n"
- + "bar\r\n"
- + "#define STRINGIFY_(x) #x\r\n"
- + "#define STRINGIFY(x) STRINGIFY_(x)\r\n"
- + "template <int N> void f(const char (&)[N]);\r\n"
- + "int main() { f(STRINGIFY(MACRO)); }\r\n";
+ String code = "#define MACRO foo\\\r\n" + "bar\r\n" + "#define STRINGIFY_(x) #x\r\n"
+ + "#define STRINGIFY(x) STRINGIFY_(x)\r\n" + "template <int N> void f(const char (&)[N]);\r\n"
+ + "int main() { f(STRINGIFY(MACRO)); }\r\n";
BindingAssertionHelper helper = new AST2AssertionHelper(code, true);
ICPPTemplateInstance f = helper.assertNonProblem("f(STRINGIFY", "f");
// 7 characters for "foobar" + the null terminator.
@@ -7572,7 +7607,7 @@ public class AST2Tests extends AST2TestBase {
public void testExpressionLabelReference_84144() throws Exception {
parseAndCheckBindings(true);
}
-
+
// void f() {
// unsigned long long labelPtr;
// labelPtr = (unsigned long long) &&L;
@@ -7598,7 +7633,7 @@ public class AST2Tests extends AST2TestBase {
// syntactically valid, but the correct parse is the cast-expression.
parseAndCheckBindings(true);
}
-
+
// int test(int waldo, int other) {
// return (waldo) && other;
// }
@@ -7607,35 +7642,35 @@ public class AST2Tests extends AST2TestBase {
// valid, but this time the correct parse is binary-expression.
parseAndCheckBindings(true);
}
-
+
// int version = 0;
// int NextVersion() {
// return __atomic_add_fetch(&version, 1, 5);
// }
- public void testAtomicBuiltin_bug456131() throws Exception {
- parseAndCheckBindings(true);
- }
-
- // void waldo(...);
- public void testVariadicCFunction_452416() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper(C);
+ public void testAtomicBuiltin_bug456131() throws Exception {
+ parseAndCheckBindings(true);
+ }
+
+ // void waldo(...);
+ public void testVariadicCFunction_452416() throws Exception {
+ BindingAssertionHelper bh = getAssertionHelper(C);
IFunction waldo = bh.assertNonProblem("waldo");
- assertTrue(waldo.getType().takesVarArgs());
- }
-
+ assertTrue(waldo.getType().takesVarArgs());
+ }
+
// struct Foo {
// struct Foo* a;
// };
- //
+ //
// int main() {
// struct Foo * f = 0;
// (f ? f->a : ((void*) 0))->a; // second 'a' cannot be resolved
// return 0;
// }
- public void testVoidPointerInTernaryOperator_460741() throws Exception {
- parseAndCheckBindings(getAboveComment(), C);
- }
-
+ public void testVoidPointerInTernaryOperator_460741() throws Exception {
+ parseAndCheckBindings(getAboveComment(), C);
+ }
+
// struct MyStruct {
// char* str;
// };
@@ -7643,12 +7678,12 @@ public class AST2Tests extends AST2TestBase {
// const struct MyStruct a, b;
// (0 ? a : b).str;
// }
- public void testCVQualifiedTypesInConversionOperator_495423() throws Exception {
- parseAndCheckBindings(getAboveComment(), C);
- }
-
- // _Alignas(8) int x;
- // _Alignas(int) char y;
+ public void testCVQualifiedTypesInConversionOperator_495423() throws Exception {
+ parseAndCheckBindings(getAboveComment(), C);
+ }
+
+ // _Alignas(8) int x;
+ // _Alignas(int) char y;
// _Alignas(16) struct { int x; int y; };
// _Alignas(8) enum { A, B, C };
// struct S {
@@ -7656,35 +7691,35 @@ public class AST2Tests extends AST2TestBase {
// _Alignas(8) int y;
// };
// _Alignas(32) struct S s;
- // _Alignas(struct S) int t;
- public void testAlignas_451082() throws Exception {
- parseAndCheckBindings(getAboveComment(), C);
- }
-
+ // _Alignas(struct S) int t;
+ public void testAlignas_451082() throws Exception {
+ parseAndCheckBindings(getAboveComment(), C);
+ }
+
// void foo(int waldo) {
// (waldo = 5) && waldo;
// }
- public void testTypeIdWithEqualsInitializer_484824() throws Exception {
- // Test that 'waldo = 5' is not parsed as a type-id, causing
- // the entire expression to be parsed as a cast-expression.
- // See also bug 471174, which is about the broader problem of
- // binary && expressions with a parenthesized left operand
- // being incorrectly parsed as cast-expressions.
- parseAndCheckBindings(getAboveComment(), C);
- }
-
- private void labelResolutionHelper(BindingAssertionHelper helper) {
- // Make sure existing labels are resolved correctly.
- ILabel label = helper.assertNonProblem("goto existent", "existent");
- assertEquals(1, helper.tu.getDeclarationsInAST(label).length);
- label = helper.assertNonProblem("&& existent", "existent");
- assertEquals(1, helper.tu.getDeclarationsInAST(label).length);
-
- // Make sure non-existent labels are not resolved.
- helper.assertProblem("goto nonexistent", "nonexistent");
- helper.assertProblem("&& nonexistent", "nonexistent");
- }
-
+ public void testTypeIdWithEqualsInitializer_484824() throws Exception {
+ // Test that 'waldo = 5' is not parsed as a type-id, causing
+ // the entire expression to be parsed as a cast-expression.
+ // See also bug 471174, which is about the broader problem of
+ // binary && expressions with a parenthesized left operand
+ // being incorrectly parsed as cast-expressions.
+ parseAndCheckBindings(getAboveComment(), C);
+ }
+
+ private void labelResolutionHelper(BindingAssertionHelper helper) {
+ // Make sure existing labels are resolved correctly.
+ ILabel label = helper.assertNonProblem("goto existent", "existent");
+ assertEquals(1, helper.tu.getDeclarationsInAST(label).length);
+ label = helper.assertNonProblem("&& existent", "existent");
+ assertEquals(1, helper.tu.getDeclarationsInAST(label).length);
+
+ // Make sure non-existent labels are not resolved.
+ helper.assertProblem("goto nonexistent", "nonexistent");
+ helper.assertProblem("&& nonexistent", "nonexistent");
+ }
+
// int main() {
// existent:
// int x;
@@ -7693,22 +7728,22 @@ public class AST2Tests extends AST2TestBase {
// void* ref1 = && existent;
// void* ref2 = && nonexistent;
// }
- public void testLabelResolution_484979() throws Exception {
- labelResolutionHelper(getAssertionHelper(C));
- labelResolutionHelper(getAssertionHelper(CPP));
- }
-
- // int arr1[5];
- // int arr2[5];
- // void foo(bool cond) {
- // cond ? arr1 : arr2;
- // }
- public void testArrayTypesInConditionalExpression_520049() throws Exception {
- BindingAssertionHelper helper = getAssertionHelper(C);
- IASTConditionalExpression expr = helper.assertNode("cond ? arr1 : arr2");
- assertSameType(expr.getExpressionType(), CommonCTypes.pointerToInt);
- }
-
+ public void testLabelResolution_484979() throws Exception {
+ labelResolutionHelper(getAssertionHelper(C));
+ labelResolutionHelper(getAssertionHelper(CPP));
+ }
+
+ // int arr1[5];
+ // int arr2[5];
+ // void foo(bool cond) {
+ // cond ? arr1 : arr2;
+ // }
+ public void testArrayTypesInConditionalExpression_520049() throws Exception {
+ BindingAssertionHelper helper = getAssertionHelper(C);
+ IASTConditionalExpression expr = helper.assertNode("cond ? arr1 : arr2");
+ assertSameType(expr.getExpressionType(), CommonCTypes.pointerToInt);
+ }
+
// struct S {
// int waldo;
// };
@@ -7716,11 +7751,11 @@ public class AST2Tests extends AST2TestBase {
// struct S* s;
// s.waldo;
// }
- public void testMemberAccessOnPointerType_526857() throws Exception {
- BindingAssertionHelper helper = getAssertionHelper(C);
- helper.assertProblem("s.waldo", "waldo");
- }
-
+ public void testMemberAccessOnPointerType_526857() throws Exception {
+ BindingAssertionHelper helper = getAssertionHelper(C);
+ helper.assertProblem("s.waldo", "waldo");
+ }
+
// struct gendisk {
// struct request_queue *queue;
// };
@@ -7742,10 +7777,10 @@ public class AST2Tests extends AST2TestBase {
//
// return 0;
// }
- public void testProblemExpressionType_403153() throws Exception {
- BindingAssertionHelper helper = getAssertionHelper(C);
- IASTExpression expr = helper.assertNode("*gd->queue->request_fn");
- assertNotNull(expr);
- assertFalse(expr.getExpressionType() instanceof IProblemType);
- }
+ public void testProblemExpressionType_403153() throws Exception {
+ BindingAssertionHelper helper = getAssertionHelper(C);
+ IASTExpression expr = helper.assertNode("*gd->queue->request_fn");
+ assertNotNull(expr);
+ assertFalse(expr.getExpressionType() instanceof IProblemType);
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilOldTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilOldTests.java
index 3407c5a16f9..819eaef340a 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilOldTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilOldTests.java
@@ -23,430 +23,675 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
public class AST2UtilOldTests extends AST2TestBase {
public AST2UtilOldTests() {
}
+
public AST2UtilOldTests(String name) {
super(name);
}
+
// Kind PRIMARY_EMPTY : void
- public void testPrimaryEmpty() throws Exception
- {
+ public void testPrimaryEmpty() throws Exception {
IASTTranslationUnit tu = parse("int x = f();".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f()" ); //$NON-NLS-1$
- }
- // Kind PRIMARY_INTEGER_LITERAL : int
- public void testPrimaryIntegerLiteral() throws Exception
- {
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f()"); //$NON-NLS-1$
+ }
+
+ // Kind PRIMARY_INTEGER_LITERAL : int
+ public void testPrimaryIntegerLiteral() throws Exception {
IASTTranslationUnit tu = parse("int x = f(1, 2+3);".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(1, 2 + 3)" ); //$NON-NLS-1$
- }
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(1, 2 + 3)"); //$NON-NLS-1$
+ }
+
// Kind PRIMARY_CHAR_LITERAL : char
- public void testPrimaryCharLiteral() throws Exception
- {
+ public void testPrimaryCharLiteral() throws Exception {
IASTTranslationUnit tu = parse("int x = f('c');".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f('c')" ); //$NON-NLS-1$
- }
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f('c')"); //$NON-NLS-1$
+ }
+
// Kind PRIMARY_FLOAT_LITERAL : float
- public void testPrimaryFloatLiteral() throws Exception
- {
+ public void testPrimaryFloatLiteral() throws Exception {
IASTTranslationUnit tu = parse("int x = f(1.13);".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(1.13)" ); //$NON-NLS-1$
- }
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(1.13)"); //$NON-NLS-1$
+ }
+
// Kind PRIMARY_STRING_LITERAL : char*
- public void testPrimaryStringLiteral() throws Exception
- {
+ public void testPrimaryStringLiteral() throws Exception {
IASTTranslationUnit tu = parse("int x = f(\"str\");".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(\"str\")" ); //$NON-NLS-1$
- }
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(\"str\")"); //$NON-NLS-1$
+ }
+
// Kind PRIMARY_BOOLEAN_LITERAL : bool
- public void testPrimaryBooleanLiteral() throws Exception
- {
+ public void testPrimaryBooleanLiteral() throws Exception {
IASTTranslationUnit tu = parse("int x = f(true);".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(true)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(true)"); //$NON-NLS-1$
}
+
// Kind PRIMARY_THIS : type of inner most enclosing structure scope
- public void testPrimaryThis() throws Exception
- {
+ public void testPrimaryThis() throws Exception {
IASTTranslationUnit tu = parse("int x = f(this);".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(this)" ); //$NON-NLS-1$
- }
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(this)"); //$NON-NLS-1$
+ }
+
// Kind PRIMARY_BRACKETED_EXPRESSION : LHS
- public void testPrimaryBracketedExpression() throws Exception
- {
+ public void testPrimaryBracketedExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = f(1, (2+3));".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(1, (2 + 3))" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(1, (2 + 3))"); //$NON-NLS-1$
}
+
// Kind ID_EXPRESSION : type of the ID
- public void testIdExpression() throws Exception
- {
+ public void testIdExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = f(a);".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(a)" ); //$NON-NLS-1$
- }
- // Kind POSTFIX_SUBSCRIPT
- public void testPostfixSubscript() throws Exception
- {
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(a)"); //$NON-NLS-1$
+ }
+
+ // Kind POSTFIX_SUBSCRIPT
+ public void testPostfixSubscript() throws Exception {
IASTTranslationUnit tu = parse("int x = f(pa[1]);".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(pa[1])" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(pa[1])"); //$NON-NLS-1$
}
-
- public void testPostfixSubscriptA() throws Exception
- {
+
+ public void testPostfixSubscriptA() throws Exception {
IASTTranslationUnit tu = parse("int x = f(pa[1][2]);".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(pa[1][2])" ); //$NON-NLS-1$
- }
-
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(pa[1][2])"); //$NON-NLS-1$
+ }
+
// Kind POSTFIX_FUNCTIONCALL : return type of called function
- public void testPostfixFunctioncallBug42822() throws Exception
- {
+ public void testPostfixFunctioncallBug42822() throws Exception {
IASTTranslationUnit tu = parse("int x = bar( foo( 3.0 ), foo( 5.0 ) ) ;".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "bar(foo(3.0), foo(5.0))" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "bar(foo(3.0), foo(5.0))"); //$NON-NLS-1$
}
+
// Kind POSTFIX_SIMPLETYPE_* : simple type
- public void testPostfixSimpletypesBug42823() throws Exception
- {
- IASTTranslationUnit tu = parse("int someInt = foo( int(3), short(4), double(3.0), float(4.0), char( 'a'), wchar_t( 'a' ), signed( 2 ), unsigned( 3 ), bool( false ), long( 3L ) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
+ public void testPostfixSimpletypesBug42823() throws Exception {
+ IASTTranslationUnit tu = parse(
+ "int someInt = foo( int(3), short(4), double(3.0), float(4.0), char( 'a'), wchar_t( 'a' ), signed( 2 ), unsigned( 3 ), bool( false ), long( 3L ) );" //$NON-NLS-1$
+ .toString(),
+ ParserLanguage.CPP);
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(int(3), short(4), double(3.0), float(4.0), char('a'), wchar_t('a'), signed(2), unsigned(3), bool(false), long(3L))" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(int(3), short(4), double(3.0), float(4.0), char('a'), wchar_t('a'), signed(2), unsigned(3), bool(false), long(3L))"); //$NON-NLS-1$
}
-
+
// Kind POSTFIX_DOT_IDEXPRESSION : type of member in the scope of the container
- public void testPostfixDotExpression() throws Exception{
- IASTTranslationUnit tu = parse("class A {int m;}; \n A a; \n int foo(char); int foo( int ); \n int x = foo( a.m );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
+ public void testPostfixDotExpression() throws Exception {
+ IASTTranslationUnit tu = parse(
+ "class A {int m;}; \n A a; \n int foo(char); int foo( int ); \n int x = foo( a.m );".toString(), //$NON-NLS-1$
+ ParserLanguage.CPP);
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a.m)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[4]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a.m)"); //$NON-NLS-1$
}
+
// Kind POSTFIX_ARROW_IDEXPRESSION : type of member in the scope of the container
- public void testPostfixArrowExpression() throws Exception{
- IASTTranslationUnit tu = parse("class A {int m;}; \n A * a; \n int foo(char); int foo( int ); \n int x = foo( a->m );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
+ public void testPostfixArrowExpression() throws Exception {
+ IASTTranslationUnit tu = parse(
+ "class A {int m;}; \n A * a; \n int foo(char); int foo( int ); \n int x = foo( a->m );".toString(), //$NON-NLS-1$
+ ParserLanguage.CPP);
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a->m)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[4]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a->m)"); //$NON-NLS-1$
}
- // Kind POSTFIX_INCREMENT : LHS
- public void testPostfixIncrement() throws Exception
- {
+
+ // Kind POSTFIX_INCREMENT : LHS
+ public void testPostfixIncrement() throws Exception {
IASTTranslationUnit tu = parse("int y = foo( x++ );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(x++)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(x++)"); //$NON-NLS-1$
}
+
// Kind POSTFIX_DECREMENT : LHS
- public void testPostfixDecrement() throws Exception
- {
+ public void testPostfixDecrement() throws Exception {
IASTTranslationUnit tu = parse("int y = foo( x-- );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(x--)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(x--)"); //$NON-NLS-1$
}
- // Kind POSTFIX_DYNAMIC_CAST
- public void testPostfixDynamicCast() throws Exception{
+
+ // Kind POSTFIX_DYNAMIC_CAST
+ public void testPostfixDynamicCast() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( dynamic_cast<B*>(a) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(dynamic_cast<B*>(a))" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(dynamic_cast<B*>(a))"); //$NON-NLS-1$
}
+
// Kind POSTFIX_REINTERPRET_CAST
- public void testPostfixReinterpretCast() throws Exception{
+ public void testPostfixReinterpretCast() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( reinterpret_cast<double *>(a) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(reinterpret_cast<double *>(a))" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(reinterpret_cast<double *>(a))"); //$NON-NLS-1$
}
+
// Kind POSTFIX_STATIC_CAST
- public void testPostfixStaticCast() throws Exception{
+ public void testPostfixStaticCast() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( static_cast<char>(a) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(static_cast<char>(a))" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(static_cast<char>(a))"); //$NON-NLS-1$
}
+
// Kind POSTFIX_CONST_CAST
- public void testPostfixConstCast() throws Exception{
+ public void testPostfixConstCast() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( const_cast<int *>(&a) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(const_cast<int *>(&a))" ); //$NON-NLS-1$
- }
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(const_cast<int *>(&a))"); //$NON-NLS-1$
+ }
+
// Kind POSTFIX_TYPEID_EXPRESSION : LHS
- public void testPostfixTypeIdExpression() throws Exception{
+ public void testPostfixTypeIdExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( typeid(5) );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(typeid(5))" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(typeid(5))"); //$NON-NLS-1$
}
+
// Kind POSTFIX_TYPEID_EXPRESSION : type of the ID
- public void testPostfixTypeIdExpression2() throws Exception{
+ public void testPostfixTypeIdExpression2() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( typeid(a) );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(typeid(a))" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(typeid(a))"); //$NON-NLS-1$
}
// Kind POSTFIX_TYPEID_TYPEID : type of the ID
- public void testPostfixTypeIdTypeId2() throws Exception{
- IASTTranslationUnit tu = parse("class A { }; int foo( int ); int x = foo( typeid(const A) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
+ public void testPostfixTypeIdTypeId2() throws Exception {
+ IASTTranslationUnit tu = parse("class A { }; int foo( int ); int x = foo( typeid(const A) );".toString(), //$NON-NLS-1$
+ ParserLanguage.CPP);
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[2]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(typeid(const A))" ); //$NON-NLS-1$
- }
- // Kind UNARY_INCREMENT : LHS
- public void testUnaryIncrement() throws Exception
- {
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[2]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(typeid(const A))"); //$NON-NLS-1$
+ }
+
+ // Kind UNARY_INCREMENT : LHS
+ public void testUnaryIncrement() throws Exception {
IASTTranslationUnit tu = parse("int y = foo( ++x );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(++x)" ); //$NON-NLS-1$
- }
- // Kind UNARY_DECREMENT : LHS
- public void testUnaryDecrement() throws Exception
- {
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(++x)"); //$NON-NLS-1$
+ }
+
+ // Kind UNARY_DECREMENT : LHS
+ public void testUnaryDecrement() throws Exception {
IASTTranslationUnit tu = parse("int y = foo( --x );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(--x)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(--x)"); //$NON-NLS-1$
}
- // Kind UNARY_STAR_CASTEXPRESSION : LHS + t_pointer
- public void testUnaryStarCastExpression() throws Exception
- {
+
+ // Kind UNARY_STAR_CASTEXPRESSION : LHS + t_pointer
+ public void testUnaryStarCastExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = f(*pa);".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(*pa)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(*pa)"); //$NON-NLS-1$
}
+
// Kind UNARY_AMPSND_CASTEXPRESSION : LHS + t_reference
- public void testUnaryAmpersandCastExpression() throws Exception
- {
+ public void testUnaryAmpersandCastExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = f(&pa);".toString(), ParserLanguage.CPP); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(&pa)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(&pa)"); //$NON-NLS-1$
}
+
// Kind UNARY_PLUS_CASTEXPRESSION : LHS
- public void testUnaryPlusCastExpression() throws Exception {
+ public void testUnaryPlusCastExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( +5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(+5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(+5)"); //$NON-NLS-1$
}
+
// Kind UNARY_MINUS_CASTEXPRESSION : LHS
- public void testUnaryMinusCastExpression() throws Exception {
+ public void testUnaryMinusCastExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( -5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(-5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(-5)"); //$NON-NLS-1$
}
- // Kind UNARY_NOT_CASTEXPRESSION : LHS
- public void testUnaryNotCastExpression() throws Exception {
+
+ // Kind UNARY_NOT_CASTEXPRESSION : LHS
+ public void testUnaryNotCastExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( !b );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(!b)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(!b)"); //$NON-NLS-1$
}
- // Kind UNARY_TILDE_CASTEXPRESSION : LHS
- public void testTildeNotCastExpression() throws Exception {
+
+ // Kind UNARY_TILDE_CASTEXPRESSION : LHS
+ public void testTildeNotCastExpression() throws Exception {
IASTTranslationUnit tu = parse("int y = foo( ~x );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(~x)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(~x)"); //$NON-NLS-1$
}
- // Kind UNARY_SIZEOF_UNARYEXPRESSION : unsigned int
- public void testUnarySizeofUnaryExpression() throws Exception {
+
+ // Kind UNARY_SIZEOF_UNARYEXPRESSION : unsigned int
+ public void testUnarySizeofUnaryExpression() throws Exception {
IASTTranslationUnit tu = parse("int y = foo( sizeof(5) );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(sizeof (5))" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(sizeof (5))"); //$NON-NLS-1$
}
- // Kind UNARY_SIZEOF_TYPEID : unsigned int
- public void testUnarySizeofTypeId() throws Exception {
+
+ // Kind UNARY_SIZEOF_TYPEID : unsigned int
+ public void testUnarySizeofTypeId() throws Exception {
IASTTranslationUnit tu = parse("int x, y = foo( sizeof(x) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- final IASTInitializerClause expression = ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[1].getInitializer()).getInitializerClause();
- isExpressionStringEqual( expression, "foo(sizeof (x))" ); //$NON-NLS-1$
+ final IASTInitializerClause expression = ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0])
+ .getDeclarators()[1].getInitializer()).getInitializerClause();
+ isExpressionStringEqual(expression, "foo(sizeof (x))"); //$NON-NLS-1$
}
- // Kind NEW_TYPEID
- public void testNewTypeId() throws Exception {
+
+ // Kind NEW_TYPEID
+ public void testNewTypeId() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( new A() );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(new A())" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(new A())"); //$NON-NLS-1$
}
- // Kind CASTEXPRESSION
- public void testCastExpression() throws Exception{
+ // Kind CASTEXPRESSION
+ public void testCastExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( (A*)b );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo((A*)b)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo((A*)b)"); //$NON-NLS-1$
}
-
+
// Kind MULTIPLICATIVE_MULTIPLY : usual arithmetic conversions
- public void testMultiplicativeMultiply() throws Exception {
+ public void testMultiplicativeMultiply() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a * b );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a * b)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a * b)"); //$NON-NLS-1$
}
- // Kind MULTIPLICATIVE_DIVIDE : usual arithmetic conversions
- public void testMultiplicativeDivide() throws Exception {
+
+ // Kind MULTIPLICATIVE_DIVIDE : usual arithmetic conversions
+ public void testMultiplicativeDivide() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b / a );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b / a)" ); //$NON-NLS-1$
- }
- // Kind MULTIPLICATIVE_MODULUS : usual arithmetic conversions
- public void testMultiplicativeModulus() throws Exception {
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b / a)"); //$NON-NLS-1$
+ }
+
+ // Kind MULTIPLICATIVE_MODULUS : usual arithmetic conversions
+ public void testMultiplicativeModulus() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b % a );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b % a)" ); //$NON-NLS-1$
- }
- // Kind ADDITIVE_PLUS : usual arithmetic conversions
- public void testAdditivePlus() throws Exception {
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b % a)"); //$NON-NLS-1$
+ }
+
+ // Kind ADDITIVE_PLUS : usual arithmetic conversions
+ public void testAdditivePlus() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b + a );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b + a)" ); //$NON-NLS-1$
- }
- // Kind ADDITIVE_MINUS : usual arithmetic conversions
- public void testAdditiveMinus() throws Exception {
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b + a)"); //$NON-NLS-1$
+ }
+
+ // Kind ADDITIVE_MINUS : usual arithmetic conversions
+ public void testAdditiveMinus() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b - a );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b - a)" ); //$NON-NLS-1$
- }
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b - a)"); //$NON-NLS-1$
+ }
+
// Kind SHIFT_LEFT : LHS
- public void testShiftLeft() throws Exception {
+ public void testShiftLeft() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a << 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a << 5)" ); //$NON-NLS-1$
- }
- // Kind SHIFT_RIGHT : LHS
- public void testShiftRight() throws Exception {
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a << 5)"); //$NON-NLS-1$
+ }
+
+ // Kind SHIFT_RIGHT : LHS
+ public void testShiftRight() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a >> 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a >> 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a >> 5)"); //$NON-NLS-1$
}
- // Kind RELATIONAL_LESSTHAN : bool
- public void testRelationalLessThan() throws Exception {
+
+ // Kind RELATIONAL_LESSTHAN : bool
+ public void testRelationalLessThan() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b < 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b < 3)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b < 3)"); //$NON-NLS-1$
}
- // Kind RELATIONAL_GREATERTHAN : bool
- public void testRelationalGreaterThan() throws Exception {
+
+ // Kind RELATIONAL_GREATERTHAN : bool
+ public void testRelationalGreaterThan() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b > 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b > 3)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b > 3)"); //$NON-NLS-1$
}
- // Kind RELATIONAL_LESSTHANEQUALTO : bool
- public void testRelationalLessThanOrEqual() throws Exception {
+
+ // Kind RELATIONAL_LESSTHANEQUALTO : bool
+ public void testRelationalLessThanOrEqual() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b <= 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b <= 3)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b <= 3)"); //$NON-NLS-1$
}
+
// Kind RELATIONAL_GREATERTHANEQUALTO : bool
- public void testRelationalGreaterThanOrEqual() throws Exception {
+ public void testRelationalGreaterThanOrEqual() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b >= 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b >= 3)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b >= 3)"); //$NON-NLS-1$
}
- // Kind EQUALITY_EQUALS : bool
- public void testEqualityEquals() throws Exception {
+
+ // Kind EQUALITY_EQUALS : bool
+ public void testEqualityEquals() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b == 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b == 3)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b == 3)"); //$NON-NLS-1$
}
- // Kind EQUALITY_NOTEQUALS : bool
- public void testEqualityNotEquals() throws Exception {
+
+ // Kind EQUALITY_NOTEQUALS : bool
+ public void testEqualityNotEquals() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b != 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b != 3)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b != 3)"); //$NON-NLS-1$
}
- // Kind ANDEXPRESSION : usual arithmetic conversions
- public void testAndExpression() throws Exception {
+
+ // Kind ANDEXPRESSION : usual arithmetic conversions
+ public void testAndExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a & b );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a & b)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a & b)"); //$NON-NLS-1$
}
- // Kind EXCLUSIVEOREXPRESSION : usual arithmetic conversions
- public void testExclusiveOrExpression() throws Exception {
+
+ // Kind EXCLUSIVEOREXPRESSION : usual arithmetic conversions
+ public void testExclusiveOrExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a ^ b );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a ^ b)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a ^ b)"); //$NON-NLS-1$
}
- // Kind INCLUSIVEOREXPRESSION : : usual arithmetic conversions
- public void testInclusiveOrExpression() throws Exception {
+
+ // Kind INCLUSIVEOREXPRESSION : : usual arithmetic conversions
+ public void testInclusiveOrExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a | b );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a | b)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a | b)"); //$NON-NLS-1$
}
- // Kind LOGICALANDEXPRESSION : bool
- public void testLogicalAndExpression() throws Exception {
+
+ // Kind LOGICALANDEXPRESSION : bool
+ public void testLogicalAndExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a && b );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a && b)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a && b)"); //$NON-NLS-1$
}
- // Kind LOGICALOREXPRESSION : bool
- public void testLogicalOrExpression() throws Exception {
+
+ // Kind LOGICALOREXPRESSION : bool
+ public void testLogicalOrExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a || b );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a || b)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a || b)"); //$NON-NLS-1$
}
- // Kind CONDITIONALEXPRESSION : conditional Expression Conversions
- public void testConditionalExpression() throws Exception {
+
+ // Kind CONDITIONALEXPRESSION : conditional Expression Conversions
+ public void testConditionalExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a > 5 ? b : c );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a > 5 ? b : c)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a > 5 ? b : c)"); //$NON-NLS-1$
}
-
+
// Kind ASSIGNMENTEXPRESSION_NORMAL : LHS
- public void testAssignmentExpressionNormal() throws Exception {
+ public void testAssignmentExpressionNormal() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a = 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a = 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a = 5)"); //$NON-NLS-1$
}
- // Kind ASSIGNMENTEXPRESSION_PLUS : LHS
- public void testAssignmentExpressionPlus() throws Exception {
+
+ // Kind ASSIGNMENTEXPRESSION_PLUS : LHS
+ public void testAssignmentExpressionPlus() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a += 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a += 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a += 5)"); //$NON-NLS-1$
}
- // Kind ASSIGNMENTEXPRESSION_MINUS : LHS
- public void testAssignmentExpressionMinus() throws Exception {
+
+ // Kind ASSIGNMENTEXPRESSION_MINUS : LHS
+ public void testAssignmentExpressionMinus() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a -= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a -= 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a -= 5)"); //$NON-NLS-1$
}
- // Kind ASSIGNMENTEXPRESSION_MULT : LHS
- public void testAssignmentExpressionMulti() throws Exception {
+
+ // Kind ASSIGNMENTEXPRESSION_MULT : LHS
+ public void testAssignmentExpressionMulti() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a *= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a *= 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a *= 5)"); //$NON-NLS-1$
}
- // Kind ASSIGNMENTEXPRESSION_DIV : LHS
- public void testAssignmentExpressionDiv() throws Exception {
+
+ // Kind ASSIGNMENTEXPRESSION_DIV : LHS
+ public void testAssignmentExpressionDiv() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a /= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a /= 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a /= 5)"); //$NON-NLS-1$
}
- // Kind ASSIGNMENTEXPRESSION_MOD : LHS
- public void testAssignmentExpressionMod() throws Exception {
+
+ // Kind ASSIGNMENTEXPRESSION_MOD : LHS
+ public void testAssignmentExpressionMod() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a %= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a %= 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a %= 5)"); //$NON-NLS-1$
}
+
// Kind ASSIGNMENTEXPRESSION_LSHIFT : LHS
- public void testAssignmentExpressionLShift() throws Exception {
+ public void testAssignmentExpressionLShift() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a >>= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a >>= 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a >>= 5)"); //$NON-NLS-1$
}
+
// Kind ASSIGNMENTEXPRESSION_RSHIFT : LHS
- public void testAssignmentExpressionRShift() throws Exception {
+ public void testAssignmentExpressionRShift() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a <<= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a <<= 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a <<= 5)"); //$NON-NLS-1$
}
+
// Kind ASSIGNMENTEXPRESSION_AND : LHS
- public void testAssignmentExpressionAnd() throws Exception {
+ public void testAssignmentExpressionAnd() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a &= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a &= 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a &= 5)"); //$NON-NLS-1$
}
- // Kind ASSIGNMENTEXPRESSION_OR : LHS
- public void testAssignmentExpressionOr() throws Exception {
+
+ // Kind ASSIGNMENTEXPRESSION_OR : LHS
+ public void testAssignmentExpressionOr() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a |= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a |= 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a |= 5)"); //$NON-NLS-1$
}
+
// Kind ASSIGNMENTEXPRESSION_XOR : LHS
- public void testAssignmentExpressionXOr() throws Exception {
+ public void testAssignmentExpressionXOr() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a ^= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a ^= 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a ^= 5)"); //$NON-NLS-1$
}
-
+
}
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 1e603734647..c533a173631 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
@@ -39,8 +39,8 @@ public class AST2UtilTests extends AST2TestBase {
}
public void testSimpleSignature() throws Exception {
- StringBuilder buff = new StringBuilder();
- buff.append("int l, m, n=0;\n"); //$NON-NLS-1$
+ StringBuilder buff = new StringBuilder();
+ buff.append("int l, m, n=0;\n"); //$NON-NLS-1$
buff.append("int j = l ? m : n;\n"); //$NON-NLS-1$
buff.append("int i = l^m;\n"); //$NON-NLS-1$
buff.append("int g = i<<=j;\n"); //$NON-NLS-1$
@@ -50,124 +50,188 @@ public class AST2UtilTests extends AST2TestBase {
buff.append("int b = d++;\n"); //$NON-NLS-1$
buff.append("int c = sizeof b;\n"); //$NON-NLS-1$
buff.append("int a = b + c;\n"); //$NON-NLS-1$
-
- IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
+
+ IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
IASTDeclaration[] d = tu.getDeclarations();
-
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[2].getInitializer()).getInitializerClause(), "0"); //$NON-NLS-1$
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[1]).getDeclarators()[0].getInitializer()).getInitializerClause(), "l ? m : n"); //$NON-NLS-1$
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[2]).getDeclarators()[0].getInitializer()).getInitializerClause(), "l ^ m"); //$NON-NLS-1$
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[3]).getDeclarators()[0].getInitializer()).getInitializerClause(), "i <<= j"); //$NON-NLS-1$
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getInitializer()).getInitializerClause(), "sizeof(int)"); //$NON-NLS-1$
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[5]).getDeclarators()[0].getInitializer()).getInitializerClause(), "~f"); //$NON-NLS-1$
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[6]).getDeclarators()[0].getInitializer()).getInitializerClause(), "++e"); //$NON-NLS-1$
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[7]).getDeclarators()[0].getInitializer()).getInitializerClause(), "d++"); //$NON-NLS-1$
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[8]).getDeclarators()[0].getInitializer()).getInitializerClause(), "sizeof b"); //$NON-NLS-1$
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[9]).getDeclarators()[0].getInitializer()).getInitializerClause(), "b + c"); //$NON-NLS-1$
+
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[2].getInitializer())
+ .getInitializerClause(),
+ "0"); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[1]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "l ? m : n"); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[2]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "l ^ m"); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[3]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "i <<= j"); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[4]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "sizeof(int)"); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[5]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "~f"); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[6]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "++e"); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[7]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "d++"); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[8]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "sizeof b"); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[9]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "b + c"); //$NON-NLS-1$
}
-
+
public void testSimpleParameter() throws Exception {
- StringBuilder buff = new StringBuilder();
- buff.append("int a(int x);\n"); //$NON-NLS-1$
+ StringBuilder buff = new StringBuilder();
+ buff.append("int a(int x);\n"); //$NON-NLS-1$
buff.append("int * b(char y, int x);\n"); //$NON-NLS-1$
buff.append("void c(int * z, float **b);\n"); //$NON-NLS-1$
buff.append("static int d(int a[restrict]);\n"); //$NON-NLS-1$
- buff.append("void e(const char* const);\n"); //$NON-NLS-1$
-
- IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
+ buff.append("void e(const char* const);\n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
IASTDeclaration[] d = tu.getDeclarations();
-
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[0]).getDeclarators()[0], "(int)"); //$NON-NLS-1$
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[1]).getDeclarators()[0], "(char, int)"); //$NON-NLS-1$
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[2]).getDeclarators()[0], "(int*, float**)"); //$NON-NLS-1$
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[3]).getDeclarators()[0], "(int[])"); //$NON-NLS-1$
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[4]).getDeclarators()[0], "(const char* const)"); //$NON-NLS-1$
-
- isSignatureEqual(((IASTSimpleDeclaration)d[0]).getDeclarators()[0], "int(int)"); //$NON-NLS-1$
- isSignatureEqual(((IASTSimpleDeclaration)d[1]).getDeclarators()[0], "int*(char, int)"); //$NON-NLS-1$
- isSignatureEqual(((IASTSimpleDeclaration)d[2]).getDeclarators()[0], "void(int*, float**)"); //$NON-NLS-1$
- isSignatureEqual(((IASTSimpleDeclaration)d[3]).getDeclarators()[0], "int(int[])"); //$NON-NLS-1$
- isSignatureEqual(((IASTSimpleDeclaration)d[4]).getDeclarators()[0], "void(const char* const)"); //$NON-NLS-1$
-
- isSignatureEqual(((IASTSimpleDeclaration)d[0]).getDeclSpecifier(), "int"); //$NON-NLS-1$
- isSignatureEqual(((IASTSimpleDeclaration)d[1]).getDeclSpecifier(), "int"); //$NON-NLS-1$
- isSignatureEqual(((IASTSimpleDeclaration)d[2]).getDeclSpecifier(), "void"); //$NON-NLS-1$
- isSignatureEqual(((IASTSimpleDeclaration)d[3]).getDeclSpecifier(), "int"); //$NON-NLS-1$
- isSignatureEqual(((IASTSimpleDeclaration)d[4]).getDeclSpecifier(), "void"); //$NON-NLS-1$
-
- isTypeEqual(((IASTSimpleDeclaration)d[0]).getDeclarators()[0], "int (int)"); //$NON-NLS-1$
- isTypeEqual(((IASTSimpleDeclaration)d[1]).getDeclarators()[0], "int * (char, int)"); //$NON-NLS-1$
- isTypeEqual(((IASTSimpleDeclaration)d[2]).getDeclarators()[0], "void (int *, float * *)"); //$NON-NLS-1$
- isTypeEqual(((IASTSimpleDeclaration)d[3]).getDeclarators()[0], "int (int * restrict)"); //$NON-NLS-1$
- isTypeEqual(((IASTSimpleDeclaration)d[4]).getDeclarators()[0], "void (const char * const)"); //$NON-NLS-1$
-
- isTypeEqual(((IFunction)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getName().resolveBinding()).getType(), "int (int)"); //$NON-NLS-1$
- isTypeEqual(((IFunction)((IASTSimpleDeclaration)d[1]).getDeclarators()[0].getName().resolveBinding()).getType(), "int * (char, int)"); //$NON-NLS-1$
- isTypeEqual(((IFunction)((IASTSimpleDeclaration)d[2]).getDeclarators()[0].getName().resolveBinding()).getType(), "void (int *, float * *)"); //$NON-NLS-1$
- isTypeEqual(((IFunction)((IASTSimpleDeclaration)d[3]).getDeclarators()[0].getName().resolveBinding()).getType(), "int (int * restrict)"); //$NON-NLS-1$
- isTypeEqual(((IFunction)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getName().resolveBinding()).getType(), "void (const char * const)"); //$NON-NLS-1$
-
- isParameterTypeEqual(((IFunction)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getName().resolveBinding()).getType(), "(int)"); //$NON-NLS-1$
- isParameterTypeEqual(((IFunction)((IASTSimpleDeclaration)d[1]).getDeclarators()[0].getName().resolveBinding()).getType(), "(char, int)"); //$NON-NLS-1$
- isParameterTypeEqual(((IFunction)((IASTSimpleDeclaration)d[2]).getDeclarators()[0].getName().resolveBinding()).getType(), "(int *, float * *)"); //$NON-NLS-1$
- isParameterTypeEqual(((IFunction)((IASTSimpleDeclaration)d[3]).getDeclarators()[0].getName().resolveBinding()).getType(), "(int * restrict)"); //$NON-NLS-1$
- isParameterTypeEqual(((IFunction)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getName().resolveBinding()).getType(), "(const char * const)"); //$NON-NLS-1$
+
+ isParameterSignatureEqual(((IASTSimpleDeclaration) d[0]).getDeclarators()[0], "(int)"); //$NON-NLS-1$
+ isParameterSignatureEqual(((IASTSimpleDeclaration) d[1]).getDeclarators()[0], "(char, int)"); //$NON-NLS-1$
+ isParameterSignatureEqual(((IASTSimpleDeclaration) d[2]).getDeclarators()[0], "(int*, float**)"); //$NON-NLS-1$
+ isParameterSignatureEqual(((IASTSimpleDeclaration) d[3]).getDeclarators()[0], "(int[])"); //$NON-NLS-1$
+ isParameterSignatureEqual(((IASTSimpleDeclaration) d[4]).getDeclarators()[0], "(const char* const)"); //$NON-NLS-1$
+
+ isSignatureEqual(((IASTSimpleDeclaration) d[0]).getDeclarators()[0], "int(int)"); //$NON-NLS-1$
+ isSignatureEqual(((IASTSimpleDeclaration) d[1]).getDeclarators()[0], "int*(char, int)"); //$NON-NLS-1$
+ isSignatureEqual(((IASTSimpleDeclaration) d[2]).getDeclarators()[0], "void(int*, float**)"); //$NON-NLS-1$
+ isSignatureEqual(((IASTSimpleDeclaration) d[3]).getDeclarators()[0], "int(int[])"); //$NON-NLS-1$
+ isSignatureEqual(((IASTSimpleDeclaration) d[4]).getDeclarators()[0], "void(const char* const)"); //$NON-NLS-1$
+
+ isSignatureEqual(((IASTSimpleDeclaration) d[0]).getDeclSpecifier(), "int"); //$NON-NLS-1$
+ isSignatureEqual(((IASTSimpleDeclaration) d[1]).getDeclSpecifier(), "int"); //$NON-NLS-1$
+ isSignatureEqual(((IASTSimpleDeclaration) d[2]).getDeclSpecifier(), "void"); //$NON-NLS-1$
+ isSignatureEqual(((IASTSimpleDeclaration) d[3]).getDeclSpecifier(), "int"); //$NON-NLS-1$
+ isSignatureEqual(((IASTSimpleDeclaration) d[4]).getDeclSpecifier(), "void"); //$NON-NLS-1$
+
+ isTypeEqual(((IASTSimpleDeclaration) d[0]).getDeclarators()[0], "int (int)"); //$NON-NLS-1$
+ isTypeEqual(((IASTSimpleDeclaration) d[1]).getDeclarators()[0], "int * (char, int)"); //$NON-NLS-1$
+ isTypeEqual(((IASTSimpleDeclaration) d[2]).getDeclarators()[0], "void (int *, float * *)"); //$NON-NLS-1$
+ isTypeEqual(((IASTSimpleDeclaration) d[3]).getDeclarators()[0], "int (int * restrict)"); //$NON-NLS-1$
+ isTypeEqual(((IASTSimpleDeclaration) d[4]).getDeclarators()[0], "void (const char * const)"); //$NON-NLS-1$
+
+ isTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "int (int)"); //$NON-NLS-1$
+ isTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[1]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "int * (char, int)"); //$NON-NLS-1$
+ isTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[2]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "void (int *, float * *)"); //$NON-NLS-1$
+ isTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[3]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "int (int * restrict)"); //$NON-NLS-1$
+ isTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[4]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "void (const char * const)"); //$NON-NLS-1$
+
+ isParameterTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "(int)"); //$NON-NLS-1$
+ isParameterTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[1]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "(char, int)"); //$NON-NLS-1$
+ isParameterTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[2]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "(int *, float * *)"); //$NON-NLS-1$
+ isParameterTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[3]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "(int * restrict)"); //$NON-NLS-1$
+ isParameterTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[4]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "(const char * const)"); //$NON-NLS-1$
}
-
+
public void testSimpleCParameterSignature() throws Exception {
- StringBuilder buff = new StringBuilder();
- buff.append("int a(int x);\n"); //$NON-NLS-1$
+ StringBuilder buff = new StringBuilder();
+ buff.append("int a(int x);\n"); //$NON-NLS-1$
buff.append("int * b(char y, int x);\n"); //$NON-NLS-1$
buff.append("void c(int * z, float **b);\n"); //$NON-NLS-1$
buff.append("static int d(int a[restrict]);\n"); //$NON-NLS-1$
-
- IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
+
+ IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
IASTDeclaration[] d = tu.getDeclarations();
-
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[0]).getDeclarators()[0], "(int)"); //$NON-NLS-1$
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[1]).getDeclarators()[0], "(char, int)"); //$NON-NLS-1$
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[2]).getDeclarators()[0], "(int*, float**)"); //$NON-NLS-1$
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[3]).getDeclarators()[0], "(int[])"); //$NON-NLS-1$
+
+ isParameterSignatureEqual(((IASTSimpleDeclaration) d[0]).getDeclarators()[0], "(int)"); //$NON-NLS-1$
+ isParameterSignatureEqual(((IASTSimpleDeclaration) d[1]).getDeclarators()[0], "(char, int)"); //$NON-NLS-1$
+ isParameterSignatureEqual(((IASTSimpleDeclaration) d[2]).getDeclarators()[0], "(int*, float**)"); //$NON-NLS-1$
+ isParameterSignatureEqual(((IASTSimpleDeclaration) d[3]).getDeclarators()[0], "(int[])"); //$NON-NLS-1$
}
-
+
public void testSimpleTypeId() throws Exception {
StringBuilder buff = new StringBuilder();
- buff.append("int x = sizeof( int );\n"); //$NON-NLS-1$
+ buff.append("int x = sizeof( int );\n"); //$NON-NLS-1$
buff.append("union Squaw { int x; double u; };\n"); //$NON-NLS-1$
buff.append("int main(int argc, char **argv) {\n"); //$NON-NLS-1$
buff.append("return sizeof( union Squaw );\n}\n"); //$NON-NLS-1$
buff.append("typedef short Z; typedef Z jc;\n"); //$NON-NLS-1$
buff.append("int y = 4;\n"); //$NON-NLS-1$
buff.append("jc myJc = (jc)y;\n"); //$NON-NLS-1$
-
- IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
+
+ IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
IASTDeclaration[] d = tu.getDeclarations();
-
+
// verify signatures
- isSignatureEqual( ((IASTTypeIdExpression)((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause()).getTypeId(), "int"); //$NON-NLS-1$
- isSignatureEqual( ((IASTTypeIdExpression)((IASTReturnStatement)((IASTCompoundStatement)((IASTFunctionDefinition)d[2]).getBody()).getStatements()[0]).getReturnValue()).getTypeId(), "union Squaw"); //$NON-NLS-1$
- isSignatureEqual( ((IASTCastExpression)((IASTEqualsInitializer)((IASTSimpleDeclaration)d[6]).getDeclarators()[0].getInitializer()).getInitializerClause()).getTypeId() , "jc"); //$NON-NLS-1$
-
+ isSignatureEqual(
+ ((IASTTypeIdExpression) ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0]
+ .getInitializer()).getInitializerClause()).getTypeId(),
+ "int"); //$NON-NLS-1$
+ isSignatureEqual(
+ ((IASTTypeIdExpression) ((IASTReturnStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) d[2])
+ .getBody()).getStatements()[0]).getReturnValue()).getTypeId(),
+ "union Squaw"); //$NON-NLS-1$
+ isSignatureEqual(
+ ((IASTCastExpression) ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[6]).getDeclarators()[0]
+ .getInitializer()).getInitializerClause()).getTypeId(),
+ "jc"); //$NON-NLS-1$
+
// verify types
- isTypeEqual( ((IASTTypeIdExpression)((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause()).getTypeId(), "int"); //$NON-NLS-1$
- isTypeEqual( ((IASTTypeIdExpression)((IASTReturnStatement)((IASTCompoundStatement)((IASTFunctionDefinition)d[2]).getBody()).getStatements()[0]).getReturnValue()).getTypeId(), "Squaw"); //$NON-NLS-1$
- isTypeEqual( ((IASTCastExpression)((IASTEqualsInitializer)((IASTSimpleDeclaration)d[6]).getDeclarators()[0].getInitializer()).getInitializerClause()).getTypeId() , "short int"); //$NON-NLS-1$
+ isTypeEqual(((IASTTypeIdExpression) ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0]
+ .getInitializer()).getInitializerClause()).getTypeId(), "int"); //$NON-NLS-1$
+ isTypeEqual(
+ ((IASTTypeIdExpression) ((IASTReturnStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) d[2])
+ .getBody()).getStatements()[0]).getReturnValue()).getTypeId(),
+ "Squaw"); //$NON-NLS-1$
+ isTypeEqual(((IASTCastExpression) ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[6]).getDeclarators()[0]
+ .getInitializer()).getInitializerClause()).getTypeId(), "short int"); //$NON-NLS-1$
}
-
+
public void testKnRC() throws Exception {
StringBuilder buff = new StringBuilder();
- buff.append("int foo(x, y) char x; int y; {}\n"); //$NON-NLS-1$
+ 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);
IASTDeclaration[] d = tu.getDeclarations();
-
- String fooSignature = ASTStringUtil.getSignatureString(((IASTFunctionDefinition)d[0]).getDeclarator());
- String foo2Signature = ASTStringUtil.getSignatureString(((IASTFunctionDefinition)d[1]).getDeclarator());
-
+
+ String fooSignature = ASTStringUtil.getSignatureString(((IASTFunctionDefinition) d[0]).getDeclarator());
+ String foo2Signature = ASTStringUtil.getSignatureString(((IASTFunctionDefinition) d[1]).getDeclarator());
+
assertEquals(fooSignature, foo2Signature);
}
-
+
public void testParseIntegral() throws Exception {
assertEquals(0, ExpressionEvaluator.getNumber("0".toCharArray()));
assertEquals(0, ExpressionEvaluator.getNumber("0x0".toCharArray()));
@@ -175,11 +239,11 @@ public class AST2UtilTests extends AST2TestBase {
assertEquals(0, ExpressionEvaluator.getNumber("000".toCharArray()));
assertEquals(0, ExpressionEvaluator.getNumber("0L".toCharArray()));
assertEquals(0, ExpressionEvaluator.getNumber("0LL".toCharArray()));
-
+
assertEquals(1, ExpressionEvaluator.getNumber("1".toCharArray()));
assertEquals(1, ExpressionEvaluator.getNumber("01".toCharArray()));
assertEquals(1, ExpressionEvaluator.getNumber("0x1".toCharArray()));
-
+
assertEquals(10, ExpressionEvaluator.getNumber("10".toCharArray()));
assertEquals(8, ExpressionEvaluator.getNumber("010".toCharArray()));
assertEquals(16, ExpressionEvaluator.getNumber("0x10".toCharArray()));
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTCPPSpecDefectTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTCPPSpecDefectTests.java
index c18e6b70cc6..27e33057060 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTCPPSpecDefectTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTCPPSpecDefectTests.java
@@ -19,31 +19,31 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.parser.ParserLanguage;
public class ASTCPPSpecDefectTests extends AST2TestBase {
-
+
public ASTCPPSpecDefectTests() {
}
-
+
public ASTCPPSpecDefectTests(String name) {
super(name);
}
-
+
public static TestSuite suite() {
return suite(ASTCPPSpecDefectTests.class);
}
-
+
protected IASTTranslationUnit parseAndCheckBindings(String code) throws Exception {
IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
NameCollector col = new NameCollector();
tu.accept(col);
assertNoProblemBindings(col);
return tu;
- }
-
+ }
+
private IASTTranslationUnit parseAndCheckBindings() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
return parseAndCheckBindings(code);
}
-
+
// // C++ defect #33
// namespace ns {
// struct S {};
@@ -53,12 +53,12 @@ public class ASTCPPSpecDefectTests extends AST2TestBase {
// void f0(int);
//
// void test() {
- // fp(f0);
+ // fp(f0);
// }
public void test33_ADLForOverloadSet_324842() throws Exception {
parseAndCheckBindings();
}
-
+
// // C++ defect #38
// template<typename T> T operator+(T&);
// struct A {
@@ -67,7 +67,7 @@ public class ASTCPPSpecDefectTests extends AST2TestBase {
public void test38_templateArgForOperator() throws Exception {
parseAndCheckBindings();
}
-
+
// template <class T1, class ...Z> class S; // #1
// template <class T1, class ...Z> class S<T1, const Z&...> {}; // #2
// template <class T1, class T2> class S<T1, const T2&> {};; // #3
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTInactiveCodeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTInactiveCodeTests.java
index c66127a5819..659d659b01f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTInactiveCodeTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTInactiveCodeTests.java
@@ -32,15 +32,15 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
* Testcases for inactive code in ast.
*/
public class ASTInactiveCodeTests extends AST2TestBase {
-
+
public static TestSuite suite() {
return suite(ASTInactiveCodeTests.class);
}
-
+
public ASTInactiveCodeTests() {
super();
}
-
+
public ASTInactiveCodeTests(String name) {
super(name);
}
@@ -68,11 +68,11 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// #endif
// int a7;
public void testIfBranches() throws Exception {
- String codeTmpl= getAboveComment();
- for (int i= 0; i < (1<<4); i++) {
+ String codeTmpl = getAboveComment();
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.C, i);
}
- for (int i= 0; i < (1<<4); i++) {
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.CPP, i);
}
}
@@ -80,26 +80,27 @@ public class ASTInactiveCodeTests extends AST2TestBase {
private void testBranches(String codeTmpl, ParserLanguage lang, int bits) throws Exception {
testBranches(codeTmpl, lang, bits, 0);
}
+
private void testBranches(String codeTmpl, ParserLanguage lang, int bits, int level) throws Exception {
- BitSet bs= convert(bits);
- char[] chars= codeTmpl.toCharArray();
- int pos= codeTmpl.indexOf('%', 0);
- int i= 0;
+ BitSet bs = convert(bits);
+ char[] chars = codeTmpl.toCharArray();
+ int pos = codeTmpl.indexOf('%', 0);
+ int i = 0;
while (pos >= 0) {
- chars[pos]= bs.get(i++) ? '1' : '0';
- pos= codeTmpl.indexOf('%', pos+1);
+ chars[pos] = bs.get(i++) ? '1' : '0';
+ pos = codeTmpl.indexOf('%', pos + 1);
}
- IASTDeclarationListOwner tu= parse(new String(chars), lang);
+ IASTDeclarationListOwner tu = parse(new String(chars), lang);
while (level-- > 0) {
final IASTDeclaration decl = tu.getDeclarations(true)[0];
if (decl instanceof IASTSimpleDeclaration) {
- tu= (IASTDeclarationListOwner) ((IASTSimpleDeclaration) decl).getDeclSpecifier();
+ tu = (IASTDeclarationListOwner) ((IASTSimpleDeclaration) decl).getDeclSpecifier();
} else {
- tu= (IASTDeclarationListOwner) decl;
+ tu = (IASTDeclarationListOwner) decl;
}
}
-
- IASTDeclaration[] decl= tu.getDeclarations(true);
+
+ IASTDeclaration[] decl = tu.getDeclarations(true);
assertEquals(8, decl.length);
assertEquals(bs.get(0), decl[0].isActive());
assertEquals(!bs.get(0) && bs.get(1), decl[1].isActive());
@@ -112,7 +113,7 @@ public class ASTInactiveCodeTests extends AST2TestBase {
}
private BitSet convert(int bits) {
- BitSet result= new BitSet(32);
+ BitSet result = new BitSet(32);
for (int i = 0; i < 32; i++) {
if ((bits & (1 << i)) != 0) {
result.set(i);
@@ -139,11 +140,11 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// #endif
// int a7;
public void testIfdefBranches() throws Exception {
- String codeTmpl= getAboveComment();
- for (int i= 0; i < (1<<4); i++) {
+ String codeTmpl = getAboveComment();
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.C, i);
}
- for (int i= 0; i < (1<<4); i++) {
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.CPP, i);
}
}
@@ -166,11 +167,11 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// #endif
// int a7;
public void testIfndefBranches() throws Exception {
- String codeTmpl= getAboveComment();
- for (int i= 0; i < (1<<4); i++) {
+ String codeTmpl = getAboveComment();
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.C, i);
}
- for (int i= 0; i < (1<<4); i++) {
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.CPP, i);
}
}
@@ -194,11 +195,11 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// int a7;
// };
public void testStructs() throws Exception {
- String codeTmpl= getAboveComment();
- for (int i= 0; i < (1<<4); i++) {
+ String codeTmpl = getAboveComment();
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.C, i, 1);
}
- for (int i= 0; i < (1<<4); i++) {
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.CPP, i, 1);
}
}
@@ -222,8 +223,8 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// int a7;
// };
public void testExternC() throws Exception {
- String codeTmpl= getAboveComment();
- for (int i= 0; i < (1<<4); i++) {
+ String codeTmpl = getAboveComment();
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.CPP, i, 1);
}
}
@@ -247,12 +248,12 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// int a7;
// }
public void testNamespace() throws Exception {
- String codeTmpl= getAboveComment();
- for (int i= 0; i < (1<<4); i++) {
+ String codeTmpl = getAboveComment();
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.CPP, i, 1);
}
}
-
+
// typedef int TInt;
// const int value= 12;
// #if 0
@@ -260,15 +261,15 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// int g(value);
// #endif
public void testAmbiguity() throws Exception {
- String code= getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, ParserLanguage.CPP);
+ String code = getAboveComment();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, ParserLanguage.CPP);
IASTDeclaration[] decls = tu.getDeclarations(true);
- IASTSimpleDeclaration decl= (IASTSimpleDeclaration) decls[2];
+ IASTSimpleDeclaration decl = (IASTSimpleDeclaration) decls[2];
assertTrue(decl.getDeclarators()[0] instanceof IASTFunctionDeclarator);
- decl= (IASTSimpleDeclaration) decls[3];
+ decl = (IASTSimpleDeclaration) decls[3];
assertFalse(decl.getDeclarators()[0] instanceof IASTFunctionDeclarator);
}
-
+
// int a; // 1
// #if 0
// int a; // 2
@@ -279,15 +280,15 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// #endif
// int b; // 2
public void testDuplicateDefinition() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
bh.assertNonProblem("a; // 1", 1);
bh.assertNonProblem("a; // 2", 1);
bh.assertNonProblem("a; // 3", 1);
bh.assertNonProblem("b; // 1", 1);
bh.assertNonProblem("b; // 2", 1);
- bh= new AST2AssertionHelper(code, true);
+ bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("a; // 1", 1);
bh.assertNonProblem("a; // 2", 1);
bh.assertNonProblem("a; // 3", 1);
@@ -297,7 +298,7 @@ public class ASTInactiveCodeTests extends AST2TestBase {
parseAndCheckBindings(code, ParserLanguage.C);
parseAndCheckBindings(code, ParserLanguage.CPP);
}
-
+
// struct S {
// #if 0
// int a;
@@ -307,19 +308,19 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// };
// #endif
public void testInactiveClosingBrace() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
- IField a= bh.assertNonProblem("a;", 1);
- IField b= bh.assertNonProblem("b;", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
+ IField a = bh.assertNonProblem("a;", 1);
+ IField b = bh.assertNonProblem("b;", 1);
assertSame(a.getOwner(), b.getOwner());
- bh= new AST2AssertionHelper(code, true);
- a= bh.assertNonProblem("a;", 1);
- b= bh.assertNonProblem("b;", 1);
+ bh = new AST2AssertionHelper(code, true);
+ a = bh.assertNonProblem("a;", 1);
+ b = bh.assertNonProblem("b;", 1);
assertSame(a.getOwner(), b.getOwner());
}
-
- // struct S
+
+ // struct S
// #if 1
// {
// int a;
@@ -332,26 +333,26 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// #endif
// };
public void testOpenBraceInActiveBranch() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
- IField a= bh.assertNonProblem("a;", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
+ IField a = bh.assertNonProblem("a;", 1);
bh.assertNoName("b;", 1);
- IField c= bh.assertNonProblem("c;", 1);
- IField d= bh.assertNonProblem("d;", 1);
+ IField c = bh.assertNonProblem("c;", 1);
+ IField d = bh.assertNonProblem("d;", 1);
assertSame(a.getOwner(), c.getOwner());
assertSame(a.getOwner(), d.getOwner());
- bh= new AST2AssertionHelper(code, true);
- a= bh.assertNonProblem("a;", 1);
+ bh = new AST2AssertionHelper(code, true);
+ a = bh.assertNonProblem("a;", 1);
bh.assertNoName("b;", 1);
- c= bh.assertNonProblem("c;", 1);
- d= bh.assertNonProblem("d;", 1);
+ c = bh.assertNonProblem("c;", 1);
+ d = bh.assertNonProblem("d;", 1);
assertSame(a.getOwner(), c.getOwner());
assertSame(a.getOwner(), d.getOwner());
}
// #if 0
- // struct S {
+ // struct S {
// #if 1
// int a;
// #else
@@ -362,26 +363,26 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// #endif
// int d;
public void testOpenBraceInInactiveBranch() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
- IField a= bh.assertNonProblem("a;", 1);
- IField b= bh.assertNonProblem("b;", 1);
- IVariable c= bh.assertNonProblem("c;", 1); // part of a different non-nested branch
- IVariable d= bh.assertNonProblem("d;", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
+ IField a = bh.assertNonProblem("a;", 1);
+ IField b = bh.assertNonProblem("b;", 1);
+ IVariable c = bh.assertNonProblem("c;", 1); // part of a different non-nested branch
+ IVariable d = bh.assertNonProblem("d;", 1);
assertSame(a.getOwner(), b.getOwner());
assertNull(c.getOwner());
assertNull(d.getOwner());
- bh= new AST2AssertionHelper(code, true);
- a= bh.assertNonProblem("a;", 1);
- b= bh.assertNonProblem("b;", 1);
- c= bh.assertNonProblem("c;", 1); // part of a different non-nested branch
- d= bh.assertNonProblem("d;", 1);
+ bh = new AST2AssertionHelper(code, true);
+ a = bh.assertNonProblem("a;", 1);
+ b = bh.assertNonProblem("b;", 1);
+ c = bh.assertNonProblem("c;", 1); // part of a different non-nested branch
+ d = bh.assertNonProblem("d;", 1);
assertSame(a.getOwner(), b.getOwner());
assertNull(c.getOwner());
assertNull(d.getOwner());
}
-
+
// #if 0
// void f() {
// #if 1
@@ -392,14 +393,14 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// }
// #endif
public void testUnexpectedBranchesInInactiveCode() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
- IFunction f= bh.assertNonProblem("f()", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
+ IFunction f = bh.assertNonProblem("f()", 1);
bh.assertNoName("a;", 1);
bh.assertNoName("b;", 1);
- bh= new AST2AssertionHelper(code, true);
- f= bh.assertNonProblem("f()", 1);
+ bh = new AST2AssertionHelper(code, true);
+ f = bh.assertNonProblem("f()", 1);
bh.assertNoName("a;", 1);
bh.assertNoName("b;", 1);
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTNodeSelectorTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTNodeSelectorTest.java
index 0547b33c61d..fba3e4f2c50 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTNodeSelectorTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTNodeSelectorTest.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
import java.io.IOException;
@@ -40,14 +40,14 @@ public class ASTNodeSelectorTest extends AST2TestBase {
protected String fCode;
protected IASTTranslationUnit fTu;
protected IASTNodeSelector fSelector;
-
+
public ASTNodeSelectorTest() {
}
public ASTNodeSelectorTest(String name) {
super(name);
}
-
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -55,13 +55,15 @@ public class ASTNodeSelectorTest extends AST2TestBase {
}
protected void createTranslationUnit() throws IOException {
- fCode= getContents(1)[0].toString();
- FileContent codeReader = FileContent.create("<test-code>", fCode.toCharArray());
- ScannerInfo scannerInfo = new ScannerInfo();
- IScanner scanner= AST2TestBase.createScanner(codeReader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, scannerInfo);
- GNUCPPSourceParser parser= new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, new NullLogService(), new GPPParserExtensionConfiguration());
- fTu= parser.parse();
- fSelector= fTu.getNodeSelector(null);
+ fCode = getContents(1)[0].toString();
+ FileContent codeReader = FileContent.create("<test-code>", fCode.toCharArray());
+ ScannerInfo scannerInfo = new ScannerInfo();
+ IScanner scanner = AST2TestBase.createScanner(codeReader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE,
+ scannerInfo);
+ GNUCPPSourceParser parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, new NullLogService(),
+ new GPPParserExtensionConfiguration());
+ fTu = parser.parse();
+ fSelector = fTu.getNodeSelector(null);
}
@Override
@@ -70,52 +72,50 @@ public class ASTNodeSelectorTest extends AST2TestBase {
}
private void testContainedName(int from, int to, String sig) {
- IASTName name= fSelector.findFirstContainedName(from, to-from);
+ IASTName name = fSelector.findFirstContainedName(from, to - from);
verify(sig, name);
}
private void verify(String sig, IASTNode node) {
if (sig == null) {
assertNull("unexpexted selection: " + (node == null ? "" : node.getRawSignature()), node);
- }
- else {
+ } else {
assertNotNull("unable to select " + sig, node);
if (node instanceof IASTName) {
assertEquals(sig, ((IASTName) node).toString());
- }
- else {
+ } else {
assertEquals(sig, node.getRawSignature());
}
}
}
private void testContainedNode(int from, int to, String sig) {
- IASTNode node= fSelector.findFirstContainedNode(from, to-from);
+ IASTNode node = fSelector.findFirstContainedNode(from, to - from);
verify(sig, node);
}
private void testName(int from, int to, String sig) {
- IASTName name= fSelector.findName(from, to-from);
+ IASTName name = fSelector.findName(from, to - from);
verify(sig, name);
}
private void testNode(int from, int to, String sig) {
- IASTNode node= fSelector.findNode(from, to-from);
+ IASTNode node = fSelector.findNode(from, to - from);
verify(sig, node);
}
private void testEnclosingName(int from, int to, String sig) {
- IASTName name= fSelector.findEnclosingName(from, to-from);
+ IASTName name = fSelector.findEnclosingName(from, to - from);
verify(sig, name);
}
private void testEnclosingNode(int from, int to, String sig) {
- IASTNode node= fSelector.findEnclosingNode(from, to-from);
+ IASTNode node = fSelector.findEnclosingNode(from, to - from);
verify(sig, node);
}
private void testExpansion(int from, int to, String sig) {
- IASTPreprocessorMacroExpansion exp= fSelector.findEnclosingMacroExpansion(from, to-from);
+ IASTPreprocessorMacroExpansion exp = fSelector.findEnclosingMacroExpansion(from, to - from);
verify(sig, exp);
}
@@ -125,33 +125,33 @@ public class ASTNodeSelectorTest extends AST2TestBase {
// #include <test>
// int a;
public void testInclusion() {
- int include_start= fCode.indexOf("#include");
- int name_start= fCode.indexOf("test");
- int include_end= fCode.indexOf(">") + 1;
-
- testContainedName(include_start-1, include_end+1, "test");
+ int include_start = fCode.indexOf("#include");
+ int name_start = fCode.indexOf("test");
+ int include_end = fCode.indexOf(">") + 1;
+
+ testContainedName(include_start - 1, include_end + 1, "test");
testContainedName(name_start, include_end, "test");
- testContainedName(include_start+1, name_start+1, null);
- testContainedName(name_start+1, name_start+7, null);
+ testContainedName(include_start + 1, name_start + 1, null);
+ testContainedName(name_start + 1, name_start + 7, null);
- testContainedNode(include_start-1, include_end+1, "#include <test>");
+ testContainedNode(include_start - 1, include_end + 1, "#include <test>");
testContainedNode(name_start, include_end, "test");
- testContainedNode(include_start+1, name_start+1, null);
- testContainedNode(name_start+1, name_start+7, null);
-
- testEnclosingName(name_start, name_start+4, "test");
+ testContainedNode(include_start + 1, name_start + 1, null);
+ testContainedNode(name_start + 1, name_start + 7, null);
+
+ testEnclosingName(name_start, name_start + 4, "test");
testEnclosingName(name_start, name_start, "test");
- testEnclosingName(name_start+4, name_start+4, "test");
- testEnclosingName(name_start-1, name_start+1, null);
- testEnclosingName(name_start+4, name_start+5, null);
+ testEnclosingName(name_start + 4, name_start + 4, "test");
+ testEnclosingName(name_start - 1, name_start + 1, null);
+ testEnclosingName(name_start + 4, name_start + 5, null);
- testEnclosingNode(name_start, name_start+4, "test");
+ testEnclosingNode(name_start, name_start + 4, "test");
testEnclosingNode(name_start, name_start, "test");
- testEnclosingNode(name_start+4, name_start+4, "test");
- testEnclosingNode(name_start-1, name_start+1, "#include <test>");
- testEnclosingNode(name_start+4-1, name_start+4+1, "#include <test>");
-
- testExpansion(name_start, name_start+4, null);
+ testEnclosingNode(name_start + 4, name_start + 4, "test");
+ testEnclosingNode(name_start - 1, name_start + 1, "#include <test>");
+ testEnclosingNode(name_start + 4 - 1, name_start + 4 + 1, "#include <test>");
+
+ testExpansion(name_start, name_start + 4, null);
}
// #define shift_offsets
@@ -163,64 +163,63 @@ public class ASTNodeSelectorTest extends AST2TestBase {
// #include EMPTY TEST_H
// }
public void testInclusionWithExpansions() {
- int inclusion_start= fCode.indexOf("#include");
- int empty_start= fCode.indexOf("EMPTY", inclusion_start);
- int testh_start= fCode.indexOf("TEST_H", empty_start);
- int file_end= fCode.length();
-
- testContainedName(inclusion_start-1, file_end-1, "EMPTY");
+ int inclusion_start = fCode.indexOf("#include");
+ int empty_start = fCode.indexOf("EMPTY", inclusion_start);
+ int testh_start = fCode.indexOf("TEST_H", empty_start);
+ int file_end = fCode.length();
+
+ testContainedName(inclusion_start - 1, file_end - 1, "EMPTY");
testContainedName(testh_start, file_end, "TEST_H");
- testContainedName(testh_start+1, file_end, null);
- testContainedName(testh_start, testh_start+5, null);
+ testContainedName(testh_start + 1, file_end, null);
+ testContainedName(testh_start, testh_start + 5, null);
- testContainedNode(inclusion_start-1, file_end+1, "#include EMPTY TEST_H");
+ testContainedNode(inclusion_start - 1, file_end + 1, "#include EMPTY TEST_H");
testContainedNode(testh_start, file_end, "TEST_H");
- testContainedNode(testh_start+1, file_end, null);
- testContainedNode(testh_start, testh_start+5, null);
-
- testName(empty_start, empty_start+5, "EMPTY");
- testName(empty_start-1, empty_start+5, null);
- testName(empty_start+1, empty_start+5, null);
- testName(empty_start, empty_start+4, null);
- testName(empty_start, empty_start+6, null);
-
- testNode(empty_start, empty_start+5, "EMPTY");
- testNode(empty_start-1, empty_start+5, null);
- testNode(empty_start+1, empty_start+5, null);
- testNode(empty_start, empty_start+4, null);
- testNode(empty_start, empty_start+6, null);
-
- testEnclosingName(empty_start, empty_start+5, "EMPTY");
+ testContainedNode(testh_start + 1, file_end, null);
+ testContainedNode(testh_start, testh_start + 5, null);
+
+ testName(empty_start, empty_start + 5, "EMPTY");
+ testName(empty_start - 1, empty_start + 5, null);
+ testName(empty_start + 1, empty_start + 5, null);
+ testName(empty_start, empty_start + 4, null);
+ testName(empty_start, empty_start + 6, null);
+
+ testNode(empty_start, empty_start + 5, "EMPTY");
+ testNode(empty_start - 1, empty_start + 5, null);
+ testNode(empty_start + 1, empty_start + 5, null);
+ testNode(empty_start, empty_start + 4, null);
+ testNode(empty_start, empty_start + 6, null);
+
+ testEnclosingName(empty_start, empty_start + 5, "EMPTY");
testEnclosingName(empty_start, empty_start, "EMPTY");
- testEnclosingName(empty_start+5, empty_start+5, "EMPTY");
- testEnclosingName(empty_start-1, empty_start, null);
- testEnclosingName(empty_start+5, empty_start+6, "test.h");
- testEnclosingName(testh_start, testh_start+6, "TEST_H");
+ testEnclosingName(empty_start + 5, empty_start + 5, "EMPTY");
+ testEnclosingName(empty_start - 1, empty_start, null);
+ testEnclosingName(empty_start + 5, empty_start + 6, "test.h");
+ testEnclosingName(testh_start, testh_start + 6, "TEST_H");
testEnclosingName(testh_start, testh_start, "TEST_H");
- testEnclosingName(testh_start+6, testh_start+6, "TEST_H");
- testEnclosingName(testh_start-1, testh_start+1, "test.h");
- testEnclosingName(testh_start+5, testh_start+7, null);
+ testEnclosingName(testh_start + 6, testh_start + 6, "TEST_H");
+ testEnclosingName(testh_start - 1, testh_start + 1, "test.h");
+ testEnclosingName(testh_start + 5, testh_start + 7, null);
- testEnclosingNode(empty_start, empty_start+5, "EMPTY");
+ testEnclosingNode(empty_start, empty_start + 5, "EMPTY");
testEnclosingNode(empty_start, empty_start, "EMPTY");
- testEnclosingNode(empty_start+5, empty_start+5, "EMPTY");
- testEnclosingNode(empty_start-1, empty_start, "#include EMPTY TEST_H");
- testEnclosingNode(empty_start+5, empty_start+6, "test.h");
- testEnclosingNode(testh_start, testh_start+6, "TEST_H");
+ testEnclosingNode(empty_start + 5, empty_start + 5, "EMPTY");
+ testEnclosingNode(empty_start - 1, empty_start, "#include EMPTY TEST_H");
+ testEnclosingNode(empty_start + 5, empty_start + 6, "test.h");
+ testEnclosingNode(testh_start, testh_start + 6, "TEST_H");
testEnclosingNode(testh_start, testh_start, "TEST_H");
- testEnclosingNode(testh_start+6, testh_start+6, "TEST_H");
- testEnclosingNode(testh_start-1, testh_start+1, "test.h");
- testEnclosingNode(testh_start+6-1, testh_start+6+1, "{\n #include EMPTY TEST_H\n }");
-
- testExpansion(empty_start, empty_start+5, "EMPTY");
+ testEnclosingNode(testh_start + 6, testh_start + 6, "TEST_H");
+ testEnclosingNode(testh_start - 1, testh_start + 1, "test.h");
+ testEnclosingNode(testh_start + 6 - 1, testh_start + 6 + 1, "{\n #include EMPTY TEST_H\n }");
+
+ testExpansion(empty_start, empty_start + 5, "EMPTY");
testExpansion(empty_start, empty_start, "EMPTY");
- testExpansion(empty_start+5, empty_start+5, "EMPTY");
- testExpansion(empty_start-1, empty_start, null);
- testExpansion(empty_start+5, empty_start+6, null);
- testExpansion(testh_start, testh_start+6, "TEST_H");
+ testExpansion(empty_start + 5, empty_start + 5, "EMPTY");
+ testExpansion(empty_start - 1, empty_start, null);
+ testExpansion(empty_start + 5, empty_start + 6, null);
+ testExpansion(testh_start, testh_start + 6, "TEST_H");
}
-
-
+
// #define shift_offsets
// int shift= shift_offsets;
//
@@ -229,37 +228,37 @@ public class ASTNodeSelectorTest extends AST2TestBase {
// #elif xx == 1
// #endif
public void testMacroInConditionalExpression() {
- int x1= fCode.indexOf("xx");
- int x2= fCode.indexOf("xx", x1+1);
- int x3= fCode.indexOf("xx", x2+1);
-
- testContainedName(x1, x1+2, "xx");
- testContainedName(x2-1, x2+2, "xx");
- testContainedName(x3, x3+3, "xx");
- testContainedName(x1, x1+1, null);
- testContainedName(x2+1, x2+2, null);
- testContainedName(x3+1, x3+1, null);
-
- testName(x1, x1+2, "xx");
- testName(x2, x2+2, "xx");
- testName(x3, x3+2, "xx");
- testName(x1+1, x1+2, null);
- testName(x2-1, x2+2, null);
- testName(x3, x3+3, null);
- testName(x3, x3+1, null);
-
- testEnclosingName(x1, x1+2, "xx");
- testEnclosingName(x2+2, x2+2, "xx");
+ int x1 = fCode.indexOf("xx");
+ int x2 = fCode.indexOf("xx", x1 + 1);
+ int x3 = fCode.indexOf("xx", x2 + 1);
+
+ testContainedName(x1, x1 + 2, "xx");
+ testContainedName(x2 - 1, x2 + 2, "xx");
+ testContainedName(x3, x3 + 3, "xx");
+ testContainedName(x1, x1 + 1, null);
+ testContainedName(x2 + 1, x2 + 2, null);
+ testContainedName(x3 + 1, x3 + 1, null);
+
+ testName(x1, x1 + 2, "xx");
+ testName(x2, x2 + 2, "xx");
+ testName(x3, x3 + 2, "xx");
+ testName(x1 + 1, x1 + 2, null);
+ testName(x2 - 1, x2 + 2, null);
+ testName(x3, x3 + 3, null);
+ testName(x3, x3 + 1, null);
+
+ testEnclosingName(x1, x1 + 2, "xx");
+ testEnclosingName(x2 + 2, x2 + 2, "xx");
testEnclosingName(x3, x3, "xx");
- testEnclosingName(x1-1, x1+2, null);
- testEnclosingName(x2+2, x2+3, null);
- testEnclosingName(x3-1, x3-1, null);
+ testEnclosingName(x1 - 1, x1 + 2, null);
+ testEnclosingName(x2 + 2, x2 + 3, null);
+ testEnclosingName(x3 - 1, x3 - 1, null);
- testExpansion(x1, x1+2, null);
- testExpansion(x2+2, x2+2, "xx");
+ testExpansion(x1, x1 + 2, null);
+ testExpansion(x2 + 2, x2 + 2, "xx");
testExpansion(x3, x3, "xx");
- testExpansion(x2+2, x2+3, null);
- testExpansion(x3-1, x3-1, null);
+ testExpansion(x2 + 2, x2 + 3, null);
+ testExpansion(x3 - 1, x3 - 1, null);
}
// #define shift_offsets
@@ -270,37 +269,37 @@ public class ASTNodeSelectorTest extends AST2TestBase {
// #elif defined(xx) == 1
// #endif
public void testMacroInDefinedExpression() {
- int x1= fCode.indexOf("xx");
- int x2= fCode.indexOf("xx", x1+1);
- int x3= fCode.indexOf("xx", x2+1);
-
- testContainedName(x1, x1+2, "xx");
- testContainedName(x2-1, x2+2, "xx");
- testContainedName(x3, x3+3, "xx");
- testContainedName(x1, x1+1, null);
- testContainedName(x2+1, x2+2, null);
- testContainedName(x3+1, x3+1, null);
-
- testName(x1, x1+2, "xx");
- testName(x2, x2+2, "xx");
- testName(x3, x3+2, "xx");
- testName(x1+1, x1+2, null);
- testName(x2-1, x2+2, null);
- testName(x3, x3+3, null);
- testName(x3, x3+1, null);
-
- testEnclosingName(x1, x1+2, "xx");
- testEnclosingName(x2+2, x2+2, "xx");
+ int x1 = fCode.indexOf("xx");
+ int x2 = fCode.indexOf("xx", x1 + 1);
+ int x3 = fCode.indexOf("xx", x2 + 1);
+
+ testContainedName(x1, x1 + 2, "xx");
+ testContainedName(x2 - 1, x2 + 2, "xx");
+ testContainedName(x3, x3 + 3, "xx");
+ testContainedName(x1, x1 + 1, null);
+ testContainedName(x2 + 1, x2 + 2, null);
+ testContainedName(x3 + 1, x3 + 1, null);
+
+ testName(x1, x1 + 2, "xx");
+ testName(x2, x2 + 2, "xx");
+ testName(x3, x3 + 2, "xx");
+ testName(x1 + 1, x1 + 2, null);
+ testName(x2 - 1, x2 + 2, null);
+ testName(x3, x3 + 3, null);
+ testName(x3, x3 + 1, null);
+
+ testEnclosingName(x1, x1 + 2, "xx");
+ testEnclosingName(x2 + 2, x2 + 2, "xx");
testEnclosingName(x3, x3, "xx");
- testEnclosingName(x1-1, x1+2, null);
- testEnclosingName(x2+2, x2+3, null);
- testEnclosingName(x3-1, x3-1, null);
+ testEnclosingName(x1 - 1, x1 + 2, null);
+ testEnclosingName(x2 + 2, x2 + 3, null);
+ testEnclosingName(x3 - 1, x3 - 1, null);
- testExpansion(x1, x1+2, null);
- testExpansion(x2+2, x2+2, null);
+ testExpansion(x1, x1 + 2, null);
+ testExpansion(x2 + 2, x2 + 2, null);
testExpansion(x3, x3, null);
- testExpansion(x2+2, x2+3, null);
- testExpansion(x3-1, x3-1, null);
+ testExpansion(x2 + 2, x2 + 3, null);
+ testExpansion(x3 - 1, x3 - 1, null);
}
// #define shift_offsets
@@ -313,40 +312,40 @@ public class ASTNodeSelectorTest extends AST2TestBase {
// #endif
// #undef xx
public void testMacroInConditional() {
- int x1= fCode.indexOf("xx");
- x1= fCode.indexOf("xx", x1+1);
- int x2= fCode.indexOf("xx", x1+1);
- int x3= fCode.indexOf("xx", x2+1);
-
- testContainedName(x1, x1+2, "xx");
- testContainedName(x2-1, x2+2, "xx");
- testContainedName(x3, x3+3, "xx");
- testContainedName(x1, x1+1, null);
- testContainedName(x2+1, x2+2, null);
- testContainedName(x3+1, x3+1, null);
-
- testName(x1, x1+2, "xx");
- testName(x2, x2+2, "xx");
- testName(x3, x3+2, "xx");
- testName(x1+1, x1+2, null);
- testName(x2-1, x2+2, null);
- testName(x3, x3+3, null);
- testName(x3, x3+1, null);
-
- testEnclosingName(x1, x1+2, "xx");
- testEnclosingName(x2+2, x2+2, "xx");
+ int x1 = fCode.indexOf("xx");
+ x1 = fCode.indexOf("xx", x1 + 1);
+ int x2 = fCode.indexOf("xx", x1 + 1);
+ int x3 = fCode.indexOf("xx", x2 + 1);
+
+ testContainedName(x1, x1 + 2, "xx");
+ testContainedName(x2 - 1, x2 + 2, "xx");
+ testContainedName(x3, x3 + 3, "xx");
+ testContainedName(x1, x1 + 1, null);
+ testContainedName(x2 + 1, x2 + 2, null);
+ testContainedName(x3 + 1, x3 + 1, null);
+
+ testName(x1, x1 + 2, "xx");
+ testName(x2, x2 + 2, "xx");
+ testName(x3, x3 + 2, "xx");
+ testName(x1 + 1, x1 + 2, null);
+ testName(x2 - 1, x2 + 2, null);
+ testName(x3, x3 + 3, null);
+ testName(x3, x3 + 1, null);
+
+ testEnclosingName(x1, x1 + 2, "xx");
+ testEnclosingName(x2 + 2, x2 + 2, "xx");
testEnclosingName(x3, x3, "xx");
- testEnclosingName(x1-1, x1+2, null);
- testEnclosingName(x2+2, x2+3, null);
- testEnclosingName(x3-1, x3-1, null);
+ testEnclosingName(x1 - 1, x1 + 2, null);
+ testEnclosingName(x2 + 2, x2 + 3, null);
+ testEnclosingName(x3 - 1, x3 - 1, null);
- testExpansion(x1, x1+2, null);
- testExpansion(x2+2, x2+2, null);
+ testExpansion(x1, x1 + 2, null);
+ testExpansion(x2 + 2, x2 + 2, null);
testExpansion(x3, x3, null);
- testExpansion(x2+2, x2+3, null);
- testExpansion(x3-1, x3-1, null);
+ testExpansion(x2 + 2, x2 + 3, null);
+ testExpansion(x3 - 1, x3 - 1, null);
}
-
+
// #define shift_offsets
// int shift= shift_offsets;
//
@@ -354,9 +353,9 @@ public class ASTNodeSelectorTest extends AST2TestBase {
// #define EXPLICIT IMPLICIT
// int a= EXPLICIT;
public void testUnreachableImplicitMacro() {
- int x1= fCode.indexOf("EXPLICIT;");
+ int x1 = fCode.indexOf("EXPLICIT;");
testContainedName(x1, fCode.length(), "EXPLICIT");
- testName(x1, x1+8, "EXPLICIT");
+ testName(x1, x1 + 8, "EXPLICIT");
testEnclosingName(x1, x1, "EXPLICIT");
}
@@ -367,34 +366,34 @@ public class ASTNodeSelectorTest extends AST2TestBase {
// #define EXPLICIT(x) x
// int a= EXPLICIT(NESTED);
public void testReachableNestedMacro() {
- int x1= fCode.indexOf("NESTED)");
+ int x1 = fCode.indexOf("NESTED)");
testContainedName(x1, fCode.length(), "NESTED");
- testName(x1, x1+6, "NESTED");
+ testName(x1, x1 + 6, "NESTED");
testEnclosingName(x1, x1, "NESTED");
}
-
+
// #define id(x,y) x y
// id(int a, =1);
// id(int b=, a);
public void testImageLocations() {
- int a1= fCode.indexOf("a");
- int a2= fCode.indexOf("a", a1+1);
- int b1= fCode.indexOf("b");
+ int a1 = fCode.indexOf("a");
+ int a2 = fCode.indexOf("a", a1 + 1);
+ int b1 = fCode.indexOf("b");
- testName(a1, a1+1, "a");
- testContainedName(a1-1, a2+2, "a");
+ testName(a1, a1 + 1, "a");
+ testContainedName(a1 - 1, a2 + 2, "a");
testEnclosingName(a1, a1, "a");
- testEnclosingName(a1+1, a1+1, "a");
+ testEnclosingName(a1 + 1, a1 + 1, "a");
- testName(a2, a2+1, "a");
- testContainedName(a2-1, a2+2, "a");
+ testName(a2, a2 + 1, "a");
+ testContainedName(a2 - 1, a2 + 2, "a");
testEnclosingName(a2, a2, "a");
- testEnclosingName(a2+1, a2+1, "a");
+ testEnclosingName(a2 + 1, a2 + 1, "a");
- testEnclosingNode(a1-1, a1+1, "id(int a, =1)");
- testContainedNode(a1-8, a1+1, "id");
+ testEnclosingNode(a1 - 1, a1 + 1, "id(int a, =1)");
+ testContainedNode(a1 - 8, a1 + 1, "id");
}
-
+
// namespace ns {int a;}
// int x= ns::a;
// #define M int b;
@@ -405,36 +404,39 @@ public class ASTNodeSelectorTest extends AST2TestBase {
// #define P()
// P()O
public void testOrdering() {
- int x1= fCode.indexOf("ns::a");
- int x2= x1 + "ns::a".length();
+ int x1 = fCode.indexOf("ns::a");
+ int x2 = x1 + "ns::a".length();
testContainedName(x1, x2, "ns");
- testEnclosingName(x2-1, x2-1, "a");
+ testEnclosingName(x2 - 1, x2 - 1, "a");
testEnclosingName(x2, x2, "a");
-
- x1= fCode.indexOf("M"); x1= fCode.indexOf("M", x1+1);
- testNode(x1, x1+1, "M");
+
+ x1 = fCode.indexOf("M");
+ x1 = fCode.indexOf("M", x1 + 1);
+ testNode(x1, x1 + 1, "M");
testEnclosingNode(x1, x1, "M");
- testEnclosingNode(x1+1, x1+1, "M");
- testContainedNode(x1-1, x1+2, "M");
+ testEnclosingNode(x1 + 1, x1 + 1, "M");
+ testContainedNode(x1 - 1, x1 + 2, "M");
- x1= fCode.indexOf("N"); x1= fCode.indexOf("N", x1+1);
- testNode(x1, x1+1, "N");
+ x1 = fCode.indexOf("N");
+ x1 = fCode.indexOf("N", x1 + 1);
+ testNode(x1, x1 + 1, "N");
testEnclosingNode(x1, x1, "N");
- testEnclosingNode(x1+1, x1+1, "N");
- testContainedNode(x1-1, x1+2, "N");
-
- x1= fCode.indexOf("O"); x1= fCode.indexOf("O", x1+1);
- testNode(x1, x1+1, "O");
+ testEnclosingNode(x1 + 1, x1 + 1, "N");
+ testContainedNode(x1 - 1, x1 + 2, "N");
+
+ x1 = fCode.indexOf("O");
+ x1 = fCode.indexOf("O", x1 + 1);
+ testNode(x1, x1 + 1, "O");
testEnclosingNode(x1, x1, "O");
- testEnclosingNode(x1+1, x1+1, "O");
- testContainedNode(x1-1, x1+2, "O");
+ testEnclosingNode(x1 + 1, x1 + 1, "O");
+ testContainedNode(x1 - 1, x1 + 2, "O");
}
-
+
// #define MACRO void m
// MACRO();
public void testEnclosingAMacro() {
- int x1= fCode.indexOf("MACRO(");
- int x2= x1 + "MACRO(".length();
+ int x1 = fCode.indexOf("MACRO(");
+ int x2 = x1 + "MACRO(".length();
testContainedName(x1, x2, "MACRO");
testEnclosingNode(x1, x2, "MACRO();");
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AccessControlTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AccessControlTests.java
index d81ac673d98..3d99d0cfc6c 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AccessControlTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AccessControlTests.java
@@ -25,34 +25,34 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.AccessContext;
import org.eclipse.cdt.internal.core.parser.ParserException;
public class AccessControlTests extends AST2TestBase {
-
+
protected class AccessAssertionHelper extends AST2AssertionHelper {
AccessAssertionHelper(String contents) throws ParserException {
super(contents, true);
}
-
+
void assertAccessible(String section, int len) {
IASTName name = findName(section, len);
IBinding binding = name.resolveBinding();
- assertNotNull(binding);
+ assertNotNull(binding);
assertTrue(AccessContext.isAccessible(binding, name));
}
-
+
void assertNotAccessible(String section, int len) {
IASTName name = findName(section, len);
IBinding binding = name.resolveBinding();
- assertNotNull(binding);
+ assertNotNull(binding);
assertFalse(AccessContext.isAccessible(binding, name));
}
}
-
+
public AccessControlTests() {
}
-
+
public AccessControlTests(String name) {
super(name);
}
-
+
public static TestSuite suite() {
return suite(AccessControlTests.class);
}
@@ -128,7 +128,7 @@ public class AccessControlTests extends AST2TestBase {
AccessAssertionHelper ah = getAssertionHelper();
ah.assertNotAccessible("a = 0", 1);
}
-
+
// class A0 {
// public:
// enum Ex {e1};
@@ -145,9 +145,9 @@ public class AccessControlTests extends AST2TestBase {
AccessAssertionHelper ah = getAssertionHelper();
ah.assertAccessible("Ex a;", 2);
}
-
+
// // Example from C++-specification 11.2-3
- // class B {
+ // class B {
// public:
// int mi;
// static int si;
@@ -159,7 +159,7 @@ public class AccessControlTests extends AST2TestBase {
//
// void DD::f() {
// mi=3; // private
- // si=3; // private
+ // si=3; // private
// B b;
// b.mi=4;
// b.si=4;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CharArrayMapTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CharArrayMapTest.java
index 25ab9a7017f..3617853de35 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CharArrayMapTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CharArrayMapTest.java
@@ -34,11 +34,13 @@ public class CharArrayMapTest extends TestCase {
final char[] chars;
final int start;
final int length;
+
public Slice(char[] chars, int start, int length) {
this.chars = chars;
this.length = length;
this.start = start;
}
+
@Override
public String toString() {
return new String(chars, start, length);
@@ -49,7 +51,7 @@ public class CharArrayMapTest extends TestCase {
final int iterations = 10000;
// insert tons of keys
char[][] keys = new char[iterations][];
- for(int i = 0; i < keys.length; i++) {
+ for (int i = 0; i < keys.length; i++) {
keys[i] = String.valueOf(i).toCharArray();
}
@@ -67,11 +69,11 @@ public class CharArrayMapTest extends TestCase {
private static long timeMap(char[][] keys) {
long start = System.currentTimeMillis();
CharArrayMap<Integer> map = new CharArrayMap<Integer>(keys.length);
- for(int i = 0; i < keys.length; i++) {
+ for (int i = 0; i < keys.length; i++) {
map.put(keys[i], i);
}
assertEquals(keys.length, map.size());
- for(int i = 0; i < keys.length; i++) {
+ for (int i = 0; i < keys.length; i++) {
assertEquals(Integer.valueOf(i), map.get(keys[i]));
}
return System.currentTimeMillis() - start;
@@ -80,11 +82,11 @@ public class CharArrayMapTest extends TestCase {
private static long timeOldMap(char[][] keys) {
long start = System.currentTimeMillis();
CharArrayObjectMap oldMap = new CharArrayObjectMap(keys.length);
- for(int i = 0; i < keys.length; i++) {
+ for (int i = 0; i < keys.length; i++) {
oldMap.put(keys[i], Integer.valueOf(i));
}
assertEquals(keys.length, oldMap.size());
- for(int i = 0; i < keys.length; i++) {
+ for (int i = 0; i < keys.length; i++) {
assertEquals(Integer.valueOf(i), oldMap.get(keys[i]));
}
return System.currentTimeMillis() - start;
@@ -129,17 +131,17 @@ public class CharArrayMapTest extends TestCase {
values.add(3);
values.add(4);
- for(int i : map.values()) {
+ for (int i : map.values()) {
assertTrue(values.remove(i));
}
// remove a mapping
assertEquals(Integer.valueOf(1), map.remove(key1));
assertEquals(3, map.size());
- assertNull(map.get(key1));
- assertFalse(map.containsKey(key1));
- assertFalse(map.containsValue(1));
- assertNull(map.remove(key1)); // its already removed
+ assertNull(map.get(key1));
+ assertFalse(map.containsKey(key1));
+ assertFalse(map.containsValue(1));
+ assertNull(map.remove(key1)); // its already removed
map.clear();
assertTrue(map.isEmpty());
@@ -169,31 +171,18 @@ public class CharArrayMapTest extends TestCase {
public void testBasicUsage2() {
char[] chars = "pantera, megadeth, soulfly, metallica, in flames, lamb of god, carcass".toCharArray();
- Slice[] slices = {
- new Slice(chars, 0, 7),
- new Slice(chars, 9, 8),
- new Slice(chars, 19, 7),
- new Slice(chars, 28, 9),
- new Slice(chars, 39, 9),
- new Slice(chars, 50, 11),
- new Slice(chars, 63, 7)
- };
-
- char[][] keys = {
- "pantera".toCharArray(),
- "megadeth".toCharArray(),
- "soulfly".toCharArray(),
- "metallica".toCharArray(),
- "in flames".toCharArray(),
- "lamb of god".toCharArray(),
- "carcass".toCharArray()
- };
+ Slice[] slices = { new Slice(chars, 0, 7), new Slice(chars, 9, 8), new Slice(chars, 19, 7),
+ new Slice(chars, 28, 9), new Slice(chars, 39, 9), new Slice(chars, 50, 11), new Slice(chars, 63, 7) };
+
+ char[][] keys = { "pantera".toCharArray(), "megadeth".toCharArray(), "soulfly".toCharArray(),
+ "metallica".toCharArray(), "in flames".toCharArray(), "lamb of god".toCharArray(),
+ "carcass".toCharArray() };
CharArrayMap<Integer> map = new CharArrayMap<Integer>();
assertTrue(map.isEmpty());
assertEquals(0, map.size());
- for(int i = 0; i < slices.length; i++) {
+ for (int i = 0; i < slices.length; i++) {
Slice slice = slices[i];
map.put(slice.chars, slice.start, slice.length, i);
}
@@ -202,7 +191,7 @@ public class CharArrayMapTest extends TestCase {
assertEquals(7, map.size());
// should still work with equivalent keys
- for(int i = 0; i < keys.length; i++) {
+ for (int i = 0; i < keys.length; i++) {
Slice slice = slices[i];
assertEquals(Integer.valueOf(i), map.get(slice.chars, slice.start, slice.length));
assertEquals(Integer.valueOf(i), map.get(keys[i]));
@@ -212,11 +201,11 @@ public class CharArrayMapTest extends TestCase {
}
Set<Integer> values = new HashSet<Integer>();
- for(int i = 0; i < keys.length; i++) {
+ for (int i = 0; i < keys.length; i++) {
values.add(i);
}
- for(int i : map.values()) {
+ for (int i : map.values()) {
assertTrue(values.remove(i));
}
@@ -227,7 +216,7 @@ public class CharArrayMapTest extends TestCase {
assertEquals(5, map.size());
// remaining keys should still be there
- for(int i = 0; i < 5; i++) {
+ for (int i = 0; i < 5; i++) {
Slice slice = slices[i];
assertEquals(Integer.valueOf(i), map.get(slice.chars, slice.start, slice.length));
assertEquals(Integer.valueOf(i), map.get(keys[i]));
@@ -241,48 +230,41 @@ public class CharArrayMapTest extends TestCase {
assertEquals(0, map.size());
}
-
public void testOrderedMap() {
char[] chars = "alpha beta aaa cappa almost".toCharArray();
- Slice[] slices = {
- new Slice(chars, 0, 5),
- new Slice(chars, 6, 4),
- new Slice(chars, 11, 3),
- new Slice(chars, 15, 5),
- new Slice(chars, 21, 6)
- };
- int[] order = {3, 4, 1, 5, 2};
-
+ Slice[] slices = { new Slice(chars, 0, 5), new Slice(chars, 6, 4), new Slice(chars, 11, 3),
+ new Slice(chars, 15, 5), new Slice(chars, 21, 6) };
+ int[] order = { 3, 4, 1, 5, 2 };
+
CharArrayMap<Integer> map = CharArrayMap.createOrderedMap();
-
- for(int i = 0; i < slices.length; i++) {
+
+ for (int i = 0; i < slices.length; i++) {
Slice slice = slices[i];
map.put(slice.chars, slice.start, slice.length, order[i]);
}
-
+
List<String> properOrder = Arrays.asList("aaa", "almost", "alpha", "beta", "cappa");
-
+
Collection<char[]> keys = map.keys();
assertEquals(5, keys.size());
{
int i = 0;
- for(char[] key : keys) {
+ for (char[] key : keys) {
assertEquals(properOrder.get(i), String.valueOf(key));
i++;
}
}
-
+
Collection<Integer> values = map.values();
assertEquals(5, values.size());
{
int i = 1;
- for(int value : values) {
+ for (int value : values) {
assertEquals(i++, value);
}
}
}
-
-
+
public void testProperFail() {
char[] hello = "hello".toCharArray();
CharArrayMap<Integer> map = new CharArrayMap<Integer>();
@@ -291,85 +273,102 @@ public class CharArrayMapTest extends TestCase {
try {
map.put(null, value);
fail();
- } catch(NullPointerException expectedException) {}
+ } catch (NullPointerException expectedException) {
+ }
try {
map.put(hello, -1, 5, value);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.put(hello, 0, -1, value);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.put(hello, 0, 100, value);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.get(null);
fail();
- } catch(NullPointerException expectedException) {}
+ } catch (NullPointerException expectedException) {
+ }
try {
map.get(hello, -1, 5);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.get(hello, 0, -1);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.get(hello, 0, 100);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.remove(null);
fail();
- } catch(NullPointerException expectedException) {}
+ } catch (NullPointerException expectedException) {
+ }
try {
map.remove(hello, -1, 5);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.remove(hello, 0, -1);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.remove(hello, 0, 100);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.containsKey(null);
fail();
- } catch(NullPointerException expectedException) {}
+ } catch (NullPointerException expectedException) {
+ }
try {
map.containsKey(hello, -1, 5);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.containsKey(hello, 0, -1);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.containsKey(hello, 0, 100);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
new CharArrayMap<Integer>(-1);
- } catch(IllegalArgumentException expectedException) {}
+ } catch (IllegalArgumentException expectedException) {
+ }
}
}
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 e7f4f249bf5..3e3e57d52f8 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
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Emanuel Graf & Guido Zgraggen - initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Emanuel Graf & Guido Zgraggen - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
@@ -24,10 +24,10 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
/**
* @author Guido Zgraggen
- *
+ *
*/
public class CommentTests extends AST2TestBase {
-
+
public static TestSuite suite() {
return suite(CommentTests.class);
}
@@ -38,7 +38,7 @@ public class CommentTests extends AST2TestBase {
assertEquals(9, comments.length);
}
-
+
public void testCommentsInHeaderFile() throws ParserException {
IASTTranslationUnit tu = parse(getHSource(), ParserLanguage.CPP, false, true);
IASTComment[] comments = tu.getComments();
@@ -53,18 +53,18 @@ public class CommentTests extends AST2TestBase {
assertEquals("//value field", new String(comments[7].getComment()));
assertEquals("//Endcomment h", new String(comments[8].getComment()));
}
-
+
public void testCountCommentsInCPPFile() throws ParserException {
IASTTranslationUnit tu = parse(getCppSource(), ParserLanguage.CPP, false, true);
IASTComment[] comments = tu.getComments();
-
+
assertEquals(10, comments.length);
}
public void testCommentsInCPPFile() throws ParserException {
IASTTranslationUnit tu = parse(getCppSource(), ParserLanguage.CPP, false, true);
IASTComment[] comments = tu.getComments();
-
+
assertEquals("// Comment in cpp", new String(comments[0].getComment()));
assertEquals("/*The magic 5 */", new String(comments[1].getComment()));
assertEquals("// Another comment", new String(comments[2].getComment()));
@@ -76,18 +76,18 @@ public class CommentTests extends AST2TestBase {
assertEquals("//Last comment in cpp", new String(comments[8].getComment()));
assertEquals("//An integer", new String(comments[9].getComment()));
}
-
+
public void testCountCommentsInCFile() throws ParserException {
IASTTranslationUnit tu = parse(getCSource(), ParserLanguage.C, false, true);
IASTComment[] comments = tu.getComments();
-
+
assertEquals(4, comments.length);
}
-
+
public void testCommentsInCFile() throws ParserException {
IASTTranslationUnit tu = parse(getCSource(), ParserLanguage.C, false, true);
IASTComment[] comments = tu.getComments();
-
+
assertEquals("//A little input/output programm", new String(comments[0].getComment()));
assertEquals("//Read the number", new String(comments[1].getComment()));
assertEquals("/*\n * That is the answer ;-)\n */", new String(comments[2].getComment()));
@@ -119,8 +119,8 @@ public class CommentTests extends AST2TestBase {
buffer.append("};\n");
buffer.append("#endif\n");
return buffer.toString();
- }
-
+ }
+
private String getCppSource() {
StringBuilder buffer = new StringBuilder();
buffer.append("void CppClass()\n");
@@ -169,7 +169,7 @@ public class CommentTests extends AST2TestBase {
buffer.append("}\n");
return buffer.toString();
}
-
+
private String getCSource() {
StringBuilder buffer = new StringBuilder();
buffer.append("//A little input/output programm\n");
@@ -196,59 +196,59 @@ public class CommentTests extends AST2TestBase {
buffer.append(" return 0; //The end\n");
buffer.append("}\n");
return buffer.toString();
- }
-
+ }
+
// #ifdef xxx
// // comment1
- // #else
+ // #else
// // comment2
// #endif
public void testCommentsInInactiveCode_bug183930() throws Exception {
- CharSequence code= getContents(1)[0];
+ CharSequence code = getContents(1)[0];
IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, true);
IASTComment[] comments = tu.getComments();
-
+
assertEquals(2, comments.length);
assertEquals("// comment1", new String(comments[0].getComment()));
assertEquals("// comment2", new String(comments[1].getComment()));
}
-
+
// //comment
public void testCommentLocation_bug186337() throws Exception {
- CharSequence code= getContents(1)[0];
+ CharSequence code = getContents(1)[0];
IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, 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);
comments = tu.getComments();
-
+
assertEquals(1, comments.length);
assertNotNull(comments[0].getFileLocation());
assertNotNull(comments[0].getNodeLocations());
}
-
- // // TODO: shows up in task list
+
+ // // TODO: shows up in task list
// #include "somefile.h" // TODO: ignored
- //
+ //
// #ifdef WHATEVA // TODO: ignored
// #endif // TODO: ignored
// // TODO: shows up in task list
public void testCommentInDirectives_bug192546() throws Exception {
- CharSequence code= getContents(1)[0];
+ CharSequence code = getContents(1)[0];
IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, false);
IASTComment[] comments = tu.getComments();
-
+
assertEquals(5, comments.length);
assertNotNull(comments[0].getFileLocation());
assertNotNull(comments[0].getNodeLocations());
for (IASTComment comment : comments) {
- IASTFileLocation loc= comment.getFileLocation();
- int idx= loc.getNodeOffset() + comment.getRawSignature().indexOf("TODO");
- assertEquals("TODO", code.subSequence(idx, idx + 4));
+ IASTFileLocation loc = comment.getFileLocation();
+ int idx = loc.getNodeOffset() + comment.getRawSignature().indexOf("TODO");
+ assertEquals("TODO", code.subSequence(idx, idx + 4));
}
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java
index 2102704166c..afb48b87188 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java
@@ -91,129 +91,127 @@ import junit.framework.TestSuite;
* @author jcamelon
*/
public class CompleteParser2Tests extends BaseTestCase {
- private static final NullLogService NULL_LOG = new NullLogService();
+ private static final NullLogService NULL_LOG = new NullLogService();
- public CompleteParser2Tests() {
+ public CompleteParser2Tests() {
}
+
public CompleteParser2Tests(String name) {
super(name);
}
- public static TestSuite suite() {
- return suite(CompleteParser2Tests.class);
- }
+ public static TestSuite suite() {
+ return suite(CompleteParser2Tests.class);
+ }
static private class NameCollector extends ASTVisitor {
- public List nameList = new ArrayList();
-
- public NameCollector() {
- this(false); // Don't visit implicit names by default
- }
-
- public NameCollector(boolean shouldVisitImplicitNames) {
- this.shouldVisitNames = true;
- this.shouldVisitImplicitNames = shouldVisitImplicitNames;
- }
-
- @Override
- public int visit(IASTName name){
- nameList.add(name);
- return PROCESS_CONTINUE;
- }
-
- public IASTName getName(int idx){
- if (idx < 0 || idx >= nameList.size())
- return null;
- return (IASTName) nameList.get(idx);
- }
-
- public int size() {
- return nameList.size();
- }
- }
-
- protected void assertInstances(NameCollector nameCollector, IBinding binding, int num) throws Exception {
- int count = 0;
- for (int i = 0; i < nameCollector.size(); i++) {
- if (nameCollector.getName(i).resolveBinding() == binding)
- count++;
- }
-
- assertEquals(num, count);
- }
-
- protected IASTTranslationUnit parse(String code, boolean expectedToPass,
- ParserLanguage lang) throws Exception {
- return parse(code, expectedToPass, lang, false);
- }
-
- protected IASTTranslationUnit parse(String code, boolean expectedToPass) throws Exception {
- return parse(code, expectedToPass, ParserLanguage.CPP);
- }
-
- /**
- * @param code
- */
- protected IASTTranslationUnit parse(String code) throws Exception {
- return parse(code, true, ParserLanguage.CPP);
- }
-
- protected IASTTranslationUnit parse(String code, boolean expectedToPass,
- ParserLanguage lang, boolean gcc) throws Exception {
- FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
- ScannerInfo scannerInfo = new ScannerInfo();
- ISourceCodeParser parser2 = null;
- IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
- if (lang == ParserLanguage.CPP) {
- ICPPParserExtensionConfiguration config = null;
- if (gcc) {
- config = new GPPParserExtensionConfiguration();
- } else {
- config = new ANSICPPParserExtensionConfiguration();
- }
- parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE,
- NULL_LOG, config);
- } else {
- ICParserExtensionConfiguration config = null;
- if (gcc) {
- config = new GCCParserExtensionConfiguration();
- } else {
- config = new ANSICParserExtensionConfiguration();
- }
-
- parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE,
- NULL_LOG, config);
- }
- IASTTranslationUnit tu = parser2.parse();
- if (parser2.encounteredError() && expectedToPass)
- throw new ParserException("FAILURE");
- if (expectedToPass) {
- if (lang == ParserLanguage.C) {
- IASTProblem[] problems = CVisitor.getProblems(tu);
- assertEquals(problems.length, 0);
- } else if (lang == ParserLanguage.CPP) {
- IASTProblem[] problems = CPPVisitor.getProblems(tu);
- assertEquals(problems.length, 0);
- }
- }
- return tu;
- }
-
- public void testEmptyCompilationUnit() throws Exception {
- parse("// no real code ");
- }
-
- public void testSimpleNamespace() throws Exception {
- IASTTranslationUnit tu = parse("namespace A { }");
- NameCollector col = new NameCollector();
+ public List nameList = new ArrayList();
+
+ public NameCollector() {
+ this(false); // Don't visit implicit names by default
+ }
+
+ public NameCollector(boolean shouldVisitImplicitNames) {
+ this.shouldVisitNames = true;
+ this.shouldVisitImplicitNames = shouldVisitImplicitNames;
+ }
+
+ @Override
+ public int visit(IASTName name) {
+ nameList.add(name);
+ return PROCESS_CONTINUE;
+ }
+
+ public IASTName getName(int idx) {
+ if (idx < 0 || idx >= nameList.size())
+ return null;
+ return (IASTName) nameList.get(idx);
+ }
+
+ public int size() {
+ return nameList.size();
+ }
+ }
+
+ protected void assertInstances(NameCollector nameCollector, IBinding binding, int num) throws Exception {
+ int count = 0;
+ for (int i = 0; i < nameCollector.size(); i++) {
+ if (nameCollector.getName(i).resolveBinding() == binding)
+ count++;
+ }
+
+ assertEquals(num, count);
+ }
+
+ protected IASTTranslationUnit parse(String code, boolean expectedToPass, ParserLanguage lang) throws Exception {
+ return parse(code, expectedToPass, lang, false);
+ }
+
+ protected IASTTranslationUnit parse(String code, boolean expectedToPass) throws Exception {
+ return parse(code, expectedToPass, ParserLanguage.CPP);
+ }
+
+ /**
+ * @param code
+ */
+ protected IASTTranslationUnit parse(String code) throws Exception {
+ return parse(code, true, ParserLanguage.CPP);
+ }
+
+ protected IASTTranslationUnit parse(String code, boolean expectedToPass, ParserLanguage lang, boolean gcc)
+ throws Exception {
+ FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
+ ScannerInfo scannerInfo = new ScannerInfo();
+ ISourceCodeParser parser2 = null;
+ IScanner scanner = AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
+ if (lang == ParserLanguage.CPP) {
+ ICPPParserExtensionConfiguration config = null;
+ if (gcc) {
+ config = new GPPParserExtensionConfiguration();
+ } else {
+ config = new ANSICPPParserExtensionConfiguration();
+ }
+ parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
+ } else {
+ ICParserExtensionConfiguration config = null;
+ if (gcc) {
+ config = new GCCParserExtensionConfiguration();
+ } else {
+ config = new ANSICParserExtensionConfiguration();
+ }
+
+ parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
+ }
+ IASTTranslationUnit tu = parser2.parse();
+ if (parser2.encounteredError() && expectedToPass)
+ throw new ParserException("FAILURE");
+ if (expectedToPass) {
+ if (lang == ParserLanguage.C) {
+ IASTProblem[] problems = CVisitor.getProblems(tu);
+ assertEquals(problems.length, 0);
+ } else if (lang == ParserLanguage.CPP) {
+ IASTProblem[] problems = CPPVisitor.getProblems(tu);
+ assertEquals(problems.length, 0);
+ }
+ }
+ return tu;
+ }
+
+ public void testEmptyCompilationUnit() throws Exception {
+ parse("// no real code ");
+ }
+
+ public void testSimpleNamespace() throws Exception {
+ IASTTranslationUnit tu = parse("namespace A { }");
+ NameCollector col = new NameCollector();
tu.accept(col);
assertEquals(col.size(), 1);
assertTrue(col.getName(0).resolveBinding() instanceof ICPPNamespace);
- }
+ }
public void testMultipleNamespaceDefinitions() throws Exception {
- IASTTranslationUnit tu = parse("namespace A { } namespace A { }");
+ IASTTranslationUnit tu = parse("namespace A { } namespace A { }");
NameCollector col = new NameCollector();
tu.accept(col);
@@ -222,8 +220,8 @@ public class CompleteParser2Tests extends BaseTestCase {
assertInstances(col, A, 2);
}
- public void testNestedNamespaceDefinitions() throws Exception {
- IASTTranslationUnit tu = parse("namespace A { namespace B { } }");
+ public void testNestedNamespaceDefinitions() throws Exception {
+ IASTTranslationUnit tu = parse("namespace A { namespace B { } }");
NameCollector col = new NameCollector();
tu.accept(col);
@@ -232,20 +230,20 @@ public class CompleteParser2Tests extends BaseTestCase {
ICPPNamespace B = (ICPPNamespace) col.getName(1).resolveBinding();
assertSame(A.getNamespaceScope(), B.getNamespaceScope().getParent());
- }
+ }
- public void testEmptyClassDeclaration() throws Exception {
- IASTTranslationUnit tu = parse("class A { };");
- NameCollector col = new NameCollector();
+ public void testEmptyClassDeclaration() throws Exception {
+ IASTTranslationUnit tu = parse("class A { };");
+ NameCollector col = new NameCollector();
tu.accept(col);
assertEquals(col.size(), 1);
assertTrue(col.getName(0).resolveBinding() instanceof ICPPClassType);
- }
+ }
- public void testSimpleSubclass() throws Exception {
- IASTTranslationUnit tu = parse("class A { }; class B : public A { };");
- NameCollector col = new NameCollector();
+ public void testSimpleSubclass() throws Exception {
+ IASTTranslationUnit tu = parse("class A { }; class B : public A { };");
+ NameCollector col = new NameCollector();
tu.accept(col);
assertEquals(col.size(), 3);
@@ -259,11 +257,11 @@ public class CompleteParser2Tests extends BaseTestCase {
assertSame(base.getBaseClass(), A);
assertEquals(base.getVisibility(), ICPPBase.v_public);
assertFalse(base.isVirtual());
- }
+ }
- public void testNestedSubclass() throws Exception {
- IASTTranslationUnit tu = parse("namespace N { class A { }; } class B : protected virtual N::A { };");
- NameCollector col = new NameCollector();
+ public void testNestedSubclass() throws Exception {
+ IASTTranslationUnit tu = parse("namespace N { class A { }; } class B : protected virtual N::A { };");
+ NameCollector col = new NameCollector();
tu.accept(col);
assertEquals(col.size(), 6);
@@ -281,319 +279,316 @@ public class CompleteParser2Tests extends BaseTestCase {
assertSame(base.getBaseClass(), A);
assertTrue(base.isVirtual());
assertEquals(base.getVisibility(), ICPPBase.v_protected);
- }
+ }
- public void testSimpleVariable() throws Exception {
- IASTTranslationUnit tu = parse("int x;");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ public void testSimpleVariable() throws Exception {
+ IASTTranslationUnit tu = parse("int x;");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 1);
- IVariable x = (IVariable) col.getName(0).resolveBinding();
+ assertEquals(col.size(), 1);
+ IVariable x = (IVariable) col.getName(0).resolveBinding();
- assertTrue(x.getType() instanceof IBasicType);
- IBasicType t = (IBasicType) x.getType();
- assertEquals(t.getType(), IBasicType.t_int);
- }
+ assertTrue(x.getType() instanceof IBasicType);
+ IBasicType t = (IBasicType) x.getType();
+ assertEquals(t.getType(), IBasicType.t_int);
+ }
public void testSimpleClassReferenceVariable() throws Exception {
- IASTTranslationUnit tu = parse("class A { }; A x;");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ IASTTranslationUnit tu = parse("class A { }; A x;");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 3);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- IVariable x = (IVariable) col.getName(2).resolveBinding();
+ assertEquals(col.size(), 3);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ IVariable x = (IVariable) col.getName(2).resolveBinding();
- assertInstances(col, A, 2);
- assertSame(x.getType(), A);
+ assertInstances(col, A, 2);
+ assertSame(x.getType(), A);
}
public void testNestedClassReferenceVariable() throws Exception {
- IASTTranslationUnit tu = parse("namespace N { class A { }; } N::A x;");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ IASTTranslationUnit tu = parse("namespace N { class A { }; } N::A x;");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 6);
- ICPPNamespace N = (ICPPNamespace) col.getName(0).resolveBinding();
- ICPPClassType A = (ICPPClassType) col.getName(1).resolveBinding();
- IVariable x = (IVariable) col.getName(5).resolveBinding();
+ assertEquals(col.size(), 6);
+ ICPPNamespace N = (ICPPNamespace) col.getName(0).resolveBinding();
+ ICPPClassType A = (ICPPClassType) col.getName(1).resolveBinding();
+ IVariable x = (IVariable) col.getName(5).resolveBinding();
- assertInstances(col, N, 2);
- assertInstances(col, A, 3);
- assertSame(x.getType(), A);
- assertSame(A.getScope(), N.getNamespaceScope());
+ assertInstances(col, N, 2);
+ assertInstances(col, A, 3);
+ assertSame(x.getType(), A);
+ assertSame(A.getScope(), N.getNamespaceScope());
}
public void testMultipleDeclaratorsVariable() throws Exception {
- IASTTranslationUnit tu = parse("class A { }; A x, y, z;");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ IASTTranslationUnit tu = parse("class A { }; A x, y, z;");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 5);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- IVariable x = (IVariable) col.getName(2).resolveBinding();
- IVariable y = (IVariable) col.getName(3).resolveBinding();
- IVariable z = (IVariable) col.getName(4).resolveBinding();
+ assertEquals(col.size(), 5);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ IVariable x = (IVariable) col.getName(2).resolveBinding();
+ IVariable y = (IVariable) col.getName(3).resolveBinding();
+ IVariable z = (IVariable) col.getName(4).resolveBinding();
- assertInstances(col, A, 2);
- assertSame(A, x.getType());
- assertSame(x.getType(), y.getType());
- assertSame(y.getType(), z.getType());
+ assertInstances(col, A, 2);
+ assertSame(A, x.getType());
+ assertSame(x.getType(), y.getType());
+ assertSame(y.getType(), z.getType());
}
public void testSimpleField() throws Exception {
- IASTTranslationUnit tu = parse("class A { double x; };");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ IASTTranslationUnit tu = parse("class A { double x; };");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 2);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPField x = (ICPPField) col.getName(1).resolveBinding();
+ assertEquals(col.size(), 2);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPField x = (ICPPField) col.getName(1).resolveBinding();
- assertSame(x.getScope(), A.getCompositeScope());
- IField[] fields = A.getFields();
- assertEquals(fields.length, 1);
- assertSame(fields[0], x);
- }
+ assertSame(x.getScope(), A.getCompositeScope());
+ IField[] fields = A.getFields();
+ assertEquals(fields.length, 1);
+ assertSame(fields[0], x);
+ }
public void testUsingClauses() throws Exception {
- IASTTranslationUnit tu = parse("namespace A { namespace B { int x; class C { static int y = 5; }; } } \n " +
- "using namespace A::B;\n " +
- "using A::B::x;" +
- "using A::B::C;" +
- "using A::B::C::y;");
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- assertEquals(col.size(), 21);
- ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
- ICPPNamespace B = (ICPPNamespace) col.getName(1).resolveBinding();
- IVariable x = (IVariable) col.getName(2).resolveBinding();
- ICPPClassType C = (ICPPClassType) col.getName(3).resolveBinding();
- ICPPField y = (ICPPField) col.getName(4).resolveBinding();
-
- ICPPUsingDeclaration using_x = (ICPPUsingDeclaration) col.getName(11).resolveBinding();
- ICPPUsingDeclaration using_C = (ICPPUsingDeclaration) col.getName(15).resolveBinding();
- ICPPUsingDeclaration using_y = (ICPPUsingDeclaration) col.getName(20).resolveBinding();
-
- assertInstances(col, A, 5);
- assertInstances(col, B, 6);
- assertInstances(col, x, 1);
- assertInstances(col, C, 2);
- assertInstances(col, y, 1);
-
- IBinding[] ds = using_x.getDelegates();
- assertSame(ds[0], x);
- assertSame(using_C.getDelegates()[0], C);
- assertSame(using_y.getDelegates()[0], y);
+ IASTTranslationUnit tu = parse("namespace A { namespace B { int x; class C { static int y = 5; }; } } \n "
+ + "using namespace A::B;\n " + "using A::B::x;" + "using A::B::C;" + "using A::B::C::y;");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ assertEquals(col.size(), 21);
+ ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
+ ICPPNamespace B = (ICPPNamespace) col.getName(1).resolveBinding();
+ IVariable x = (IVariable) col.getName(2).resolveBinding();
+ ICPPClassType C = (ICPPClassType) col.getName(3).resolveBinding();
+ ICPPField y = (ICPPField) col.getName(4).resolveBinding();
+
+ ICPPUsingDeclaration using_x = (ICPPUsingDeclaration) col.getName(11).resolveBinding();
+ ICPPUsingDeclaration using_C = (ICPPUsingDeclaration) col.getName(15).resolveBinding();
+ ICPPUsingDeclaration using_y = (ICPPUsingDeclaration) col.getName(20).resolveBinding();
+
+ assertInstances(col, A, 5);
+ assertInstances(col, B, 6);
+ assertInstances(col, x, 1);
+ assertInstances(col, C, 2);
+ assertInstances(col, y, 1);
+
+ IBinding[] ds = using_x.getDelegates();
+ assertSame(ds[0], x);
+ assertSame(using_C.getDelegates()[0], C);
+ assertSame(using_y.getDelegates()[0], y);
}
public void testEnumerations() throws Exception {
- IASTTranslationUnit tu = parse("namespace A { enum E { e1, e2, e3 }; E varE;}");
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- assertEquals(col.size(), 7);
- ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
- IEnumeration E = (IEnumeration) col.getName(1).resolveBinding();
- IEnumerator e1 = (IEnumerator) col.getName(2).resolveBinding();
- IEnumerator e2 = (IEnumerator) col.getName(3).resolveBinding();
- IEnumerator e3 = (IEnumerator) col.getName(4).resolveBinding();
- IVariable varE = (IVariable) col.getName(6).resolveBinding();
-
- assertInstances(col, E, 2);
- assertSame(E.getScope(), A.getNamespaceScope());
- assertSame(e1.getScope(), A.getNamespaceScope());
- assertNotNull(e2);
- assertNotNull(e3);
- assertNotNull(varE);
+ IASTTranslationUnit tu = parse("namespace A { enum E { e1, e2, e3 }; E varE;}");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ assertEquals(col.size(), 7);
+ ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
+ IEnumeration E = (IEnumeration) col.getName(1).resolveBinding();
+ IEnumerator e1 = (IEnumerator) col.getName(2).resolveBinding();
+ IEnumerator e2 = (IEnumerator) col.getName(3).resolveBinding();
+ IEnumerator e3 = (IEnumerator) col.getName(4).resolveBinding();
+ IVariable varE = (IVariable) col.getName(6).resolveBinding();
+
+ assertInstances(col, E, 2);
+ assertSame(E.getScope(), A.getNamespaceScope());
+ assertSame(e1.getScope(), A.getNamespaceScope());
+ assertNotNull(e2);
+ assertNotNull(e3);
+ assertNotNull(varE);
}
public void testSimpleFunction() throws Exception {
- IASTTranslationUnit tu = parse("void foo(void);");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ IASTTranslationUnit tu = parse("void foo(void);");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 2);
- IFunction foo = (IFunction) col.getName(0).resolveBinding();
- IParameter p = (IParameter) col.getName(1).resolveBinding();
+ assertEquals(col.size(), 2);
+ IFunction foo = (IFunction) col.getName(0).resolveBinding();
+ IParameter p = (IParameter) col.getName(1).resolveBinding();
- assertEquals(0, foo.getParameters().length);
- assertSame(p.getScope(), foo.getFunctionScope());
+ assertEquals(0, foo.getParameters().length);
+ assertSame(p.getScope(), foo.getFunctionScope());
}
public void testSimpleFunctionWithTypes() throws Exception {
- IASTTranslationUnit tu = parse("class A { public: \n class B { }; }; const A::B & foo(A * myParam);");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ IASTTranslationUnit tu = parse("class A { public: \n class B { }; }; const A::B & foo(A * myParam);");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 8);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPClassType B = (ICPPClassType) col.getName(1).resolveBinding();
- IFunction foo = (IFunction) col.getName(5).resolveBinding();
- IParameter p = (IParameter) col.getName(7).resolveBinding();
+ assertEquals(col.size(), 8);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPClassType B = (ICPPClassType) col.getName(1).resolveBinding();
+ IFunction foo = (IFunction) col.getName(5).resolveBinding();
+ IParameter p = (IParameter) col.getName(7).resolveBinding();
- assertInstances(col, A, 3);
- assertInstances(col, B, 3);
+ assertInstances(col, A, 3);
+ assertInstances(col, B, 3);
- IFunctionType ftype = foo.getType();
- assertTrue(ftype.getReturnType() instanceof ICPPReferenceType);
- ICPPReferenceType rt = (ICPPReferenceType) ftype.getReturnType();
- assertTrue(rt.getType() instanceof IQualifierType);
- assertSame(((IQualifierType)rt.getType()).getType(), B);
+ IFunctionType ftype = foo.getType();
+ assertTrue(ftype.getReturnType() instanceof ICPPReferenceType);
+ ICPPReferenceType rt = (ICPPReferenceType) ftype.getReturnType();
+ assertTrue(rt.getType() instanceof IQualifierType);
+ assertSame(((IQualifierType) rt.getType()).getType(), B);
- IType pt = ftype.getParameterTypes()[0];
- assertTrue(p.getType().isSameType(pt));
- assertTrue(pt instanceof IPointerType);
- assertSame(((IPointerType) pt).getType(), A);
+ IType pt = ftype.getParameterTypes()[0];
+ assertTrue(p.getType().isSameType(pt));
+ assertTrue(pt instanceof IPointerType);
+ assertSame(((IPointerType) pt).getType(), A);
}
public void testSimpleMethod() throws Exception {
- IASTTranslationUnit tu = parse("class A { void foo(); };");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ IASTTranslationUnit tu = parse("class A { void foo(); };");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 2);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPMethod foo = (ICPPMethod) col.getName(1).resolveBinding();
+ assertEquals(col.size(), 2);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPMethod foo = (ICPPMethod) col.getName(1).resolveBinding();
- assertSame(foo.getScope(), A.getCompositeScope());
+ assertSame(foo.getScope(), A.getCompositeScope());
}
public void testSimpleMethodWithTypes() throws Exception {
- IASTTranslationUnit tu = parse("class U { }; class A { U foo(U areDumb); };");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ IASTTranslationUnit tu = parse("class U { }; class A { U foo(U areDumb); };");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 6);
- ICPPClassType U = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPClassType A = (ICPPClassType) col.getName(1).resolveBinding();
- ICPPMethod foo = (ICPPMethod) col.getName(3).resolveBinding();
- IParameter p = (IParameter) col.getName(5).resolveBinding();
+ assertEquals(col.size(), 6);
+ ICPPClassType U = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPClassType A = (ICPPClassType) col.getName(1).resolveBinding();
+ ICPPMethod foo = (ICPPMethod) col.getName(3).resolveBinding();
+ IParameter p = (IParameter) col.getName(5).resolveBinding();
- assertInstances(col, U, 3);
- assertSame(foo.getScope(), A.getCompositeScope());
- IFunctionType ft = foo.getType();
- assertSame(ft.getReturnType(), U);
- assertSame(p.getType(), U);
+ assertInstances(col, U, 3);
+ assertSame(foo.getScope(), A.getCompositeScope());
+ IFunctionType ft = foo.getType();
+ assertSame(ft.getReturnType(), U);
+ assertSame(p.getType(), U);
}
public void testUsingDeclarationWithFunctionsAndMethods() throws Exception {
- IASTTranslationUnit tu = parse("namespace N { int foo(void); } class A { static int bar(void); }; using N::foo; using ::A::bar;");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ IASTTranslationUnit tu = parse(
+ "namespace N { int foo(void); } class A { static int bar(void); }; using N::foo; using ::A::bar;");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 12);
- ICPPNamespace N = (ICPPNamespace) col.getName(0).resolveBinding();
- IFunction foo = (IFunction) col.getName(1).resolveBinding();
- ICPPClassType A = (ICPPClassType) col.getName(3).resolveBinding();
- ICPPMethod bar = (ICPPMethod) col.getName(4).resolveBinding();
+ assertEquals(col.size(), 12);
+ ICPPNamespace N = (ICPPNamespace) col.getName(0).resolveBinding();
+ IFunction foo = (IFunction) col.getName(1).resolveBinding();
+ ICPPClassType A = (ICPPClassType) col.getName(3).resolveBinding();
+ ICPPMethod bar = (ICPPMethod) col.getName(4).resolveBinding();
- ICPPUsingDeclaration using_foo = (ICPPUsingDeclaration) col.getName(8).resolveBinding();
- ICPPUsingDeclaration using_bar = (ICPPUsingDeclaration) col.getName(11).resolveBinding();
+ ICPPUsingDeclaration using_foo = (ICPPUsingDeclaration) col.getName(8).resolveBinding();
+ ICPPUsingDeclaration using_bar = (ICPPUsingDeclaration) col.getName(11).resolveBinding();
- assertInstances(col, N, 2);
- assertInstances(col, foo, 1);
- assertInstances(col, A, 2);
- assertInstances(col, bar, 1);
+ assertInstances(col, N, 2);
+ assertInstances(col, foo, 1);
+ assertInstances(col, A, 2);
+ assertInstances(col, bar, 1);
- assertSame(using_foo.getDelegates()[0], foo);
- assertSame(using_bar.getDelegates()[0], bar);
+ assertSame(using_foo.getDelegates()[0], foo);
+ assertSame(using_bar.getDelegates()[0], bar);
}
public void testLinkageSpec() throws Exception {
IASTTranslationUnit tu = parse("extern \"C\" { int foo(); }");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 1);
- IFunction foo = (IFunction) col.getName(0).resolveBinding();
- assertNotNull(foo);
+ assertEquals(col.size(), 1);
+ IFunction foo = (IFunction) col.getName(0).resolveBinding();
+ assertNotNull(foo);
}
public void testBogdansExample() throws Exception {
- IASTTranslationUnit tu = parse("namespace A { namespace B { enum e1{e_1,e_2}; int x; class C { static int y = 5; }; }} ");
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- assertEquals(col.size(), 8);
- ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
- ICPPNamespace B = (ICPPNamespace) col.getName(1).resolveBinding();
- IEnumeration e1 = (IEnumeration) col.getName(2).resolveBinding();
- IEnumerator e_1 = (IEnumerator) col.getName(3).resolveBinding();
- IEnumerator e_2 = (IEnumerator) col.getName(4).resolveBinding();
- IVariable x = (IVariable) col.getName(5).resolveBinding();
- ICPPClassType C = (ICPPClassType) col.getName(6).resolveBinding();
- ICPPField y = (ICPPField) col.getName(7).resolveBinding();
-
- assertSame(B.getScope(), A.getNamespaceScope());
- assertSame(e1.getScope(), B.getNamespaceScope());
- assertSame(e_1.getScope(), B.getNamespaceScope());
- assertSame(e_2.getType(), e1);
- assertNotNull(x);
- assertNotNull(C);
- assertNotNull(y);
+ IASTTranslationUnit tu = parse(
+ "namespace A { namespace B { enum e1{e_1,e_2}; int x; class C { static int y = 5; }; }} ");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ assertEquals(col.size(), 8);
+ ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
+ ICPPNamespace B = (ICPPNamespace) col.getName(1).resolveBinding();
+ IEnumeration e1 = (IEnumeration) col.getName(2).resolveBinding();
+ IEnumerator e_1 = (IEnumerator) col.getName(3).resolveBinding();
+ IEnumerator e_2 = (IEnumerator) col.getName(4).resolveBinding();
+ IVariable x = (IVariable) col.getName(5).resolveBinding();
+ ICPPClassType C = (ICPPClassType) col.getName(6).resolveBinding();
+ ICPPField y = (ICPPField) col.getName(7).resolveBinding();
+
+ assertSame(B.getScope(), A.getNamespaceScope());
+ assertSame(e1.getScope(), B.getNamespaceScope());
+ assertSame(e_1.getScope(), B.getNamespaceScope());
+ assertSame(e_2.getType(), e1);
+ assertNotNull(x);
+ assertNotNull(C);
+ assertNotNull(y);
}
public void testAndrewsExample() throws Exception {
IASTTranslationUnit tu = parse("namespace N{ class A {}; } using namespace N; class B: public A{};");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 5);
- ICPPNamespace N = (ICPPNamespace) col.getName(0).resolveBinding();
- ICPPClassType A = (ICPPClassType) col.getName(1).resolveBinding();
- ICPPClassType B = (ICPPClassType) col.getName(3).resolveBinding();
+ assertEquals(col.size(), 5);
+ ICPPNamespace N = (ICPPNamespace) col.getName(0).resolveBinding();
+ ICPPClassType A = (ICPPClassType) col.getName(1).resolveBinding();
+ ICPPClassType B = (ICPPClassType) col.getName(3).resolveBinding();
- assertInstances(col, N, 2);
- assertInstances(col, A, 2);
+ assertInstances(col, N, 2);
+ assertInstances(col, A, 2);
- ICPPBase base = B.getBases()[0];
- assertSame(base.getBaseClass(), A);
+ ICPPBase base = B.getBases()[0];
+ assertSame(base.getBaseClass(), A);
}
public void testSimpleTypedef() throws Exception {
IASTTranslationUnit tu = parse("typedef int myInt;\n myInt var;");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 3);
- ITypedef myInt = (ITypedef) col.getName(0).resolveBinding();
- IVariable var = (IVariable) col.getName(2).resolveBinding();
+ assertEquals(col.size(), 3);
+ ITypedef myInt = (ITypedef) col.getName(0).resolveBinding();
+ IVariable var = (IVariable) col.getName(2).resolveBinding();
- assertInstances(col, myInt, 2);
- assertTrue(myInt.getType() instanceof IBasicType);
- assertSame(var.getType(), myInt);
+ assertInstances(col, myInt, 2);
+ assertTrue(myInt.getType() instanceof IBasicType);
+ assertSame(var.getType(), myInt);
}
public void testComplexTypedef() throws Exception {
IASTTranslationUnit tu = parse("class A{ }; typedef A ** A_DOUBLEPTR;");
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- assertEquals(col.size(), 3);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- ITypedef APTR = (ITypedef) col.getName(2).resolveBinding();
-
- assertInstances(col, A, 2);
- assertTrue(APTR.getType() instanceof IPointerType);
- IPointerType pt = (IPointerType) APTR.getType();
- assertTrue(pt.getType() instanceof IPointerType);
- pt = (IPointerType) pt.getType();
- assertSame(pt.getType(), A);
- }
-
- protected void assertQualifiedName(String[] fromAST, String[] theTruth)
- {
- assertNotNull(fromAST);
- assertNotNull(theTruth);
- assertEquals(fromAST.length, theTruth.length);
- for (int i = 0; i < fromAST.length; ++i)
- {
- assertEquals(fromAST[i], theTruth[i]);
- }
- }
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ assertEquals(col.size(), 3);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ ITypedef APTR = (ITypedef) col.getName(2).resolveBinding();
+
+ assertInstances(col, A, 2);
+ assertTrue(APTR.getType() instanceof IPointerType);
+ IPointerType pt = (IPointerType) APTR.getType();
+ assertTrue(pt.getType() instanceof IPointerType);
+ pt = (IPointerType) pt.getType();
+ assertSame(pt.getType(), A);
+ }
+
+ protected void assertQualifiedName(String[] fromAST, String[] theTruth) {
+ assertNotNull(fromAST);
+ assertNotNull(theTruth);
+ assertEquals(fromAST.length, theTruth.length);
+ for (int i = 0; i < fromAST.length; ++i) {
+ assertEquals(fromAST[i], theTruth[i]);
+ }
+ }
public void testBug40842() throws Exception {
Writer code = new StringWriter();
@@ -609,13 +604,13 @@ public class CompleteParser2Tests extends BaseTestCase {
public void testNestedClassname() throws Exception {
IASTTranslationUnit tu = parse("namespace A { \n class A::B { };}");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
- ICPPClassType B = (ICPPClassType) col.getName(1).resolveBinding();
- assertInstances(col, A, 2);
- assertEquals(B.getScope(), A.getNamespaceScope());
+ ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
+ ICPPClassType B = (ICPPClassType) col.getName(1).resolveBinding();
+ assertInstances(col, A, 2);
+ assertEquals(B.getScope(), A.getNamespaceScope());
}
public void testForwardDeclaration() throws Exception {
@@ -630,28 +625,28 @@ public class CompleteParser2Tests extends BaseTestCase {
public void testElaboratedType() throws Exception {
IASTTranslationUnit tu = parse("class A; class A * a;");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 3);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- IVariable a = (IVariable) col.getName(2).resolveBinding();
- IPointerType ptr = (IPointerType) a.getType();
- assertInstances(col, A, 2);
- assertSame(ptr.getType(), A);
+ assertEquals(col.size(), 3);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ IVariable a = (IVariable) col.getName(2).resolveBinding();
+ IPointerType ptr = (IPointerType) a.getType();
+ assertInstances(col, A, 2);
+ assertSame(ptr.getType(), A);
}
public void testForewardDeclarationWithUsage() throws Exception {
IASTTranslationUnit tu = parse("class A; A * anA;class A { };");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 4);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- IVariable anA = (IVariable) col.getName(2).resolveBinding();
- assertInstances(col, A, 3);
- IPointerType ptr = (IPointerType) anA.getType();
- assertSame(ptr.getType(), A);
+ assertEquals(col.size(), 4);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ IVariable anA = (IVariable) col.getName(2).resolveBinding();
+ assertInstances(col, A, 3);
+ IPointerType ptr = (IPointerType) anA.getType();
+ assertSame(ptr.getType(), A);
}
public void testASM() throws Exception {
@@ -677,146 +672,137 @@ public class CompleteParser2Tests extends BaseTestCase {
parse("asm (\"addl %%ebx,%%eax\" \"=a\"(foo) :\"a\"(foo) : \"b\"(bar));", false, ParserLanguage.CPP, true);//$NON-NLS-1$
// Code from bug 145389.
- parse("#define mb() __asm__ __volatile__ (\"sync\" : : : \"memory\")\r\n" +
- "\r\n" +
- "int main(int argc, char **argv) {\r\n" +
- " mb();\r\n" +
- "}");
+ parse("#define mb() __asm__ __volatile__ (\"sync\" : : : \"memory\")\r\n" + "\r\n"
+ + "int main(int argc, char **argv) {\r\n" + " mb();\r\n" + "}");
// Code from bug 117001
- parse("static inline long\r\n" +
- "div_ll_X_l_rem(long long divs, long div, long *rem)\r\n" +
- "{\r\n" +
- " long dum2;\r\n" +
- " __asm__(\"divl %2\":\"=a\"(dum2), \"=d\"(*rem) // syntax error indicated at \":\"\r\n" +
- " : \"rm\"(div), \"A\"(divs));\r\n" +
- "\r\n" +
- " return dum2;\r\n" +
- "\r\n" +
- "}");
+ parse("static inline long\r\n" + "div_ll_X_l_rem(long long divs, long div, long *rem)\r\n" + "{\r\n"
+ + " long dum2;\r\n"
+ + " __asm__(\"divl %2\":\"=a\"(dum2), \"=d\"(*rem) // syntax error indicated at \":\"\r\n"
+ + " : \"rm\"(div), \"A\"(divs));\r\n" + "\r\n" + " return dum2;\r\n" + "\r\n" + "}");
}
public void testOverride() throws Exception {
IASTTranslationUnit tu = parse("void foo();\n void foo(int);\n");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 3);
- IFunction foo1 = (IFunction) col.getName(0).resolveBinding();
- IFunction foo2 = (IFunction) col.getName(1).resolveBinding();
+ assertEquals(col.size(), 3);
+ IFunction foo1 = (IFunction) col.getName(0).resolveBinding();
+ IFunction foo2 = (IFunction) col.getName(1).resolveBinding();
- assertNotSame(foo1, foo2);
+ assertNotSame(foo1, foo2);
}
public void testSimpleExpression() throws Exception {
IASTTranslationUnit tu = parse("int x; int y = x;");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 3);
- IVariable x = (IVariable) col.getName(0).resolveBinding();
- IVariable y = (IVariable) col.getName(1).resolveBinding();
- assertInstances(col, x, 2);
- assertNotNull(y);
+ assertEquals(col.size(), 3);
+ IVariable x = (IVariable) col.getName(0).resolveBinding();
+ IVariable y = (IVariable) col.getName(1).resolveBinding();
+ assertInstances(col, x, 2);
+ assertNotNull(y);
}
public void testParameterExpressions() throws Exception {
IASTTranslationUnit tu = parse("int x = 5; void foo(int sub = x) { }");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 4);
- IVariable x = (IVariable) col.getName(0).resolveBinding();
- assertInstances(col, x, 2);
+ assertEquals(col.size(), 4);
+ IVariable x = (IVariable) col.getName(0).resolveBinding();
+ assertInstances(col, x, 2);
}
public void testNestedNamespaceExpression() throws Exception {
IASTTranslationUnit tu = parse("namespace A { int x = 666; } int y = A::x;");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 6);
- ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
- IVariable x = (IVariable) col.getName(1).resolveBinding();
- assertInstances(col, A, 2);
- assertInstances(col, x, 3);
+ assertEquals(col.size(), 6);
+ ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
+ IVariable x = (IVariable) col.getName(1).resolveBinding();
+ assertInstances(col, A, 2);
+ assertInstances(col, x, 3);
}
public void testConstructorChain() throws Exception {
IASTTranslationUnit tu = parse("int x = 5;\n class A \n{ public : \n int a; \n A() : a(x) { } };");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 6);
- IVariable x = (IVariable) col.getName(0).resolveBinding();
- ICPPField a = (ICPPField) col.getName(2).resolveBinding();
- ICPPConstructor A = (ICPPConstructor) col.getName(3).resolveBinding();
- assertNotNull(A);
- assertInstances(col, x, 2);
- assertInstances(col, a, 2);
+ assertEquals(col.size(), 6);
+ IVariable x = (IVariable) col.getName(0).resolveBinding();
+ ICPPField a = (ICPPField) col.getName(2).resolveBinding();
+ ICPPConstructor A = (ICPPConstructor) col.getName(3).resolveBinding();
+ assertNotNull(A);
+ assertInstances(col, x, 2);
+ assertInstances(col, a, 2);
}
public void testArrayModExpression() throws Exception {
IASTTranslationUnit tu = parse("const int x = 5; int y[ x ]; ");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 3);
- IVariable x = (IVariable) col.getName(0).resolveBinding();
- IVariable y = (IVariable) col.getName(1).resolveBinding();
- assertInstances(col, x, 2);
- assertTrue(y.getType() instanceof IArrayType);
- assertTrue(((IArrayType)y.getType()).getType() instanceof IBasicType);
+ assertEquals(col.size(), 3);
+ IVariable x = (IVariable) col.getName(0).resolveBinding();
+ IVariable y = (IVariable) col.getName(1).resolveBinding();
+ assertInstances(col, x, 2);
+ assertTrue(y.getType() instanceof IArrayType);
+ assertTrue(((IArrayType) y.getType()).getType() instanceof IBasicType);
}
public void testPointerVariable() throws Exception {
IASTTranslationUnit tu = parse("class A { }; A * anA;");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 3);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- IVariable anA = (IVariable) col.getName(2).resolveBinding();
- assertInstances(col, A, 2);
- assertTrue(anA.getType() instanceof IPointerType);
- assertSame(((IPointerType) anA.getType()).getType(), A);
+ assertEquals(col.size(), 3);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ IVariable anA = (IVariable) col.getName(2).resolveBinding();
+ assertInstances(col, A, 2);
+ assertTrue(anA.getType() instanceof IPointerType);
+ assertSame(((IPointerType) anA.getType()).getType(), A);
}
public void testExceptionSpecification() throws Exception {
IASTTranslationUnit tu = parse("class A { }; void foo(void) throw (A);");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 4);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- assertInstances(col, A, 2);
+ assertEquals(col.size(), 4);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ assertInstances(col, A, 2);
}
public void testNewExpressions() throws Exception {
IASTTranslationUnit tu = parse("typedef int A; int B; int C; int D; int P; int*p = new (P) (A[B][C][D]);");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 11);
- ITypedef A = (ITypedef) col.getName(0).resolveBinding();
- IVariable B = (IVariable) col.getName(1).resolveBinding();
- IVariable C = (IVariable) col.getName(2).resolveBinding();
- IVariable D = (IVariable) col.getName(3).resolveBinding();
- IVariable P = (IVariable) col.getName(4).resolveBinding();
- IVariable p = (IVariable) col.getName(5).resolveBinding();
+ assertEquals(col.size(), 11);
+ ITypedef A = (ITypedef) col.getName(0).resolveBinding();
+ IVariable B = (IVariable) col.getName(1).resolveBinding();
+ IVariable C = (IVariable) col.getName(2).resolveBinding();
+ IVariable D = (IVariable) col.getName(3).resolveBinding();
+ IVariable P = (IVariable) col.getName(4).resolveBinding();
+ IVariable p = (IVariable) col.getName(5).resolveBinding();
- assertInstances(col, A, 2);
- assertInstances(col, B, 2);
- assertInstances(col, C, 2);
- assertInstances(col, D, 2);
- assertInstances(col, P, 2);
+ assertInstances(col, A, 2);
+ assertInstances(col, B, 2);
+ assertInstances(col, C, 2);
+ assertInstances(col, D, 2);
+ assertInstances(col, P, 2);
- assertTrue(p.getType() instanceof IPointerType);
+ assertTrue(p.getType() instanceof IPointerType);
}
public void testBug41520() throws Exception {
IASTTranslationUnit tu = parse("int f() { const int x = 666; const int y(x); }");
- IASTCompoundStatement s = (IASTCompoundStatement) ((IASTFunctionDefinition)tu.getDeclarations()[0]).getBody();
- IASTDeclarationStatement ds = (IASTDeclarationStatement) s.getStatements()[1];
+ IASTCompoundStatement s = (IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[0]).getBody();
+ IASTDeclarationStatement ds = (IASTDeclarationStatement) s.getStatements()[1];
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) ds.getDeclaration();
IASTDeclarator dtor = decl.getDeclarators()[0];
@@ -824,145 +810,149 @@ public class CompleteParser2Tests extends BaseTestCase {
assertNotNull(dtor.getInitializer());
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 4);
- IVariable x = (IVariable) col.getName(1).resolveBinding();
- IVariable y = (IVariable) col.getName(2).resolveBinding();
- assertNotNull(y);
- assertInstances(col, x, 2);
+ assertEquals(col.size(), 4);
+ IVariable x = (IVariable) col.getName(1).resolveBinding();
+ IVariable y = (IVariable) col.getName(2).resolveBinding();
+ assertNotNull(y);
+ assertInstances(col, x, 2);
}
public void testNewXReferences() throws Exception {
IASTTranslationUnit tu = parse("const int max = 5;\n int * x = new int[max];");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 3);
- IVariable max = (IVariable) col.getName(0).resolveBinding();
- assertInstances(col, max, 2);
+ assertEquals(col.size(), 3);
+ IVariable max = (IVariable) col.getName(0).resolveBinding();
+ assertInstances(col, max, 2);
}
public void testQualifiedNameReferences() throws Exception {
// Used to cause AST Semantic exception
- IASTTranslationUnit tu = parse("class A{ class B{ class C { public: int cMethod(); }; }; }; \n int A::B::C::cMethod() {}; \n");
+ IASTTranslationUnit tu = parse(
+ "class A{ class B{ class C { public: int cMethod(); }; }; }; \n int A::B::C::cMethod() {}; \n");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 9);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPClassType B = (ICPPClassType) col.getName(1).resolveBinding();
- ICPPClassType C = (ICPPClassType) col.getName(2).resolveBinding();
- ICPPMethod cMethod = (ICPPMethod) col.getName(3).resolveBinding();
+ assertEquals(col.size(), 9);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPClassType B = (ICPPClassType) col.getName(1).resolveBinding();
+ ICPPClassType C = (ICPPClassType) col.getName(2).resolveBinding();
+ ICPPMethod cMethod = (ICPPMethod) col.getName(3).resolveBinding();
- assertInstances(col, A, 2);
- assertInstances(col, B, 2);
- assertInstances(col, C, 2);
- assertInstances(col, cMethod, 3);
- assertEquals(cMethod.getVisibility(), ICPPMember.v_public);
- assertSame(cMethod.getScope(), C.getCompositeScope());
- assertSame(C.getScope(), B.getCompositeScope());
- assertSame(B.getScope(), A.getCompositeScope());
+ assertInstances(col, A, 2);
+ assertInstances(col, B, 2);
+ assertInstances(col, C, 2);
+ assertInstances(col, cMethod, 3);
+ assertEquals(cMethod.getVisibility(), ICPPMember.v_public);
+ assertSame(cMethod.getScope(), C.getCompositeScope());
+ assertSame(C.getScope(), B.getCompositeScope());
+ assertSame(B.getScope(), A.getCompositeScope());
}
public void testIsConstructor() throws Exception {
IASTTranslationUnit tu = parse("class A{ public: A(); }; \n A::A() {}; \n");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 5);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPConstructor ctor = (ICPPConstructor) col.getName(1).resolveBinding();
+ assertEquals(col.size(), 5);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPConstructor ctor = (ICPPConstructor) col.getName(1).resolveBinding();
- assertInstances(col, A, 2);
- assertInstances(col, ctor, 3);
+ assertInstances(col, A, 2);
+ assertInstances(col, ctor, 3);
}
public void testIsDestructor() throws Exception {
IASTTranslationUnit tu = parse("class A{ public: ~A(); }; \n A::~A() {}; \n");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 5);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPMethod dtor = (ICPPMethod) col.getName(1).resolveBinding();
+ assertEquals(col.size(), 5);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPMethod dtor = (ICPPMethod) col.getName(1).resolveBinding();
- assertInstances(col, A, 2);
- assertInstances(col, dtor, 3);
+ assertInstances(col, A, 2);
+ assertInstances(col, dtor, 3);
}
public void testBug41445() throws Exception {
IASTTranslationUnit tu = parse("class A { }; namespace N { class B : public A { struct A {}; }; }");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 5);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPNamespace N = (ICPPNamespace) col.getName(1).resolveBinding();
- ICPPClassType B = (ICPPClassType) col.getName(2).resolveBinding();
- ICPPClassType A2 = (ICPPClassType) col.getName(4).resolveBinding();
+ assertEquals(col.size(), 5);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPNamespace N = (ICPPNamespace) col.getName(1).resolveBinding();
+ ICPPClassType B = (ICPPClassType) col.getName(2).resolveBinding();
+ ICPPClassType A2 = (ICPPClassType) col.getName(4).resolveBinding();
- assertInstances(col, A, 2);
- assertNotSame(A, A2);
- assertSame(A2.getScope(), B.getCompositeScope());
- assertSame(B.getScope(), N.getNamespaceScope());
- assertSame(B.getBases()[0].getBaseClass(), A);
+ assertInstances(col, A, 2);
+ assertNotSame(A, A2);
+ assertSame(A2.getScope(), B.getCompositeScope());
+ assertSame(B.getScope(), N.getNamespaceScope());
+ assertSame(B.getBases()[0].getBaseClass(), A);
}
public void testSimpleFunctionBody() throws Exception {
- IASTTranslationUnit tu = parse("class A { int f1(); }; const int x = 4; int f() { return x; } int A::f1() { return x; }");
+ IASTTranslationUnit tu = parse(
+ "class A { int f1(); }; const int x = 4; int f() { return x; } int A::f1() { return x; }");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 9);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPMethod f1 = (ICPPMethod) col.getName(1).resolveBinding();
- IVariable x = (IVariable) col.getName(2).resolveBinding();
+ assertEquals(col.size(), 9);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPMethod f1 = (ICPPMethod) col.getName(1).resolveBinding();
+ IVariable x = (IVariable) col.getName(2).resolveBinding();
- assertInstances(col, A, 2);
- assertInstances(col, f1, 3);
- assertInstances(col, x, 3);
+ assertInstances(col, A, 2);
+ assertInstances(col, f1, 3);
+ assertInstances(col, x, 3);
}
public void testSimpleForLoop() throws Exception {
- IASTTranslationUnit tu = parse("const int FIVE = 5; void f() { int x = 0; for (int i = 0; i < FIVE; ++i) { x += i; } }");
+ IASTTranslationUnit tu = parse(
+ "const int FIVE = 5; void f() { int x = 0; for (int i = 0; i < FIVE; ++i) { x += i; } }");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 9);
- IVariable FIVE = (IVariable) col.getName(0).resolveBinding();
- IVariable x = (IVariable) col.getName(2).resolveBinding();
- IVariable i = (IVariable) col.getName(3).resolveBinding();
+ assertEquals(col.size(), 9);
+ IVariable FIVE = (IVariable) col.getName(0).resolveBinding();
+ IVariable x = (IVariable) col.getName(2).resolveBinding();
+ IVariable i = (IVariable) col.getName(3).resolveBinding();
- assertInstances(col, FIVE, 2);
- assertInstances(col, x, 2);
- assertInstances(col, i, 4);
+ assertInstances(col, FIVE, 2);
+ assertInstances(col, x, 2);
+ assertInstances(col, i, 4);
}
public void testBug42541() throws Exception {
IASTTranslationUnit tu = parse("union{ int v; char a; } id;");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 4);
+ assertEquals(col.size(), 4);
- ICPPClassType unnamed = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPField v = (ICPPField) col.getName(1).resolveBinding();
- ICPPField a = (ICPPField) col.getName(2).resolveBinding();
- IVariable id = (IVariable) col.getName(3).resolveBinding();
+ ICPPClassType unnamed = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPField v = (ICPPField) col.getName(1).resolveBinding();
+ ICPPField a = (ICPPField) col.getName(2).resolveBinding();
+ IVariable id = (IVariable) col.getName(3).resolveBinding();
- assertEquals(unnamed.getKey(), ICompositeType.k_union);
- assertSame(v.getScope(), unnamed.getCompositeScope());
- assertSame(a.getScope(), unnamed.getCompositeScope());
- assertSame(id.getType(), unnamed);
+ assertEquals(unnamed.getKey(), ICompositeType.k_union);
+ assertSame(v.getScope(), unnamed.getCompositeScope());
+ assertSame(a.getScope(), unnamed.getCompositeScope());
+ assertSame(id.getType(), unnamed);
}
public void testSimpleIfStatement() throws Exception {
- IASTTranslationUnit tu =parse("const bool T = true; int foo() { if (T) { return 5; } else if (! T) return 20; else { return 10; } }");
+ IASTTranslationUnit tu = parse(
+ "const bool T = true; int foo() { if (T) { return 5; } else if (! T) return 20; else { return 10; } }");
IASTFunctionDefinition foo = (IASTFunctionDefinition) tu.getDeclarations()[1];
- IASTCompoundStatement compound = (IASTCompoundStatement) foo.getBody();
+ IASTCompoundStatement compound = (IASTCompoundStatement) foo.getBody();
IASTIfStatement ifstmt = (IASTIfStatement) compound.getStatements()[0];
assertTrue(ifstmt.getConditionExpression() instanceof IASTIdExpression);
assertTrue(ifstmt.getThenClause() instanceof IASTCompoundStatement);
@@ -973,62 +963,58 @@ public class CompleteParser2Tests extends BaseTestCase {
assertTrue(ifstmt.getElseClause() instanceof IASTCompoundStatement);
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 4);
+ assertEquals(col.size(), 4);
- IVariable T = (IVariable) col.getName(0).resolveBinding();
- assertInstances(col, T, 3);
+ IVariable T = (IVariable) col.getName(0).resolveBinding();
+ assertInstances(col, T, 3);
}
public void testSimpleWhileStatement() throws Exception {
- IASTTranslationUnit tu = parse("const bool T = true; void foo() { int x = 0; while(T) { ++x; if (x == 100) break; } }");
+ IASTTranslationUnit tu = parse(
+ "const bool T = true; void foo() { int x = 0; while(T) { ++x; if (x == 100) break; } }");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 6);
- IVariable T = (IVariable) col.getName(0).resolveBinding();
- IVariable x = (IVariable) col.getName(2).resolveBinding();
- assertInstances(col, T, 2);
- assertInstances(col, x, 3);
+ assertEquals(col.size(), 6);
+ IVariable T = (IVariable) col.getName(0).resolveBinding();
+ IVariable x = (IVariable) col.getName(2).resolveBinding();
+ assertInstances(col, T, 2);
+ assertInstances(col, x, 3);
}
public void testSimpleSwitchStatement() throws Exception {
- IASTTranslationUnit tu = parse("const int x = 5; const int y = 10; " +
- "void foo() { " +
- " while(true) { " +
- " switch(x) { " +
- " case 1: break; " +
- " case 2: goto blah; " +
- " case y: continue; " +
- " default: break; " +
- " } " +
- " } " +
- " blah : ; " +
- "} ");
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- assertEquals(col.size(), 7);
- IVariable x = (IVariable) col.getName(0).resolveBinding();
- IVariable y = (IVariable) col.getName(1).resolveBinding();
- ILabel blah = (ILabel) col.getName(4).resolveBinding();
- assertNotNull(blah);
- assertInstances(col, x, 2);
- assertInstances(col, y, 2);
- assertInstances(col, blah, 2);
+ IASTTranslationUnit tu = parse("const int x = 5; const int y = 10; " + "void foo() { "
+ + " while(true) { " + " switch(x) { "
+ + " case 1: break; " + " case 2: goto blah; "
+ + " case y: continue; " + " default: break; "
+ + " } " + " } "
+ + " blah : ; " + "} ");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ assertEquals(col.size(), 7);
+ IVariable x = (IVariable) col.getName(0).resolveBinding();
+ IVariable y = (IVariable) col.getName(1).resolveBinding();
+ ILabel blah = (ILabel) col.getName(4).resolveBinding();
+ assertNotNull(blah);
+ assertInstances(col, x, 2);
+ assertInstances(col, y, 2);
+ assertInstances(col, blah, 2);
}
public void testSimpleDoStatement() throws Exception {
- IASTTranslationUnit tu = parse("const int x = 3; int counter = 0; void foo() { do { ++counter; } while(counter != x); } ");
+ IASTTranslationUnit tu = parse(
+ "const int x = 3; int counter = 0; void foo() { do { ++counter; } while(counter != x); } ");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 6);
- IVariable x = (IVariable) col.getName(0).resolveBinding();
- IVariable counter = (IVariable) col.getName(1).resolveBinding();
- assertInstances(col, x, 2);
- assertInstances(col, counter, 3);
+ assertEquals(col.size(), 6);
+ IVariable x = (IVariable) col.getName(0).resolveBinding();
+ IVariable counter = (IVariable) col.getName(1).resolveBinding();
+ assertInstances(col, x, 2);
+ assertInstances(col, counter, 3);
}
public void testThrowStatement() throws Exception {
@@ -1045,75 +1031,77 @@ public class CompleteParser2Tests extends BaseTestCase {
}
public void testScoping() throws Exception {
- IASTTranslationUnit tu = parse("void foo() { int x = 3; if (x == 1) { int x = 4; } else int x = 2; }");
+ IASTTranslationUnit tu = parse("void foo() { int x = 3; if (x == 1) { int x = 4; } else int x = 2; }");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 5);
- IVariable x1 = (IVariable) col.getName(1).resolveBinding();
- IVariable x2 = (IVariable) col.getName(3).resolveBinding();
- IVariable x3 = (IVariable) col.getName(4).resolveBinding();
+ assertEquals(col.size(), 5);
+ IVariable x1 = (IVariable) col.getName(1).resolveBinding();
+ IVariable x2 = (IVariable) col.getName(3).resolveBinding();
+ IVariable x3 = (IVariable) col.getName(4).resolveBinding();
- assertInstances(col, x1, 2);
- assertInstances(col, x2, 1);
- assertInstances(col, x3, 1);
+ assertInstances(col, x1, 2);
+ assertInstances(col, x2, 1);
+ assertInstances(col, x3, 1);
}
public void testEnumeratorReferences() throws Exception {
- IASTTranslationUnit tu = parse("enum E { e1, e2, e3 }; E anE = e1;");
+ IASTTranslationUnit tu = parse("enum E { e1, e2, e3 }; E anE = e1;");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 7);
- IEnumeration E = (IEnumeration) col.getName(0).resolveBinding();
- IEnumerator e1 = (IEnumerator) col.getName(1).resolveBinding();
- IEnumerator e2 = (IEnumerator) col.getName(2).resolveBinding();
- IEnumerator e3 = (IEnumerator) col.getName(3).resolveBinding();
- IVariable anE = (IVariable) col.getName(5).resolveBinding();
+ assertEquals(col.size(), 7);
+ IEnumeration E = (IEnumeration) col.getName(0).resolveBinding();
+ IEnumerator e1 = (IEnumerator) col.getName(1).resolveBinding();
+ IEnumerator e2 = (IEnumerator) col.getName(2).resolveBinding();
+ IEnumerator e3 = (IEnumerator) col.getName(3).resolveBinding();
+ IVariable anE = (IVariable) col.getName(5).resolveBinding();
- assertInstances(col, E, 2);
- assertInstances(col, e1, 2);
- assertInstances(col, e2, 1);
- assertInstances(col, e3, 1);
- assertInstances(col, anE, 1);
+ assertInstances(col, E, 2);
+ assertInstances(col, e1, 2);
+ assertInstances(col, e2, 1);
+ assertInstances(col, e3, 1);
+ assertInstances(col, anE, 1);
}
public void testBug42840() throws Exception {
- IASTTranslationUnit tu = parse("void foo(); void foo() { } class SearchMe { };");
+ IASTTranslationUnit tu = parse("void foo(); void foo() { } class SearchMe { };");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 3);
- IFunction foo = (IFunction) col.getName(0).resolveBinding();
+ assertEquals(col.size(), 3);
+ IFunction foo = (IFunction) col.getName(0).resolveBinding();
- assertInstances(col, foo, 2);
+ assertInstances(col, foo, 2);
}
public void testBug42872() throws Exception {
- IASTTranslationUnit tu = parse("struct B {}; struct D : B {}; void foo(D* dp) { B* bp = dynamic_cast<B*>(dp); }");
+ IASTTranslationUnit tu = parse(
+ "struct B {}; struct D : B {}; void foo(D* dp) { B* bp = dynamic_cast<B*>(dp); }");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 10);
- ICompositeType B = (ICompositeType) col.getName(0).resolveBinding();
- ICompositeType D = (ICompositeType) col.getName(1).resolveBinding();
+ assertEquals(col.size(), 10);
+ ICompositeType B = (ICompositeType) col.getName(0).resolveBinding();
+ ICompositeType D = (ICompositeType) col.getName(1).resolveBinding();
- assertInstances(col, B, 4);
- assertInstances(col, D, 2);
+ assertInstances(col, B, 4);
+ assertInstances(col, D, 2);
}
public void testBug43503A() throws Exception {
- IASTTranslationUnit tu = parse("class SD_01 { void f_SD_01() {}}; int main(){ SD_01 * a = new SD_01(); a->f_SD_01(); } ");
+ IASTTranslationUnit tu = parse(
+ "class SD_01 { void f_SD_01() {}}; int main(){ SD_01 * a = new SD_01(); a->f_SD_01(); } ");
NameCollector col = new NameCollector(true);
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 9);
- ICPPClassType SD_01 = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPMethod f_SD_01 = (ICPPMethod) col.getName(1).resolveBinding();
- ICPPConstructor ctor = SD_01.getConstructors()[0];
- assertInstances(col, SD_01, 3);
- assertInstances(col, ctor, 1);
- assertInstances(col, f_SD_01, 2);
+ assertEquals(col.size(), 9);
+ ICPPClassType SD_01 = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPMethod f_SD_01 = (ICPPMethod) col.getName(1).resolveBinding();
+ ICPPConstructor ctor = SD_01.getConstructors()[0];
+ assertInstances(col, SD_01, 3);
+ assertInstances(col, ctor, 1);
+ assertInstances(col, f_SD_01, 2);
}
public void testBug42979() throws Exception {
@@ -1130,44 +1118,45 @@ public class CompleteParser2Tests extends BaseTestCase {
IASTTranslationUnit tu = parse(code.toString());
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 12);
- ICompositeType OperatorOverload = (ICompositeType) col.getName(0).resolveBinding();
- ICPPMethod op1 = (ICPPMethod) col.getName(1).resolveBinding();
- ICPPMethod op2 = (ICPPMethod) col.getName(4).resolveBinding();
+ assertEquals(col.size(), 12);
+ ICompositeType OperatorOverload = (ICompositeType) col.getName(0).resolveBinding();
+ ICPPMethod op1 = (ICPPMethod) col.getName(1).resolveBinding();
+ ICPPMethod op2 = (ICPPMethod) col.getName(4).resolveBinding();
- assertInstances(col, OperatorOverload, 5);
- assertInstances(col, op1, 1);
- assertInstances(col, op2, 3);
+ assertInstances(col, OperatorOverload, 5);
+ assertInstances(col, op1, 1);
+ assertInstances(col, op2, 3);
}
+
/**
* class A { static int x; } int A::x = 5;
*/
public void testBug43373() throws Exception {
- IASTTranslationUnit tu = parse("class A { static int x; }; int A::x = 5;");
+ IASTTranslationUnit tu = parse("class A { static int x; }; int A::x = 5;");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 5);
- ICompositeType A = (ICompositeType) col.getName(0).resolveBinding();
- ICPPField x = (ICPPField) col.getName(1).resolveBinding();
+ assertEquals(col.size(), 5);
+ ICompositeType A = (ICompositeType) col.getName(0).resolveBinding();
+ ICPPField x = (ICPPField) col.getName(1).resolveBinding();
- assertInstances(col, A, 2);
- assertInstances(col, x, 3);
+ assertInstances(col, A, 2);
+ assertInstances(col, x, 3);
}
public void testBug39504() throws Exception {
- IASTTranslationUnit tu = parse("const int w = 2; int x[ 5 ]; int y = sizeof (x[w]);");
+ IASTTranslationUnit tu = parse("const int w = 2; int x[ 5 ]; int y = sizeof (x[w]);");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 5);
- IVariable w = (IVariable) col.getName(0).resolveBinding();
- IVariable x = (IVariable) col.getName(1).resolveBinding();
+ assertEquals(col.size(), 5);
+ IVariable w = (IVariable) col.getName(0).resolveBinding();
+ IVariable x = (IVariable) col.getName(1).resolveBinding();
- assertInstances(col, w, 2);
- assertInstances(col, x, 2);
+ assertInstances(col, w, 2);
+ assertInstances(col, x, 2);
}
public void testBug43375() throws Exception {
@@ -1183,12 +1172,12 @@ public class CompleteParser2Tests extends BaseTestCase {
buff.append(" }; ");
buff.append("class SD_01 { \n");
buff.append(" public: \n");
- buff.append(" SD_02 *next; \n"); // REFERENCE SD_02
+ buff.append(" SD_02 *next; \n"); // REFERENCE SD_02
buff.append(" void f_SD_01(); \n");
buff.append("}; \n");
buff.append("int main(){ \n");
- buff.append(" SD_01* a = new SD_01(); \n"); // REFERENCE SD_01 * 2
- buff.append(" a->f_SD_01(); \n"); // REFERENCE a && REFERENCE f_SD_01
+ buff.append(" SD_01* a = new SD_01(); \n"); // REFERENCE SD_01 * 2
+ buff.append(" a->f_SD_01(); \n"); // REFERENCE a && REFERENCE f_SD_01
buff.append("} \n");
buff.append("void SD_01::f_SD_01() \n"); // REFERENCE SD_01
buff.append("{ \n");
@@ -1197,41 +1186,42 @@ public class CompleteParser2Tests extends BaseTestCase {
IASTTranslationUnit tu = parse(buff.toString());
NameCollector col = new NameCollector(true);
- tu.accept(col);
-
- assertEquals(col.size(), 18);
- ICompositeType SD_02 = (ICompositeType) col.getName(0).resolveBinding();
- ICPPMethod f_SD_02 = (ICPPMethod) col.getName(1).resolveBinding();
- ICPPClassType SD_01 = (ICPPClassType) col.getName(2).resolveBinding();
- ICPPField next = (ICPPField) col.getName(4).resolveBinding();
- ICPPMethod f_SD_01 = (ICPPMethod) col.getName(5).resolveBinding();
- ICPPConstructor ctor = SD_01.getConstructors()[0];
+ tu.accept(col);
- assertInstances(col, SD_02, 2);
- assertInstances(col, f_SD_02, 2);
- assertInstances(col, SD_01, 4);
- assertInstances(col, ctor, 1);
- assertInstances(col, next, 2);
- assertInstances(col, f_SD_01, 4);
+ assertEquals(col.size(), 18);
+ ICompositeType SD_02 = (ICompositeType) col.getName(0).resolveBinding();
+ ICPPMethod f_SD_02 = (ICPPMethod) col.getName(1).resolveBinding();
+ ICPPClassType SD_01 = (ICPPClassType) col.getName(2).resolveBinding();
+ ICPPField next = (ICPPField) col.getName(4).resolveBinding();
+ ICPPMethod f_SD_01 = (ICPPMethod) col.getName(5).resolveBinding();
+ ICPPConstructor ctor = SD_01.getConstructors()[0];
+
+ assertInstances(col, SD_02, 2);
+ assertInstances(col, f_SD_02, 2);
+ assertInstances(col, SD_01, 4);
+ assertInstances(col, ctor, 1);
+ assertInstances(col, next, 2);
+ assertInstances(col, f_SD_01, 4);
}
- public void testBug43679_A () throws Exception {
- IASTTranslationUnit tu = parse("struct Sample { int size() const; }; extern const Sample * getSample(); int trouble() { return getSample()->size(); } ");
+ public void testBug43679_A() throws Exception {
+ IASTTranslationUnit tu = parse(
+ "struct Sample { int size() const; }; extern const Sample * getSample(); int trouble() { return getSample()->size(); } ");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 7);
- ICompositeType sample = (ICompositeType) col.getName(0).resolveBinding();
- ICPPMethod size = (ICPPMethod) col.getName(1).resolveBinding();
- IFunction getSample = (IFunction) col.getName(3).resolveBinding();
+ assertEquals(col.size(), 7);
+ ICompositeType sample = (ICompositeType) col.getName(0).resolveBinding();
+ ICPPMethod size = (ICPPMethod) col.getName(1).resolveBinding();
+ IFunction getSample = (IFunction) col.getName(3).resolveBinding();
- assertInstances(col, sample, 2);
- assertInstances(col, size, 2);
- assertInstances(col, getSample, 2);
+ assertInstances(col, sample, 2);
+ assertInstances(col, size, 2);
+ assertInstances(col, getSample, 2);
}
- public void testBug43679_B () throws Exception {
- IASTTranslationUnit tu = parse("struct Sample{int size() const; }; struct Sample; ");
+ public void testBug43679_B() throws Exception {
+ IASTTranslationUnit tu = parse("struct Sample{int size() const; }; struct Sample; ");
NameCollector col = new NameCollector();
tu.accept(col);
@@ -1282,7 +1272,8 @@ public class CompleteParser2Tests extends BaseTestCase {
StringBuilder buffer = new StringBuilder();
buffer.append("struct Inner { int a,b,c; };");
buffer.append("struct A { int x; int y[]; struct Inner innerArray[]; int z[]; };");
- buffer.append("struct A myA = { .x = 4, .y[3] = 4, .y[4] = 3, .innerArray[0].a = 3, .innerArray[1].b = 5, .innerArray[2].c=6, .z = { 1,4,5} };");
+ buffer.append(
+ "struct A myA = { .x = 4, .y[3] = 4, .y[4] = 3, .innerArray[0].a = 3, .innerArray[1].b = 5, .innerArray[2].c=6, .z = { 1,4,5} };");
parse(buffer.toString(), true, ParserLanguage.C);
}
@@ -1291,7 +1282,7 @@ public class CompleteParser2Tests extends BaseTestCase {
}
public void testBug39551B() throws Exception {
- //this used to be 99.99 * __I__, but I don't know where the __I__ came from, its not in C99, nor in GCC
+ //this used to be 99.99 * __I__, but I don't know where the __I__ came from, its not in C99, nor in GCC
parse("_Imaginary double id = 99.99 * 1i;", true, ParserLanguage.C);
}
@@ -1300,21 +1291,13 @@ public class CompleteParser2Tests extends BaseTestCase {
}
public void testCBoolAsParameter() throws Exception {
- parse("void f(_Bool b) {} " +
- "_Bool g(_Bool b) {} " +
- "void main(){" +
- " _Bool b; " +
- " f(b);" +
- " f(g((_Bool) 1) );" +
- "}",
- true, ParserLanguage.C);
+ parse("void f(_Bool b) {} " + "_Bool g(_Bool b) {} " + "void main(){" + " _Bool b; " + " f(b);"
+ + " f(g((_Bool) 1) );" + "}", true, ParserLanguage.C);
}
public void testBug44510() throws Exception {
- IASTTranslationUnit tu = parse("int initialize(); " +
- "int initialize(char){} " +
- "int initialize(){ return 1; } " +
- "void main(){ int i = initialize(); }");
+ IASTTranslationUnit tu = parse("int initialize(); " + "int initialize(char){} "
+ + "int initialize(){ return 1; } " + "void main(){ int i = initialize(); }");
NameCollector col = new NameCollector();
tu.accept(col);
@@ -1343,7 +1326,7 @@ public class CompleteParser2Tests extends BaseTestCase {
IVariable obj1 = (IVariable) col.getName(2).resolveBinding();
IEnumeration myEnum = (IEnumeration) col.getName(3).resolveBinding();
IEnumerator item = (IEnumerator) col.getName(4).resolveBinding();
- IVariable obj2 = (IVariable)col.getName(6).resolveBinding();
+ IVariable obj2 = (IVariable) col.getName(6).resolveBinding();
assertInstances(col, myClass, 2);
assertInstances(col, myEnum, 2);
@@ -1465,7 +1448,7 @@ public class CompleteParser2Tests extends BaseTestCase {
assertInstances(col, foo, 2);
}
- public void testErrorHandling_1() throws Exception {
+ public void testErrorHandling_1() throws Exception {
IASTTranslationUnit tu = parse("A anA; int x = c; class A {}; A * anotherA = &anA; int b;", false);
NameCollector col = new NameCollector();
@@ -1484,13 +1467,13 @@ public class CompleteParser2Tests extends BaseTestCase {
assertNotNull(p);
assertNotNull(p2);
- IProblemType pt= (IProblemType) anA.getType();
+ IProblemType pt = (IProblemType) anA.getType();
assertEquals(ISemanticProblem.TYPE_UNRESOLVED_NAME, pt.getID());
}
public void testBug44340() throws Exception {
// Inline function with reference to variables declared after them
- IASTTranslationUnit tu = parse ("class A{ int getX() {return x[1];} int x[10];};");
+ IASTTranslationUnit tu = parse("class A{ int getX() {return x[1];} int x[10];};");
NameCollector col = new NameCollector();
tu.accept(col);
@@ -1520,9 +1503,9 @@ public class CompleteParser2Tests extends BaseTestCase {
assertEquals(col.size(), 4);
IFunction f1 = (IFunction) col.getName(0).resolveBinding();
- IParameter p1 = (IParameter)col.getName(1).resolveBinding();
+ IParameter p1 = (IParameter) col.getName(1).resolveBinding();
IFunction f2 = (IFunction) col.getName(2).resolveBinding();
- IParameter p2 = (IParameter)col.getName(3).resolveBinding();
+ IParameter p2 = (IParameter) col.getName(3).resolveBinding();
assertSame(f1, f2);
assertSame(p1, p2);
}
@@ -1538,9 +1521,9 @@ public class CompleteParser2Tests extends BaseTestCase {
assertEquals(col.size(), 4);
IFunction f1 = (IFunction) col.getName(0).resolveBinding();
- IParameter p1 = (IParameter)col.getName(1).resolveBinding();
+ IParameter p1 = (IParameter) col.getName(1).resolveBinding();
IFunction f2 = (IFunction) col.getName(2).resolveBinding();
- IParameter p2 = (IParameter)col.getName(3).resolveBinding();
+ IParameter p2 = (IParameter) col.getName(3).resolveBinding();
assertNotSame(f1, f2);
assertNotSame(p1, p2);
@@ -1558,12 +1541,12 @@ public class CompleteParser2Tests extends BaseTestCase {
IEnumeration _A = (IEnumeration) col.getName(0).resolveBinding();
ITypedef A = (ITypedef) col.getName(1).resolveBinding();
- ITypedef pA = (ITypedef)col.getName(2).resolveBinding();
+ ITypedef pA = (ITypedef) col.getName(2).resolveBinding();
assertNotNull(_A);
assertSame(A.getType(), _A);
assertTrue(pA.getType() instanceof IPointerType);
- assertSame(((IPointerType)pA.getType()).getType(), _A);
+ assertSame(((IPointerType) pA.getType()).getType(), _A);
}
public void testBug55163() throws Exception {
@@ -1579,14 +1562,15 @@ public class CompleteParser2Tests extends BaseTestCase {
tu.accept(col);
assertEquals(col.size(), 11);
- IVariable i = (IVariable)col.getName(1).resolveBinding();
- IVariable n = (IVariable)col.getName(2).resolveBinding();
- IVariable di = (IVariable)col.getName(3).resolveBinding();
+ IVariable i = (IVariable) col.getName(1).resolveBinding();
+ IVariable n = (IVariable) col.getName(2).resolveBinding();
+ IVariable di = (IVariable) col.getName(3).resolveBinding();
assertInstances(col, i, 6);
assertInstances(col, n, 2);
assertInstances(col, di, 2);
}
+
public void testBug55673() throws Exception {
Writer writer = new StringWriter();
writer.write("struct Example { int i; int (* pfi) (int); }; ");
@@ -1597,11 +1581,11 @@ public class CompleteParser2Tests extends BaseTestCase {
tu.accept(col);
assertEquals(col.size(), 4);
- ICPPField pfi = (ICPPField)col.getName(2).resolveBinding();
+ ICPPField pfi = (ICPPField) col.getName(2).resolveBinding();
assertNotNull(pfi);
assertTrue(pfi.getType() instanceof IPointerType);
- assertTrue(((IPointerType)pfi.getType()).getType() instanceof IFunctionType);
+ assertTrue(((IPointerType) pfi.getType()).getType() instanceof IFunctionType);
}
public void testBug54531() throws Exception {
@@ -1676,7 +1660,7 @@ public class CompleteParser2Tests extends BaseTestCase {
}
public void testBug57800() throws Exception {
- Writer writer= new StringWriter();
+ Writer writer = new StringWriter();
writer.write("class G2 { int j; };");
writer.write("typedef G2 AltG2;");
writer.write("class AltG3 : AltG2 { int x;};");
@@ -1739,144 +1723,143 @@ public class CompleteParser2Tests extends BaseTestCase {
parse(writer.toString());
}
- public void testBug59302() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class A { class N{}; }; ");
- writer.write("class B { friend class A::N; }; ");
- parse(writer.toString());
- }
-
- public void testULong() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#ifndef ASMINCLUDE\n");
- writer.write("typedef unsigned short ushort;\n");
- writer.write("typedef volatile unsigned long semaphore;\n");
- writer.write("typedef unsigned long ulong;\n");
- writer.write("#ifndef _NO_LONGLONG\n");
- writer.write("typedef long long longlong;\n");
- writer.write("typedef unsigned long long ulonglong;\n");
- writer.write("#endif /* _NO_LONGLONG */\n");
- writer.write("#endif /* ASMINCLUDE */\n");
- writer.write("typedef struct section_type_ {\n");
- writer.write("ulong source;\n");
- writer.write("ulong dest;\n");
- writer.write("ulong bytes;\n");
- writer.write("} section_type;\n");
- parse(writer.toString());
- }
-
- public void testBug47926() throws Exception {
- parse("void f() {} class A {}; void main() { A * a = new A(); a->f(); }", false);
- }
-
- public void testBug50984_ASTMethod_getOwnerClassSpecifier_ClassCastException() throws Exception {
- Writer writer = new StringWriter();
- writer.write("template < typename _OutIter > ");
- writer.write("class num_put { ");
- writer.write(" typedef _OutIter iter_type; ");
- writer.write(" template< typename _ValueT > ");
- writer.write(" iter_type _M_convert_float(iter_type); ");
- writer.write("}; ");
- writer.write("template < typename _OutIter > ");
- writer.write("template < typename _ValueT > ");
- writer.write("_OutIter num_put<_OutIter>::_M_convert_float(_OutIter) { } ");
- parse(writer.toString());
- }
-
- public void testGloballyQualifiedUsingDeclaration() throws Exception {
+ public void testBug59302() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class A { class N{}; }; ");
+ writer.write("class B { friend class A::N; }; ");
+ parse(writer.toString());
+ }
+
+ public void testULong() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#ifndef ASMINCLUDE\n");
+ writer.write("typedef unsigned short ushort;\n");
+ writer.write("typedef volatile unsigned long semaphore;\n");
+ writer.write("typedef unsigned long ulong;\n");
+ writer.write("#ifndef _NO_LONGLONG\n");
+ writer.write("typedef long long longlong;\n");
+ writer.write("typedef unsigned long long ulonglong;\n");
+ writer.write("#endif /* _NO_LONGLONG */\n");
+ writer.write("#endif /* ASMINCLUDE */\n");
+ writer.write("typedef struct section_type_ {\n");
+ writer.write("ulong source;\n");
+ writer.write("ulong dest;\n");
+ writer.write("ulong bytes;\n");
+ writer.write("} section_type;\n");
+ parse(writer.toString());
+ }
+
+ public void testBug47926() throws Exception {
+ parse("void f() {} class A {}; void main() { A * a = new A(); a->f(); }", false);
+ }
+
+ public void testBug50984_ASTMethod_getOwnerClassSpecifier_ClassCastException() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("template < typename _OutIter > ");
+ writer.write("class num_put { ");
+ writer.write(" typedef _OutIter iter_type; ");
+ writer.write(" template< typename _ValueT > ");
+ writer.write(" iter_type _M_convert_float(iter_type); ");
+ writer.write("}; ");
+ writer.write("template < typename _OutIter > ");
+ writer.write("template < typename _ValueT > ");
+ writer.write("_OutIter num_put<_OutIter>::_M_convert_float(_OutIter) { } ");
+ parse(writer.toString());
+ }
+
+ public void testGloballyQualifiedUsingDeclaration() throws Exception {
parse("int iii; namespace N { using ::iii; }");
}
- public void test57513_new() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class A{ A(); A(int); }; \n");
- writer.write(" void f() { \n");
- writer.write(" A * a1 = new A; \n");
- writer.write(" A * a2 = new(1)A(); \n");
- writer.write(" A * a3 = new A(1); \n");
- writer.write("} \n");
+ public void test57513_new() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class A{ A(); A(int); }; \n");
+ writer.write(" void f() { \n");
+ writer.write(" A * a1 = new A; \n");
+ writer.write(" A * a2 = new(1)A(); \n");
+ writer.write(" A * a3 = new A(1); \n");
+ writer.write("} \n");
- parse(writer.toString());
+ parse(writer.toString());
}
- public void test57513_NoConstructor() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class A{ }; \n");
- writer.write(" void f() { \n");
- writer.write(" A * a1 = new A; \n");
- writer.write("} \n");
+ public void test57513_NoConstructor() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class A{ }; \n");
+ writer.write(" void f() { \n");
+ writer.write(" A * a1 = new A; \n");
+ writer.write("} \n");
- parse(writer.toString());
+ parse(writer.toString());
}
- public void test57513_ctorinit() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class A{ A(); A(A *); }; \n");
- writer.write("class B : public A { B(); }; \n");
- writer.write("B::B():A(new A){} \n");
+ public void test57513_ctorinit() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class A{ A(); A(A *); }; \n");
+ writer.write("class B : public A { B(); }; \n");
+ writer.write("B::B():A(new A){} \n");
- parse(writer.toString());
- }
+ parse(writer.toString());
+ }
- public void test575513_qualified() throws Exception {
- Writer writer = new StringWriter();
- writer.write("namespace Foo{ ");
- writer.write(" class Bar{ public : Bar(); }; ");
- writer.write("} ");
- writer.write("void main(){ ");
- writer.write(" Foo::Bar * bar = new Foo::Bar(); ");
- writer.write("} ");
+ public void test575513_qualified() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("namespace Foo{ ");
+ writer.write(" class Bar{ public : Bar(); }; ");
+ writer.write("} ");
+ writer.write("void main(){ ");
+ writer.write(" Foo::Bar * bar = new Foo::Bar(); ");
+ writer.write("} ");
- parse(writer.toString());
+ parse(writer.toString());
}
- public void testBug60944() throws Exception {
- Writer writer = new StringWriter();
- writer.write("typedef int OurInt;\n");
- writer.write("class A { int x; };\n");
- writer.write("typedef A AnotherA;\n");
- writer.write("typedef AnotherA SecondA;\n");
- writer.write("typedef OurInt AnotherInt;\n");
- parse(writer.toString());
+ public void testBug60944() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("typedef int OurInt;\n");
+ writer.write("class A { int x; };\n");
+ writer.write("typedef A AnotherA;\n");
+ writer.write("typedef AnotherA SecondA;\n");
+ writer.write("typedef OurInt AnotherInt;\n");
+ parse(writer.toString());
}
- public void testDestructorReference() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class ABC {\n");
- writer.write(" public:\n");
- writer.write(" ~ABC(){ }\n");
- writer.write("};\n");
- writer.write("int main() { ABC * abc = new ABC();\n");
- writer.write("abc->~ABC();\n");
- writer.write("}\n");
+ public void testDestructorReference() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class ABC {\n");
+ writer.write(" public:\n");
+ writer.write(" ~ABC(){ }\n");
+ writer.write("};\n");
+ writer.write("int main() { ABC * abc = new ABC();\n");
+ writer.write("abc->~ABC();\n");
+ writer.write("}\n");
parse(writer.toString());
- }
-
- public void testBug39676_tough() throws Exception {
- parse("int widths[] = {[0 ... 9] = 1,[10 ... 99] = 2,[100] = 3 };", true, ParserLanguage.C, true);
- }
-
- public void testBug60939() throws Exception {
- for (int i = 0; i < 2; ++i)
- {
- Writer writer = new StringWriter();
- writer.write("namespace ABC { class DEF { }; }\n");
- if (i == 0)
- writer.write("using namespace ABC;\n");
- else
- writer.write("using ABC::DEF;\n");
- writer.write("class GHI : public DEF { };");
- parse(writer.toString());
- }
- }
-
- public void testBug64010() throws Exception {
- Writer writer = new StringWriter();
- writer.write(" #define ONE else if (0) { } \n");
- writer.write(" #define TEN ONE ONE ONE ONE ONE ONE ONE ONE ONE ONE \n ");
- writer.write(" #define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN \n ");
- writer.write(" #define THOU HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN \n");
+ }
+
+ public void testBug39676_tough() throws Exception {
+ parse("int widths[] = {[0 ... 9] = 1,[10 ... 99] = 2,[100] = 3 };", true, ParserLanguage.C, true);
+ }
+
+ public void testBug60939() throws Exception {
+ for (int i = 0; i < 2; ++i) {
+ Writer writer = new StringWriter();
+ writer.write("namespace ABC { class DEF { }; }\n");
+ if (i == 0)
+ writer.write("using namespace ABC;\n");
+ else
+ writer.write("using ABC::DEF;\n");
+ writer.write("class GHI : public DEF { };");
+ parse(writer.toString());
+ }
+ }
+
+ public void testBug64010() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write(" #define ONE else if (0) { } \n");
+ writer.write(" #define TEN ONE ONE ONE ONE ONE ONE ONE ONE ONE ONE \n ");
+ writer.write(" #define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN \n ");
+ writer.write(" #define THOU HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN \n");
writer.write("void foo() ");
writer.write("{ ");
writer.write(" if (0) { } ");
@@ -1887,7 +1870,7 @@ public class CompleteParser2Tests extends BaseTestCase {
parse(writer.toString());
}
- public void testBug64271() throws Exception {
+ public void testBug64271() throws Exception {
Writer writer = new StringWriter();
writer.write("typedef int DWORD;\n");
writer.write("typedef char BYTE;\n");
@@ -1903,32 +1886,33 @@ public class CompleteParser2Tests extends BaseTestCase {
parse(writer.toString());
}
- public void testBug47752() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class BBC\n");
- writer.write("{\n");
- writer.write("int x;\n");
- writer.write("};\n");
- writer.write("void func(BBC bar)\n");
- writer.write("try\n");
- writer.write("{\n");
- writer.write("}\n");
- writer.write("catch (BBC error)\n");
- writer.write("{\n");
- writer.write(" //... error handling code ...\n");
- writer.write("}\n");
- parse(writer.toString());
+ public void testBug47752() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class BBC\n");
+ writer.write("{\n");
+ writer.write("int x;\n");
+ writer.write("};\n");
+ writer.write("void func(BBC bar)\n");
+ writer.write("try\n");
+ writer.write("{\n");
+ writer.write("}\n");
+ writer.write("catch (BBC error)\n");
+ writer.write("{\n");
+ writer.write(" //... error handling code ...\n");
+ writer.write("}\n");
+ parse(writer.toString());
}
- public void testBug61972() throws Exception {
- parse("#define DEF1(A1) A1\n#define DEF2 DEF1(DEF2)\nDEF2;", false);
+
+ public void testBug61972() throws Exception {
+ parse("#define DEF1(A1) A1\n#define DEF2 DEF1(DEF2)\nDEF2;", false);
}
- public void testBug65569() throws Exception {
- parse("class Sample;\nstruct Sample { /* ... */ };");
+ public void testBug65569() throws Exception {
+ parse("class Sample;\nstruct Sample { /* ... */ };");
}
- public void testBug64268() throws Exception {
- Writer writer = new StringWriter();
+ public void testBug64268() throws Exception {
+ Writer writer = new StringWriter();
writer.write("#define BODY \\\n");
writer.write("for (;;) { \\\n");
writer.write("/* this multi-line comment messes \\\n");
@@ -1939,117 +1923,117 @@ public class CompleteParser2Tests extends BaseTestCase {
parse(writer.toString());
}
- public void testBug67622() throws Exception {
- parse("const char * x = __FILE__;");
- }
-
- public void testBug67680() throws Exception {
- Writer writer = new StringWriter();
- writer.write("template < class T> class Base {}; \n");
- writer.write("class Derived : public Base, Base<int>, foo {}; \n");
-
- parse(writer.toString(), false);
- }
-
- public void testTypeIDSignature() throws Exception {
- parse("int * v = (int*)0;");//$NON-NLS-1$
- }
-
- public void testUnaryAmperCast() throws Exception {
- Writer writer = new StringWriter();
- writer.write("void f(char *); \r\n ");
- writer.write("void f(char ); \n ");
- writer.write("void main() { \n ");
- writer.write(" char * t = new char[ 5 ]; \n ");
- writer.write(" f(&t[1]); \n ");
- writer.write("} \n ");
-
- parse(writer.toString());
- }
-
- public void testBug68235() throws Exception {
- Writer writer = new StringWriter();
- writer.write(" struct xTag { int x; }; ");
- writer.write(" typedef xTag xType; ");
- writer.write(" typedef struct yTag { int x; } yType; ");
- writer.write(" class C1 { xType x; yType y; }; ");
-
- parse(writer.toString());
- }
-
- public void testBug60407() throws Exception {
- Writer writer = new StringWriter();
- writer.write("struct ZZZ { int x, y, z; };\r\n");
- writer.write("typedef struct ZZZ _FILE;\n");
- writer.write("typedef _FILE FILE;\n");
- writer.write("static void static_function(FILE * lcd){}\n");
- writer.write("int main(int argc, char **argv) {\n");
- writer.write("FILE * file = 0;\n");
- writer.write("static_function(file);\n");
- writer.write("return 0;\n");
- writer.write("}\n");
- parse(writer.toString());
- }
-
- public void testBug68623() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class A { \n");
- writer.write(" A(); \n");
- writer.write(" class sub{}; \n");
- writer.write(" sub * x; \n");
- writer.write("}; \n");
- writer.write("A::A() : x((sub *) 0) {} \n");
-
- parse(writer.toString());
-
- writer = new StringWriter();
- writer.write("class A { \n");
- writer.write(" A() : x (0) {} \n");
- writer.write(" int x; \n");
- writer.write("}; \n");
-
- parse(writer.toString());
- }
-
- public void testBug69798() throws Exception {
- Writer writer = new StringWriter();
- writer.write("enum Flags { FLAG1, FLAG2 }; \n");
- writer.write("int f() { int a, b; b = (a ? FLAG1 : 0) | FLAG2; } \n");
-
- parse(writer.toString());
- }
-
- public void testBug69662() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class A { operator float * (); }; \n");
- writer.write("A::operator float * () { } \n");
-
- parse(writer.toString());
- }
-
- public void testBug68528() throws Exception {
- Writer writer = new StringWriter();
- writer.write("namespace N526026\n");
- writer.write("{\n");
- writer.write("template <typename T>\n");
- writer.write("class T526026\n");
- writer.write("{\n");
- writer.write("typedef int diff;\n");
- writer.write("};\n");
- writer.write("\n");
- writer.write("template<typename T>\n");
- writer.write("inline T526026< T >\n");
- writer.write("operator+(typename T526026<T>::diff d, const T526026<T> & x)\n");
- writer.write("{ return T526026< T >(); }\n");
- writer.write("}\n");
- parse(writer.toString(), false);
- }
-
- public void testBug71094() throws Exception {
- Writer writer = new StringWriter();
- writer.write("using namespace DOESNOTEXIST;\n");
- writer.write("class A { int x; };\n");
- parse(writer.toString(), false);
+ public void testBug67622() throws Exception {
+ parse("const char * x = __FILE__;");
+ }
+
+ public void testBug67680() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("template < class T> class Base {}; \n");
+ writer.write("class Derived : public Base, Base<int>, foo {}; \n");
+
+ parse(writer.toString(), false);
+ }
+
+ public void testTypeIDSignature() throws Exception {
+ parse("int * v = (int*)0;");//$NON-NLS-1$
+ }
+
+ public void testUnaryAmperCast() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("void f(char *); \r\n ");
+ writer.write("void f(char ); \n ");
+ writer.write("void main() { \n ");
+ writer.write(" char * t = new char[ 5 ]; \n ");
+ writer.write(" f(&t[1]); \n ");
+ writer.write("} \n ");
+
+ parse(writer.toString());
+ }
+
+ public void testBug68235() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write(" struct xTag { int x; }; ");
+ writer.write(" typedef xTag xType; ");
+ writer.write(" typedef struct yTag { int x; } yType; ");
+ writer.write(" class C1 { xType x; yType y; }; ");
+
+ parse(writer.toString());
+ }
+
+ public void testBug60407() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("struct ZZZ { int x, y, z; };\r\n");
+ writer.write("typedef struct ZZZ _FILE;\n");
+ writer.write("typedef _FILE FILE;\n");
+ writer.write("static void static_function(FILE * lcd){}\n");
+ writer.write("int main(int argc, char **argv) {\n");
+ writer.write("FILE * file = 0;\n");
+ writer.write("static_function(file);\n");
+ writer.write("return 0;\n");
+ writer.write("}\n");
+ parse(writer.toString());
+ }
+
+ public void testBug68623() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class A { \n");
+ writer.write(" A(); \n");
+ writer.write(" class sub{}; \n");
+ writer.write(" sub * x; \n");
+ writer.write("}; \n");
+ writer.write("A::A() : x((sub *) 0) {} \n");
+
+ parse(writer.toString());
+
+ writer = new StringWriter();
+ writer.write("class A { \n");
+ writer.write(" A() : x (0) {} \n");
+ writer.write(" int x; \n");
+ writer.write("}; \n");
+
+ parse(writer.toString());
+ }
+
+ public void testBug69798() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("enum Flags { FLAG1, FLAG2 }; \n");
+ writer.write("int f() { int a, b; b = (a ? FLAG1 : 0) | FLAG2; } \n");
+
+ parse(writer.toString());
+ }
+
+ public void testBug69662() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class A { operator float * (); }; \n");
+ writer.write("A::operator float * () { } \n");
+
+ parse(writer.toString());
+ }
+
+ public void testBug68528() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("namespace N526026\n");
+ writer.write("{\n");
+ writer.write("template <typename T>\n");
+ writer.write("class T526026\n");
+ writer.write("{\n");
+ writer.write("typedef int diff;\n");
+ writer.write("};\n");
+ writer.write("\n");
+ writer.write("template<typename T>\n");
+ writer.write("inline T526026< T >\n");
+ writer.write("operator+(typename T526026<T>::diff d, const T526026<T> & x)\n");
+ writer.write("{ return T526026< T >(); }\n");
+ writer.write("}\n");
+ parse(writer.toString(), false);
+ }
+
+ public void testBug71094() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("using namespace DOESNOTEXIST;\n");
+ writer.write("class A { int x; };\n");
+ parse(writer.toString(), false);
}
public void testPredefinedSymbol_bug70928() throws Exception {
@@ -2084,9 +2068,9 @@ public class CompleteParser2Tests extends BaseTestCase {
writer.write("int func3 (void) __attribute__((id,id (3)));\n");
writer.write("int func4 (void) __attribute__((id,id (1+2)));\n");
writer.write("void (****f1)(void) __attribute__((noreturn));\n");
- writer.write("void (__attribute__((noreturn)) ****f2) (void);\n");
- writer.write("char *__attribute__((aligned(8))) *f3;\n");
- writer.write("char * __attribute__((aligned(8))) * f3;\n");
+ writer.write("void (__attribute__((noreturn)) ****f2) (void);\n");
+ writer.write("char *__attribute__((aligned(8))) *f3;\n");
+ writer.write("char * __attribute__((aligned(8))) * f3;\n");
writer.write("void fatal1 () __attribute__ ((noreturn));\n");
writer.write("int square1 (int) __attribute__ ((pure));\n");
writer.write("extern int\n");
@@ -2158,166 +2142,165 @@ public class CompleteParser2Tests extends BaseTestCase {
parse(writer.toString(), true, ParserLanguage.CPP, true);
}
- public void testBug73652() throws Exception {
- StringWriter writer = new StringWriter();
- writer.write("#define DoSuperMethodA IDoSuperMethodA\n");
- writer.write("#define IDoSuperMethodA(a,b,c) IIntuition->IDoSuperMethodA(a,b,c)\n");
+ public void testBug73652() throws Exception {
+ StringWriter writer = new StringWriter();
+ writer.write("#define DoSuperMethodA IDoSuperMethodA\n");
+ writer.write("#define IDoSuperMethodA(a,b,c) IIntuition->IDoSuperMethodA(a,b,c)\n");
writer.write("void hang(void)\n");
writer.write("{\n");
writer.write("DoSuperMethodA(0,0,0);\n");
writer.write("}\n");
- parse(writer.toString() , false);
- }
-
- public void testBug73428() throws Exception {
- parse("namespace { }");//$NON-NLS-1$
- parse("namespace { };");//$NON-NLS-1$
- parse("namespace { int abc; };");//$NON-NLS-1$
- parse("namespace { int abc; }");//$NON-NLS-1$
- }
-
- public void testBug73615() throws Exception {
- for (int i = 0; i < 2; ++i) {
- StringWriter writer = new StringWriter();
- if (i == 0)
- writer.write("class B;\n");
- writer.write("class A { A(B *); };\n");
- if (i == 0)
- parse(writer.toString());
- else
- parse(writer.toString(), false);
- }
- }
-
- public void testBug74180() throws Exception {
- parse("enum DHCPFOBoolean { false, true } additionalHB, more_payload; \n", true,
- ParserLanguage.C);
- }
-
- public void testBug72691() throws Exception {
- StringWriter writer = new StringWriter();
- writer.write("typedef int * PINT; \n");
- writer.write("typedef int * PINT; \n");
- writer.write("PINT pint; \n");
- parse(writer.toString());
- }
-
- public void testBug72691_2() throws Exception {
- StringWriter writer = new StringWriter();
- writer.write("typedef int * PINT; \n");
- writer.write("namespace N { \n");
- writer.write(" typedef int * PINT; \n");
- writer.write("} \n");
- writer.write("using namespace N; \n");
- writer.write("PINT pint; \n");
- parse(writer.toString());
- }
-
- public void testBug74328() throws Exception {
- Writer writer = new StringWriter();
- writer.write("int\n");
- writer.write("main(int argc, char **argv) {\n");
- writer.write(" char *sign;\n");
- writer.write("sign = \"\"; // IProblem generated here, syntax error\n");
- writer.write("return argc;\n");
- writer.write("}\n");
- parse(writer.toString());
- }
-
- public void testBug71733() throws Exception {
- Writer writer = new StringWriter();
- writer.write("void foo(int);\n");
- writer.write("#define BLAH() \\\n");
- writer.write(" foo (/* slash / is misinterpreted as end of comment */ \\\n");
- writer.write(" 4);\n");
- writer.write("int f() { BLAH() }\n");
- parse(writer.toString());
- }
-
- public void testBug69526() throws Exception {
- Writer writer = new StringWriter();
- writer.write("unsigned inkernel;\n");
- writer.write("#define lock_kernel() (inkernel |= 0x01)");
- writer.write("int main(int argc, char **argv) {");
- writer.write("lock_kernel();");
- writer.write("}");
- parse(writer.toString());
- }
-
- public void testBug69454() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#define CATCH_ALL_EXCEPTIONS() \\\n");
- writer.write(" catch(Exception &ex) { handleException(ex); } \\\n");
- writer.write(" catch(...) { handleException(); } \n");
- writer.write("class Exception; \n");
- writer.write("void handleException(Exception & ex) {} \n");
- writer.write("void handleException() {} \n");
- writer.write("void f() { \n");
- writer.write(" try { int i; } \n");
- writer.write(" CATCH_ALL_EXCEPTIONS(); \n");
- writer.write("} \n");
-
- parse(writer.toString());
- }
-
- public void testBug72692A() throws Exception {
- Writer writer = new StringWriter();
- writer.write("extern double pow(double, double);\n");
- writer.write("extern double pow2(double, double){}\n");
- writer.write("namespace DS {\n");
- writer.write("using ::pow;\n");
- writer.write("using ::pow2;\n");
- writer.write("}\n");
- writer.write("using DS::pow;\n");
- writer.write("using DS::pow2;\n");
- parse(writer.toString());
- }
-
- public void testBug72692B() throws Exception {
- Writer writer = new StringWriter();
- writer.write("extern double pow(double, double);\n");
- writer.write("namespace DS {\n");
- writer.write("using ::pow;\n");
- writer.write("inline float pow(float __x, float __y)\n");
- writer.write("{ return ::pow(static_cast<double>(__x), static_cast<double>(__y)); }\n");
- writer.write("}\n");
- writer.write("using namespace DS;\n");
- writer.write("float foo() { double d1 = 3.0, d2 = 4.0; return pow(d1, d2); }");
- parse(writer.toString());
- }
-
- public void testBug72692C() throws Exception {
- Writer writer = new StringWriter();
- writer.write("extern double pow(double, double){}\n");
- writer.write("namespace DS {\n");
- writer.write("using ::pow;\n");
- writer.write("}\n");
- writer.write("using DS::pow;\n");
- parse(writer.toString());
- }
-
- public void testBug74575A() throws Exception {
- Writer writer = new StringWriter();
- writer.write("double pow(double, double);\n");
- writer.write("float pow(float __x, float __y)\n");
- writer.write("{ return 0; }\n");
- parse(writer.toString());
- }
-
- public void testBug75338() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class Thrown { };\n");
- writer.write("void foo() throw(Thrown);");
- parse(writer.toString());
- }
-
- public void testBug74847() throws Exception {
- String code = "class A : public FOO {};";
- parse(code, false);
- }
-
- public void testBug76696() throws Exception {
- Writer writer = new StringWriter();
+ parse(writer.toString(), false);
+ }
+
+ public void testBug73428() throws Exception {
+ parse("namespace { }");//$NON-NLS-1$
+ parse("namespace { };");//$NON-NLS-1$
+ parse("namespace { int abc; };");//$NON-NLS-1$
+ parse("namespace { int abc; }");//$NON-NLS-1$
+ }
+
+ public void testBug73615() throws Exception {
+ for (int i = 0; i < 2; ++i) {
+ StringWriter writer = new StringWriter();
+ if (i == 0)
+ writer.write("class B;\n");
+ writer.write("class A { A(B *); };\n");
+ if (i == 0)
+ parse(writer.toString());
+ else
+ parse(writer.toString(), false);
+ }
+ }
+
+ public void testBug74180() throws Exception {
+ parse("enum DHCPFOBoolean { false, true } additionalHB, more_payload; \n", true, ParserLanguage.C);
+ }
+
+ public void testBug72691() throws Exception {
+ StringWriter writer = new StringWriter();
+ writer.write("typedef int * PINT; \n");
+ writer.write("typedef int * PINT; \n");
+ writer.write("PINT pint; \n");
+ parse(writer.toString());
+ }
+
+ public void testBug72691_2() throws Exception {
+ StringWriter writer = new StringWriter();
+ writer.write("typedef int * PINT; \n");
+ writer.write("namespace N { \n");
+ writer.write(" typedef int * PINT; \n");
+ writer.write("} \n");
+ writer.write("using namespace N; \n");
+ writer.write("PINT pint; \n");
+ parse(writer.toString());
+ }
+
+ public void testBug74328() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("int\n");
+ writer.write("main(int argc, char **argv) {\n");
+ writer.write(" char *sign;\n");
+ writer.write("sign = \"\"; // IProblem generated here, syntax error\n");
+ writer.write("return argc;\n");
+ writer.write("}\n");
+ parse(writer.toString());
+ }
+
+ public void testBug71733() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("void foo(int);\n");
+ writer.write("#define BLAH() \\\n");
+ writer.write(" foo (/* slash / is misinterpreted as end of comment */ \\\n");
+ writer.write(" 4);\n");
+ writer.write("int f() { BLAH() }\n");
+ parse(writer.toString());
+ }
+
+ public void testBug69526() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("unsigned inkernel;\n");
+ writer.write("#define lock_kernel() (inkernel |= 0x01)");
+ writer.write("int main(int argc, char **argv) {");
+ writer.write("lock_kernel();");
+ writer.write("}");
+ parse(writer.toString());
+ }
+
+ public void testBug69454() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#define CATCH_ALL_EXCEPTIONS() \\\n");
+ writer.write(" catch(Exception &ex) { handleException(ex); } \\\n");
+ writer.write(" catch(...) { handleException(); } \n");
+ writer.write("class Exception; \n");
+ writer.write("void handleException(Exception & ex) {} \n");
+ writer.write("void handleException() {} \n");
+ writer.write("void f() { \n");
+ writer.write(" try { int i; } \n");
+ writer.write(" CATCH_ALL_EXCEPTIONS(); \n");
+ writer.write("} \n");
+
+ parse(writer.toString());
+ }
+
+ public void testBug72692A() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("extern double pow(double, double);\n");
+ writer.write("extern double pow2(double, double){}\n");
+ writer.write("namespace DS {\n");
+ writer.write("using ::pow;\n");
+ writer.write("using ::pow2;\n");
+ writer.write("}\n");
+ writer.write("using DS::pow;\n");
+ writer.write("using DS::pow2;\n");
+ parse(writer.toString());
+ }
+
+ public void testBug72692B() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("extern double pow(double, double);\n");
+ writer.write("namespace DS {\n");
+ writer.write("using ::pow;\n");
+ writer.write("inline float pow(float __x, float __y)\n");
+ writer.write("{ return ::pow(static_cast<double>(__x), static_cast<double>(__y)); }\n");
+ writer.write("}\n");
+ writer.write("using namespace DS;\n");
+ writer.write("float foo() { double d1 = 3.0, d2 = 4.0; return pow(d1, d2); }");
+ parse(writer.toString());
+ }
+
+ public void testBug72692C() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("extern double pow(double, double){}\n");
+ writer.write("namespace DS {\n");
+ writer.write("using ::pow;\n");
+ writer.write("}\n");
+ writer.write("using DS::pow;\n");
+ parse(writer.toString());
+ }
+
+ public void testBug74575A() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("double pow(double, double);\n");
+ writer.write("float pow(float __x, float __y)\n");
+ writer.write("{ return 0; }\n");
+ parse(writer.toString());
+ }
+
+ public void testBug75338() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class Thrown { };\n");
+ writer.write("void foo() throw(Thrown);");
+ parse(writer.toString());
+ }
+
+ public void testBug74847() throws Exception {
+ String code = "class A : public FOO {};";
+ parse(code, false);
+ }
+
+ public void testBug76696() throws Exception {
+ Writer writer = new StringWriter();
writer.write(" void f(){ \n");
writer.write(" if (A a) { \n");
writer.write(" } else { \n");
@@ -2325,200 +2308,200 @@ public class CompleteParser2Tests extends BaseTestCase {
writer.write(" } \n");
parse(writer.toString(), false);
- }
-
- public void testBug74069() throws Exception {
- Writer writer = new StringWriter();
- writer.write("int f() { \n");
- writer.write(" int a, b, c; \n");
- writer.write(" if (a < b) \n");
- writer.write(" if (b < c) \n");
- writer.write(" return b; \n");
- writer.write(" else if (a < c) \n");
- writer.write(" return c; \n");
- writer.write(" else \n");
- writer.write(" return a; \n");
- writer.write(" else if (a < c) \n");
- writer.write(" return a; \n");
- writer.write(" else if (b < c) \n");
- writer.write(" return c; \n");
- writer.write(" else \n");
- writer.write(" return b; \n");
- writer.write("} \n");
-
- parse(writer.toString());
- }
-
- public void testBug77805() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#if X // Do something only if X is true\n");
- writer.write("/* some statements */\n");
- writer.write("#endif\n");
- parse(writer.toString());
- }
-
- public void testBug77821() throws Exception {
- Writer writer = new StringWriter();
- writer.write("typedef struct { /* ... */ }TYPE;\n");
- writer.write("void ptrArith(const TYPE* pType) {\n");
- writer.write("TYPE *temp = 0;\n");
- writer.write("temp = (TYPE*)(pType + 1); /* Parser error is here */\n}\n");
- parse(writer.toString());
- }
-
- public void testBug77009() throws Exception {
+ }
+
+ public void testBug74069() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("int f() { \n");
+ writer.write(" int a, b, c; \n");
+ writer.write(" if (a < b) \n");
+ writer.write(" if (b < c) \n");
+ writer.write(" return b; \n");
+ writer.write(" else if (a < c) \n");
+ writer.write(" return c; \n");
+ writer.write(" else \n");
+ writer.write(" return a; \n");
+ writer.write(" else if (a < c) \n");
+ writer.write(" return a; \n");
+ writer.write(" else if (b < c) \n");
+ writer.write(" return c; \n");
+ writer.write(" else \n");
+ writer.write(" return b; \n");
+ writer.write("} \n");
+
+ parse(writer.toString());
+ }
+
+ public void testBug77805() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#if X // Do something only if X is true\n");
+ writer.write("/* some statements */\n");
+ writer.write("#endif\n");
+ parse(writer.toString());
+ }
+
+ public void testBug77821() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("typedef struct { /* ... */ }TYPE;\n");
+ writer.write("void ptrArith(const TYPE* pType) {\n");
+ writer.write("TYPE *temp = 0;\n");
+ writer.write("temp = (TYPE*)(pType + 1); /* Parser error is here */\n}\n");
+ parse(writer.toString());
+ }
+
+ public void testBug77009() throws Exception {
parse("int foo(volatile int &);\n");
}
- public void testBug77281() throws Exception {
- Writer writer = new StringWriter();
- writer.write("void fun2(float a, float b) {}\n");
+ public void testBug77281() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("void fun2(float a, float b) {}\n");
writer.write("int main() { fun2(0.24f, 0.25f); }\n");
- parse(writer.toString());
- }
-
- public void testBug77921() throws Exception {
- Writer writer = new StringWriter();
- writer.write("void f()\n{\n");
- writer.write("static float v0[] = { -1.0f, -1.0f, 1.0f };\n}\n");
- parse(writer.toString());
- }
-
- public void testBug71317A() throws Exception {
- Writer writer = new StringWriter();
- writer.write("void f();\n");
- writer.write("namespace NS {\n");
- writer.write("using ::f;\n");
- writer.write("using ::f;\n}");
- parse(writer.toString());
- }
-
- public void testBug71317B() throws Exception {
- Writer writer = new StringWriter();
- writer.write("void f();\n");
- writer.write("namespace NS {\n");
- writer.write("void f();\n");
- writer.write("using ::f;\n}");
- parse(writer.toString());
- }
-
- public void testBug77097() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#define SOME_MACRO() { \\\r\n");
- writer.write("printf(\"Hello World\"); \\\r\n");
- writer.write("printf(\"Good morning\"); \\\r\n");
- parse(writer.toString());
- }
-
- public void testBug77276() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#if (!defined(OS_LIBMODE_R) && !defined(OS_LIBMODE_RP) && \\\r\n");
- writer.write("!defined(OS_LIBMODE_T))\r\n");
- writer.write("#define OS_LIBMODE_DP\r\n");
- writer.write("#endif\r\n");
- parse(writer.toString());
- }
-
- public void testBug78165() throws Exception {
- Writer writer = new StringWriter();
- writer.write("struct Node {\n");
- writer.write("struct Node* Next; // OK: Refers to Node at global scope\n");
- writer.write("struct Data* Data; // OK: Declares type Data at global scope and member Data\n");
- writer.write("};\n");
- writer.write("struct Data {\n");
- writer.write("struct Node* Node; // OK: Refers to Node at global scope\n");
- writer.write("friend struct Glob; // OK: Refers to (as yet) undeclared Glob at global scope.\n");
- writer.write("};\n");
- writer.write("struct Base {\n");
- writer.write("struct Data; // OK: Declares nested Data\n");
- writer.write("struct ::Data* thatData; // OK: Refers to ::Data\n");
- writer.write("struct Base::Data* thisData; // OK: Refers to nested Data\n");
- writer.write("friend class ::Data; // OK: global Data is a friend\n");
- writer.write("friend class Data; // OK: nested Data is a friend\n");
- writer.write("struct Data { /* ... */ }; // Defines nested Data\n");
- writer.write("struct Data; // OK: Redeclares nested Data\n");
- writer.write("};\n");
- writer.write("struct Data; // OK: Redeclares Data at global scope\n");
- writer.write("struct Base::Data* pBase; // OK: refers to nested Data\n");
-
- parse(writer.toString());
- }
-
- public void testBug103560() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#define A(a, b) a ## b \n");
- writer.write("#define FOOBAR 1 \n");
- writer.write("int i = A(FOO, BAR); \n");
- parse(writer.toString(), true, ParserLanguage.CPP);
- }
-
- public void test158192_declspec_on_class() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class __declspec(foobar) Foo1 {};\n");
- writer.write("union __declspec(foobar) Foo2 {};\n");
- writer.write("struct __declspec(foobar) Foo3 {};\n");
- IASTTranslationUnit tu = parse(writer.toString(), true, ParserLanguage.CPP, true);
-
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- assertEquals(3, col.size());
- ICompositeType fooClass = (ICompositeType) col.getName(0).resolveBinding();
- ICompositeType fooUnion = (ICompositeType) col.getName(1).resolveBinding();
- ICompositeType fooStruct = (ICompositeType) col.getName(2).resolveBinding();
-
- assertEquals(ICPPClassType.k_class, fooClass.getKey());
- assertEquals(ICompositeType.k_union, fooUnion.getKey());
- assertEquals(ICompositeType.k_struct, fooStruct.getKey());
-
- assertInstances(col, fooClass, 1);
- assertInstances(col, fooUnion, 1);
- assertInstances(col, fooStruct, 1);
- }
-
- public void test158192_declspec_on_variable() throws Exception {
- Writer writer = new StringWriter();
- writer.write("__declspec(foobar) class Foo {} bar;\n");
- IASTTranslationUnit tu = parse(writer.toString(), true, ParserLanguage.CPP, true);
-
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- assertEquals(2, col.size());
- ICompositeType fooClass = (ICompositeType) col.getName(0).resolveBinding();
- ICPPVariable bar = (ICPPVariable) col.getName(1).resolveBinding();
-
- assertInstances(col, fooClass, 1);
- assertInstances(col, bar, 1);
- }
-
- public void test158192_declspec_in_declarator() throws Exception {
- Writer writer = new StringWriter();
-
- writer.write("int * __declspec(foo) bar = 0;\n");
- IASTTranslationUnit tu = parse(writer.toString(), true, ParserLanguage.CPP, true);
-
- IASTProblem[] problems = CPPVisitor.getProblems(tu);
- assertFalse("__declspec rejected inside declarator", problems.length > 0);
-
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- assertEquals(1, col.size());
- ICPPVariable bar = (ICPPVariable) col.getName(0).resolveBinding();
-
- assertInstances(col, bar, 1);
- }
-
- public void test173874_nestedClasses() throws Exception {
- String code = "class aClass { class bClass; int x; };";
- IASTTranslationUnit tu = parse(code, true, ParserLanguage.CPP, true);
-
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- ICPPClassType cls = (ICPPClassType)col.getName(0).resolveBinding();
- ICPPClassType[] nested = cls.getNestedClasses();
- assertEquals(1, nested.length);
- }
+ parse(writer.toString());
+ }
+
+ public void testBug77921() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("void f()\n{\n");
+ writer.write("static float v0[] = { -1.0f, -1.0f, 1.0f };\n}\n");
+ parse(writer.toString());
+ }
+
+ public void testBug71317A() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("void f();\n");
+ writer.write("namespace NS {\n");
+ writer.write("using ::f;\n");
+ writer.write("using ::f;\n}");
+ parse(writer.toString());
+ }
+
+ public void testBug71317B() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("void f();\n");
+ writer.write("namespace NS {\n");
+ writer.write("void f();\n");
+ writer.write("using ::f;\n}");
+ parse(writer.toString());
+ }
+
+ public void testBug77097() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#define SOME_MACRO() { \\\r\n");
+ writer.write("printf(\"Hello World\"); \\\r\n");
+ writer.write("printf(\"Good morning\"); \\\r\n");
+ parse(writer.toString());
+ }
+
+ public void testBug77276() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#if (!defined(OS_LIBMODE_R) && !defined(OS_LIBMODE_RP) && \\\r\n");
+ writer.write("!defined(OS_LIBMODE_T))\r\n");
+ writer.write("#define OS_LIBMODE_DP\r\n");
+ writer.write("#endif\r\n");
+ parse(writer.toString());
+ }
+
+ public void testBug78165() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("struct Node {\n");
+ writer.write("struct Node* Next; // OK: Refers to Node at global scope\n");
+ writer.write("struct Data* Data; // OK: Declares type Data at global scope and member Data\n");
+ writer.write("};\n");
+ writer.write("struct Data {\n");
+ writer.write("struct Node* Node; // OK: Refers to Node at global scope\n");
+ writer.write("friend struct Glob; // OK: Refers to (as yet) undeclared Glob at global scope.\n");
+ writer.write("};\n");
+ writer.write("struct Base {\n");
+ writer.write("struct Data; // OK: Declares nested Data\n");
+ writer.write("struct ::Data* thatData; // OK: Refers to ::Data\n");
+ writer.write("struct Base::Data* thisData; // OK: Refers to nested Data\n");
+ writer.write("friend class ::Data; // OK: global Data is a friend\n");
+ writer.write("friend class Data; // OK: nested Data is a friend\n");
+ writer.write("struct Data { /* ... */ }; // Defines nested Data\n");
+ writer.write("struct Data; // OK: Redeclares nested Data\n");
+ writer.write("};\n");
+ writer.write("struct Data; // OK: Redeclares Data at global scope\n");
+ writer.write("struct Base::Data* pBase; // OK: refers to nested Data\n");
+
+ parse(writer.toString());
+ }
+
+ public void testBug103560() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#define A(a, b) a ## b \n");
+ writer.write("#define FOOBAR 1 \n");
+ writer.write("int i = A(FOO, BAR); \n");
+ parse(writer.toString(), true, ParserLanguage.CPP);
+ }
+
+ public void test158192_declspec_on_class() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class __declspec(foobar) Foo1 {};\n");
+ writer.write("union __declspec(foobar) Foo2 {};\n");
+ writer.write("struct __declspec(foobar) Foo3 {};\n");
+ IASTTranslationUnit tu = parse(writer.toString(), true, ParserLanguage.CPP, true);
+
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ assertEquals(3, col.size());
+ ICompositeType fooClass = (ICompositeType) col.getName(0).resolveBinding();
+ ICompositeType fooUnion = (ICompositeType) col.getName(1).resolveBinding();
+ ICompositeType fooStruct = (ICompositeType) col.getName(2).resolveBinding();
+
+ assertEquals(ICPPClassType.k_class, fooClass.getKey());
+ assertEquals(ICompositeType.k_union, fooUnion.getKey());
+ assertEquals(ICompositeType.k_struct, fooStruct.getKey());
+
+ assertInstances(col, fooClass, 1);
+ assertInstances(col, fooUnion, 1);
+ assertInstances(col, fooStruct, 1);
+ }
+
+ public void test158192_declspec_on_variable() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("__declspec(foobar) class Foo {} bar;\n");
+ IASTTranslationUnit tu = parse(writer.toString(), true, ParserLanguage.CPP, true);
+
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ assertEquals(2, col.size());
+ ICompositeType fooClass = (ICompositeType) col.getName(0).resolveBinding();
+ ICPPVariable bar = (ICPPVariable) col.getName(1).resolveBinding();
+
+ assertInstances(col, fooClass, 1);
+ assertInstances(col, bar, 1);
+ }
+
+ public void test158192_declspec_in_declarator() throws Exception {
+ Writer writer = new StringWriter();
+
+ writer.write("int * __declspec(foo) bar = 0;\n");
+ IASTTranslationUnit tu = parse(writer.toString(), true, ParserLanguage.CPP, true);
+
+ IASTProblem[] problems = CPPVisitor.getProblems(tu);
+ assertFalse("__declspec rejected inside declarator", problems.length > 0);
+
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ assertEquals(1, col.size());
+ ICPPVariable bar = (ICPPVariable) col.getName(0).resolveBinding();
+
+ assertInstances(col, bar, 1);
+ }
+
+ public void test173874_nestedClasses() throws Exception {
+ String code = "class aClass { class bClass; int x; };";
+ IASTTranslationUnit tu = parse(code, true, ParserLanguage.CPP, true);
+
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ ICPPClassType cls = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPClassType[] nested = cls.getNestedClasses();
+ assertEquals(1, nested.length);
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMFileBasePluginTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMFileBasePluginTest.java
index 3ec01f9e9b3..15ca397d23e 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMFileBasePluginTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMFileBasePluginTest.java
@@ -40,15 +40,15 @@ import org.eclipse.core.runtime.NullProgressMonitor;
* @author dsteffle
*/
public class DOMFileBasePluginTest extends TestCase {
- static NullProgressMonitor monitor;
- static IWorkspace workspace;
- static IProject project;
- static FileManager fileManager;
- static int numProjects = 0;
- static Class className;
+ static NullProgressMonitor monitor;
+ static IWorkspace workspace;
+ static IProject project;
+ static FileManager fileManager;
+ static int numProjects = 0;
+ static Class className;
static ICProject cPrj;
- public DOMFileBasePluginTest() {
+ public DOMFileBasePluginTest() {
}
public DOMFileBasePluginTest(String name) {
@@ -56,112 +56,111 @@ public class DOMFileBasePluginTest extends TestCase {
}
private void initialize(Class aClassName) {
- if( CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null){
+ if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) {
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
monitor = new NullProgressMonitor();
-
+
workspace = ResourcesPlugin.getWorkspace();
-
- try {
- cPrj = CProjectHelper.createCCProject("ParserTestProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
- project = cPrj.getProject();
-
- // ugly
- if (className == null || !className.equals(aClassName)) {
- className = aClassName;
- numProjects++;
- }
- } catch ( CoreException e ) {
- /*boo*/
- }
+
+ try {
+ cPrj = CProjectHelper.createCCProject("ParserTestProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
+ project = cPrj.getProject();
+
+ // ugly
+ if (className == null || !className.equals(aClassName)) {
+ className = aClassName;
+ numProjects++;
+ }
+ } catch (CoreException e) {
+ /*boo*/
+ }
if (project == null)
throw new NullPointerException("Unable to create project"); //$NON-NLS-1$
-
-
+
//Create file manager
fileManager = new FileManager();
- }
- }
-
- public DOMFileBasePluginTest(String name, Class className)
- {
- super(name);
- initialize(className);
- }
-
- public void cleanupProject() throws Exception {
- numProjects--;
-
- try{
- if (numProjects == 0) {
- project.delete( true, false, monitor );
- project = null;
- }
- } catch( Throwable e ){
- /*boo*/
- }
- }
-
- @Override
+ }
+ }
+
+ public DOMFileBasePluginTest(String name, Class className) {
+ super(name);
+ initialize(className);
+ }
+
+ public void cleanupProject() throws Exception {
+ numProjects--;
+
+ try {
+ if (numProjects == 0) {
+ project.delete(true, false, monitor);
+ project = null;
+ }
+ } catch (Throwable e) {
+ /*boo*/
+ }
+ }
+
+ @Override
protected void tearDown() throws Exception {
- if( project == null || !project.exists() )
- return;
-
- IResource [] members = project.members();
- for( int i = 0; i < members.length; i++ ){
- if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$
- continue;
- if (members[i].getName().equals(".settings"))
- continue;
- try{
- members[i].delete( false, monitor );
- } catch( Throwable e ){
- /*boo*/
- }
- }
+ if (project == null || !project.exists())
+ return;
+
+ IResource[] members = project.members();
+ for (int i = 0; i < members.length; i++) {
+ if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
+ continue;
+ if (members[i].getName().equals(".settings"))
+ continue;
+ try {
+ members[i].delete(false, monitor);
+ } catch (Throwable e) {
+ /*boo*/
+ }
+ }
}
- // below can be used to work with large files (too large for memory)
-// protected IFile importFile(String fileName) throws Exception {
-// IFile file = cPrj.getProject().getFile(fileName);
-// if (!file.exists()) {
-// try{
-// FileInputStream fileIn = new FileInputStream(
-// CTestPlugin.getDefault().getFileInPlugin(new Path("resources/parser/" + fileName)));
-// file.create(fileIn,false, monitor);
-// } catch (CoreException e) {
-// e.printStackTrace();
-// } catch (FileNotFoundException e) {
-// e.printStackTrace();
-// }
-// }
-//
-// return file;
-// }
-
- protected IFolder importFolder(String folderName) throws Exception {
- IFolder folder = project.getProject().getFolder(folderName);
-
+ // below can be used to work with large files (too large for memory)
+ // protected IFile importFile(String fileName) throws Exception {
+ // IFile file = cPrj.getProject().getFile(fileName);
+ // if (!file.exists()) {
+ // try{
+ // FileInputStream fileIn = new FileInputStream(
+ // CTestPlugin.getDefault().getFileInPlugin(new Path("resources/parser/" + fileName)));
+ // file.create(fileIn,false, monitor);
+ // } catch (CoreException e) {
+ // e.printStackTrace();
+ // } catch (FileNotFoundException e) {
+ // e.printStackTrace();
+ // }
+ // }
+ //
+ // return file;
+ // }
+
+ protected IFolder importFolder(String folderName) throws Exception {
+ IFolder folder = project.getProject().getFolder(folderName);
+
//Create file input stream
- if( !folder.exists() )
- folder.create( false, false, monitor );
-
+ if (!folder.exists())
+ folder.create(false, false, monitor);
+
return folder;
- }
- public IFile importFile(String fileName, String contents ) throws Exception{
+ }
+
+ public IFile importFile(String fileName, String contents) throws Exception {
//Obtain file handle
IFile file = project.getProject().getFile(fileName);
-
- InputStream stream = new ByteArrayInputStream( contents.getBytes() );
+
+ InputStream stream = new ByteArrayInputStream(contents.getBytes());
//Create file input stream
- if( file.exists() )
- file.setContents( stream, false, false, monitor );
+ if (file.exists())
+ file.setContents(stream, false, false, monitor);
else
- file.create( stream, false, monitor );
-
+ file.create(stream, false, monitor);
+
fileManager.addFile(file);
-
+
return file;
}
-
+
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCParserExtensionTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCParserExtensionTestSuite.java
index dd588742150..e07a843f9fd 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCParserExtensionTestSuite.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCParserExtensionTestSuite.java
@@ -24,12 +24,12 @@ import junit.framework.TestSuite;
public class DOMGCCParserExtensionTestSuite extends TestCase {
public static Test suite() {
- TestSuite suite= new TestSuite(DOMGCCParserExtensionTestSuite.class.getName());
-// suite.addTestSuite( GCCScannerExtensionsTest.class );
-// suite.addTestSuite( GCCQuickParseExtensionsTest.class );
-// suite.addTestSuite( GCCCompleteParseExtensionsTest.class );
- suite.addTestSuite( DOMGCCSelectionParseExtensionsTest.class);
+ TestSuite suite = new TestSuite(DOMGCCParserExtensionTestSuite.class.getName());
+ // suite.addTestSuite( GCCScannerExtensionsTest.class );
+ // suite.addTestSuite( GCCQuickParseExtensionsTest.class );
+ // suite.addTestSuite( GCCCompleteParseExtensionsTest.class );
+ suite.addTestSuite(DOMGCCSelectionParseExtensionsTest.class);
return suite;
}
-
+
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCSelectionParseExtensionsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCSelectionParseExtensionsTest.java
index a31a0140b5a..d7072b53209 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCSelectionParseExtensionsTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCSelectionParseExtensionsTest.java
@@ -35,14 +35,13 @@ public class DOMGCCSelectionParseExtensionsTest extends DOMSelectionParseTestBas
super(name, DOMGCCSelectionParseExtensionsTest.class);
}
- public void testBug43021() throws Exception
- {
+ public void testBug43021() throws Exception {
Writer writer = new StringWriter();
- writer.write( "extern int johnc(__const char *__restrict __format, ...);\n" ); //$NON-NLS-1$
- writer.write( "void m() {johnc(\"HI\");}" ); //$NON-NLS-1$
+ writer.write("extern int johnc(__const char *__restrict __format, ...);\n"); //$NON-NLS-1$
+ writer.write("void m() {johnc(\"HI\");}"); //$NON-NLS-1$
String code = writer.toString();
- int startIndex = code.indexOf( "{johnc") + 1; //$NON-NLS-1$
- IASTNode node = parse( code, startIndex, startIndex + 5 );
- assertNotNull( node );
+ int startIndex = code.indexOf("{johnc") + 1; //$NON-NLS-1$
+ IASTNode node = parse(code, startIndex, startIndex + 5);
+ assertNotNull(node);
}
}
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 a105e0ef215..8a2de1cfbd7 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
@@ -41,446 +41,448 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
public class DOMLocationMacroTests extends AST2TestBase {
final ParserLanguage[] languages = new ParserLanguage[] { ParserLanguage.C, ParserLanguage.CPP };
-
- public DOMLocationMacroTests() {
+
+ public DOMLocationMacroTests() {
}
public DOMLocationMacroTests(String name) {
super(name);
}
- public void testObjectStyleMacroExpansionSimpleDeclarator() throws Exception
- {
- StringBuilder buffer = new StringBuilder( "#define ABC D\n" ); //$NON-NLS-1$
- buffer.append( "int ABC;"); //$NON-NLS-1$
- String code = buffer.toString();
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTPreprocessorObjectStyleMacroDefinition ABC = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[0];
- IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTDeclarator d = var.getDeclarators()[0];
- assertEquals( d.getName().toString(), "D"); //$NON-NLS-1$
- IASTNodeLocation [] declaratorLocations = d.getNodeLocations();
- assertEquals( declaratorLocations.length, 1 );
- IASTMacroExpansionLocation expansion = (IASTMacroExpansionLocation) declaratorLocations[0];
- IASTPreprocessorObjectStyleMacroDefinition fromExpansion = (IASTPreprocessorObjectStyleMacroDefinition) expansion.getExpansion().getMacroDefinition();
- assertEqualsMacros( fromExpansion, ABC );
- assertEquals( expansion.getNodeOffset(), 0 );
- assertEquals( expansion.getNodeLength(), 1 );
- IASTNodeLocation [] macroLocation = expansion.getExpansion().getNodeLocations();
- assertEquals( macroLocation.length, 1 );
- assertTrue( macroLocation[0] instanceof IASTFileLocation );
- assertEquals( macroLocation[0].getNodeOffset(), code.indexOf( "int ABC;") + "int ".length() ); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals( macroLocation[0].getNodeLength(), "ABC".length() ); //$NON-NLS-1$
- }
- }
-
- public void testObjectMacroExpansionModestDeclarator() throws Exception
- {
- StringBuilder buffer = new StringBuilder( "#define ABC * D\n" ); //$NON-NLS-1$
- buffer.append( "int ABC;"); //$NON-NLS-1$
- String code = buffer.toString();
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTPreprocessorObjectStyleMacroDefinition ABC = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[0];
- IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTDeclarator d = var.getDeclarators()[0];
- assertEquals( d.getName().toString(), "D"); //$NON-NLS-1$
- assertEquals( d.getPointerOperators().length, 1 );
- IASTNodeLocation [] declaratorLocations = d.getNodeLocations();
- assertEquals( declaratorLocations.length, 1 );
- IASTMacroExpansionLocation expansion = (IASTMacroExpansionLocation) declaratorLocations[0];
- IASTPreprocessorObjectStyleMacroDefinition fromExpansion = (IASTPreprocessorObjectStyleMacroDefinition) expansion.getExpansion().getMacroDefinition();
- assertEqualsMacros( fromExpansion, ABC );
- assertEquals( expansion.getNodeOffset(), 0 );
- assertEquals( 2, expansion.getNodeLength() );
- IASTNodeLocation [] macroLocation = expansion.getExpansion().getNodeLocations();
- assertEquals( macroLocation.length, 1 );
- assertTrue( macroLocation[0] instanceof IASTFileLocation );
- assertEquals( macroLocation[0].getNodeOffset(), code.indexOf( "int ABC;") + "int ".length() ); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals( macroLocation[0].getNodeLength(), "ABC".length() ); //$NON-NLS-1$
-
- IASTName n = d.getName();
- IASTNodeLocation [] nameLocations = n.getNodeLocations();
- assertEquals( nameLocations.length, 1 );
- final IASTMacroExpansionLocation nodeLocation = (IASTMacroExpansionLocation) nameLocations[0];
- assertEquals( nodeLocation.getNodeOffset(), 1 );
- assertEquals( nodeLocation.getNodeLength(), 1 );
-
- assertEquals( nodeLocation.getExpansion().getNodeLocations()[0].getNodeOffset(), macroLocation[0].getNodeOffset() );
- assertEquals( nodeLocation.getExpansion().getNodeLocations()[0].getNodeLength(), macroLocation[0].getNodeLength() );
-
- IASTPointer po = (IASTPointer) d.getPointerOperators()[0];
- assertFalse( po.isConst() );
- assertFalse( po.isVolatile() );
- IASTMacroExpansionLocation pointerLocation = (IASTMacroExpansionLocation) po.getNodeLocations()[0];
- assertEquals( pointerLocation.getNodeOffset(), 0 );
- assertEquals( pointerLocation.getNodeLength(), 1 );
- assertEquals( pointerLocation.getExpansion().getNodeLocations()[0].getNodeOffset(), macroLocation[0].getNodeOffset() );
- assertEquals( pointerLocation.getExpansion().getNodeLocations()[0].getNodeLength(), macroLocation[0].getNodeLength() );
- assertEqualsMacros( pointerLocation.getExpansion().getMacroDefinition(), nodeLocation.getExpansion().getMacroDefinition() );
- }
- }
-
- public void testObjectMacroExpansionPartialDeclSpec() throws Exception
- {
- StringBuilder buffer = new StringBuilder( "#define XYZ const\n"); //$NON-NLS-1$
- buffer.append( "XYZ int var;"); //$NON-NLS-1$
- String code = buffer.toString();
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTPreprocessorObjectStyleMacroDefinition defXYZ = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[0];
- IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTSimpleDeclSpecifier declSpec = (IASTSimpleDeclSpecifier) var.getDeclSpecifier();
- IASTNodeLocation [] declSpecLocations = declSpec.getNodeLocations();
- assertEquals( declSpecLocations.length, 2 );
- IASTMacroExpansionLocation expansion = (IASTMacroExpansionLocation) declSpecLocations[0];
- assertEqualsMacros( defXYZ, expansion.getExpansion().getMacroDefinition() );
- assertEquals( expansion.getNodeOffset(), 0 );
- assertEquals( expansion.getNodeLength(), 1 );
- IASTNodeLocation [] expansionLocations = expansion.getExpansion().getNodeLocations();
- assertEquals( expansionLocations.length, 1 );
- assertTrue( expansionLocations[0] instanceof IASTFileLocation );
- assertEquals( expansionLocations[0].getNodeOffset(), code.indexOf( "XYZ int")); //$NON-NLS-1$
- assertEquals( expansionLocations[0].getNodeLength(), "XYZ".length()); //$NON-NLS-1$
- IASTFileLocation second = (IASTFileLocation) declSpecLocations[1];
- assertEquals( second.getNodeOffset(), code.indexOf( " int") ); //$NON-NLS-1$
- assertEquals( second.getNodeLength(), " int".length() ); //$NON-NLS-1$
- }
- }
-
- public void testObjectMacroExpansionNested() throws Exception
- {
- StringBuilder buffer = new StringBuilder( "#define XYZ const\n"); //$NON-NLS-1$
- buffer.append( "#define PO *\n"); //$NON-NLS-1$
- buffer.append( "#define C_PO PO XYZ\n"); //$NON-NLS-1$
- buffer.append( "int C_PO var;"); //$NON-NLS-1$
- String code = buffer.toString();
-
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- final IASTPreprocessorMacroDefinition[] macroDefinitions = tu.getMacroDefinitions();
- IASTPreprocessorMacroDefinition XYZ = macroDefinitions[0];
- IASTPreprocessorMacroDefinition PO = macroDefinitions[1];
- IASTPreprocessorMacroDefinition C_PO = macroDefinitions[2];
- IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- assertTrue( var.getDeclarators()[0].getPointerOperators().length > 0 );
- IASTNodeLocation [] locations = var.getNodeLocations();
- assertEquals( 3, locations.length);
- IASTFileLocation start_loc = (IASTFileLocation) locations[0];
- assertEquals( start_loc.getNodeOffset(), code.indexOf( "int") ); //$NON-NLS-1$
- assertEquals( start_loc.getNodeLength(), "int ".length()); //$NON-NLS-1$
- IASTMacroExpansionLocation mac_loc = (IASTMacroExpansionLocation) locations[1];
- final IASTPreprocessorMacroDefinition C_PO2 = mac_loc.getExpansion().getMacroDefinition();
- assertEqualsMacros( C_PO, C_PO2 );
- assertEquals( 0, mac_loc.getNodeOffset());
- assertEquals( 2, mac_loc.getNodeLength() );
- IASTFileLocation end_loc = (IASTFileLocation) locations[2];
- assertEquals( code.indexOf( " var"), end_loc.getNodeOffset() ); //$NON-NLS-1$
- assertEquals( " var;".length(), end_loc.getNodeLength() ); //$NON-NLS-1$
- }
- }
-
- public void testObjectMacroExpansionComplex() throws Exception
- {
- StringBuilder buffer = new StringBuilder( "#define XYZ const\n"); //$NON-NLS-1$
- buffer.append( "#define PO *\n"); //$NON-NLS-1$
- buffer.append( "#define C_PO PO XYZ\n"); //$NON-NLS-1$
- buffer.append( "#define IT int\n"); //$NON-NLS-1$
- buffer.append( "#define V var\n"); //$NON-NLS-1$
- buffer.append( "XYZ IT C_PO C_PO V;"); //$NON-NLS-1$
- String code = buffer.toString();
-
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTPreprocessorObjectStyleMacroDefinition XYZ = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[0];
-// IASTPreprocessorObjectStyleMacroDefinition PO = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[1];
- IASTPreprocessorObjectStyleMacroDefinition C_PO = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[2];
- IASTPreprocessorObjectStyleMacroDefinition IT = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[3];
- IASTPreprocessorObjectStyleMacroDefinition V = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[4];
-
- IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- final IASTNodeLocation[] nodeLocations = var.getNodeLocations();
-
- assertEquals( 10, nodeLocations.length );
- IASTMacroExpansionLocation first_loc = (IASTMacroExpansionLocation) nodeLocations[0];
- assertEqualsMacros( first_loc.getExpansion().getMacroDefinition(), XYZ );
- IASTFileLocation second_loc = (IASTFileLocation) nodeLocations[1];
- assertEquals( 1, second_loc.getNodeLength() );
- IASTMacroExpansionLocation third_loc = (IASTMacroExpansionLocation) nodeLocations[2];
- assertEqualsMacros( third_loc.getExpansion().getMacroDefinition(), IT );
- IASTFileLocation fourth_loc = (IASTFileLocation) nodeLocations[3];
- assertEquals( 1, fourth_loc.getNodeLength() );
- IASTMacroExpansionLocation fifth_loc = (IASTMacroExpansionLocation) nodeLocations[4];
- assertEqualsMacros( fifth_loc.getExpansion().getMacroDefinition(), C_PO );
- IASTFileLocation sixth_loc = (IASTFileLocation) nodeLocations[5];
- assertEquals( 1, sixth_loc.getNodeLength() );
- IASTMacroExpansionLocation seventh_loc = (IASTMacroExpansionLocation) nodeLocations[6];
- assertEqualsMacros( seventh_loc.getExpansion().getMacroDefinition(), C_PO );
- IASTFileLocation eighth_loc = (IASTFileLocation) nodeLocations[7];
- assertEquals( 1, eighth_loc.getNodeLength() );
- IASTMacroExpansionLocation ninth_loc = (IASTMacroExpansionLocation) nodeLocations[8];
- assertEqualsMacros( ninth_loc.getExpansion().getMacroDefinition(), V );
- IASTFileLocation tenth_loc = (IASTFileLocation) nodeLocations[9];
- assertEquals( 1, tenth_loc.getNodeLength() );
-
- final IASTFileLocation flatLocation = var.getFileLocation();
- assertNotNull( flatLocation);
- assertEquals( code.indexOf("XYZ IT C_PO C_PO V;"), flatLocation.getNodeOffset() ); //$NON-NLS-1$
- assertEquals( "XYZ IT C_PO C_PO V;".length(), flatLocation.getNodeLength() ); //$NON-NLS-1$
-
-
- }
- }
-
- public void testStdioBug() throws ParserException
- {
- StringBuilder buffer = new StringBuilder( "#define _PTR void *\n"); //$NON-NLS-1$
- buffer.append( "#define __cdecl __attribute__ ((__cdecl__))\n" ); //$NON-NLS-1$
- buffer.append( "#define _EXFUN(name, proto) __cdecl name proto\n"); //$NON-NLS-1$
- buffer.append( "_PTR _EXFUN(memchr,(const _PTR, int, size_t));\n"); //$NON-NLS-1$
- String code = buffer.toString();
-
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language, true, true);
- final IASTPreprocessorMacroDefinition[] macroDefinitions = tu.getMacroDefinitions();
- IASTPreprocessorObjectStyleMacroDefinition _PTR = (IASTPreprocessorObjectStyleMacroDefinition) macroDefinitions[0];
- IASTPreprocessorFunctionStyleMacroDefinition _EXFUN = (IASTPreprocessorFunctionStyleMacroDefinition) macroDefinitions[2];
- IASTSimpleDeclaration memchr = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTNodeLocation [] locations = memchr.getNodeLocations();
- assertEquals( locations.length, 4 );
- IASTMacroExpansionLocation loc_1 = (IASTMacroExpansionLocation) locations[0];
- assertEqualsMacros( _PTR, loc_1.getExpansion().getMacroDefinition() );
- IASTFileLocation loc_2 = (IASTFileLocation) locations[1];
- assertEquals( loc_2.getNodeOffset(), code.indexOf( " _EXFUN(")); //$NON-NLS-1$
- assertEquals( loc_2.getNodeLength(), " ".length() ); //$NON-NLS-1$
- IASTMacroExpansionLocation loc_3 = (IASTMacroExpansionLocation) locations[2];
- assertEqualsMacros( _EXFUN, loc_3.getExpansion().getMacroDefinition() );
- IASTFileLocation loc_4 = (IASTFileLocation) locations[3];
- assertEquals( loc_4.getNodeOffset(), code.indexOf( ";")); //$NON-NLS-1$
- assertEquals( loc_4.getNodeLength(), 1 );
- IASTFileLocation flat = memchr.getFileLocation();
- assertEquals( flat.getNodeOffset() , code.indexOf( "_PTR _EXFUN(memchr,(const _PTR, int, size_t));")); //$NON-NLS-1$
- assertEquals( flat.getNodeLength(), "_PTR _EXFUN(memchr,(const _PTR, int, size_t));".length() ); //$NON-NLS-1$
-
- IASTDeclarator d = memchr.getDeclarators()[0];
- IASTFileLocation f = d.getFileLocation();
- assertEquals( code.indexOf( "_PTR _EXFUN(memchr,(const _PTR, int, size_t))"), f.getNodeOffset() ); //$NON-NLS-1$
- assertEquals( "_PTR _EXFUN(memchr,(const _PTR, int, size_t))".length(), f.getNodeLength() ); //$NON-NLS-1$
- }
- }
-
- private void assertEqualsMacros(IASTPreprocessorMacroDefinition fromExpansion, IASTPreprocessorMacroDefinition source) {
- assertEquals( fromExpansion.getExpansion(), source.getExpansion() );
- assertEquals( fromExpansion.getName().toString(), source.getName().toString() );
- }
-
- public void testMacroBindings() throws Exception
- {
- StringBuilder buffer = new StringBuilder( "#define ABC def\n"); //$NON-NLS-1$
- buffer.append( "int ABC;\n"); //$NON-NLS-1$
- buffer.append( "#undef ABC\n"); //$NON-NLS-1$
- buffer.append( "#define ABC ghi\n"); //$NON-NLS-1$
- buffer.append( "int ABC;\n"); //$NON-NLS-1$
- String code = buffer.toString();
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTPreprocessorMacroDefinition [] macros = tu.getMacroDefinitions();
- assertEquals( macros.length, 2 );
- IASTPreprocessorObjectStyleMacroDefinition ABC1 = (IASTPreprocessorObjectStyleMacroDefinition) macros[0];
- IASTPreprocessorObjectStyleMacroDefinition ABC2 = (IASTPreprocessorObjectStyleMacroDefinition) macros[1];
- IMacroBinding binding1 = (IMacroBinding) ABC1.getName().resolveBinding();
- assertNotNull( binding1 );
- IMacroBinding binding2 = (IMacroBinding) ABC2.getName().resolveBinding();
- assertNotNull( binding2 );
- assertNotSame( binding1, binding2 );
- IASTName [] firstReferences = tu.getReferences( binding1 );
- IASTName [] firstDeclarations = tu.getDeclarationsInAST( binding1 );
- assertEquals( firstReferences.length, 2 );
- assertEquals( firstReferences[0].getPropertyInParent(), IASTPreprocessorMacroExpansion.EXPANSION_NAME );
- assertEquals( firstReferences[0].getParent().getParent(), tu );
- assertEquals( firstReferences[1].getPropertyInParent(), IASTPreprocessorStatement.MACRO_NAME );
- assertTrue( firstReferences[1].getParent() instanceof IASTPreprocessorUndefStatement );
- assertEquals( firstDeclarations.length, 1 );
- assertSame( ABC1.getName(), firstDeclarations[0] );
- IASTName [] secondReferences = tu.getReferences(binding2);
- IASTName [] secondDeclarations = tu.getDeclarationsInAST( binding2 );
- assertEquals( 1, secondReferences.length );
- assertEquals( secondReferences[0].getPropertyInParent(), IASTPreprocessorMacroExpansion.EXPANSION_NAME );
- assertEquals( secondReferences[0].getParent().getParent(), tu );
- assertSame( ABC2.getName(), secondDeclarations[0]);
- }
- }
-
-
- public void testBug90978() throws Exception {
- StringBuilder buffer = new StringBuilder( "#define MACRO mm\n"); //$NON-NLS-1$
- buffer.append( "int MACRO;\n"); //$NON-NLS-1$
- String code = buffer.toString();
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTPreprocessorObjectStyleMacroDefinition MACRO = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[0];
- IASTName macro_name = MACRO.getName();
- IMacroBinding binding = (IMacroBinding) macro_name.resolveBinding();
- IASTName [] references = tu.getReferences( binding );
- assertEquals( references.length, 1 );
- IASTName reference = references[0];
- IASTNodeLocation [] nodeLocations = reference.getNodeLocations();
- assertEquals( nodeLocations.length, 1 );
- assertTrue( nodeLocations[0] instanceof IASTFileLocation );
- IASTFileLocation loc = (IASTFileLocation) nodeLocations[0];
- assertEquals( code.indexOf( "int MACRO") + "int ".length(), loc.getNodeOffset() ); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals( "MACRO".length(), loc.getNodeLength() ); //$NON-NLS-1$
- }
- }
-
- public void testBug94933() throws Exception {
- StringBuilder buffer = new StringBuilder( "#define API extern\n" ); //$NON-NLS-1$
- buffer.append( "#define MYAPI API\n"); //$NON-NLS-1$
- buffer.append( "MYAPI void func() {}" ); //$NON-NLS-1$
- String code = buffer.toString();
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
- assertNotNull( f.getFileLocation() );
- }
- }
-
- public void testFunctionMacroExpansionWithNameSubstitution_Bug173637() throws Exception
- {
- StringBuilder buffer = new StringBuilder( "#define PLUS5(x) (x+5)\n"); //$NON-NLS-1$
- buffer.append( "#define FUNCTION PLUS5 \n"); //$NON-NLS-1$
- buffer.append( "int var= FUNCTION(1);"); //$NON-NLS-1$
- String code = buffer.toString();
-
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTEqualsInitializer initializer= (IASTEqualsInitializer)var.getDeclarators()[0].getInitializer();
- IASTInitializerClause expr= initializer.getInitializerClause();
- assertNotNull(expr.getFileLocation());
- IASTNodeLocation [] locations = expr.getNodeLocations();
- assertEquals(1, locations.length);
- IASTMacroExpansionLocation macroExpansion = (IASTMacroExpansionLocation) locations[0];
- IASTNodeLocation[] expLocations= macroExpansion.getExpansion().getNodeLocations();
- assertEquals(1, expLocations.length);
- assertEquals(code.indexOf("FUNCTION(1)"), expLocations[0].getNodeOffset());
- assertEquals("FUNCTION(1)".length(), expLocations[0].getNodeLength());
- }
- }
-
-
- private void assertMacroLocation(IASTDeclaration decl, int index, int length) {
- IASTSimpleDeclaration var = (IASTSimpleDeclaration) decl;
- IASTEqualsInitializer initializer= (IASTEqualsInitializer)var.getDeclarators()[0].getInitializer();
- IASTInitializerClause expr= initializer.getInitializerClause();
- assertNotNull(expr.getFileLocation());
- IASTNodeLocation [] locations = expr.getNodeLocations();
- assertEquals(1, locations.length);
- IASTMacroExpansionLocation macroExpansion = (IASTMacroExpansionLocation) locations[0];
- IASTNodeLocation[] expLocations= macroExpansion.getExpansion().getNodeLocations();
- assertEquals(1, expLocations.length);
- IASTFileLocation fileLocation = expLocations[0].asFileLocation();
- assertEquals(index, fileLocation.getNodeOffset());
- assertEquals(length, fileLocation.getNodeLength());
- }
-
- private void assertExpressionLocation(IASTDeclaration decl, int index, int length) {
- IASTSimpleDeclaration var = (IASTSimpleDeclaration) decl;
- IASTEqualsInitializer initializer= (IASTEqualsInitializer)var.getDeclarators()[0].getInitializer();
- IASTInitializerClause expr= initializer.getInitializerClause();
- IASTFileLocation fileLocation = expr.getFileLocation();
- assertNotNull(fileLocation);
- assertEquals(index, fileLocation.getNodeOffset());
- assertEquals(length, fileLocation.getNodeLength());
- }
-
-
- public void testBug186257() throws Exception {
- StringBuilder sb = new StringBuilder();
- sb.append("typedef char STR; \n"); //$NON-NLS-1$
- sb.append("#define Nullstr Null(STR*) \n"); //$NON-NLS-1$
- sb.append("#define Null(x) ((x)NULL) \n"); //$NON-NLS-1$
- sb.append("int x = Nullstr; \n"); //$NON-NLS-1$
- sb.append("int y = whatever; \n"); //$NON-NLS-1$
- String code = sb.toString();
-
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTDeclaration[] decls = tu.getDeclarations();
- assertMacroLocation(decls[1], code.indexOf("Nullstr;"), "Nullstr".length()); //$NON-NLS-1$ //$NON-NLS-2$
- assertExpressionLocation(decls[2], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
-
- public void testArgumentExpansion() throws Exception {
- StringBuilder sb = new StringBuilder();
- sb.append("#define ADD(a,b, c) (a) + (b) + (c) \n"); //$NON-NLS-1$
- sb.append("#define ONEYONENOE 111111 \n"); //$NON-NLS-1$
- sb.append("#define TWO 2 \n"); //$NON-NLS-1$
- sb.append("#define THREE 3 \n"); //$NON-NLS-1$
- sb.append("int x = ADD(ONEYONENOE,TWO, THREE); \n"); //$NON-NLS-1$
- sb.append("int y = whatever; \n"); //$NON-NLS-1$
- String code = sb.toString();
-
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTDeclaration[] decls = tu.getDeclarations();
- assertMacroLocation(decls[0], code.indexOf("ADD(ONEYONENOE,TWO, THREE)"), "ADD(ONEYONENOE,TWO, THREE)".length()); //$NON-NLS-1$ //$NON-NLS-2$
- assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
-
- public void testArgumentCapture() throws Exception {
- StringBuilder sb = new StringBuilder();
- sb.append("#define add(x,y) x + y \n"); //$NON-NLS-1$
- sb.append("#define add2 add(x, \n"); //$NON-NLS-1$
- sb.append("int x = add2 z); \n"); //$NON-NLS-1$
- sb.append("int y = whatever; \n"); //$NON-NLS-1$
- String code = sb.toString();
-
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTDeclaration[] decls = tu.getDeclarations();
- assertMacroLocation(decls[0], code.indexOf("add2 z);"), "add2 z)".length()); //$NON-NLS-1$ //$NON-NLS-2$
- assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
-
- public void testFunctionMacroNotCalled() throws Exception {
- StringBuilder sb = new StringBuilder();
- sb.append("#define FUNCTION(x) x \n"); //$NON-NLS-1$
- sb.append("#define YO FUNCTION \n"); //$NON-NLS-1$
- sb.append("int x = YO; \n"); //$NON-NLS-1$
- sb.append("int y = whatever; \n"); //$NON-NLS-1$
- String code = sb.toString();
-
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTDeclaration[] decls = tu.getDeclarations();
- assertMacroLocation(decls[0], code.indexOf("YO;"), "YO".length()); //$NON-NLS-1$ //$NON-NLS-2$
- assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public void testBuildFunctionMacroName() throws Exception {
- StringBuilder sb = new StringBuilder();
- sb.append("#define FUN1(x) x \n"); //$NON-NLS-1$
- sb.append("#define FUN1(x) x \n"); //$NON-NLS-1$
- sb.append("#define MAKEFUN(num) FUN ## num \n"); //$NON-NLS-1$
- sb.append("int x = MAKEFUN(1)(z); \n"); //$NON-NLS-1$
- sb.append("int y = whatever; \n"); //$NON-NLS-1$
- String code = sb.toString();
-
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTDeclaration[] decls = tu.getDeclarations();
- assertMacroLocation(decls[0], code.indexOf("MAKEFUN(1)(z);"), "MAKEFUN(1)(z)".length()); //$NON-NLS-1$ //$NON-NLS-2$
- assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
+ public void testObjectStyleMacroExpansionSimpleDeclarator() throws Exception {
+ StringBuilder buffer = new StringBuilder("#define ABC D\n"); //$NON-NLS-1$
+ buffer.append("int ABC;"); //$NON-NLS-1$
+ String code = buffer.toString();
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTPreprocessorObjectStyleMacroDefinition ABC = (IASTPreprocessorObjectStyleMacroDefinition) tu
+ .getMacroDefinitions()[0];
+ IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTDeclarator d = var.getDeclarators()[0];
+ assertEquals(d.getName().toString(), "D"); //$NON-NLS-1$
+ IASTNodeLocation[] declaratorLocations = d.getNodeLocations();
+ assertEquals(declaratorLocations.length, 1);
+ IASTMacroExpansionLocation expansion = (IASTMacroExpansionLocation) declaratorLocations[0];
+ IASTPreprocessorObjectStyleMacroDefinition fromExpansion = (IASTPreprocessorObjectStyleMacroDefinition) expansion
+ .getExpansion().getMacroDefinition();
+ assertEqualsMacros(fromExpansion, ABC);
+ assertEquals(expansion.getNodeOffset(), 0);
+ assertEquals(expansion.getNodeLength(), 1);
+ IASTNodeLocation[] macroLocation = expansion.getExpansion().getNodeLocations();
+ assertEquals(macroLocation.length, 1);
+ assertTrue(macroLocation[0] instanceof IASTFileLocation);
+ assertEquals(macroLocation[0].getNodeOffset(), code.indexOf("int ABC;") + "int ".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(macroLocation[0].getNodeLength(), "ABC".length()); //$NON-NLS-1$
+ }
+ }
+
+ public void testObjectMacroExpansionModestDeclarator() throws Exception {
+ StringBuilder buffer = new StringBuilder("#define ABC * D\n"); //$NON-NLS-1$
+ buffer.append("int ABC;"); //$NON-NLS-1$
+ String code = buffer.toString();
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTPreprocessorObjectStyleMacroDefinition ABC = (IASTPreprocessorObjectStyleMacroDefinition) tu
+ .getMacroDefinitions()[0];
+ IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTDeclarator d = var.getDeclarators()[0];
+ assertEquals(d.getName().toString(), "D"); //$NON-NLS-1$
+ assertEquals(d.getPointerOperators().length, 1);
+ IASTNodeLocation[] declaratorLocations = d.getNodeLocations();
+ assertEquals(declaratorLocations.length, 1);
+ IASTMacroExpansionLocation expansion = (IASTMacroExpansionLocation) declaratorLocations[0];
+ IASTPreprocessorObjectStyleMacroDefinition fromExpansion = (IASTPreprocessorObjectStyleMacroDefinition) expansion
+ .getExpansion().getMacroDefinition();
+ assertEqualsMacros(fromExpansion, ABC);
+ assertEquals(expansion.getNodeOffset(), 0);
+ assertEquals(2, expansion.getNodeLength());
+ IASTNodeLocation[] macroLocation = expansion.getExpansion().getNodeLocations();
+ assertEquals(macroLocation.length, 1);
+ assertTrue(macroLocation[0] instanceof IASTFileLocation);
+ assertEquals(macroLocation[0].getNodeOffset(), code.indexOf("int ABC;") + "int ".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(macroLocation[0].getNodeLength(), "ABC".length()); //$NON-NLS-1$
+
+ IASTName n = d.getName();
+ IASTNodeLocation[] nameLocations = n.getNodeLocations();
+ assertEquals(nameLocations.length, 1);
+ final IASTMacroExpansionLocation nodeLocation = (IASTMacroExpansionLocation) nameLocations[0];
+ assertEquals(nodeLocation.getNodeOffset(), 1);
+ assertEquals(nodeLocation.getNodeLength(), 1);
+
+ assertEquals(nodeLocation.getExpansion().getNodeLocations()[0].getNodeOffset(),
+ macroLocation[0].getNodeOffset());
+ assertEquals(nodeLocation.getExpansion().getNodeLocations()[0].getNodeLength(),
+ macroLocation[0].getNodeLength());
+
+ IASTPointer po = (IASTPointer) d.getPointerOperators()[0];
+ assertFalse(po.isConst());
+ assertFalse(po.isVolatile());
+ IASTMacroExpansionLocation pointerLocation = (IASTMacroExpansionLocation) po.getNodeLocations()[0];
+ assertEquals(pointerLocation.getNodeOffset(), 0);
+ assertEquals(pointerLocation.getNodeLength(), 1);
+ assertEquals(pointerLocation.getExpansion().getNodeLocations()[0].getNodeOffset(),
+ macroLocation[0].getNodeOffset());
+ assertEquals(pointerLocation.getExpansion().getNodeLocations()[0].getNodeLength(),
+ macroLocation[0].getNodeLength());
+ assertEqualsMacros(pointerLocation.getExpansion().getMacroDefinition(),
+ nodeLocation.getExpansion().getMacroDefinition());
+ }
+ }
+
+ public void testObjectMacroExpansionPartialDeclSpec() throws Exception {
+ StringBuilder buffer = new StringBuilder("#define XYZ const\n"); //$NON-NLS-1$
+ buffer.append("XYZ int var;"); //$NON-NLS-1$
+ String code = buffer.toString();
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTPreprocessorObjectStyleMacroDefinition defXYZ = (IASTPreprocessorObjectStyleMacroDefinition) tu
+ .getMacroDefinitions()[0];
+ IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTSimpleDeclSpecifier declSpec = (IASTSimpleDeclSpecifier) var.getDeclSpecifier();
+ IASTNodeLocation[] declSpecLocations = declSpec.getNodeLocations();
+ assertEquals(declSpecLocations.length, 2);
+ IASTMacroExpansionLocation expansion = (IASTMacroExpansionLocation) declSpecLocations[0];
+ assertEqualsMacros(defXYZ, expansion.getExpansion().getMacroDefinition());
+ assertEquals(expansion.getNodeOffset(), 0);
+ assertEquals(expansion.getNodeLength(), 1);
+ IASTNodeLocation[] expansionLocations = expansion.getExpansion().getNodeLocations();
+ assertEquals(expansionLocations.length, 1);
+ assertTrue(expansionLocations[0] instanceof IASTFileLocation);
+ assertEquals(expansionLocations[0].getNodeOffset(), code.indexOf("XYZ int")); //$NON-NLS-1$
+ assertEquals(expansionLocations[0].getNodeLength(), "XYZ".length()); //$NON-NLS-1$
+ IASTFileLocation second = (IASTFileLocation) declSpecLocations[1];
+ assertEquals(second.getNodeOffset(), code.indexOf(" int")); //$NON-NLS-1$
+ assertEquals(second.getNodeLength(), " int".length()); //$NON-NLS-1$
+ }
+ }
+
+ public void testObjectMacroExpansionNested() throws Exception {
+ StringBuilder buffer = new StringBuilder("#define XYZ const\n"); //$NON-NLS-1$
+ buffer.append("#define PO *\n"); //$NON-NLS-1$
+ buffer.append("#define C_PO PO XYZ\n"); //$NON-NLS-1$
+ buffer.append("int C_PO var;"); //$NON-NLS-1$
+ String code = buffer.toString();
+
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ final IASTPreprocessorMacroDefinition[] macroDefinitions = tu.getMacroDefinitions();
+ IASTPreprocessorMacroDefinition XYZ = macroDefinitions[0];
+ IASTPreprocessorMacroDefinition PO = macroDefinitions[1];
+ IASTPreprocessorMacroDefinition C_PO = macroDefinitions[2];
+ IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ assertTrue(var.getDeclarators()[0].getPointerOperators().length > 0);
+ IASTNodeLocation[] locations = var.getNodeLocations();
+ assertEquals(3, locations.length);
+ IASTFileLocation start_loc = (IASTFileLocation) locations[0];
+ assertEquals(start_loc.getNodeOffset(), code.indexOf("int")); //$NON-NLS-1$
+ assertEquals(start_loc.getNodeLength(), "int ".length()); //$NON-NLS-1$
+ IASTMacroExpansionLocation mac_loc = (IASTMacroExpansionLocation) locations[1];
+ final IASTPreprocessorMacroDefinition C_PO2 = mac_loc.getExpansion().getMacroDefinition();
+ assertEqualsMacros(C_PO, C_PO2);
+ assertEquals(0, mac_loc.getNodeOffset());
+ assertEquals(2, mac_loc.getNodeLength());
+ IASTFileLocation end_loc = (IASTFileLocation) locations[2];
+ assertEquals(code.indexOf(" var"), end_loc.getNodeOffset()); //$NON-NLS-1$
+ assertEquals(" var;".length(), end_loc.getNodeLength()); //$NON-NLS-1$
+ }
+ }
+
+ public void testObjectMacroExpansionComplex() throws Exception {
+ StringBuilder buffer = new StringBuilder("#define XYZ const\n"); //$NON-NLS-1$
+ buffer.append("#define PO *\n"); //$NON-NLS-1$
+ buffer.append("#define C_PO PO XYZ\n"); //$NON-NLS-1$
+ buffer.append("#define IT int\n"); //$NON-NLS-1$
+ buffer.append("#define V var\n"); //$NON-NLS-1$
+ buffer.append("XYZ IT C_PO C_PO V;"); //$NON-NLS-1$
+ String code = buffer.toString();
+
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTPreprocessorObjectStyleMacroDefinition XYZ = (IASTPreprocessorObjectStyleMacroDefinition) tu
+ .getMacroDefinitions()[0];
+ // IASTPreprocessorObjectStyleMacroDefinition PO = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[1];
+ IASTPreprocessorObjectStyleMacroDefinition C_PO = (IASTPreprocessorObjectStyleMacroDefinition) tu
+ .getMacroDefinitions()[2];
+ IASTPreprocessorObjectStyleMacroDefinition IT = (IASTPreprocessorObjectStyleMacroDefinition) tu
+ .getMacroDefinitions()[3];
+ IASTPreprocessorObjectStyleMacroDefinition V = (IASTPreprocessorObjectStyleMacroDefinition) tu
+ .getMacroDefinitions()[4];
+
+ IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ final IASTNodeLocation[] nodeLocations = var.getNodeLocations();
+
+ assertEquals(10, nodeLocations.length);
+ IASTMacroExpansionLocation first_loc = (IASTMacroExpansionLocation) nodeLocations[0];
+ assertEqualsMacros(first_loc.getExpansion().getMacroDefinition(), XYZ);
+ IASTFileLocation second_loc = (IASTFileLocation) nodeLocations[1];
+ assertEquals(1, second_loc.getNodeLength());
+ IASTMacroExpansionLocation third_loc = (IASTMacroExpansionLocation) nodeLocations[2];
+ assertEqualsMacros(third_loc.getExpansion().getMacroDefinition(), IT);
+ IASTFileLocation fourth_loc = (IASTFileLocation) nodeLocations[3];
+ assertEquals(1, fourth_loc.getNodeLength());
+ IASTMacroExpansionLocation fifth_loc = (IASTMacroExpansionLocation) nodeLocations[4];
+ assertEqualsMacros(fifth_loc.getExpansion().getMacroDefinition(), C_PO);
+ IASTFileLocation sixth_loc = (IASTFileLocation) nodeLocations[5];
+ assertEquals(1, sixth_loc.getNodeLength());
+ IASTMacroExpansionLocation seventh_loc = (IASTMacroExpansionLocation) nodeLocations[6];
+ assertEqualsMacros(seventh_loc.getExpansion().getMacroDefinition(), C_PO);
+ IASTFileLocation eighth_loc = (IASTFileLocation) nodeLocations[7];
+ assertEquals(1, eighth_loc.getNodeLength());
+ IASTMacroExpansionLocation ninth_loc = (IASTMacroExpansionLocation) nodeLocations[8];
+ assertEqualsMacros(ninth_loc.getExpansion().getMacroDefinition(), V);
+ IASTFileLocation tenth_loc = (IASTFileLocation) nodeLocations[9];
+ assertEquals(1, tenth_loc.getNodeLength());
+
+ final IASTFileLocation flatLocation = var.getFileLocation();
+ assertNotNull(flatLocation);
+ assertEquals(code.indexOf("XYZ IT C_PO C_PO V;"), flatLocation.getNodeOffset()); //$NON-NLS-1$
+ assertEquals("XYZ IT C_PO C_PO V;".length(), flatLocation.getNodeLength()); //$NON-NLS-1$
+
+ }
+ }
+
+ public void testStdioBug() throws ParserException {
+ StringBuilder buffer = new StringBuilder("#define _PTR void *\n"); //$NON-NLS-1$
+ buffer.append("#define __cdecl __attribute__ ((__cdecl__))\n"); //$NON-NLS-1$
+ buffer.append("#define _EXFUN(name, proto) __cdecl name proto\n"); //$NON-NLS-1$
+ buffer.append("_PTR _EXFUN(memchr,(const _PTR, int, size_t));\n"); //$NON-NLS-1$
+ String code = buffer.toString();
+
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language, true, true);
+ final IASTPreprocessorMacroDefinition[] macroDefinitions = tu.getMacroDefinitions();
+ IASTPreprocessorObjectStyleMacroDefinition _PTR = (IASTPreprocessorObjectStyleMacroDefinition) macroDefinitions[0];
+ IASTPreprocessorFunctionStyleMacroDefinition _EXFUN = (IASTPreprocessorFunctionStyleMacroDefinition) macroDefinitions[2];
+ IASTSimpleDeclaration memchr = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTNodeLocation[] locations = memchr.getNodeLocations();
+ assertEquals(locations.length, 4);
+ IASTMacroExpansionLocation loc_1 = (IASTMacroExpansionLocation) locations[0];
+ assertEqualsMacros(_PTR, loc_1.getExpansion().getMacroDefinition());
+ IASTFileLocation loc_2 = (IASTFileLocation) locations[1];
+ assertEquals(loc_2.getNodeOffset(), code.indexOf(" _EXFUN(")); //$NON-NLS-1$
+ assertEquals(loc_2.getNodeLength(), " ".length()); //$NON-NLS-1$
+ IASTMacroExpansionLocation loc_3 = (IASTMacroExpansionLocation) locations[2];
+ assertEqualsMacros(_EXFUN, loc_3.getExpansion().getMacroDefinition());
+ IASTFileLocation loc_4 = (IASTFileLocation) locations[3];
+ assertEquals(loc_4.getNodeOffset(), code.indexOf(";")); //$NON-NLS-1$
+ assertEquals(loc_4.getNodeLength(), 1);
+ IASTFileLocation flat = memchr.getFileLocation();
+ assertEquals(flat.getNodeOffset(), code.indexOf("_PTR _EXFUN(memchr,(const _PTR, int, size_t));")); //$NON-NLS-1$
+ assertEquals(flat.getNodeLength(), "_PTR _EXFUN(memchr,(const _PTR, int, size_t));".length()); //$NON-NLS-1$
+
+ IASTDeclarator d = memchr.getDeclarators()[0];
+ IASTFileLocation f = d.getFileLocation();
+ assertEquals(code.indexOf("_PTR _EXFUN(memchr,(const _PTR, int, size_t))"), f.getNodeOffset()); //$NON-NLS-1$
+ assertEquals("_PTR _EXFUN(memchr,(const _PTR, int, size_t))".length(), f.getNodeLength()); //$NON-NLS-1$
+ }
+ }
+
+ private void assertEqualsMacros(IASTPreprocessorMacroDefinition fromExpansion,
+ IASTPreprocessorMacroDefinition source) {
+ assertEquals(fromExpansion.getExpansion(), source.getExpansion());
+ assertEquals(fromExpansion.getName().toString(), source.getName().toString());
+ }
+
+ public void testMacroBindings() throws Exception {
+ StringBuilder buffer = new StringBuilder("#define ABC def\n"); //$NON-NLS-1$
+ buffer.append("int ABC;\n"); //$NON-NLS-1$
+ buffer.append("#undef ABC\n"); //$NON-NLS-1$
+ buffer.append("#define ABC ghi\n"); //$NON-NLS-1$
+ buffer.append("int ABC;\n"); //$NON-NLS-1$
+ String code = buffer.toString();
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTPreprocessorMacroDefinition[] macros = tu.getMacroDefinitions();
+ assertEquals(macros.length, 2);
+ IASTPreprocessorObjectStyleMacroDefinition ABC1 = (IASTPreprocessorObjectStyleMacroDefinition) macros[0];
+ IASTPreprocessorObjectStyleMacroDefinition ABC2 = (IASTPreprocessorObjectStyleMacroDefinition) macros[1];
+ IMacroBinding binding1 = (IMacroBinding) ABC1.getName().resolveBinding();
+ assertNotNull(binding1);
+ IMacroBinding binding2 = (IMacroBinding) ABC2.getName().resolveBinding();
+ assertNotNull(binding2);
+ assertNotSame(binding1, binding2);
+ IASTName[] firstReferences = tu.getReferences(binding1);
+ IASTName[] firstDeclarations = tu.getDeclarationsInAST(binding1);
+ assertEquals(firstReferences.length, 2);
+ assertEquals(firstReferences[0].getPropertyInParent(), IASTPreprocessorMacroExpansion.EXPANSION_NAME);
+ assertEquals(firstReferences[0].getParent().getParent(), tu);
+ assertEquals(firstReferences[1].getPropertyInParent(), IASTPreprocessorStatement.MACRO_NAME);
+ assertTrue(firstReferences[1].getParent() instanceof IASTPreprocessorUndefStatement);
+ assertEquals(firstDeclarations.length, 1);
+ assertSame(ABC1.getName(), firstDeclarations[0]);
+ IASTName[] secondReferences = tu.getReferences(binding2);
+ IASTName[] secondDeclarations = tu.getDeclarationsInAST(binding2);
+ assertEquals(1, secondReferences.length);
+ assertEquals(secondReferences[0].getPropertyInParent(), IASTPreprocessorMacroExpansion.EXPANSION_NAME);
+ assertEquals(secondReferences[0].getParent().getParent(), tu);
+ assertSame(ABC2.getName(), secondDeclarations[0]);
+ }
+ }
+
+ public void testBug90978() throws Exception {
+ StringBuilder buffer = new StringBuilder("#define MACRO mm\n"); //$NON-NLS-1$
+ buffer.append("int MACRO;\n"); //$NON-NLS-1$
+ String code = buffer.toString();
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTPreprocessorObjectStyleMacroDefinition MACRO = (IASTPreprocessorObjectStyleMacroDefinition) tu
+ .getMacroDefinitions()[0];
+ IASTName macro_name = MACRO.getName();
+ IMacroBinding binding = (IMacroBinding) macro_name.resolveBinding();
+ IASTName[] references = tu.getReferences(binding);
+ assertEquals(references.length, 1);
+ IASTName reference = references[0];
+ IASTNodeLocation[] nodeLocations = reference.getNodeLocations();
+ assertEquals(nodeLocations.length, 1);
+ assertTrue(nodeLocations[0] instanceof IASTFileLocation);
+ IASTFileLocation loc = (IASTFileLocation) nodeLocations[0];
+ assertEquals(code.indexOf("int MACRO") + "int ".length(), loc.getNodeOffset()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("MACRO".length(), loc.getNodeLength()); //$NON-NLS-1$
+ }
+ }
+
+ public void testBug94933() throws Exception {
+ StringBuilder buffer = new StringBuilder("#define API extern\n"); //$NON-NLS-1$
+ buffer.append("#define MYAPI API\n"); //$NON-NLS-1$
+ buffer.append("MYAPI void func() {}"); //$NON-NLS-1$
+ String code = buffer.toString();
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ assertNotNull(f.getFileLocation());
+ }
+ }
+
+ public void testFunctionMacroExpansionWithNameSubstitution_Bug173637() throws Exception {
+ StringBuilder buffer = new StringBuilder("#define PLUS5(x) (x+5)\n"); //$NON-NLS-1$
+ buffer.append("#define FUNCTION PLUS5 \n"); //$NON-NLS-1$
+ buffer.append("int var= FUNCTION(1);"); //$NON-NLS-1$
+ String code = buffer.toString();
+
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTEqualsInitializer initializer = (IASTEqualsInitializer) var.getDeclarators()[0].getInitializer();
+ IASTInitializerClause expr = initializer.getInitializerClause();
+ assertNotNull(expr.getFileLocation());
+ IASTNodeLocation[] locations = expr.getNodeLocations();
+ assertEquals(1, locations.length);
+ IASTMacroExpansionLocation macroExpansion = (IASTMacroExpansionLocation) locations[0];
+ IASTNodeLocation[] expLocations = macroExpansion.getExpansion().getNodeLocations();
+ assertEquals(1, expLocations.length);
+ assertEquals(code.indexOf("FUNCTION(1)"), expLocations[0].getNodeOffset());
+ assertEquals("FUNCTION(1)".length(), expLocations[0].getNodeLength());
+ }
+ }
+
+ private void assertMacroLocation(IASTDeclaration decl, int index, int length) {
+ IASTSimpleDeclaration var = (IASTSimpleDeclaration) decl;
+ IASTEqualsInitializer initializer = (IASTEqualsInitializer) var.getDeclarators()[0].getInitializer();
+ IASTInitializerClause expr = initializer.getInitializerClause();
+ assertNotNull(expr.getFileLocation());
+ IASTNodeLocation[] locations = expr.getNodeLocations();
+ assertEquals(1, locations.length);
+ IASTMacroExpansionLocation macroExpansion = (IASTMacroExpansionLocation) locations[0];
+ IASTNodeLocation[] expLocations = macroExpansion.getExpansion().getNodeLocations();
+ assertEquals(1, expLocations.length);
+ IASTFileLocation fileLocation = expLocations[0].asFileLocation();
+ assertEquals(index, fileLocation.getNodeOffset());
+ assertEquals(length, fileLocation.getNodeLength());
+ }
+
+ private void assertExpressionLocation(IASTDeclaration decl, int index, int length) {
+ IASTSimpleDeclaration var = (IASTSimpleDeclaration) decl;
+ IASTEqualsInitializer initializer = (IASTEqualsInitializer) var.getDeclarators()[0].getInitializer();
+ IASTInitializerClause expr = initializer.getInitializerClause();
+ IASTFileLocation fileLocation = expr.getFileLocation();
+ assertNotNull(fileLocation);
+ assertEquals(index, fileLocation.getNodeOffset());
+ assertEquals(length, fileLocation.getNodeLength());
+ }
+
+ public void testBug186257() throws Exception {
+ StringBuilder sb = new StringBuilder();
+ sb.append("typedef char STR; \n"); //$NON-NLS-1$
+ sb.append("#define Nullstr Null(STR*) \n"); //$NON-NLS-1$
+ sb.append("#define Null(x) ((x)NULL) \n"); //$NON-NLS-1$
+ sb.append("int x = Nullstr; \n"); //$NON-NLS-1$
+ sb.append("int y = whatever; \n"); //$NON-NLS-1$
+ String code = sb.toString();
+
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ assertMacroLocation(decls[1], code.indexOf("Nullstr;"), "Nullstr".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertExpressionLocation(decls[2], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public void testArgumentExpansion() throws Exception {
+ StringBuilder sb = new StringBuilder();
+ sb.append("#define ADD(a,b, c) (a) + (b) + (c) \n"); //$NON-NLS-1$
+ sb.append("#define ONEYONENOE 111111 \n"); //$NON-NLS-1$
+ sb.append("#define TWO 2 \n"); //$NON-NLS-1$
+ sb.append("#define THREE 3 \n"); //$NON-NLS-1$
+ sb.append("int x = ADD(ONEYONENOE,TWO, THREE); \n"); //$NON-NLS-1$
+ sb.append("int y = whatever; \n"); //$NON-NLS-1$
+ String code = sb.toString();
+
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ assertMacroLocation(decls[0], code.indexOf("ADD(ONEYONENOE,TWO, THREE)"), //$NON-NLS-1$
+ "ADD(ONEYONENOE,TWO, THREE)".length()); //$NON-NLS-1$
+ assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public void testArgumentCapture() throws Exception {
+ StringBuilder sb = new StringBuilder();
+ sb.append("#define add(x,y) x + y \n"); //$NON-NLS-1$
+ sb.append("#define add2 add(x, \n"); //$NON-NLS-1$
+ sb.append("int x = add2 z); \n"); //$NON-NLS-1$
+ sb.append("int y = whatever; \n"); //$NON-NLS-1$
+ String code = sb.toString();
+
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ assertMacroLocation(decls[0], code.indexOf("add2 z);"), "add2 z)".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public void testFunctionMacroNotCalled() throws Exception {
+ StringBuilder sb = new StringBuilder();
+ sb.append("#define FUNCTION(x) x \n"); //$NON-NLS-1$
+ sb.append("#define YO FUNCTION \n"); //$NON-NLS-1$
+ sb.append("int x = YO; \n"); //$NON-NLS-1$
+ sb.append("int y = whatever; \n"); //$NON-NLS-1$
+ String code = sb.toString();
+
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ assertMacroLocation(decls[0], code.indexOf("YO;"), "YO".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public void testBuildFunctionMacroName() throws Exception {
+ StringBuilder sb = new StringBuilder();
+ sb.append("#define FUN1(x) x \n"); //$NON-NLS-1$
+ sb.append("#define FUN1(x) x \n"); //$NON-NLS-1$
+ sb.append("#define MAKEFUN(num) FUN ## num \n"); //$NON-NLS-1$
+ sb.append("int x = MAKEFUN(1)(z); \n"); //$NON-NLS-1$
+ sb.append("int y = whatever; \n"); //$NON-NLS-1$
+ String code = sb.toString();
+
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ assertMacroLocation(decls[0], code.indexOf("MAKEFUN(1)(z);"), "MAKEFUN(1)(z)".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-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 b8dbd56ffd5..997fd70aaef 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
@@ -82,343 +82,346 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
*/
public class DOMLocationTests extends AST2TestBase {
- public DOMLocationTests() {
+ public DOMLocationTests() {
}
public DOMLocationTests(String name) {
setName(name);
}
- public static TestSuite suite() {
- return suite(DOMLocationTests.class);
- }
+ public static TestSuite suite() {
+ return suite(DOMLocationTests.class);
+ }
public void testBaseCase() throws ParserException {
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse("int x;", p); //$NON-NLS-1$
- IASTDeclaration declaration = tu.getDeclarations()[0];
- IASTNodeLocation[] nodeLocations = declaration.getNodeLocations();
- assertNotNull(nodeLocations);
- assertEquals(nodeLocations.length, 1);
- assertTrue(nodeLocations[0] instanceof IASTFileLocation);
- IASTFileLocation fileLocation = ((IASTFileLocation) nodeLocations[0]);
- assertEquals(fileLocation.getFileName(), TEST_CODE);
- assertEquals(fileLocation.getNodeOffset(), 0);
- assertEquals(fileLocation.getNodeLength(), 6);
- IASTNodeLocation[] tuLocations = tu.getNodeLocations();
- assertEquals(tuLocations.length, nodeLocations.length);
- assertEquals(fileLocation.getFileName(), ((IASTFileLocation) tuLocations[0]).getFileName());
- assertEquals(fileLocation.getNodeOffset(), tuLocations[0].getNodeOffset());
- assertEquals(fileLocation.getNodeLength(), tuLocations[0].getNodeLength());
- }
- }
-
- public void testSimpleDeclaration() throws ParserException {
- String code = "int xLen5, * yLength8, zLength16( int );"; //$NON-NLS-1$
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- IASTDeclaration[] declarations = tu.getDeclarations();
- assertEquals(declarations.length, 1);
- IASTSimpleDeclaration declaration = (IASTSimpleDeclaration) declarations[0];
- IASTNodeLocation[] nodeLocations = declaration.getNodeLocations();
- assertNotNull(nodeLocations);
- assertEquals(nodeLocations.length, 1);
- assertTrue(nodeLocations[0] instanceof IASTFileLocation);
- IASTFileLocation fileLocation = ((IASTFileLocation) nodeLocations[0]);
- assertEquals(fileLocation.getFileName(), TEST_CODE);
- assertEquals(fileLocation.getNodeOffset(), 0);
- assertEquals(fileLocation.getNodeLength(), code.indexOf(";") + 1); //$NON-NLS-1$
- IASTDeclarator[] declarators = declaration.getDeclarators();
- assertEquals(declarators.length, 3);
- for (int i = 0; i < 3; ++i) {
- IASTDeclarator declarator = declarators[i];
- switch (i) {
- case 0:
- assertSoleLocation(declarator, code.indexOf("xLen5"), "xLen5".length()); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case 1:
- assertSoleLocation(declarator, code.indexOf("* yLength8"), "* yLength8".length()); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case 2:
- assertSoleLocation(declarator, code.indexOf("zLength16( int )"), "zLength16( int )".length()); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- }
- }
-
- }
- }
-
- public void testSimpleObjectStyleMacroDefinition() throws Exception {
- String code = "/* hi */\n#define FOOT 0x01\n\n"; //$NON-NLS-1$
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- IASTDeclaration[] declarations = tu.getDeclarations();
- assertEquals(declarations.length, 0);
- IASTPreprocessorMacroDefinition[] macros = tu.getMacroDefinitions();
- assertNotNull(macros);
- assertEquals(macros.length, 1);
- assertSoleLocation(macros[0], code.indexOf("#"), code.indexOf("0x01") + 4 - code.indexOf("#")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertTrue(macros[0] instanceof IASTPreprocessorObjectStyleMacroDefinition);
- assertEquals(macros[0].getName().toString(), "FOOT"); //$NON-NLS-1$
- assertEquals(macros[0].getExpansion(), "0x01"); //$NON-NLS-1$
- }
- }
-
- public void testSimpleFunctionStyleMacroDefinition() throws Exception {
- String code = "#define FOOBAH( WOOBAH ) JOHN##WOOBAH\n\n"; //$NON-NLS-1$
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- IASTDeclaration[] declarations = tu.getDeclarations();
- assertEquals(declarations.length, 0);
- IASTPreprocessorMacroDefinition[] macros = tu.getMacroDefinitions();
- assertNotNull(macros);
- assertEquals(macros.length, 1);
- assertTrue(macros[0] instanceof IASTPreprocessorFunctionStyleMacroDefinition);
- assertSoleLocation(macros[0], code.indexOf("#define"), code.indexOf("##WOOBAH") + 8 - code.indexOf("#define")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$s
- assertEquals(macros[0].getName().toString(), "FOOBAH"); //$NON-NLS-1$
- assertEquals(macros[0].getExpansion(), "JOHN##WOOBAH"); //$NON-NLS-1$
- IASTFunctionStyleMacroParameter[] parms = ((IASTPreprocessorFunctionStyleMacroDefinition) macros[0]).getParameters();
- assertNotNull(parms);
- assertEquals(parms.length, 1);
- assertEquals(parms[0].getParameter(), "WOOBAH"); //$NON-NLS-1$
- }
-
- }
-
- private void assertSoleLocation(IASTNode n, int offset, int length) {
- assertEquals(length, ((ASTNode)n).getLength());
- IASTNodeLocation[] locations = n.getNodeLocations();
- assertEquals(1, locations.length);
- IASTNodeLocation nodeLocation = locations[0];
- assertEquals(offset, nodeLocation.getNodeOffset());
- assertEquals(length, nodeLocation.getNodeLength());
- }
-
- private void assertFileLocation(IASTNode n, int offset, int length) {
- IASTNodeLocation location = n.getFileLocation();
- assertEquals(offset, location.getNodeOffset());
- assertEquals(length, location.getNodeLength());
- }
-
- 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);
- IASTDeclaration[] declarations = tu.getDeclarations();
- assertEquals(declarations.length, 1);
- IASTFunctionDefinition definition = (IASTFunctionDefinition) declarations[0];
- IASTFunctionDeclarator declarator = definition.getDeclarator();
- assertSoleLocation(declarator, code.indexOf("foo"), code.indexOf("int x;") + 6 - code.indexOf("foo")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
- assertEquals(body.getStatements().length, 1);
- IASTReturnStatement returnStatement = (IASTReturnStatement) body.getStatements()[0];
- IASTIdExpression expression = (IASTIdExpression) returnStatement.getReturnValue();
- assertSoleLocation(expression, code.indexOf("return ") + "return ".length(), 1); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBug84343() throws Exception {
- String code = "class A {}; int f() {\nA * b = 0;\nreturn b;}"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[1];
- IASTDeclarationStatement ds = (IASTDeclarationStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0];
- IASTSimpleDeclaration b = (IASTSimpleDeclaration) ds.getDeclaration();
- ICPPASTNamedTypeSpecifier namedTypeSpec = (ICPPASTNamedTypeSpecifier) b.getDeclSpecifier();
- assertSoleLocation(namedTypeSpec, code.indexOf("\nA") + 1, 1); //$NON-NLS-1$
- }
-
- public void testBug84366() throws Exception {
- String code = "enum hue { red, blue, green };"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- IASTSimpleDeclaration d = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTEnumerationSpecifier enumeration = (IASTEnumerationSpecifier) d.getDeclSpecifier();
- IASTEnumerationSpecifier.IASTEnumerator enumerator = enumeration.getEnumerators()[0];
- assertSoleLocation(enumerator, code.indexOf("red"), "red".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBug84375() throws Exception {
- String code = "class D { public: int x; };\nclass C : public virtual D {};"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- IASTSimpleDeclaration d2 = (IASTSimpleDeclaration) tu.getDeclarations()[1];
- ICPPASTCompositeTypeSpecifier classSpec = (ICPPASTCompositeTypeSpecifier) d2.getDeclSpecifier();
- ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier [] bases = classSpec.getBaseSpecifiers();
- assertSoleLocation(bases[0], code.indexOf("public virtual D"), "public virtual D".length()); //$NON-NLS-1$ //$NON-NLS-2$
-
- }
-
- public void testBug84357() throws Exception {
- String code = "class X { int a;\n};\nint X:: * pmi = &X::a;"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- IASTSimpleDeclaration pmi = (IASTSimpleDeclaration) tu.getDeclarations()[1];
- IASTDeclarator d = pmi.getDeclarators()[0];
- IASTPointerOperator p = d.getPointerOperators()[0];
- assertSoleLocation(p, code.indexOf("X:: *"), "X:: *".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBug84367() throws Exception {
- String code = "void foo( int );"; //$NON-NLS-1$
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- IASTSimpleDeclaration definition = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTStandardFunctionDeclarator declarator = (IASTStandardFunctionDeclarator) definition.getDeclarators()[0];
- IASTParameterDeclaration parameter = declarator.getParameters()[0];
- assertSoleLocation(parameter, code.indexOf("int"), 3); //$NON-NLS-1$
- }
- }
-
- public void testElaboratedTypeSpecifier() throws ParserException {
- String code = "/* blah */ struct A anA; /* blah */"; //$NON-NLS-1$
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- IASTSimpleDeclaration declaration = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTElaboratedTypeSpecifier elabType = (IASTElaboratedTypeSpecifier) declaration.getDeclSpecifier();
- assertSoleLocation(elabType, code.indexOf("struct"), "struct A".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public void testBug83852() throws Exception {
- String code = "/* blah */ typedef short jc; int x = 4; jc myJc = (jc)x; "; //$NON-NLS-1$
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- IASTDeclaration[] declarations = tu.getDeclarations();
- assertEquals(3, declarations.length);
- for (int i = 0; i < 3; ++i) {
- IASTSimpleDeclaration decl = (IASTSimpleDeclaration) declarations[i];
- int start = 0, length = 0;
- switch (i) {
- case 0:
- start = code.indexOf("typedef"); //$NON-NLS-1$
- length = "typedef short jc;".length(); //$NON-NLS-1$
- break;
- case 1:
- start = code.indexOf("int x = 4;"); //$NON-NLS-1$
- length = "int x = 4;".length(); //$NON-NLS-1$
- break;
- case 2:
- start = code.indexOf("jc myJc = (jc)x;"); //$NON-NLS-1$
- length = "jc myJc = (jc)x;".length(); //$NON-NLS-1$
- break;
- }
- assertSoleLocation(decl, start, length);
- }
- IASTEqualsInitializer initializer = (IASTEqualsInitializer) ((IASTSimpleDeclaration) declarations[2])
- .getDeclarators()[0].getInitializer();
- IASTCastExpression castExpression = (IASTCastExpression) initializer.getInitializerClause();
- IASTTypeId typeId = castExpression.getTypeId();
- assertSoleLocation(typeId, code.indexOf("(jc)") + 1, "jc".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public void testBug83853() throws ParserException {
- String code = "int f() {return (1?0:1); }"; //$NON-NLS-1$
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- IASTFunctionDefinition definition = (IASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement statement = (IASTCompoundStatement) definition.getBody();
- IASTReturnStatement returnStatement = (IASTReturnStatement) statement.getStatements()[0];
- IASTUnaryExpression unaryExpression = (IASTUnaryExpression) returnStatement.getReturnValue();
- assertEquals(unaryExpression.getOperator(), IASTUnaryExpression.op_bracketedPrimary);
- IASTConditionalExpression conditional = (IASTConditionalExpression) unaryExpression.getOperand();
- assertSoleLocation(conditional, code.indexOf("1?0:1"), "1?0:1".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public void testBug84374() throws Exception {
- String code = "class P1 { public: int x; };\nclass P2 { public: int x; };\nclass B : public P1, public P2 {};\nvoid main() {\nB * b = new B();\n}"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- IASTFunctionDefinition main = (IASTFunctionDefinition) tu.getDeclarations()[3];
- IASTCompoundStatement statement = (IASTCompoundStatement) main.getBody();
- IASTDeclarationStatement decl = (IASTDeclarationStatement) statement.getStatements()[0];
- IASTSimpleDeclaration b = (IASTSimpleDeclaration) decl.getDeclaration();
- IASTEqualsInitializer initializerExpression = (IASTEqualsInitializer) b.getDeclarators()[0].getInitializer();
- assertSoleLocation(initializerExpression.getInitializerClause(),code.indexOf("new B()"), "new B()".length()); //$NON-NLS-1$ //$NON-NLS-2$
- ICPPASTNewExpression newExpression = (ICPPASTNewExpression) initializerExpression.getInitializerClause();
- assertSoleLocation(newExpression, code.indexOf("new B()"), "new B()".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBug83737() throws Exception {
- String code = "void f() { if( a == 0 ) g( a ); else if( a < 0 ) g( a >> 1 ); else if( a > 0 ) g( *(&a + 2) ); }"; //$NON-NLS-1$
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- IASTFunctionDefinition definition = (IASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement statement = (IASTCompoundStatement) definition.getBody();
- IASTIfStatement first_if = (IASTIfStatement) statement.getStatements()[0];
- IASTIfStatement second_if = (IASTIfStatement) first_if.getElseClause();
- IASTIfStatement third_if = (IASTIfStatement) second_if.getElseClause();
- assertNull(third_if.getElseClause());
- int first_if_start = code.indexOf("if( a == 0 )"); //$NON-NLS-1$
- int total_if_length = "if( a == 0 ) g( a ); else if( a < 0 ) g( a >> 1 ); else if( a > 0 ) g( *(&a + 2) );".length(); //$NON-NLS-1$
- int total_if_end = first_if_start + total_if_length;
- int second_if_start = code.indexOf("if( a < 0 )"); //$NON-NLS-1$
- int third_if_start = code.indexOf("if( a > 0 )"); //$NON-NLS-1$
- assertSoleLocation(first_if, first_if_start, total_if_length);
- assertSoleLocation(second_if, second_if_start, total_if_end - second_if_start);
- assertSoleLocation(third_if, third_if_start, total_if_end - third_if_start);
- }
- }
-
- public void testBug84467() throws Exception {
- String code = "class D { };\n D d1;\n const D d2;\n void foo() {\n typeid(d1) == typeid(d2);\n }"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- IASTBinaryExpression bexp = (IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
- .getDeclarations()[3]).getBody()).getStatements()[0]).getExpression();
- IASTUnaryExpression exp = (IASTUnaryExpression) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
- .getDeclarations()[3]).getBody()).getStatements()[0])
- .getExpression()).getOperand1();
-
- assertSoleLocation(bexp, code.indexOf("typeid(d1) == typeid(d2)"), "typeid(d1) == typeid(d2)".length()); //$NON-NLS-1$ //$NON-NLS-2$
- assertSoleLocation(exp, code.indexOf("typeid(d1)"), "typeid(d1)".length()); //$NON-NLS-1$ //$NON-NLS-2$
- exp = (IASTUnaryExpression) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
- .getDeclarations()[3]).getBody()).getStatements()[0]).getExpression()).getOperand2();
- assertSoleLocation(exp, code.indexOf("typeid(d2)"), "typeid(d2)".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBug84576() throws Exception {
- String code = "namespace A {\n extern \"C\" int g();\n }"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTLinkageSpecification spec = (ICPPASTLinkageSpecification) ((ICPPASTNamespaceDefinition) tu.getDeclarations()[0]).getDeclarations()[0];
- assertSoleLocation(spec, code.indexOf("extern \"C\""), "extern \"C\" int g();".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testSimplePreprocessorStatements() throws Exception
- {
- StringBuilder buffer = new StringBuilder();
- buffer.append( "#ifndef _APPLE_H_\n"); //$NON-NLS-1$
- buffer.append( "#define _APPLE_H_\n"); //$NON-NLS-1$
- buffer.append( "#undef _APPLE_H_\n"); //$NON-NLS-1$
- buffer.append( "#endif\n"); //$NON-NLS-1$
- String code = buffer.toString();
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- assertEquals( tu.getDeclarations().length, 0 );
- IASTPreprocessorStatement [] statements = tu.getAllPreprocessorStatements();
- assertEquals( statements.length, 4 );
- IASTPreprocessorIfndefStatement ifndef = (IASTPreprocessorIfndefStatement) statements[0];
- assertTrue( ifndef.taken() );
- assertSoleLocation( ifndef, code.indexOf( "#ifndef _APPLE_H_"), "#ifndef _APPLE_H_".length() ); //$NON-NLS-1$ //$NON-NLS-2$
- IASTPreprocessorObjectStyleMacroDefinition definition = (IASTPreprocessorObjectStyleMacroDefinition) statements[1];
- assertSoleLocation( definition, code.indexOf( "#define _APPLE_H_"), "#define _APPLE_H_".length() ); //$NON-NLS-1$ //$NON-NLS-2$
- IASTPreprocessorUndefStatement undef = (IASTPreprocessorUndefStatement) statements[2];
- assertSoleLocation( undef, code.indexOf("#undef _APPLE_H_"), "#undef _APPLE_H_".length() ); //$NON-NLS-1$ //$NON-NLS-2$
- IASTPreprocessorEndifStatement endif = (IASTPreprocessorEndifStatement) statements[3];
- assertSoleLocation( endif, code.indexOf( "#endif"), "#endif".length() ); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public void testBug162180() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append( "#include <notfound.h>\n"); //$NON-NLS-1$
- buffer.append( "int x;\n"); //$NON-NLS-1$
- String code = buffer.toString();
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p, false, false);
- IASTDeclaration[] decls= tu.getDeclarations();
- assertEquals( decls.length, 1 );
- IASTPreprocessorStatement [] statements = tu.getAllPreprocessorStatements();
- assertEquals( statements.length, 1 );
- IASTProblem[] problems = tu.getPreprocessorProblems();
- assertEquals( problems.length, 1 );
- assertSoleLocation( decls[0], code, "int x;");
- }
- }
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse("int x;", p); //$NON-NLS-1$
+ IASTDeclaration declaration = tu.getDeclarations()[0];
+ IASTNodeLocation[] nodeLocations = declaration.getNodeLocations();
+ assertNotNull(nodeLocations);
+ assertEquals(nodeLocations.length, 1);
+ assertTrue(nodeLocations[0] instanceof IASTFileLocation);
+ IASTFileLocation fileLocation = ((IASTFileLocation) nodeLocations[0]);
+ assertEquals(fileLocation.getFileName(), TEST_CODE);
+ assertEquals(fileLocation.getNodeOffset(), 0);
+ assertEquals(fileLocation.getNodeLength(), 6);
+ IASTNodeLocation[] tuLocations = tu.getNodeLocations();
+ assertEquals(tuLocations.length, nodeLocations.length);
+ assertEquals(fileLocation.getFileName(), ((IASTFileLocation) tuLocations[0]).getFileName());
+ assertEquals(fileLocation.getNodeOffset(), tuLocations[0].getNodeOffset());
+ assertEquals(fileLocation.getNodeLength(), tuLocations[0].getNodeLength());
+ }
+ }
+
+ public void testSimpleDeclaration() throws ParserException {
+ String code = "int xLen5, * yLength8, zLength16( int );"; //$NON-NLS-1$
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ IASTDeclaration[] declarations = tu.getDeclarations();
+ assertEquals(declarations.length, 1);
+ IASTSimpleDeclaration declaration = (IASTSimpleDeclaration) declarations[0];
+ IASTNodeLocation[] nodeLocations = declaration.getNodeLocations();
+ assertNotNull(nodeLocations);
+ assertEquals(nodeLocations.length, 1);
+ assertTrue(nodeLocations[0] instanceof IASTFileLocation);
+ IASTFileLocation fileLocation = ((IASTFileLocation) nodeLocations[0]);
+ assertEquals(fileLocation.getFileName(), TEST_CODE);
+ assertEquals(fileLocation.getNodeOffset(), 0);
+ assertEquals(fileLocation.getNodeLength(), code.indexOf(";") + 1); //$NON-NLS-1$
+ IASTDeclarator[] declarators = declaration.getDeclarators();
+ assertEquals(declarators.length, 3);
+ for (int i = 0; i < 3; ++i) {
+ IASTDeclarator declarator = declarators[i];
+ switch (i) {
+ case 0:
+ assertSoleLocation(declarator, code.indexOf("xLen5"), "xLen5".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ case 1:
+ assertSoleLocation(declarator, code.indexOf("* yLength8"), "* yLength8".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ case 2:
+ assertSoleLocation(declarator, code.indexOf("zLength16( int )"), "zLength16( int )".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ }
+ }
+
+ }
+ }
+
+ public void testSimpleObjectStyleMacroDefinition() throws Exception {
+ String code = "/* hi */\n#define FOOT 0x01\n\n"; //$NON-NLS-1$
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ IASTDeclaration[] declarations = tu.getDeclarations();
+ assertEquals(declarations.length, 0);
+ IASTPreprocessorMacroDefinition[] macros = tu.getMacroDefinitions();
+ assertNotNull(macros);
+ assertEquals(macros.length, 1);
+ assertSoleLocation(macros[0], code.indexOf("#"), code.indexOf("0x01") + 4 - code.indexOf("#")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertTrue(macros[0] instanceof IASTPreprocessorObjectStyleMacroDefinition);
+ assertEquals(macros[0].getName().toString(), "FOOT"); //$NON-NLS-1$
+ assertEquals(macros[0].getExpansion(), "0x01"); //$NON-NLS-1$
+ }
+ }
+
+ public void testSimpleFunctionStyleMacroDefinition() throws Exception {
+ String code = "#define FOOBAH( WOOBAH ) JOHN##WOOBAH\n\n"; //$NON-NLS-1$
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ IASTDeclaration[] declarations = tu.getDeclarations();
+ assertEquals(declarations.length, 0);
+ IASTPreprocessorMacroDefinition[] macros = tu.getMacroDefinitions();
+ assertNotNull(macros);
+ assertEquals(macros.length, 1);
+ assertTrue(macros[0] instanceof IASTPreprocessorFunctionStyleMacroDefinition);
+ assertSoleLocation(macros[0], code.indexOf("#define"), //$NON-NLS-1$
+ code.indexOf("##WOOBAH") + 8 - code.indexOf("#define")); //$NON-NLS-1$ //$NON-NLS-2$s
+ assertEquals(macros[0].getName().toString(), "FOOBAH"); //$NON-NLS-1$
+ assertEquals(macros[0].getExpansion(), "JOHN##WOOBAH"); //$NON-NLS-1$
+ IASTFunctionStyleMacroParameter[] parms = ((IASTPreprocessorFunctionStyleMacroDefinition) macros[0])
+ .getParameters();
+ assertNotNull(parms);
+ assertEquals(parms.length, 1);
+ assertEquals(parms[0].getParameter(), "WOOBAH"); //$NON-NLS-1$
+ }
+
+ }
+
+ private void assertSoleLocation(IASTNode n, int offset, int length) {
+ assertEquals(length, ((ASTNode) n).getLength());
+ IASTNodeLocation[] locations = n.getNodeLocations();
+ assertEquals(1, locations.length);
+ IASTNodeLocation nodeLocation = locations[0];
+ assertEquals(offset, nodeLocation.getNodeOffset());
+ assertEquals(length, nodeLocation.getNodeLength());
+ }
+
+ private void assertFileLocation(IASTNode n, int offset, int length) {
+ IASTNodeLocation location = n.getFileLocation();
+ assertEquals(offset, location.getNodeOffset());
+ assertEquals(length, location.getNodeLength());
+ }
+
+ 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);
+ IASTDeclaration[] declarations = tu.getDeclarations();
+ assertEquals(declarations.length, 1);
+ IASTFunctionDefinition definition = (IASTFunctionDefinition) declarations[0];
+ IASTFunctionDeclarator declarator = definition.getDeclarator();
+ assertSoleLocation(declarator, code.indexOf("foo"), code.indexOf("int x;") + 6 - code.indexOf("foo")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
+ assertEquals(body.getStatements().length, 1);
+ IASTReturnStatement returnStatement = (IASTReturnStatement) body.getStatements()[0];
+ IASTIdExpression expression = (IASTIdExpression) returnStatement.getReturnValue();
+ assertSoleLocation(expression, code.indexOf("return ") + "return ".length(), 1); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBug84343() throws Exception {
+ String code = "class A {}; int f() {\nA * b = 0;\nreturn b;}"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[1];
+ IASTDeclarationStatement ds = (IASTDeclarationStatement) ((IASTCompoundStatement) f.getBody())
+ .getStatements()[0];
+ IASTSimpleDeclaration b = (IASTSimpleDeclaration) ds.getDeclaration();
+ ICPPASTNamedTypeSpecifier namedTypeSpec = (ICPPASTNamedTypeSpecifier) b.getDeclSpecifier();
+ assertSoleLocation(namedTypeSpec, code.indexOf("\nA") + 1, 1); //$NON-NLS-1$
+ }
+
+ public void testBug84366() throws Exception {
+ String code = "enum hue { red, blue, green };"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ IASTSimpleDeclaration d = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTEnumerationSpecifier enumeration = (IASTEnumerationSpecifier) d.getDeclSpecifier();
+ IASTEnumerationSpecifier.IASTEnumerator enumerator = enumeration.getEnumerators()[0];
+ assertSoleLocation(enumerator, code.indexOf("red"), "red".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBug84375() throws Exception {
+ String code = "class D { public: int x; };\nclass C : public virtual D {};"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ IASTSimpleDeclaration d2 = (IASTSimpleDeclaration) tu.getDeclarations()[1];
+ ICPPASTCompositeTypeSpecifier classSpec = (ICPPASTCompositeTypeSpecifier) d2.getDeclSpecifier();
+ ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier[] bases = classSpec.getBaseSpecifiers();
+ assertSoleLocation(bases[0], code.indexOf("public virtual D"), "public virtual D".length()); //$NON-NLS-1$ //$NON-NLS-2$
+
+ }
+
+ public void testBug84357() throws Exception {
+ String code = "class X { int a;\n};\nint X:: * pmi = &X::a;"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ IASTSimpleDeclaration pmi = (IASTSimpleDeclaration) tu.getDeclarations()[1];
+ IASTDeclarator d = pmi.getDeclarators()[0];
+ IASTPointerOperator p = d.getPointerOperators()[0];
+ assertSoleLocation(p, code.indexOf("X:: *"), "X:: *".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBug84367() throws Exception {
+ String code = "void foo( int );"; //$NON-NLS-1$
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ IASTSimpleDeclaration definition = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTStandardFunctionDeclarator declarator = (IASTStandardFunctionDeclarator) definition.getDeclarators()[0];
+ IASTParameterDeclaration parameter = declarator.getParameters()[0];
+ assertSoleLocation(parameter, code.indexOf("int"), 3); //$NON-NLS-1$
+ }
+ }
+
+ public void testElaboratedTypeSpecifier() throws ParserException {
+ String code = "/* blah */ struct A anA; /* blah */"; //$NON-NLS-1$
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ IASTSimpleDeclaration declaration = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTElaboratedTypeSpecifier elabType = (IASTElaboratedTypeSpecifier) declaration.getDeclSpecifier();
+ assertSoleLocation(elabType, code.indexOf("struct"), "struct A".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public void testBug83852() throws Exception {
+ String code = "/* blah */ typedef short jc; int x = 4; jc myJc = (jc)x; "; //$NON-NLS-1$
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ IASTDeclaration[] declarations = tu.getDeclarations();
+ assertEquals(3, declarations.length);
+ for (int i = 0; i < 3; ++i) {
+ IASTSimpleDeclaration decl = (IASTSimpleDeclaration) declarations[i];
+ int start = 0, length = 0;
+ switch (i) {
+ case 0:
+ start = code.indexOf("typedef"); //$NON-NLS-1$
+ length = "typedef short jc;".length(); //$NON-NLS-1$
+ break;
+ case 1:
+ start = code.indexOf("int x = 4;"); //$NON-NLS-1$
+ length = "int x = 4;".length(); //$NON-NLS-1$
+ break;
+ case 2:
+ start = code.indexOf("jc myJc = (jc)x;"); //$NON-NLS-1$
+ length = "jc myJc = (jc)x;".length(); //$NON-NLS-1$
+ break;
+ }
+ assertSoleLocation(decl, start, length);
+ }
+ IASTEqualsInitializer initializer = (IASTEqualsInitializer) ((IASTSimpleDeclaration) declarations[2])
+ .getDeclarators()[0].getInitializer();
+ IASTCastExpression castExpression = (IASTCastExpression) initializer.getInitializerClause();
+ IASTTypeId typeId = castExpression.getTypeId();
+ assertSoleLocation(typeId, code.indexOf("(jc)") + 1, "jc".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public void testBug83853() throws ParserException {
+ String code = "int f() {return (1?0:1); }"; //$NON-NLS-1$
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ IASTFunctionDefinition definition = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement statement = (IASTCompoundStatement) definition.getBody();
+ IASTReturnStatement returnStatement = (IASTReturnStatement) statement.getStatements()[0];
+ IASTUnaryExpression unaryExpression = (IASTUnaryExpression) returnStatement.getReturnValue();
+ assertEquals(unaryExpression.getOperator(), IASTUnaryExpression.op_bracketedPrimary);
+ IASTConditionalExpression conditional = (IASTConditionalExpression) unaryExpression.getOperand();
+ assertSoleLocation(conditional, code.indexOf("1?0:1"), "1?0:1".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public void testBug84374() throws Exception {
+ String code = "class P1 { public: int x; };\nclass P2 { public: int x; };\nclass B : public P1, public P2 {};\nvoid main() {\nB * b = new B();\n}"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ IASTFunctionDefinition main = (IASTFunctionDefinition) tu.getDeclarations()[3];
+ IASTCompoundStatement statement = (IASTCompoundStatement) main.getBody();
+ IASTDeclarationStatement decl = (IASTDeclarationStatement) statement.getStatements()[0];
+ IASTSimpleDeclaration b = (IASTSimpleDeclaration) decl.getDeclaration();
+ IASTEqualsInitializer initializerExpression = (IASTEqualsInitializer) b.getDeclarators()[0].getInitializer();
+ assertSoleLocation(initializerExpression.getInitializerClause(), code.indexOf("new B()"), "new B()".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ ICPPASTNewExpression newExpression = (ICPPASTNewExpression) initializerExpression.getInitializerClause();
+ assertSoleLocation(newExpression, code.indexOf("new B()"), "new B()".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBug83737() throws Exception {
+ String code = "void f() { if( a == 0 ) g( a ); else if( a < 0 ) g( a >> 1 ); else if( a > 0 ) g( *(&a + 2) ); }"; //$NON-NLS-1$
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ IASTFunctionDefinition definition = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement statement = (IASTCompoundStatement) definition.getBody();
+ IASTIfStatement first_if = (IASTIfStatement) statement.getStatements()[0];
+ IASTIfStatement second_if = (IASTIfStatement) first_if.getElseClause();
+ IASTIfStatement third_if = (IASTIfStatement) second_if.getElseClause();
+ assertNull(third_if.getElseClause());
+ int first_if_start = code.indexOf("if( a == 0 )"); //$NON-NLS-1$
+ int total_if_length = "if( a == 0 ) g( a ); else if( a < 0 ) g( a >> 1 ); else if( a > 0 ) g( *(&a + 2) );" //$NON-NLS-1$
+ .length();
+ int total_if_end = first_if_start + total_if_length;
+ int second_if_start = code.indexOf("if( a < 0 )"); //$NON-NLS-1$
+ int third_if_start = code.indexOf("if( a > 0 )"); //$NON-NLS-1$
+ assertSoleLocation(first_if, first_if_start, total_if_length);
+ assertSoleLocation(second_if, second_if_start, total_if_end - second_if_start);
+ assertSoleLocation(third_if, third_if_start, total_if_end - third_if_start);
+ }
+ }
+
+ public void testBug84467() throws Exception {
+ String code = "class D { };\n D d1;\n const D d2;\n void foo() {\n typeid(d1) == typeid(d2);\n }"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ IASTBinaryExpression bexp = (IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
+ .getDeclarations()[3]).getBody()).getStatements()[0]).getExpression();
+ IASTUnaryExpression exp = (IASTUnaryExpression) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
+ .getDeclarations()[3]).getBody()).getStatements()[0]).getExpression()).getOperand1();
+
+ assertSoleLocation(bexp, code.indexOf("typeid(d1) == typeid(d2)"), "typeid(d1) == typeid(d2)".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertSoleLocation(exp, code.indexOf("typeid(d1)"), "typeid(d1)".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ exp = (IASTUnaryExpression) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
+ .getDeclarations()[3]).getBody()).getStatements()[0]).getExpression()).getOperand2();
+ assertSoleLocation(exp, code.indexOf("typeid(d2)"), "typeid(d2)".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBug84576() throws Exception {
+ String code = "namespace A {\n extern \"C\" int g();\n }"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTLinkageSpecification spec = (ICPPASTLinkageSpecification) ((ICPPASTNamespaceDefinition) tu
+ .getDeclarations()[0]).getDeclarations()[0];
+ assertSoleLocation(spec, code.indexOf("extern \"C\""), "extern \"C\" int g();".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testSimplePreprocessorStatements() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#ifndef _APPLE_H_\n"); //$NON-NLS-1$
+ buffer.append("#define _APPLE_H_\n"); //$NON-NLS-1$
+ buffer.append("#undef _APPLE_H_\n"); //$NON-NLS-1$
+ buffer.append("#endif\n"); //$NON-NLS-1$
+ String code = buffer.toString();
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ assertEquals(tu.getDeclarations().length, 0);
+ IASTPreprocessorStatement[] statements = tu.getAllPreprocessorStatements();
+ assertEquals(statements.length, 4);
+ IASTPreprocessorIfndefStatement ifndef = (IASTPreprocessorIfndefStatement) statements[0];
+ assertTrue(ifndef.taken());
+ assertSoleLocation(ifndef, code.indexOf("#ifndef _APPLE_H_"), "#ifndef _APPLE_H_".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ IASTPreprocessorObjectStyleMacroDefinition definition = (IASTPreprocessorObjectStyleMacroDefinition) statements[1];
+ assertSoleLocation(definition, code.indexOf("#define _APPLE_H_"), "#define _APPLE_H_".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ IASTPreprocessorUndefStatement undef = (IASTPreprocessorUndefStatement) statements[2];
+ assertSoleLocation(undef, code.indexOf("#undef _APPLE_H_"), "#undef _APPLE_H_".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ IASTPreprocessorEndifStatement endif = (IASTPreprocessorEndifStatement) statements[3];
+ assertSoleLocation(endif, code.indexOf("#endif"), "#endif".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public void testBug162180() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#include <notfound.h>\n"); //$NON-NLS-1$
+ buffer.append("int x;\n"); //$NON-NLS-1$
+ String code = buffer.toString();
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p, false, false);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ assertEquals(decls.length, 1);
+ IASTPreprocessorStatement[] statements = tu.getAllPreprocessorStatements();
+ assertEquals(statements.length, 1);
+ IASTProblem[] problems = tu.getPreprocessorProblems();
+ assertEquals(problems.length, 1);
+ assertSoleLocation(decls[0], code, "int x;");
+ }
+ }
private void assertSoleLocation(IASTNode node, String code, String snip) {
assertSoleLocation(node, code.indexOf(snip), snip.length());
@@ -428,380 +431,382 @@ public class DOMLocationTests extends AST2TestBase {
assertFileLocation(node, code.indexOf(snip), snip.length());
}
- public void testBug162180_0() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append( "#include <notfound.h>\n"); //$NON-NLS-1$
- buffer.append( "#include <notfound1.h> \r\n"); //$NON-NLS-1$
- buffer.append( "#include <notfound2.h> // more stuff \n"); //$NON-NLS-1$
- buffer.append( "int x;\n"); //$NON-NLS-1$
- String code = buffer.toString();
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p, false, false);
- IASTDeclaration[] decls= tu.getDeclarations();
- IASTPreprocessorStatement [] statements = tu.getAllPreprocessorStatements();
- IASTProblem[] problems = tu.getPreprocessorProblems();
- assertEquals( 1, decls.length);
- assertEquals( 3, statements.length);
- assertEquals( 3, problems.length);
- String snip= "<notfound.h>";
- assertSoleLocation(statements[0], code, "#include <notfound.h>");
- assertSoleLocation(statements[1], code, "#include <notfound1.h>");
- assertSoleLocation(statements[2], code, "#include <notfound2.h>");
- assertSoleLocation(decls[0], code, "int x;");
- }
- }
-
- public void test162180_1() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append( "#define xxx(!) int a\n"); // [0-20]
- buffer.append( "int x;\n"); // [21-27]
- buffer.append( "int x\\i;\n"); // [28-36]
- buffer.append( "int x2;\n"); // [37-44]
- String code = buffer.toString();
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p, false, false);
- IASTDeclaration[] decls= tu.getDeclarations();
- IASTPreprocessorStatement [] statements = tu.getAllPreprocessorStatements();
- IASTProblem[] problems = tu.getPreprocessorProblems();
- assertEquals( 3, decls.length);
- assertEquals( 0, statements.length);
- assertEquals( 2, problems.length);
- assertSoleLocation(problems[0], code, "xxx(!");
- assertSoleLocation( decls[0], code, "int x;");
- assertSoleLocation( problems[1], code, "\\");
- assertFileLocation( decls[1], code, "int x\\i;");
- assertSoleLocation( decls[2], code, "int x2;");
- }
- }
-
- public void test162180_2() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append( "#define ! x\n");
- buffer.append( "int x;\n");
- String code = buffer.toString();
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p, false, false);
- IASTDeclaration[] decls= tu.getDeclarations();
- IASTPreprocessorStatement [] statements = tu.getAllPreprocessorStatements();
- IASTProblem[] problems = tu.getPreprocessorProblems();
- assertEquals( 1, decls.length);
- assertEquals( 0, statements.length);
- assertEquals( 1, problems.length);
- assertSoleLocation(problems[0], code, "!");
- assertSoleLocation( decls[0], code, "int x;");
- }
- }
-
- public void test162180_3() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append( "#define nix(x) x\n");
- buffer.append( "nix(y,z);");
- buffer.append( "int x;\n");
- String code = buffer.toString();
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p, false, false);
- IASTDeclaration[] decls= tu.getDeclarations();
- IASTPreprocessorStatement [] statements = tu.getAllPreprocessorStatements();
- IASTProblem[] problems = tu.getPreprocessorProblems();
- assertEquals( 2, decls.length);
- assertEquals( 1, statements.length);
- assertEquals( 1, problems.length);
- assertSoleLocation(problems[0], code, "nix(y,");
- assertSoleLocation( decls[1], code, "int x;");
- }
- }
-
- public void test162180_4() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append( "#include \"\"\n");
- buffer.append( "#else\n");
- buffer.append( "int x;\n");
- String code = buffer.toString();
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p, false, false);
- IASTDeclaration[] decls= tu.getDeclarations();
- IASTProblem[] problems = tu.getPreprocessorProblems();
- assertEquals( 1, decls.length);
- assertEquals( 2, problems.length);
- assertSoleLocation(problems[0], code, "#include \"\"");
- assertSoleLocation(problems[1], code, "#else");
- assertSoleLocation( decls[0], code, "int x;");
- }
- }
-
- public void testBug85820() throws Exception {
+ public void testBug162180_0() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#include <notfound.h>\n"); //$NON-NLS-1$
+ buffer.append("#include <notfound1.h> \r\n"); //$NON-NLS-1$
+ buffer.append("#include <notfound2.h> // more stuff \n"); //$NON-NLS-1$
+ buffer.append("int x;\n"); //$NON-NLS-1$
+ String code = buffer.toString();
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p, false, false);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ IASTPreprocessorStatement[] statements = tu.getAllPreprocessorStatements();
+ IASTProblem[] problems = tu.getPreprocessorProblems();
+ assertEquals(1, decls.length);
+ assertEquals(3, statements.length);
+ assertEquals(3, problems.length);
+ String snip = "<notfound.h>";
+ assertSoleLocation(statements[0], code, "#include <notfound.h>");
+ assertSoleLocation(statements[1], code, "#include <notfound1.h>");
+ assertSoleLocation(statements[2], code, "#include <notfound2.h>");
+ assertSoleLocation(decls[0], code, "int x;");
+ }
+ }
+
+ public void test162180_1() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#define xxx(!) int a\n"); // [0-20]
+ buffer.append("int x;\n"); // [21-27]
+ buffer.append("int x\\i;\n"); // [28-36]
+ buffer.append("int x2;\n"); // [37-44]
+ String code = buffer.toString();
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p, false, false);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ IASTPreprocessorStatement[] statements = tu.getAllPreprocessorStatements();
+ IASTProblem[] problems = tu.getPreprocessorProblems();
+ assertEquals(3, decls.length);
+ assertEquals(0, statements.length);
+ assertEquals(2, problems.length);
+ assertSoleLocation(problems[0], code, "xxx(!");
+ assertSoleLocation(decls[0], code, "int x;");
+ assertSoleLocation(problems[1], code, "\\");
+ assertFileLocation(decls[1], code, "int x\\i;");
+ assertSoleLocation(decls[2], code, "int x2;");
+ }
+ }
+
+ public void test162180_2() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#define ! x\n");
+ buffer.append("int x;\n");
+ String code = buffer.toString();
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p, false, false);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ IASTPreprocessorStatement[] statements = tu.getAllPreprocessorStatements();
+ IASTProblem[] problems = tu.getPreprocessorProblems();
+ assertEquals(1, decls.length);
+ assertEquals(0, statements.length);
+ assertEquals(1, problems.length);
+ assertSoleLocation(problems[0], code, "!");
+ assertSoleLocation(decls[0], code, "int x;");
+ }
+ }
+
+ public void test162180_3() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#define nix(x) x\n");
+ buffer.append("nix(y,z);");
+ buffer.append("int x;\n");
+ String code = buffer.toString();
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p, false, false);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ IASTPreprocessorStatement[] statements = tu.getAllPreprocessorStatements();
+ IASTProblem[] problems = tu.getPreprocessorProblems();
+ assertEquals(2, decls.length);
+ assertEquals(1, statements.length);
+ assertEquals(1, problems.length);
+ assertSoleLocation(problems[0], code, "nix(y,");
+ assertSoleLocation(decls[1], code, "int x;");
+ }
+ }
+
+ public void test162180_4() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#include \"\"\n");
+ buffer.append("#else\n");
+ buffer.append("int x;\n");
+ String code = buffer.toString();
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p, false, false);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ IASTProblem[] problems = tu.getPreprocessorProblems();
+ assertEquals(1, decls.length);
+ assertEquals(2, problems.length);
+ assertSoleLocation(problems[0], code, "#include \"\"");
+ assertSoleLocation(problems[1], code, "#else");
+ assertSoleLocation(decls[0], code, "int x;");
+ }
+ }
+
+ public void testBug85820() throws Exception {
String code = "int *p = (int []){2, 4};"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse( code, ParserLanguage.C );
+ IASTTranslationUnit tu = parse(code, ParserLanguage.C);
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTDeclarator d = sd.getDeclarators()[0];
- assertSoleLocation( d, code.indexOf("*p = (int []){2, 4}"), "*p = (int []){2, 4}".length() ); //$NON-NLS-1$//$NON-NLS-2$
+ assertSoleLocation(d, code.indexOf("*p = (int []){2, 4}"), "*p = (int []){2, 4}".length()); //$NON-NLS-1$//$NON-NLS-2$
}
-
- public void testBug86323() throws Exception {
+
+ public void testBug86323() throws Exception {
String code = "void f() { int i=0; for (; i<10; i++) { } }"; //$NON-NLS-1$
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- IASTForStatement for_stmt = (IASTForStatement) ((IASTCompoundStatement)((IASTFunctionDefinition)tu.getDeclarations()[0]).getBody()).getStatements()[1];
- assertTrue( for_stmt.getInitializerStatement() instanceof IASTNullStatement );
- }
- }
-
- public void testBug86698_1() throws Exception {
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ IASTForStatement for_stmt = (IASTForStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
+ .getDeclarations()[0]).getBody()).getStatements()[1];
+ assertTrue(for_stmt.getInitializerStatement() instanceof IASTNullStatement);
+ }
+ }
+
+ public void testBug86698_1() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "struct C;\n"); //$NON-NLS-1$
- buffer.append( "void no_opt(C*);\n"); //$NON-NLS-1$
- buffer.append( "struct C {\n"); //$NON-NLS-1$
- buffer.append( "int c;\n"); //$NON-NLS-1$
- buffer.append( "C() : c(0) { no_opt(this); }\n"); //$NON-NLS-1$
- buffer.append( "};\n"); //$NON-NLS-1$
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
- final ICPPASTCompositeTypeSpecifier ct= getCompositeType(tu, 2);
+ buffer.append("struct C;\n"); //$NON-NLS-1$
+ buffer.append("void no_opt(C*);\n"); //$NON-NLS-1$
+ buffer.append("struct C {\n"); //$NON-NLS-1$
+ buffer.append("int c;\n"); //$NON-NLS-1$
+ buffer.append("C() : c(0) { no_opt(this); }\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
+ final ICPPASTCompositeTypeSpecifier ct = getCompositeType(tu, 2);
final ICPPASTFunctionDefinition fdef = getDeclaration(ct, 1);
ICPPASTFunctionDeclarator funC = (ICPPASTFunctionDeclarator) fdef.getDeclarator();
- assertSoleLocation( funC, buffer.toString().indexOf("C()"), "C()".length() ); //$NON-NLS-1$//$NON-NLS-2$
- ICPPASTConstructorChainInitializer memInit= fdef.getMemberInitializers()[0];
- assertSoleLocation( memInit, buffer.toString().indexOf("c(0)"), "c(0)".length() ); //$NON-NLS-1$//$NON-NLS-2$
+ assertSoleLocation(funC, buffer.toString().indexOf("C()"), "C()".length()); //$NON-NLS-1$//$NON-NLS-2$
+ ICPPASTConstructorChainInitializer memInit = fdef.getMemberInitializers()[0];
+ assertSoleLocation(memInit, buffer.toString().indexOf("c(0)"), "c(0)".length()); //$NON-NLS-1$//$NON-NLS-2$
}
- public void testBug86698_2() throws Exception {
+ public void testBug86698_2() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "int f(int);\n"); //$NON-NLS-1$
- buffer.append( "class C {\n"); //$NON-NLS-1$
- buffer.append( "int i;\n"); //$NON-NLS-1$
- buffer.append( "double d;\n"); //$NON-NLS-1$
- buffer.append( "public:\n"); //$NON-NLS-1$
- buffer.append( "C(int, double);\n"); //$NON-NLS-1$
- buffer.append( "};\n"); //$NON-NLS-1$
- buffer.append( "C::C(int ii, double id)\n"); //$NON-NLS-1$
- buffer.append( "try\n"); //$NON-NLS-1$
- buffer.append( ": i(f(ii)), d(id)\n"); //$NON-NLS-1$
- buffer.append( "{\n }\n"); //$NON-NLS-1$
- buffer.append( "catch (...)\n"); //$NON-NLS-1$
- buffer.append( "{\n }\n"); //$NON-NLS-1$
-
- final String code = buffer.toString();
+ buffer.append("int f(int);\n"); //$NON-NLS-1$
+ buffer.append("class C {\n"); //$NON-NLS-1$
+ buffer.append("int i;\n"); //$NON-NLS-1$
+ buffer.append("double d;\n"); //$NON-NLS-1$
+ buffer.append("public:\n"); //$NON-NLS-1$
+ buffer.append("C(int, double);\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+ buffer.append("C::C(int ii, double id)\n"); //$NON-NLS-1$
+ buffer.append("try\n"); //$NON-NLS-1$
+ buffer.append(": i(f(ii)), d(id)\n"); //$NON-NLS-1$
+ buffer.append("{\n }\n"); //$NON-NLS-1$
+ buffer.append("catch (...)\n"); //$NON-NLS-1$
+ buffer.append("{\n }\n"); //$NON-NLS-1$
+
+ final String code = buffer.toString();
IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- final IASTFunctionDefinition fdef = (IASTFunctionDefinition)tu.getDeclarations()[2];
+ final IASTFunctionDefinition fdef = (IASTFunctionDefinition) tu.getDeclarations()[2];
assertInstance(fdef, ICPPASTFunctionWithTryBlock.class);
- assertSoleLocation(fdef.getDeclarator(), code.indexOf("C::C(int ii, double id)"), "C::C(int ii, double id)".length() ); //$NON-NLS-1$//$NON-NLS-2$
- ICPPASTFunctionWithTryBlock tryblock= ((ICPPASTFunctionWithTryBlock) fdef);
+ assertSoleLocation(fdef.getDeclarator(), code.indexOf("C::C(int ii, double id)"), //$NON-NLS-1$
+ "C::C(int ii, double id)".length()); //$NON-NLS-1$
+ ICPPASTFunctionWithTryBlock tryblock = ((ICPPASTFunctionWithTryBlock) fdef);
assertSoleLocation(tryblock.getCatchHandlers()[0], code.indexOf("catch"), "catch (...)\n{\n }".length());
}
- 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);
-
- IASTProblem[] problems= tu.getPreprocessorProblems();
- assertEquals(1, problems.length);
- assertSoleLocation(problems[0], buffer.indexOf("X"), "X".length() );
- }
-
- 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);
-
- IASTProblem[] problems= tu.getPreprocessorProblems();
- assertEquals(1, problems.length);
- assertSoleLocation(problems[0], buffer.indexOf("X"), "X".length() );
- }
-
- 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);
- IASTDeclaration[] decls= tu.getDeclarations();
- assertEquals(1, decls.length);
- assertSoleLocation(decls[0], 0, buffer.length());
- assertTrue(decls[0] instanceof IASTSimpleDeclaration);
- IASTSimpleDeclaration simpleDecl= (IASTSimpleDeclaration)decls[0];
- IASTDeclarator[] declarators= simpleDecl.getDeclarators();
- assertEquals(1, declarators.length);
- IASTInitializer initializer= declarators[0].getInitializer();
- assertTrue(initializer instanceof IASTEqualsInitializer);
- IASTInitializerClause expr= ((IASTEqualsInitializer)initializer).getInitializerClause();
- assertTrue(expr instanceof IASTTypeIdExpression);
- assertSoleLocation(expr, buffer.indexOf("sizeof"), "sizeof(int)".length());
- }
-
- public void testBug120607() throws Exception {
- // C/C++ Indexer rejects valid pre-processor directive
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=120607
- StringBuilder buffer = new StringBuilder();
- buffer.append("#import \"include_once.h\"\n");
- buffer.append("#warning \"deprecated include\"\n");
- buffer.append("#line 5\n");
- buffer.append("# 5 \"foo.h\"\n");
- buffer.append("#ident \"version 1.0\"\n");
- buffer.append("#assert thisIsTrue(value)\n");
- buffer.append("#unassert thisIsTrue(value)\n");
- buffer.append("#invalid");
- String code= buffer.toString();
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, true, false);
-
- IASTProblem[] problems= tu.getPreprocessorProblems();
- assertEquals(3, problems.length);
- assertEquals(IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND, problems[0].getID());
- assertEquals(IProblem.PREPROCESSOR_POUND_WARNING, problems[1].getID());
- assertEquals(IProblem.PREPROCESSOR_INVALID_DIRECTIVE, problems[2].getID());
- assertSoleLocation(problems[0], code, "#import \"include_once.h\"");
- assertSoleLocation(problems[1], code, "\"deprecated include\"");
- assertSoleLocation(problems[2], code, "#invalid");
- }
-
- public void testBug527396_1() throws Exception {
- String code = "void foo() noexcept {}"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarator();
- String rawDeclarator = "foo() noexcept"; //$NON-NLS-1$
- assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testBug527396_2() throws Exception {
- String code = "void foo() noexcept(false) {}"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarator();
- String rawDeclarator = "foo() noexcept(false)"; //$NON-NLS-1$
- assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testBug527396_3() throws Exception {
- String code = "void foo() {}"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarator();
- String rawDeclarator = "foo()"; //$NON-NLS-1$
- assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testBug527396_4() throws Exception {
- String code = "void foo() noexcept;"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- IASTSimpleDeclaration definition = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarators()[0];
- String rawDeclarator = "foo() noexcept"; //$NON-NLS-1$
- assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testBug527396_5() throws Exception {
- String code = "void foo() noexcept(false);"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- IASTSimpleDeclaration definition = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarators()[0];
- String rawDeclarator = "foo() noexcept(false)"; //$NON-NLS-1$
- assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testBug527396_6() throws Exception {
- String code = "void foo();"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- IASTSimpleDeclaration definition = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarators()[0];
- String rawDeclarator = "foo()"; //$NON-NLS-1$
- assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testSwitchInitStatement_1() throws Exception {
- String code = "void foo() { switch (int i = 1; i) {} }"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
- IASTSwitchStatement statement = (IASTSwitchStatement) body.getStatements()[0];
- String rawDeclarator = "switch (int i = 1; i) {}"; //$NON-NLS-1$
- assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testSwitchInitStatement_2() throws Exception {
- String code = "void foo() { char c = 'a'; switch (; c) {} }"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
- IASTSwitchStatement statement = (IASTSwitchStatement) body.getStatements()[1];
- String rawDeclarator = "switch (; c) {}"; //$NON-NLS-1$
- assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testIfInitStatement_1() throws Exception {
- String code = "void foo() { if (int i = 1; i == 1) {} }"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
- IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
- String rawDeclarator = "if (int i = 1; i == 1) {}"; //$NON-NLS-1$
- assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testIfInitStatement_2() throws Exception {
- String code = "void foo() { if (; bool b = true) {} }"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
- IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
- String rawDeclarator = "if (; bool b = true) {}"; //$NON-NLS-1$
- assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testConstexprIf_1() throws Exception {
- String code = "void foo() { if constexpr (true) {} }"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
- IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
- String rawDeclarator = "if constexpr (true) {}"; //$NON-NLS-1$
- assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testConstexprIf_2() throws Exception {
- String code = "void foo() { if constexpr (constexpr int i = 1; i == 1) {} }"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
- IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
- String rawDeclarator = "if constexpr (constexpr int i = 1; i == 1) {}"; //$NON-NLS-1$
- assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testConstexprIf_3() throws Exception {
- String code = "void foo() { if constexpr (; constexpr bool b = true) {} }"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
- IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
- String rawDeclarator = "if constexpr (; constexpr bool b = true) {}"; //$NON-NLS-1$
- assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- // int main(void){
- // #define one 1
- // int integer = one;
- // return integer;
- // }
- public void testRawSignature_Bug117029() throws Exception {
- String content= getContents(1)[0].toString();
- IASTTranslationUnit tu= parse(content, ParserLanguage.CPP);
- IASTFunctionDefinition decl= (IASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement compound= (IASTCompoundStatement) decl.getBody();
- assertEquals("int integer = one;", compound.getStatements()[0].getRawSignature());
- assertEquals("return integer;", compound.getStatements()[1].getRawSignature());
- }
-
+ 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);
+
+ IASTProblem[] problems = tu.getPreprocessorProblems();
+ assertEquals(1, problems.length);
+ assertSoleLocation(problems[0], buffer.indexOf("X"), "X".length());
+ }
+
+ 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);
+
+ IASTProblem[] problems = tu.getPreprocessorProblems();
+ assertEquals(1, problems.length);
+ assertSoleLocation(problems[0], buffer.indexOf("X"), "X".length());
+ }
+
+ 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);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ assertEquals(1, decls.length);
+ assertSoleLocation(decls[0], 0, buffer.length());
+ assertTrue(decls[0] instanceof IASTSimpleDeclaration);
+ IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) decls[0];
+ IASTDeclarator[] declarators = simpleDecl.getDeclarators();
+ assertEquals(1, declarators.length);
+ IASTInitializer initializer = declarators[0].getInitializer();
+ assertTrue(initializer instanceof IASTEqualsInitializer);
+ IASTInitializerClause expr = ((IASTEqualsInitializer) initializer).getInitializerClause();
+ assertTrue(expr instanceof IASTTypeIdExpression);
+ assertSoleLocation(expr, buffer.indexOf("sizeof"), "sizeof(int)".length());
+ }
+
+ public void testBug120607() throws Exception {
+ // C/C++ Indexer rejects valid pre-processor directive
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=120607
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#import \"include_once.h\"\n");
+ buffer.append("#warning \"deprecated include\"\n");
+ buffer.append("#line 5\n");
+ buffer.append("# 5 \"foo.h\"\n");
+ buffer.append("#ident \"version 1.0\"\n");
+ buffer.append("#assert thisIsTrue(value)\n");
+ buffer.append("#unassert thisIsTrue(value)\n");
+ buffer.append("#invalid");
+ String code = buffer.toString();
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, true, false);
+
+ IASTProblem[] problems = tu.getPreprocessorProblems();
+ assertEquals(3, problems.length);
+ assertEquals(IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND, problems[0].getID());
+ assertEquals(IProblem.PREPROCESSOR_POUND_WARNING, problems[1].getID());
+ assertEquals(IProblem.PREPROCESSOR_INVALID_DIRECTIVE, problems[2].getID());
+ assertSoleLocation(problems[0], code, "#import \"include_once.h\"");
+ assertSoleLocation(problems[1], code, "\"deprecated include\"");
+ assertSoleLocation(problems[2], code, "#invalid");
+ }
+
+ public void testBug527396_1() throws Exception {
+ String code = "void foo() noexcept {}"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarator();
+ String rawDeclarator = "foo() noexcept"; //$NON-NLS-1$
+ assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testBug527396_2() throws Exception {
+ String code = "void foo() noexcept(false) {}"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarator();
+ String rawDeclarator = "foo() noexcept(false)"; //$NON-NLS-1$
+ assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testBug527396_3() throws Exception {
+ String code = "void foo() {}"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarator();
+ String rawDeclarator = "foo()"; //$NON-NLS-1$
+ assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testBug527396_4() throws Exception {
+ String code = "void foo() noexcept;"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ IASTSimpleDeclaration definition = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarators()[0];
+ String rawDeclarator = "foo() noexcept"; //$NON-NLS-1$
+ assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testBug527396_5() throws Exception {
+ String code = "void foo() noexcept(false);"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ IASTSimpleDeclaration definition = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarators()[0];
+ String rawDeclarator = "foo() noexcept(false)"; //$NON-NLS-1$
+ assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testBug527396_6() throws Exception {
+ String code = "void foo();"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ IASTSimpleDeclaration definition = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarators()[0];
+ String rawDeclarator = "foo()"; //$NON-NLS-1$
+ assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testSwitchInitStatement_1() throws Exception {
+ String code = "void foo() { switch (int i = 1; i) {} }"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
+ IASTSwitchStatement statement = (IASTSwitchStatement) body.getStatements()[0];
+ String rawDeclarator = "switch (int i = 1; i) {}"; //$NON-NLS-1$
+ assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testSwitchInitStatement_2() throws Exception {
+ String code = "void foo() { char c = 'a'; switch (; c) {} }"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
+ IASTSwitchStatement statement = (IASTSwitchStatement) body.getStatements()[1];
+ String rawDeclarator = "switch (; c) {}"; //$NON-NLS-1$
+ assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testIfInitStatement_1() throws Exception {
+ String code = "void foo() { if (int i = 1; i == 1) {} }"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
+ IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
+ String rawDeclarator = "if (int i = 1; i == 1) {}"; //$NON-NLS-1$
+ assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testIfInitStatement_2() throws Exception {
+ String code = "void foo() { if (; bool b = true) {} }"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
+ IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
+ String rawDeclarator = "if (; bool b = true) {}"; //$NON-NLS-1$
+ assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testConstexprIf_1() throws Exception {
+ String code = "void foo() { if constexpr (true) {} }"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
+ IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
+ String rawDeclarator = "if constexpr (true) {}"; //$NON-NLS-1$
+ assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testConstexprIf_2() throws Exception {
+ String code = "void foo() { if constexpr (constexpr int i = 1; i == 1) {} }"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
+ IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
+ String rawDeclarator = "if constexpr (constexpr int i = 1; i == 1) {}"; //$NON-NLS-1$
+ assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testConstexprIf_3() throws Exception {
+ String code = "void foo() { if constexpr (; constexpr bool b = true) {} }"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
+ IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
+ String rawDeclarator = "if constexpr (; constexpr bool b = true) {}"; //$NON-NLS-1$
+ assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ // int main(void){
+ // #define one 1
+ // int integer = one;
+ // return integer;
+ // }
+ public void testRawSignature_Bug117029() throws Exception {
+ String content = getContents(1)[0].toString();
+ IASTTranslationUnit tu = parse(content, ParserLanguage.CPP);
+ IASTFunctionDefinition decl = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement compound = (IASTCompoundStatement) decl.getBody();
+ assertEquals("int integer = one;", compound.getStatements()[0].getRawSignature());
+ assertEquals("return integer;", compound.getStatements()[1].getRawSignature());
+ }
+
public void testTemplateIdNameLocation_Bug211444() throws Exception {
- IASTTranslationUnit tu = parse( "Foo::template test<T> bar;", ParserLanguage.CPP );
+ IASTTranslationUnit tu = parse("Foo::template test<T> bar;", ParserLanguage.CPP);
NameCollector col = new NameCollector();
- tu.accept( col );
-
+ tu.accept(col);
+
ICPPASTQualifiedName qn = (ICPPASTQualifiedName) col.getName(0);
IASTName lastName = qn.getLastName();
assertTrue(lastName instanceof ICPPASTTemplateId);
- ICPPASTTemplateId templateId= (ICPPASTTemplateId) lastName;
- IASTName templateIdName= templateId.getTemplateName();
-
+ ICPPASTTemplateId templateId = (ICPPASTTemplateId) lastName;
+ IASTName templateIdName = templateId.getTemplateName();
+
assertEquals("test", templateIdName.getRawSignature()); //$NON-NLS-1$
}
@@ -820,11 +825,12 @@ public class DOMLocationTests extends AST2TestBase {
public void testFunctionDeclaratorLocationContainsVirtualSpecifiers_Bug518628() throws Exception {
String testCode = getAboveComment();
BindingAssertionHelper assertionHelper = getAssertionHelper(ParserLanguage.CPP);
- String[] funcDeclaratorSignatures = new String[]{"func1() final", "func2() override", "func3() final override", "func4() override final"};
+ String[] funcDeclaratorSignatures = new String[] { "func1() final", "func2() override",
+ "func3() final override", "func4() override final" };
Arrays.stream(funcDeclaratorSignatures).forEach(signature -> {
IASTNode func1Declarator = assertionHelper.assertNode(signature, ICPPASTFunctionDeclarator.class);
assertFileLocation(func1Declarator, testCode, signature);
-
+
});
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java
index d66145b3f87..b7174a8adbb 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java
@@ -33,7 +33,7 @@ import junit.framework.TestSuite;
*/
public class DOMParserTestSuite extends TestCase {
public static Test suite() {
- TestSuite suite= new TestSuite(DOMParserTestSuite.class.getName());
+ TestSuite suite = new TestSuite(DOMParserTestSuite.class.getName());
suite.addTest(AST2Tests.suite());
suite.addTestSuite(GCCTests.class);
suite.addTest(AST2CPPTests.suite());
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 f20700f017d..0242505d264 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
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Emanuel Graf - initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Emanuel Graf - initial API and implementation
* Markus Schorn (Wind River Systems)
******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
@@ -36,164 +36,163 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
*
*/
public class DOMPreprocessorInformationTest extends AST2TestBase {
-
+
public void testPragma() throws Exception {
String msg = "GCC poison printf sprintf fprintf";
- StringBuilder buffer = new StringBuilder( "#pragma " + msg + "\n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("#pragma " + msg + "\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(1, st.length);
assertTrue(st[0] instanceof IASTPreprocessorPragmaStatement);
IASTPreprocessorPragmaStatement pragma = (IASTPreprocessorPragmaStatement) st[0];
assertEquals(msg, new String(pragma.getMessage()));
}
-
+
public void testElIf() throws Exception {
String cond = "2 == 2";
- StringBuilder buffer = new StringBuilder( "#if 1 == 2\n#elif " + cond + "\n#else\n#endif\n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("#if 1 == 2\n#elif " + cond + "\n#else\n#endif\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(4, st.length);
assertTrue(st[1] instanceof IASTPreprocessorElifStatement);
IASTPreprocessorElifStatement pragma = (IASTPreprocessorElifStatement) st[1];
assertEquals(cond, new String(pragma.getCondition()));
}
-
+
public void testIf() throws Exception {
String cond = "2 == 2";
- StringBuilder buffer = new StringBuilder( "#if " + cond + "\n#endif\n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("#if " + cond + "\n#endif\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(2, st.length);
assertTrue(st[0] instanceof IASTPreprocessorIfStatement);
IASTPreprocessorIfStatement pragma = (IASTPreprocessorIfStatement) st[0];
assertEquals(cond, new String(pragma.getCondition()));
}
-
- public void testIfDef() throws Exception{
+
+ public void testIfDef() throws Exception {
String cond = "SYMBOL";
- StringBuilder buffer = new StringBuilder( "#ifdef " + cond + "\n#endif\n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("#ifdef " + cond + "\n#endif\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(2, st.length);
assertTrue(st[0] instanceof IASTPreprocessorIfdefStatement);
IASTPreprocessorIfdefStatement pragma = (IASTPreprocessorIfdefStatement) st[0];
assertEquals(cond, new String(pragma.getCondition()));
}
-
- public void testIfnDef() throws Exception{
+
+ public void testIfnDef() throws Exception {
String cond = "SYMBOL";
- StringBuilder buffer = new StringBuilder( "#ifndef " + cond + "\n#endif\n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("#ifndef " + cond + "\n#endif\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(2, st.length);
assertTrue(st[0] instanceof IASTPreprocessorIfndefStatement);
IASTPreprocessorIfndefStatement pragma = (IASTPreprocessorIfndefStatement) st[0];
assertEquals(cond, new String(pragma.getCondition()));
}
-
- public void testError() 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 );
+ StringBuilder buffer = new StringBuilder("#error " + msg + "\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, false, false);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(1, st.length);
assertTrue(st[0] instanceof IASTPreprocessorErrorStatement);
IASTPreprocessorErrorStatement pragma = (IASTPreprocessorErrorStatement) st[0];
assertEquals(msg, new String(pragma.getMessage()));
}
-
+
public void testPragmaWithSpaces() throws Exception {
String msg = "GCC poison printf sprintf fprintf";
- StringBuilder buffer = new StringBuilder( "# pragma " + msg + " \n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("# pragma " + msg + " \n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(1, st.length);
assertTrue(st[0] instanceof IASTPreprocessorPragmaStatement);
IASTPreprocessorPragmaStatement pragma = (IASTPreprocessorPragmaStatement) st[0];
assertEquals(msg, new String(pragma.getMessage()));
}
-
+
public void testElIfWithSpaces() throws Exception {
String cond = "2 == 2";
- StringBuilder buffer = new StringBuilder( "#if 1 == 2\n# elif " + cond + " \n#else\n#endif\n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("#if 1 == 2\n# elif " + cond + " \n#else\n#endif\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(4, st.length);
assertTrue(st[1] instanceof IASTPreprocessorElifStatement);
IASTPreprocessorElifStatement pragma = (IASTPreprocessorElifStatement) st[1];
assertEquals(cond, new String(pragma.getCondition()));
}
-
+
public void testIfWithSpaces() throws Exception {
String cond = "2 == 2";
- StringBuilder buffer = new StringBuilder( "# if " + cond + " \n#endif\n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("# if " + cond + " \n#endif\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(2, st.length);
assertTrue(st[0] instanceof IASTPreprocessorIfStatement);
IASTPreprocessorIfStatement pragma = (IASTPreprocessorIfStatement) st[0];
assertEquals(cond, new String(pragma.getCondition()));
}
-
- public void testIfDefWithSpaces() throws Exception{
+
+ public void testIfDefWithSpaces() throws Exception {
String cond = "SYMBOL";
- StringBuilder buffer = new StringBuilder( "# ifdef " + cond + " \n#endif\n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("# ifdef " + cond + " \n#endif\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(2, st.length);
assertTrue(st[0] instanceof IASTPreprocessorIfdefStatement);
IASTPreprocessorIfdefStatement pragma = (IASTPreprocessorIfdefStatement) st[0];
assertEquals(cond, new String(pragma.getCondition()));
}
-
- public void testIfnDefWithSpaces() throws Exception{
+
+ public void testIfnDefWithSpaces() throws Exception {
String cond = "SYMBOL";
- StringBuilder buffer = new StringBuilder( "# ifndef " + cond + "\t\n#endif\n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("# ifndef " + cond + "\t\n#endif\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(2, st.length);
assertTrue(st[0] instanceof IASTPreprocessorIfndefStatement);
IASTPreprocessorIfndefStatement pragma = (IASTPreprocessorIfndefStatement) st[0];
assertEquals(cond, new String(pragma.getCondition()));
}
-
- public void testErrorWithSpaces() 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 );
+ StringBuilder buffer = new StringBuilder("# error \t" + msg + " \n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, false, false);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(1, st.length);
assertTrue(st[0] instanceof IASTPreprocessorErrorStatement);
IASTPreprocessorErrorStatement pragma = (IASTPreprocessorErrorStatement) st[0];
assertEquals(msg, new String(pragma.getMessage()));
}
-
+
public void testMacroExpansion() throws Exception {
StringBuilder sb = new StringBuilder();
sb.append("#define add(a, b) (a) + (b) \n");
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, false, false);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(1, st.length);
assertTrue(st[0] instanceof IASTPreprocessorFunctionStyleMacroDefinition);
-
+
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTEqualsInitializer einit = (IASTEqualsInitializer) decl.getDeclarators()[0].getInitializer();
- IASTInitializerClause init= einit.getInitializerClause();
-
-
+ IASTInitializerClause init = einit.getInitializerClause();
+
IASTNodeLocation[] nodeLocations = init.getNodeLocations();
assertEquals(1, nodeLocations.length);
}
-
+
// #ifdef xxx
// #elif
// #endif
public void testElifWithoutCondition_bug185324() throws Exception {
- CharSequence code= getContents(1)[0];
+ CharSequence code = getContents(1)[0];
IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, false);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(3, st.length);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSearchUtil.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSearchUtil.java
index f3ccbef95b8..142355b1775 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSearchUtil.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSearchUtil.java
@@ -44,93 +44,92 @@ import org.eclipse.core.runtime.content.IContentType;
*/
public class DOMSearchUtil {
public static final int DECLARATIONS = 1;
- public static final int DEFINITIONS = 2;
- public static final int DECLARATIONS_DEFINITIONS = 3;
- public static final int REFERENCES = 4;
- public static final int ALL_OCCURRENCES = 5;
-
- /**
- * Retrieves the ParserLanguage from an file.
- */
- public static ParserLanguage getLanguageFromFile(IFile file) {
- IProject project = file.getProject();
- IContentType contentType = CCorePlugin.getContentType(project, file.getFullPath().lastSegment());
- if (contentType != null) {
- String lid = contentType.getId();
- if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(lid) ||
- CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(lid)) {
- return ParserLanguage.CPP;
- }
- }
- return ParserLanguage.C;
- }
-
- /**
- * The NameCollector used to get IASTNames from an IASTNode.
- *
- * @author dsteffle
- */
- static public class NameCollector extends ASTVisitor {
- {
- shouldVisitNames = true;
- }
- public List nameList = new ArrayList();
-
- @Override
+ public static final int DEFINITIONS = 2;
+ public static final int DECLARATIONS_DEFINITIONS = 3;
+ public static final int REFERENCES = 4;
+ public static final int ALL_OCCURRENCES = 5;
+
+ /**
+ * Retrieves the ParserLanguage from an file.
+ */
+ public static ParserLanguage getLanguageFromFile(IFile file) {
+ IProject project = file.getProject();
+ IContentType contentType = CCorePlugin.getContentType(project, file.getFullPath().lastSegment());
+ if (contentType != null) {
+ String lid = contentType.getId();
+ if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(lid) || CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(lid)) {
+ return ParserLanguage.CPP;
+ }
+ }
+ return ParserLanguage.C;
+ }
+
+ /**
+ * The NameCollector used to get IASTNames from an IASTNode.
+ *
+ * @author dsteffle
+ */
+ static public class NameCollector extends ASTVisitor {
+ {
+ shouldVisitNames = true;
+ }
+ public List nameList = new ArrayList();
+
+ @Override
public int visit(IASTName name) {
- nameList.add(name);
- return PROCESS_CONTINUE;
- }
+ nameList.add(name);
+ return PROCESS_CONTINUE;
+ }
- public IASTName getName(int idx) {
- if (idx < 0 || idx >= nameList.size())
- return null;
- return (IASTName) nameList.get(idx);
- }
+ public IASTName getName(int idx) {
+ if (idx < 0 || idx >= nameList.size())
+ return null;
+ return (IASTName) nameList.get(idx);
+ }
- public int size() {
- return nameList.size();
- }
- }
+ public int size() {
+ return nameList.size();
+ }
+ }
/**
* Returns the ParserLanguage corresponding to the IPath and IProject.
* Returns ParserLanguage.CPP if the file type is a header.
*/
- public static ParserLanguage getLanguage(IPath path, IProject project) {
- //FIXME: ALAIN, for headers should we assume CPP ??
- // The problem is that it really depends on how the header was included.
- String id = null;
- IContentType contentType = CCorePlugin.getContentType(project, path.lastSegment());
- if (contentType != null) {
- id = contentType.getId();
- }
- if (id != null) {
- if (CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(id)) {
- return ParserLanguage.CPP;
- } else if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(id)) {
- return ParserLanguage.CPP;
- } else if (CCorePlugin.CONTENT_TYPE_CHEADER.equals(id)) {
- return ParserLanguage.C;
- } else if (CCorePlugin.CONTENT_TYPE_CSOURCE.equals(id)) {
- return ParserLanguage.C;
- } else if (CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(id)) {
- // ???
- // What do we do here ?
- }
- }
+ public static ParserLanguage getLanguage(IPath path, IProject project) {
+ //FIXME: ALAIN, for headers should we assume CPP ??
+ // The problem is that it really depends on how the header was included.
+ String id = null;
+ IContentType contentType = CCorePlugin.getContentType(project, path.lastSegment());
+ if (contentType != null) {
+ id = contentType.getId();
+ }
+ if (id != null) {
+ if (CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(id)) {
+ return ParserLanguage.CPP;
+ } else if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(id)) {
+ return ParserLanguage.CPP;
+ } else if (CCorePlugin.CONTENT_TYPE_CHEADER.equals(id)) {
+ return ParserLanguage.C;
+ } else if (CCorePlugin.CONTENT_TYPE_CSOURCE.equals(id)) {
+ return ParserLanguage.C;
+ } else if (CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(id)) {
+ // ???
+ // What do we do here ?
+ }
+ }
return ParserLanguage.CPP;
- }
-
- /**
- * This is used to get the names from the TU that the IASTName searchName belongs to.
- *
- * @param searchName the IASTName whose references/declarations are to be retrieved
- * @param limitTo used to specify whether to get declarations, references, or both, one of:
- * (CSearchPattern.DECLARATION | CSearchPattern.REFERENCES | CSearchPattern.ALL_OCCURRENCES)
- * @return IASTName[] declarations, references, or both depending on limitTo that correspond to the IASTName searchName searched for
- */
- public static IName[] getNamesFromDOM(IASTName searchName, int limitTo) {
+ }
+
+ /**
+ * This is used to get the names from the TU that the IASTName searchName belongs to.
+ *
+ * @param searchName the IASTName whose references/declarations are to be retrieved
+ * @param limitTo used to specify whether to get declarations, references, or both, one of:
+ * (CSearchPattern.DECLARATION | CSearchPattern.REFERENCES | CSearchPattern.ALL_OCCURRENCES)
+ * @return IASTName[] declarations, references, or both depending on limitTo that correspond to the IASTName searchName searched for
+ */
+ public static IName[] getNamesFromDOM(IASTName searchName, int limitTo) {
IName[] names = null;
IASTTranslationUnit tu = searchName.getTranslationUnit();
@@ -141,28 +140,29 @@ public class DOMSearchUtil {
IBinding binding = searchName.resolveBinding();
if (binding instanceof IIndexBinding) {
Assert.fail("Not implemented");
-// try {
-// ArrayList pdomNames = new ArrayList();
-// IPDOMResolver pdom= ((PDOMBinding) binding).getPDOM();
-// // First decls
-// names= pdom.getDeclarations(binding);
-// pdomNames.addAll(Arrays.asList(names));
-// // Next defs
-// names= pdom.getDefinitions(binding);
-// pdomNames.addAll(Arrays.asList(names));
-// names = (IName[])pdomNames.toArray(new IName[pdomNames.size()]);
-// } catch (CoreException e) {
-// CCorePlugin.log(e);
-// }
+ // try {
+ // ArrayList pdomNames = new ArrayList();
+ // IPDOMResolver pdom= ((PDOMBinding) binding).getPDOM();
+ // // First decls
+ // names= pdom.getDeclarations(binding);
+ // pdomNames.addAll(Arrays.asList(names));
+ // // Next defs
+ // names= pdom.getDefinitions(binding);
+ // pdomNames.addAll(Arrays.asList(names));
+ // names = (IName[])pdomNames.toArray(new IName[pdomNames.size()]);
+ // } catch (CoreException e) {
+ // CCorePlugin.log(e);
+ // }
} else {
names = getNames(tu, binding, limitTo);
if (names == null || names.length == 0) { // try alternate strategies
try {
// fix for 86829, 95224
- if ((binding instanceof ICPPConstructor || (binding instanceof ICPPMethod && ((ICPPMethod)binding).isDestructor()))
+ if ((binding instanceof ICPPConstructor
+ || (binding instanceof ICPPMethod && ((ICPPMethod) binding).isDestructor()))
&& binding.getScope() instanceof ICPPClassScope) {
- binding = ((ICPPClassScope) binding.getScope()).getClassType();
+ binding = ((ICPPClassScope) binding.getScope()).getClassType();
names = getNames(tu, binding, limitTo);
}
} catch (DOMException e) {
@@ -171,24 +171,23 @@ public class DOMSearchUtil {
}
return names;
- }
+ }
private static IASTName[] getNames(IASTTranslationUnit tu, IBinding binding, int limitTo) {
- IASTName[] names = null;
- if (limitTo == DECLARATIONS ||
- limitTo == DECLARATIONS_DEFINITIONS) {
- names = tu.getDeclarationsInAST(binding);
- } else if (limitTo == REFERENCES) {
- names = tu.getReferences(binding);
- } else if (limitTo == DEFINITIONS) {
- names = tu.getDefinitionsInAST(binding);
- } else if (limitTo == ALL_OCCURRENCES) {
- names = tu.getDeclarationsInAST(binding);
- names = ArrayUtil.addAll(IASTName.class, names, tu.getReferences(binding));
- } else { // assume ALL
- names = tu.getDeclarationsInAST(binding);
- names = ArrayUtil.addAll(IASTName.class, names, tu.getReferences(binding));
- }
+ IASTName[] names = null;
+ if (limitTo == DECLARATIONS || limitTo == DECLARATIONS_DEFINITIONS) {
+ names = tu.getDeclarationsInAST(binding);
+ } else if (limitTo == REFERENCES) {
+ names = tu.getReferences(binding);
+ } else if (limitTo == DEFINITIONS) {
+ names = tu.getDefinitionsInAST(binding);
+ } else if (limitTo == ALL_OCCURRENCES) {
+ names = tu.getDeclarationsInAST(binding);
+ names = ArrayUtil.addAll(IASTName.class, names, tu.getReferences(binding));
+ } else { // assume ALL
+ names = tu.getDeclarationsInAST(binding);
+ names = ArrayUtil.addAll(IASTName.class, names, tu.getReferences(binding));
+ }
return names;
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTest.java
index 53552724954..5a0cf21157e 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTest.java
@@ -151,24 +151,22 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testBug57898() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Gonzo { public: void playHorn(); };\n");
- writer.write( "void Gonzo::playHorn() { return; }\n");
- writer.write( "int main(int argc, char **argv) { Gonzo gonzo; gonzo.playHorn(); }\n");
+ writer.write("class Gonzo { public: void playHorn(); };\n");
+ writer.write("void Gonzo::playHorn() { return; }\n");
+ writer.write("int main(int argc, char **argv) { Gonzo gonzo; gonzo.playHorn(); }\n");
String code = writer.toString();
- for( int i = 0; i < 3; ++i )
- {
+ for (int i = 0; i < 3; ++i) {
int start = -1, stop = -1;
- switch( i )
- {
- case 0:
- start = code.indexOf("void playHorn") + 5;
- break;
- case 1:
- start = code.indexOf("::playHorn") + 2;
- break;
- case 2:
- start = code.indexOf(".playHorn") + 1;
- break;
+ switch (i) {
+ case 0:
+ start = code.indexOf("void playHorn") + 5;
+ break;
+ case 1:
+ start = code.indexOf("::playHorn") + 2;
+ break;
+ case 2:
+ start = code.indexOf(".playHorn") + 1;
+ break;
}
stop = start + 8;
IASTNode node = parse(code, start, stop);
@@ -186,7 +184,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testConstructorDestructorDeclaration() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Gonzo { Gonzo(); ~Gonzo(); };");
+ writer.write("class Gonzo { Gonzo(); ~Gonzo(); };");
String code = writer.toString();
int offset = code.indexOf(" Gonzo()") + 1;
IASTNode node = parse(code, offset, offset + 5);
@@ -204,8 +202,8 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testBug60264() throws Exception {
Writer writer = new StringWriter();
- writer.write( "namespace Muppets { int i; }\n");
- writer.write( "int main(int argc, char **argv) { Muppets::i = 1; }\n");
+ writer.write("namespace Muppets { int i; }\n");
+ writer.write("int main(int argc, char **argv) { Muppets::i = 1; }\n");
String code = writer.toString();
int index = code.indexOf("Muppets::");
IASTNode node = parse(code, index, index + 7);
@@ -233,14 +231,14 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testBug61613() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Foo { // ** (A) **\n");
- writer.write( " public:\n");
- writer.write( "Foo() {};\n");
- writer.write( "};\n");
- writer.write( "int \n");
- writer.write( "main(int argc, char **argv) {\n");
- writer.write( "Foo foo; // ** (B) **\n");
- writer.write( "}\n");
+ writer.write("class Foo { // ** (A) **\n");
+ writer.write(" public:\n");
+ writer.write("Foo() {};\n");
+ writer.write("};\n");
+ writer.write("int \n");
+ writer.write("main(int argc, char **argv) {\n");
+ writer.write("Foo foo; // ** (B) **\n");
+ writer.write("}\n");
String code = writer.toString();
int index = code.indexOf("class Foo") + 6;
IASTNode node = parse(code, index, index + 3);
@@ -256,35 +254,33 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testBug60038() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Gonzo {\n");
- writer.write( "public:\n");
- writer.write( "Gonzo( const Gonzo & other ){}\n");
- writer.write( "Gonzo() {}\n");
- writer.write( "~Gonzo(){}\n");
- writer.write( "};\n");
- writer.write( "int main(int argc, char **argv) {\n");
- writer.write( " Gonzo * g = new Gonzo();\n");
- writer.write( " Gonzo * g2 = new Gonzo( *g );\n");
- writer.write( " g->~Gonzo();\n");
- writer.write( " return (int) g2;\n");
- writer.write( "}\n");
+ writer.write("class Gonzo {\n");
+ writer.write("public:\n");
+ writer.write("Gonzo( const Gonzo & other ){}\n");
+ writer.write("Gonzo() {}\n");
+ writer.write("~Gonzo(){}\n");
+ writer.write("};\n");
+ writer.write("int main(int argc, char **argv) {\n");
+ writer.write(" Gonzo * g = new Gonzo();\n");
+ writer.write(" Gonzo * g2 = new Gonzo( *g );\n");
+ writer.write(" g->~Gonzo();\n");
+ writer.write(" return (int) g2;\n");
+ writer.write("}\n");
String code = writer.toString();
- for( int i = 0; i < 3; ++i )
- {
+ for (int i = 0; i < 3; ++i) {
int startOffset = 0, endOffset = 0;
- switch( i )
- {
- case 0:
- startOffset = code.indexOf("new Gonzo()") + 4;
- endOffset = startOffset + 5;
- break;
- case 1:
- startOffset = code.indexOf("new Gonzo( ") + 4;
- endOffset = startOffset + 5;
- break;
- default:
- startOffset = code.indexOf("->~") + 2;
- endOffset = startOffset + 6;
+ switch (i) {
+ case 0:
+ startOffset = code.indexOf("new Gonzo()") + 4;
+ endOffset = startOffset + 5;
+ break;
+ case 1:
+ startOffset = code.indexOf("new Gonzo( ") + 4;
+ endOffset = startOffset + 5;
+ break;
+ default:
+ startOffset = code.indexOf("->~") + 2;
+ endOffset = startOffset + 6;
}
IASTNode node = parse(code, startOffset, endOffset);
assertTrue(node instanceof IASTName);
@@ -295,35 +291,34 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
}
assertTrue(binding instanceof ICPPMethod);
IName[] decls = null;
- switch( i )
- {
- case 0:
- assertTrue(binding instanceof ICPPConstructor);
- decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "Gonzo");
- assertEquals(((ASTNode) decls[0]).getOffset(), 53);
- assertEquals(((ASTNode) decls[0]).getLength(), 5);
- break;
- case 1:
- assertTrue(binding instanceof ICPPConstructor);
- decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "Gonzo");
- assertEquals(((ASTNode) decls[0]).getOffset(), 22);
- assertEquals(((ASTNode) decls[0]).getLength(), 5);
- break;
- default:
- assertFalse( binding instanceof ICPPConstructor);
- String name = ((IASTName) node).toString();
- assertEquals(name.indexOf("~"), 0);
- assertEquals(name.indexOf("Gonzo"), 1);
- decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "~Gonzo");
- assertEquals(((ASTNode) decls[0]).getOffset(), 64);
- assertEquals(((ASTNode) decls[0]).getLength(), 6);
- break;
+ switch (i) {
+ case 0:
+ assertTrue(binding instanceof ICPPConstructor);
+ decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "Gonzo");
+ assertEquals(((ASTNode) decls[0]).getOffset(), 53);
+ assertEquals(((ASTNode) decls[0]).getLength(), 5);
+ break;
+ case 1:
+ assertTrue(binding instanceof ICPPConstructor);
+ decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "Gonzo");
+ assertEquals(((ASTNode) decls[0]).getOffset(), 22);
+ assertEquals(((ASTNode) decls[0]).getLength(), 5);
+ break;
+ default:
+ assertFalse(binding instanceof ICPPConstructor);
+ String name = ((IASTName) node).toString();
+ assertEquals(name.indexOf("~"), 0);
+ assertEquals(name.indexOf("Gonzo"), 1);
+ decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "~Gonzo");
+ assertEquals(((ASTNode) decls[0]).getOffset(), 64);
+ assertEquals(((ASTNode) decls[0]).getLength(), 6);
+ break;
}
}
@@ -331,16 +326,16 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testMethodReference() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Sample { public:\n");
- writer.write( " int getAnswer() const;\n");
- writer.write( "};\n");
- writer.write( "int main(int argc, char **argv) {\n");
- writer.write( " Sample * s = new Sample();\n");
- writer.write( " return s->getAnswer();\n");
- writer.write( "}\n");
+ writer.write("class Sample { public:\n");
+ writer.write(" int getAnswer() const;\n");
+ writer.write("};\n");
+ writer.write("int main(int argc, char **argv) {\n");
+ writer.write(" Sample * s = new Sample();\n");
+ writer.write(" return s->getAnswer();\n");
+ writer.write("}\n");
String code = writer.toString();
int startIndex = code.indexOf("->getAnswer") + 2;
- IASTNode node = parse(code, startIndex, startIndex+9);
+ IASTNode node = parse(code, startIndex, startIndex + 9);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPMethod);
assertEquals(((IASTName) node).toString(), "getAnswer");
@@ -367,10 +362,10 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testBug63966() throws Exception {
Writer writer = new StringWriter();
- writer.write( "void foo(int a) {}\n");
- writer.write( "void foo(long a) {}\n");
- writer.write( "int main(int argc, char **argv) {\n");
- writer.write( "foo(1); \n }");
+ writer.write("void foo(int a) {}\n");
+ writer.write("void foo(long a) {}\n");
+ writer.write("int main(int argc, char **argv) {\n");
+ writer.write("foo(1); \n }");
String code = writer.toString();
int startIndex = code.indexOf("foo(1)");
parse(code, startIndex, startIndex + 3);
@@ -378,16 +373,14 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testBug66744() throws Exception {
Writer writer = new StringWriter();
- writer.write( "enum EColours { RED, GREEN, BLUE }; \n");
- writer.write( "void foo() { EColours color = GREEN; } \n");
+ writer.write("enum EColours { RED, GREEN, BLUE }; \n");
+ writer.write("void foo() { EColours color = GREEN; } \n");
String code = writer.toString();
int startIndex = code.indexOf("EColours color");
parse(code, startIndex, startIndex + 8);
}
-
-
public void testBug68527() throws Exception {
Writer writer = new StringWriter();
writer.write("struct X;\n");
@@ -399,15 +392,15 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testBug60407() throws Exception {
Writer writer = new StringWriter();
- writer.write( "struct ZZZ { int x, y, z; };\n");
- writer.write( "typedef struct ZZZ _FILE;\n");
- writer.write( "typedef _FILE FILE;\n");
- writer.write( "static void static_function(FILE * lcd){}\n");
- writer.write( "int main(int argc, char **argv) {\n");
- writer.write( "FILE * file = 0;\n");
- writer.write( "static_function( file );\n");
- writer.write( "return 0;\n" );
- writer.write( "}\n");
+ writer.write("struct ZZZ { int x, y, z; };\n");
+ writer.write("typedef struct ZZZ _FILE;\n");
+ writer.write("typedef _FILE FILE;\n");
+ writer.write("static void static_function(FILE * lcd){}\n");
+ writer.write("int main(int argc, char **argv) {\n");
+ writer.write("FILE * file = 0;\n");
+ writer.write("static_function( file );\n");
+ writer.write("return 0;\n");
+ writer.write("}\n");
String code = writer.toString();
int startIndex = code.indexOf("static_function( file )");
parse(code, startIndex, startIndex + "static_function".length());
@@ -415,14 +408,14 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testBug61800() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class B {};\n");
- writer.write( "class ABCDEF {\n");
- writer.write( " static B stInt; };\n");
- writer.write( "B ABCDEF::stInt = 5;\n");
+ writer.write("class B {};\n");
+ writer.write("class ABCDEF {\n");
+ writer.write(" static B stInt; };\n");
+ writer.write("B ABCDEF::stInt = 5;\n");
String code = writer.toString();
int startIndex = code.indexOf("::stInt") + 2;
- IASTNode node = parse(code, startIndex, startIndex+ 5);
+ IASTNode node = parse(code, startIndex, startIndex + 5);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
assertEquals(((IASTName) node).toString(), "stInt");
@@ -434,16 +427,16 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
}
public void testBug68739() throws Exception {
- Writer writer = new StringWriter();
- writer.write( "int fprintf( int *, const char *, ... ); \n");
- writer.write( "void boo( int * lcd ) { \n");
- writer.write( " /**/fprintf( lcd, \"%c%s 0x%x\", ' ', \"bbb\", 2 ); \n");
- writer.write( "} \n");
+ Writer writer = new StringWriter();
+ writer.write("int fprintf( int *, const char *, ... ); \n");
+ writer.write("void boo( int * lcd ) { \n");
+ writer.write(" /**/fprintf( lcd, \"%c%s 0x%x\", ' ', \"bbb\", 2 ); \n");
+ writer.write("} \n");
- String code = writer.toString();
+ String code = writer.toString();
int startIndex = code.indexOf("/**/fprintf") + 4;
- IASTNode node = parse(code, startIndex, startIndex+ 7);
+ IASTNode node = parse(code, startIndex, startIndex + 7);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IFunction);
@@ -452,17 +445,17 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testBug72818() throws Exception {
Writer writer = new StringWriter();
- writer.write( "union Squaw { int x; double u; };\n");
- writer.write( "int main(int argc, char **argv) {\n");
- writer.write( "return sizeof( Squaw );\n");
- writer.write( "}\n");
+ writer.write("union Squaw { int x; double u; };\n");
+ writer.write("int main(int argc, char **argv) {\n");
+ writer.write("return sizeof( Squaw );\n");
+ writer.write("}\n");
String code = writer.toString();
- int startIndex = code.indexOf("sizeof( ") + "sizeof( ".length(); //$NON-NLS-2$
+ int startIndex = code.indexOf("sizeof( ") + "sizeof( ".length(); //$NON-NLS-2$
IASTNode node = parse(code, startIndex, startIndex + 5);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPClassType);
assertEquals(((IASTName) node).toString(), "Squaw");
- assertEquals(((ICPPClassType)((IASTName) node).resolveBinding()).getKey(), ICompositeType.k_union);
+ assertEquals(((ICPPClassType) ((IASTName) node).resolveBinding()).getKey(), ICompositeType.k_union);
IName[] decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "Squaw");
@@ -472,16 +465,16 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void test72220() throws Exception {
Writer writer = new StringWriter();
- writer.write( "const int FOUND_ME = 1;\n");
- writer.write( "class Test{\n");
- writer.write( "public:\n");
- writer.write( "const int findCode() const;\n");
- writer.write( "};\n");
- writer.write( "const int Test::findCode() const {\n");
- writer.write( "return FOUND_ME;\n");
- writer.write( "}\n");
+ writer.write("const int FOUND_ME = 1;\n");
+ writer.write("class Test{\n");
+ writer.write("public:\n");
+ writer.write("const int findCode() const;\n");
+ writer.write("};\n");
+ writer.write("const int Test::findCode() const {\n");
+ writer.write("return FOUND_ME;\n");
+ writer.write("}\n");
String code = writer.toString();
- int startIndex = code.indexOf("return ") + "return ".length(); //$NON-NLS-2$
+ int startIndex = code.indexOf("return ") + "return ".length(); //$NON-NLS-2$
IASTNode node = parse(code, startIndex, startIndex + 8);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IVariable);
@@ -493,17 +486,17 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getLength(), 8);
}
- public void testBug72721() throws Exception{
- Writer writer = new StringWriter();
- writer.write(" class ABC { public: ABC(int); }; \n");
- writer.write("void f() { \n");
- writer.write(" int j = 1; \n");
- writer.write(" new ABC( j + 1 ); \n");
- writer.write("} \n");
+ public void testBug72721() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write(" class ABC { public: ABC(int); }; \n");
+ writer.write("void f() { \n");
+ writer.write(" int j = 1; \n");
+ writer.write(" new ABC( j + 1 ); \n");
+ writer.write("} \n");
- String code = writer.toString();
- int startIndex = code.indexOf("ABC(");
- IASTNode node = parse(code, startIndex, startIndex + 3);
+ String code = writer.toString();
+ int startIndex = code.indexOf("ABC(");
+ IASTNode node = parse(code, startIndex, startIndex + 3);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPConstructor);
assertEquals(((IASTName) node).toString(), "ABC");
@@ -514,17 +507,17 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getLength(), 3);
}
- public void testBug72372() throws Exception{
- Writer writer = new StringWriter();
- writer.write("namespace B { \n");
- writer.write(" class SD_02 { void f_SD(); }; \n");
- writer.write("} \n");
- writer.write("using namespace B; \n");
- writer.write("void SD_02::f_SD(){} \n");
+ public void testBug72372() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("namespace B { \n");
+ writer.write(" class SD_02 { void f_SD(); }; \n");
+ writer.write("} \n");
+ writer.write("using namespace B; \n");
+ writer.write("void SD_02::f_SD(){} \n");
- String code = writer.toString();
- int startIndex = code.indexOf(":f_SD");
- IASTNode node = parse(code, startIndex + 1, startIndex + 5);
+ String code = writer.toString();
+ int startIndex = code.indexOf(":f_SD");
+ IASTNode node = parse(code, startIndex + 1, startIndex + 5);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPMethod);
assertEquals(((IASTName) node).toString(), "f_SD");
@@ -534,21 +527,22 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getOffset(), 71);
assertEquals(((ASTNode) decls[0]).getLength(), 4);
}
- public void testBug72372_2() throws Exception{
- Writer writer = new StringWriter();
- writer.write("namespace A { \n");
- writer.write(" namespace B { \n");
- writer.write(" void f_SD(); \n");
- writer.write(" } \n");
- writer.write("} \n");
- writer.write("namespace C { \n");
- writer.write(" using namespace A; \n");
- writer.write("} \n");
- writer.write("void C::B::f_SD(){} \n");
-
- String code = writer.toString();
- int startIndex = code.indexOf(":f_SD");
- IASTNode node = parse(code, startIndex + 1, startIndex + 5);
+
+ public void testBug72372_2() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("namespace A { \n");
+ writer.write(" namespace B { \n");
+ writer.write(" void f_SD(); \n");
+ writer.write(" } \n");
+ writer.write("} \n");
+ writer.write("namespace C { \n");
+ writer.write(" using namespace A; \n");
+ writer.write("} \n");
+ writer.write("void C::B::f_SD(){} \n");
+
+ String code = writer.toString();
+ int startIndex = code.indexOf(":f_SD");
+ IASTNode node = parse(code, startIndex + 1, startIndex + 5);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IFunction);
assertEquals(((IASTName) node).toString(), "f_SD");
@@ -559,14 +553,14 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getLength(), 4);
}
- public void testBug72713() throws Exception{
- Writer writer = new StringWriter();
- writer.write( "class Deck{ void initialize(); }; \n");
- writer.write( "void Deck::initialize(){} \n");
+ public void testBug72713() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class Deck{ void initialize(); }; \n");
+ writer.write("void Deck::initialize(){} \n");
- String code = writer.toString();
- int startIndex = code.indexOf(":initialize");
- IASTNode node = parse(code, startIndex + 1, startIndex + 11);
+ String code = writer.toString();
+ int startIndex = code.indexOf(":initialize");
+ IASTNode node = parse(code, startIndex + 1, startIndex + 11);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPMethod);
assertEquals(((IASTName) node).toString(), "initialize");
@@ -577,15 +571,15 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getLength(), 10);
}
- public void testBug72712() throws Exception{
- Writer writer = new StringWriter();
- writer.write( "class B{ public: B(); }; void f(){ B* b; b = new B(); }");
+ public void testBug72712() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class B{ public: B(); }; void f(){ B* b; b = new B(); }");
- String code = writer.toString();
- int startIndex = code.indexOf("new B" ) + 4;
+ String code = writer.toString();
+ int startIndex = code.indexOf("new B") + 4;
- IASTNode node = parse(code, startIndex, startIndex + 1);
- node = TestUtil.findImplicitName(node);
+ IASTNode node = parse(code, startIndex, startIndex + 1);
+ node = TestUtil.findImplicitName(node);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPConstructor);
assertEquals(((IASTName) node).toString(), "B");
@@ -596,16 +590,16 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(1, ((ASTNode) decls[0]).getLength());
}
- public void testBug72712_2() throws Exception{
- Writer writer = new StringWriter();
- writer.write( "class A {}; \n");
- writer.write( "class B{ public: B( A* ); }; \n");
- writer.write( "void f(){ B* b; b = new B( (A*)0 ); } \n");
+ public void testBug72712_2() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class A {}; \n");
+ writer.write("class B{ public: B( A* ); }; \n");
+ writer.write("void f(){ B* b; b = new B( (A*)0 ); } \n");
- String code = writer.toString();
- int startIndex = code.indexOf("(A*)" ) + 1;
+ String code = writer.toString();
+ int startIndex = code.indexOf("(A*)") + 1;
- IASTNode node = parse(code, startIndex, startIndex + 1);
+ IASTNode node = parse(code, startIndex, startIndex + 1);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPClassType);
assertEquals(((IASTName) node).toString(), "A");
@@ -616,18 +610,18 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getLength(), 1);
}
- public void testBug72814() throws Exception{
- CPPASTNameBase.sAllowNameComputation= true;
+ public void testBug72814() throws Exception {
+ CPPASTNameBase.sAllowNameComputation = true;
- Writer writer = new StringWriter();
- writer.write( "namespace N{ \n");
- writer.write( " template < class T > class AAA { T _t; };\n");
- writer.write( "} \n");
- writer.write( "N::AAA<int> a; \n");
+ Writer writer = new StringWriter();
+ writer.write("namespace N{ \n");
+ writer.write(" template < class T > class AAA { T _t; };\n");
+ writer.write("} \n");
+ writer.write("N::AAA<int> a; \n");
- String code = writer.toString();
- int startIndex = code.indexOf("AAA<int>");
- IASTNode node = parse(code, startIndex, startIndex + 3);
+ String code = writer.toString();
+ int startIndex = code.indexOf("AAA<int>");
+ IASTNode node = parse(code, startIndex, startIndex + 3);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPClassType);
@@ -638,28 +632,28 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getOffset(), 75);
assertEquals(((ASTNode) decls[0]).getLength(), 3);
- node = parse(code, startIndex, startIndex + 8);
+ node = parse(code, startIndex, startIndex + 8);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPClassType);
assertEquals(((IASTName) node).toString(), "AAA<int>");
decls = getDeclarationOffTU((IASTName) node);
// TODO raised bug 92632 for below
-// assertEquals(decls.length, 1);
-// assertEquals(decls[0].toString(), "AAA");
-// assertEquals(((ASTNode) decls[0]).getOffset(), 15);
-// assertEquals(((ASTNode) decls[0]).getLength(), 3);
+ // assertEquals(decls.length, 1);
+ // assertEquals(decls[0].toString(), "AAA");
+ // assertEquals(((ASTNode) decls[0]).getOffset(), 15);
+ // assertEquals(((ASTNode) decls[0]).getLength(), 3);
}
public void testBug72710() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Card{\n");
- writer.write( " Card( int rank );\n");
- writer.write( " int rank;\n");
- writer.write( "};\n");
- writer.write( "Card::Card( int rank ) {\n");
- writer.write( "this->rank = rank;\n");
- writer.write( "}\n");
+ writer.write("class Card{\n");
+ writer.write(" Card( int rank );\n");
+ writer.write(" int rank;\n");
+ writer.write("};\n");
+ writer.write("Card::Card( int rank ) {\n");
+ writer.write("this->rank = rank;\n");
+ writer.write("}\n");
String code = writer.toString();
int index = code.indexOf("this->rank") + 6;
IASTNode node = parse(code, index, index + 4);
@@ -673,9 +667,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getLength(), 4);
}
-
- public void testBug75731() throws Exception
- {
+ public void testBug75731() throws Exception {
Writer writer = new StringWriter();
writer.write("int rank() {\n");
writer.write("return 5;\n}\n");
@@ -698,7 +690,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IFunction);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
IName[] decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -710,7 +702,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPClassType);
assertEquals(((IASTName) node).toString(), "Card");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "Card");
@@ -722,7 +714,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPConstructor);
assertEquals(((IASTName) node).toString(), "Card");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 2);
assertEquals(decls[0].toString(), "Card");
@@ -734,7 +726,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IParameter);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 2);
assertEquals(decls[0].toString(), "rank");
@@ -746,7 +738,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -758,7 +750,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPMethod);
assertEquals(((IASTName) node).toString(), "getRank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "getRank");
@@ -770,7 +762,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPClassType);
assertEquals(((IASTName) node).toString(), "Card");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "Card");
@@ -782,7 +774,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPConstructor);
assertEquals(((IASTName) node).toString(), "Card");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 2);
assertEquals(decls[0].toString(), "Card");
@@ -794,7 +786,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IParameter);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 2);
assertEquals(decls[0].toString(), "rank");
@@ -806,7 +798,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -818,7 +810,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IFunction);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -830,7 +822,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -842,7 +834,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -854,7 +846,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -866,7 +858,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IParameter);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 2);
assertEquals(decls[0].toString(), "rank");
@@ -878,7 +870,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -890,7 +882,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -902,7 +894,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -914,7 +906,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPMethod);
assertEquals(((IASTName) node).toString(), "getRank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "getRank");
@@ -935,7 +927,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPNamespace);
assertEquals(((IASTName) node).toString(), "N");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
IName[] decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "N");
@@ -954,7 +946,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IParameter);
assertEquals(((IASTName) node).toString(), "itself");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
IName[] decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "itself");
@@ -974,7 +966,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICompositeType);
assertEquals(((IASTName) node).toString(), "Data");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
IName[] decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "Data");
@@ -995,7 +987,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICompositeType);
assertEquals(((IASTName) node).toString(), "Data");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
}
public void testBug64326() throws Exception {
@@ -1073,10 +1065,10 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
ICElement[] scope = new ICElement[1];
scope[0] = new CProject(null, project);
-// // TODO need to register to an index and wait for it to finish before this test will work
-//
-// Set matches = SearchEngine.getMatchesFromSearchEngine(SearchEngine.createCSearchScope(scope), (IASTName) node, CSearchPattern.DECLARATIONS);
-// assertEquals(matches.size(), 1);
+ // // TODO need to register to an index and wait for it to finish before this test will work
+ //
+ // Set matches = SearchEngine.getMatchesFromSearchEngine(SearchEngine.createCSearchScope(scope), (IASTName) node, CSearchPattern.DECLARATIONS);
+ // assertEquals(matches.size(), 1);
}
public void testBug78114() throws Exception {
@@ -1148,7 +1140,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
writer.write("return (0); \n");
writer.write(" }\n");
- String code = writer.toString();
+ String code = writer.toString();
int index = code.indexOf("operator=(zero)");
IASTNode node = parse(code, index, index + 9, true);
@@ -1435,159 +1427,159 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getLength(), 1);
}
- public void testBug86504() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class C { };\n");
- writer.write("void f(int(C)) { } // void f(int (*fp)(C c)) { }\n");
- writer.write("// not: void f(int C);\n");
- writer.write("int g(C);\n");
- writer.write("void foo() {\n");
- writer.write("f(g); // openDeclarations on g causes StackOverflowError\n");
- writer.write("}\n");
-
- String code = writer.toString();
-
- int index = code.indexOf("g); ");
- IASTNode node = parse(code, index, index + 1, true);
- assertTrue(node instanceof IASTName);
- assertTrue(((IASTName) node).resolveBinding() instanceof ICPPFunction);
- assertEquals(((IASTName) node).toString(), "g");
-
- IName[] decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "g");
- assertEquals(((ASTNode) decls[0]).getOffset(), 89);
- assertEquals(((ASTNode) decls[0]).getLength(), 1);
- }
-
- public void testBug79811() throws Exception {
- Writer writer = new StringWriter();
- writer.write("enum E{E0};\n");
- writer.write("void f() {\n");
- writer.write("enum E{E1};\n");
- writer.write("E e; //this one is incorrectly found\n");
- writer.write("}\n");
- writer.write("E f; //ok\n");
-
- String code = writer.toString();
-
- int index = code.indexOf("E{E0}");
- IASTNode node = parse(code, index, index + 1, true);
- assertTrue(node instanceof IASTName);
- assertTrue(((IASTName) node).resolveBinding() instanceof IEnumeration);
- assertEquals(((IASTName) node).toString(), "E");
-
- IName[] decls = getReferencesOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "E");
- assertEquals(((ASTNode) decls[0]).getOffset(), 76);
- assertEquals(((ASTNode) decls[0]).getLength(), 1);
- }
-
- public void testBugLabelWithMacro() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#define UINT32 unsigned int\n");
- writer.write("#define HANDLE unsigned int**\n");
- writer.write("void foo()\n");
- writer.write("{\n");
- writer.write("UINT32 u;\n");
- writer.write("HANDLE h;\n");
- writer.write("}\n");
- writer.write("int foo2() {\n");
- writer.write("test:\n");
- writer.write("goto test;\n");
- writer.write("return foo();\n");
- writer.write("}\n");
-
- String code = writer.toString();
-
- int index = code.indexOf("HANDLE h");
- IASTNode node = parse(code, index, index + 6, true);
- assertTrue(node instanceof IASTName);
- assertTrue(((IASTName) node).resolveBinding() instanceof IMacroBinding);
- assertEquals(((IASTName) node).toString(), "HANDLE");
-
- IName[] decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "HANDLE");
- assertEquals(((ASTNode) decls[0]).getOffset(), 36);
- assertEquals(((ASTNode) decls[0]).getLength(), 6);
-
- index = code.indexOf("test;");
- node = parse(code, index, index + 4, true);
- assertTrue(node instanceof IASTName);
- assertTrue(((IASTName) node).resolveBinding() instanceof ILabel);
- assertEquals(((IASTName) node).toString(), "test");
-
- decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "test");
- assertLocation(code, "test:", 4, decls[0]);
- }
-
- public void testBugMethodDef() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class tetrahedron {\n");
- writer.write("private:\n");
- writer.write("int color;\n");
- writer.write("public:\n");
- writer.write("/* Methods */\n");
- writer.write("void setColor(int c) \n");
- writer.write("{color = c < 0 ? 0 : c;};\n");
- writer.write("void set();\n");
- writer.write("};\n");
- writer.write("void tetrahedron::set() {\n");
- writer.write("int color;\n");
- writer.write("setColor(color);\n");
- writer.write("}\n");
-
- String code = writer.toString();
-
- int index = code.indexOf("setColor(color)");
- IASTNode node = parse(code, index, index + 8, true);
- assertTrue(node instanceof IASTName);
- assertTrue(((IASTName) node).resolveBinding() instanceof ICPPMethod);
- assertEquals(((IASTName) node).toString(), "setColor");
-
- IName[] decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "setColor");
- assertEquals(((ASTNode) decls[0]).getOffset(), 67);
- assertEquals(((ASTNode) decls[0]).getLength(), 8);
-
- IName[] refs = getReferencesOffTU((IASTName) node);
- assertEquals(refs.length, 1);
- assertEquals(refs[0].toString(), "setColor");
- assertEquals(((ASTNode)refs[0]).getOffset(), 162);
- assertEquals(((ASTNode)refs[0]).getLength(), 8);
- }
-
- public void testBug86698A() throws Exception {
- Writer writer = new StringWriter();
- writer.write("struct C;\n");
- writer.write("void no_opt(C*);\n");
- writer.write("struct C {\n");
- writer.write("int c;\n");
- writer.write("C() : c(0) { no_opt(this); }\n");
- writer.write("};\n");
-
- String code = writer.toString();
-
- int index = code.indexOf("c(0)");
- IASTNode node = parse(code, index, index + 1, true);
- assertTrue(node instanceof IASTName);
- assertTrue(((IASTName) node).resolveBinding() instanceof IVariable);
- assertEquals(((IASTName) node).toString(), "c");
-
- IName[] decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "c");
- assertEquals(((ASTNode) decls[0]).getOffset(), 42);
- assertEquals(((ASTNode) decls[0]).getLength(), 1);
- }
-
- public void testBug86698B() throws Exception {
- Writer writer = new StringWriter();
+ public void testBug86504() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class C { };\n");
+ writer.write("void f(int(C)) { } // void f(int (*fp)(C c)) { }\n");
+ writer.write("// not: void f(int C);\n");
+ writer.write("int g(C);\n");
+ writer.write("void foo() {\n");
+ writer.write("f(g); // openDeclarations on g causes StackOverflowError\n");
+ writer.write("}\n");
+
+ String code = writer.toString();
+
+ int index = code.indexOf("g); ");
+ IASTNode node = parse(code, index, index + 1, true);
+ assertTrue(node instanceof IASTName);
+ assertTrue(((IASTName) node).resolveBinding() instanceof ICPPFunction);
+ assertEquals(((IASTName) node).toString(), "g");
+
+ IName[] decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "g");
+ assertEquals(((ASTNode) decls[0]).getOffset(), 89);
+ assertEquals(((ASTNode) decls[0]).getLength(), 1);
+ }
+
+ public void testBug79811() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("enum E{E0};\n");
+ writer.write("void f() {\n");
+ writer.write("enum E{E1};\n");
+ writer.write("E e; //this one is incorrectly found\n");
+ writer.write("}\n");
+ writer.write("E f; //ok\n");
+
+ String code = writer.toString();
+
+ int index = code.indexOf("E{E0}");
+ IASTNode node = parse(code, index, index + 1, true);
+ assertTrue(node instanceof IASTName);
+ assertTrue(((IASTName) node).resolveBinding() instanceof IEnumeration);
+ assertEquals(((IASTName) node).toString(), "E");
+
+ IName[] decls = getReferencesOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "E");
+ assertEquals(((ASTNode) decls[0]).getOffset(), 76);
+ assertEquals(((ASTNode) decls[0]).getLength(), 1);
+ }
+
+ public void testBugLabelWithMacro() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#define UINT32 unsigned int\n");
+ writer.write("#define HANDLE unsigned int**\n");
+ writer.write("void foo()\n");
+ writer.write("{\n");
+ writer.write("UINT32 u;\n");
+ writer.write("HANDLE h;\n");
+ writer.write("}\n");
+ writer.write("int foo2() {\n");
+ writer.write("test:\n");
+ writer.write("goto test;\n");
+ writer.write("return foo();\n");
+ writer.write("}\n");
+
+ String code = writer.toString();
+
+ int index = code.indexOf("HANDLE h");
+ IASTNode node = parse(code, index, index + 6, true);
+ assertTrue(node instanceof IASTName);
+ assertTrue(((IASTName) node).resolveBinding() instanceof IMacroBinding);
+ assertEquals(((IASTName) node).toString(), "HANDLE");
+
+ IName[] decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "HANDLE");
+ assertEquals(((ASTNode) decls[0]).getOffset(), 36);
+ assertEquals(((ASTNode) decls[0]).getLength(), 6);
+
+ index = code.indexOf("test;");
+ node = parse(code, index, index + 4, true);
+ assertTrue(node instanceof IASTName);
+ assertTrue(((IASTName) node).resolveBinding() instanceof ILabel);
+ assertEquals(((IASTName) node).toString(), "test");
+
+ decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "test");
+ assertLocation(code, "test:", 4, decls[0]);
+ }
+
+ public void testBugMethodDef() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class tetrahedron {\n");
+ writer.write("private:\n");
+ writer.write("int color;\n");
+ writer.write("public:\n");
+ writer.write("/* Methods */\n");
+ writer.write("void setColor(int c) \n");
+ writer.write("{color = c < 0 ? 0 : c;};\n");
+ writer.write("void set();\n");
+ writer.write("};\n");
+ writer.write("void tetrahedron::set() {\n");
+ writer.write("int color;\n");
+ writer.write("setColor(color);\n");
+ writer.write("}\n");
+
+ String code = writer.toString();
+
+ int index = code.indexOf("setColor(color)");
+ IASTNode node = parse(code, index, index + 8, true);
+ assertTrue(node instanceof IASTName);
+ assertTrue(((IASTName) node).resolveBinding() instanceof ICPPMethod);
+ assertEquals(((IASTName) node).toString(), "setColor");
+
+ IName[] decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "setColor");
+ assertEquals(((ASTNode) decls[0]).getOffset(), 67);
+ assertEquals(((ASTNode) decls[0]).getLength(), 8);
+
+ IName[] refs = getReferencesOffTU((IASTName) node);
+ assertEquals(refs.length, 1);
+ assertEquals(refs[0].toString(), "setColor");
+ assertEquals(((ASTNode) refs[0]).getOffset(), 162);
+ assertEquals(((ASTNode) refs[0]).getLength(), 8);
+ }
+
+ public void testBug86698A() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("struct C;\n");
+ writer.write("void no_opt(C*);\n");
+ writer.write("struct C {\n");
+ writer.write("int c;\n");
+ writer.write("C() : c(0) { no_opt(this); }\n");
+ writer.write("};\n");
+
+ String code = writer.toString();
+
+ int index = code.indexOf("c(0)");
+ IASTNode node = parse(code, index, index + 1, true);
+ assertTrue(node instanceof IASTName);
+ assertTrue(((IASTName) node).resolveBinding() instanceof IVariable);
+ assertEquals(((IASTName) node).toString(), "c");
+
+ IName[] decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "c");
+ assertEquals(((ASTNode) decls[0]).getOffset(), 42);
+ assertEquals(((ASTNode) decls[0]).getLength(), 1);
+ }
+
+ public void testBug86698B() throws Exception {
+ Writer writer = new StringWriter();
writer.write("int f(int);\n");
writer.write("class C {\n");
writer.write("int i;\n");
@@ -1609,18 +1601,18 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
String code = writer.toString();
- int index = code.indexOf("i(f(ii)), d(id)");
- IASTNode node = parse(code, index, index + 1, true);
- assertTrue(node instanceof IASTName);
- assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
- assertEquals(((IASTName) node).toString(), "i");
+ int index = code.indexOf("i(f(ii)), d(id)");
+ IASTNode node = parse(code, index, index + 1, true);
+ assertTrue(node instanceof IASTName);
+ assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
+ assertEquals(((IASTName) node).toString(), "i");
- IName[] decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "i");
- assertEquals(code.indexOf("int i") + 4, ((ASTNode) decls[0]).getOffset());
- assertEquals(((ASTNode) decls[0]).getLength(), 1);
- }
+ IName[] decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "i");
+ assertEquals(code.indexOf("int i") + 4, ((ASTNode) decls[0]).getOffset());
+ assertEquals(((ASTNode) decls[0]).getLength(), 1);
+ }
public void testBug64181() throws Exception {
StringBuilder buffer = new StringBuilder();
@@ -1637,7 +1629,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
String code = buffer.toString();
int index = code.indexOf("Foo::bar;");
- IASTNode node = parse(code, index, index + 3, true);
+ IASTNode node = parse(code, index, index + 3, true);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPNamespace);
@@ -1659,7 +1651,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
String code = buffer.toString();
int index = code.indexOf("MyChicken c;");
- IASTNode node = parse(code, index, index + 9, true);
+ IASTNode node = parse(code, index, index + 9, true);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IMacroBinding);
@@ -1671,44 +1663,44 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getLength(), 9);
}
- public void testBug86993() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("#define _BEGIN_STD_C extern \"C\" {\n");
- buffer.append("#define _END_STD_C }\n");
- buffer.append("_BEGIN_STD_C\n");
- buffer.append("char c; // selection on this fails because offset for \n");
- buffer.append("_END_STD_C\n");
- buffer.append("char foo() {\n");
- buffer.append("return c; // ref \n");
- buffer.append("}\n");
-
- String code = buffer.toString();
- int index = code.indexOf("return c;");
- IASTNode node = parse(code, index + 7, index + 8, true);
- assertNotNull(node);
- assertTrue(node instanceof IASTName);
- assertTrue(((IASTName) node).resolveBinding() instanceof ICPPVariable);
- assertEquals(((IASTName) node).toString(), "c");
- IName[] decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "c");
- assertLocation(code, "c;", 1, decls[0]);
-
- index = code.indexOf("char c");
- node = parse(code, index + 5, index + 6, true);
- assertNotNull(node);
- assertTrue(node instanceof IASTName);
- assertTrue(((IASTName) node).resolveBinding() instanceof ICPPVariable);
- IName[] refs = getReferencesOffTU((IASTName) node);
- assertEquals(refs.length, 1);
- assertEquals(refs[0].toString(), "c");
- assertLocation(code, "c; // ref", 1, refs[0]);
- }
-
- private void assertLocation(String code, String occur, int length, IName name) {
- int offset= code.indexOf(occur);
- final IASTFileLocation loc= name.getFileLocation();
- assertEquals(offset, loc.getNodeOffset());
- assertEquals(length, loc.getNodeLength());
+ public void testBug86993() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#define _BEGIN_STD_C extern \"C\" {\n");
+ buffer.append("#define _END_STD_C }\n");
+ buffer.append("_BEGIN_STD_C\n");
+ buffer.append("char c; // selection on this fails because offset for \n");
+ buffer.append("_END_STD_C\n");
+ buffer.append("char foo() {\n");
+ buffer.append("return c; // ref \n");
+ buffer.append("}\n");
+
+ String code = buffer.toString();
+ int index = code.indexOf("return c;");
+ IASTNode node = parse(code, index + 7, index + 8, true);
+ assertNotNull(node);
+ assertTrue(node instanceof IASTName);
+ assertTrue(((IASTName) node).resolveBinding() instanceof ICPPVariable);
+ assertEquals(((IASTName) node).toString(), "c");
+ IName[] decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "c");
+ assertLocation(code, "c;", 1, decls[0]);
+
+ index = code.indexOf("char c");
+ node = parse(code, index + 5, index + 6, true);
+ assertNotNull(node);
+ assertTrue(node instanceof IASTName);
+ assertTrue(((IASTName) node).resolveBinding() instanceof ICPPVariable);
+ IName[] refs = getReferencesOffTU((IASTName) node);
+ assertEquals(refs.length, 1);
+ assertEquals(refs[0].toString(), "c");
+ assertLocation(code, "c; // ref", 1, refs[0]);
+ }
+
+ private void assertLocation(String code, String occur, int length, IName name) {
+ int offset = code.indexOf(occur);
+ final IASTFileLocation loc = name.getFileLocation();
+ assertEquals(offset, loc.getNodeOffset());
+ assertEquals(length, loc.getNodeLength());
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTestBase.java
index 9a4d9355a15..f4706f4842e 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTestBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTestBase.java
@@ -40,30 +40,31 @@ public class DOMSelectionParseTestBase extends DOMFileBasePluginTest {
}
protected IASTNode parse(String code, int offset1, int offset2) throws Exception {
- return parse( code, offset1, offset2, true );
+ return parse(code, offset1, offset2, true);
}
protected IASTNode parse(String code, int offset1, int offset2, boolean expectedToPass) throws Exception {
IFile file = importFile("temp.cpp", code); //$NON-NLS-1$
return parse(file, offset1, offset2, expectedToPass);
}
-
+
protected IASTNode parse(IFile file, int offset1, int offset2, boolean expectedToPass) throws Exception {
- ITranslationUnit tu = (ITranslationUnit)CCorePlugin.getDefault().getCoreModel().create(file);
+ ITranslationUnit tu = (ITranslationUnit) CCorePlugin.getDefault().getCoreModel().create(file);
IASTTranslationUnit ast = tu.getAST();
- IASTName name= ast.getNodeSelector(null).findName(offset1, offset2 - offset1);
+ IASTName name = ast.getNodeSelector(null).findName(offset1, offset2 - offset1);
+
+ if (!expectedToPass)
+ return null;
- if (!expectedToPass) return null;
-
assertNotNull(name);
return name;
}
-
+
protected IName[] getDeclarationOffTU(IASTName name) {
- return DOMSearchUtil.getNamesFromDOM(name, DOMSearchUtil.DECLARATIONS);
+ return DOMSearchUtil.getNamesFromDOM(name, DOMSearchUtil.DECLARATIONS);
+ }
+
+ protected IName[] getReferencesOffTU(IASTName name) {
+ return DOMSearchUtil.getNamesFromDOM(name, DOMSearchUtil.REFERENCES);
}
-
- protected IName[] getReferencesOffTU(IASTName name) {
- return DOMSearchUtil.getNamesFromDOM(name, DOMSearchUtil.REFERENCES);
- }
}
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 8dced8669da..fb3039a0d25 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
@@ -34,254 +34,252 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
* Testcases related to recovery from invalid syntax.
*/
public class FaultToleranceTests extends AST2TestBase {
-
+
public static TestSuite suite() {
return suite(FaultToleranceTests.class);
}
-
+
public FaultToleranceTests() {
super();
}
-
+
public FaultToleranceTests(String name) {
super(name);
}
-
+
// typedef int tint;
// struct X {
// int a;
// }
// tint b;
- public void testCompositeTypeWithoutSemi() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTCompositeTypeSpecifier def= getCompositeType(tu, 1);
- IASTProblemDeclaration pdecl= getDeclaration(tu, 2);
- IASTSimpleDeclaration sdecl= getDeclaration(tu, 3);
- }
- }
+ public void testCompositeTypeWithoutSemi() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTCompositeTypeSpecifier def = getCompositeType(tu, 1);
+ IASTProblemDeclaration pdecl = getDeclaration(tu, 2);
+ IASTSimpleDeclaration sdecl = getDeclaration(tu, 3);
+ }
+ }
// typedef int tint;
// struct X {
// int a;
// } c
// tint b;
- public void testCompositeTypeWithDtorWithoutSemi() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTSimpleDeclaration sdecl= getDeclaration(tu, 1);
- assertInstance(sdecl.getDeclSpecifier(), IASTCompositeTypeSpecifier.class);
- assertEquals(1, sdecl.getDeclarators().length);
- IASTProblemDeclaration pdecl= getDeclaration(tu, 2);
- sdecl= getDeclaration(tu, 3);
- }
- }
-
+ public void testCompositeTypeWithDtorWithoutSemi() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTSimpleDeclaration sdecl = getDeclaration(tu, 1);
+ assertInstance(sdecl.getDeclSpecifier(), IASTCompositeTypeSpecifier.class);
+ assertEquals(1, sdecl.getDeclarators().length);
+ IASTProblemDeclaration pdecl = getDeclaration(tu, 2);
+ sdecl = getDeclaration(tu, 3);
+ }
+ }
+
// typedef int tint;
- // int a
+ // int a
// tint b;
- public void testVariableWithoutSemi() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTSimpleDeclaration sdecl= getDeclaration(tu, 1);
- assertEquals("int a", sdecl.getRawSignature());
- IASTProblemDeclaration pdecl= getDeclaration(tu, 2);
- sdecl= getDeclaration(tu, 3);
- }
- }
+ public void testVariableWithoutSemi() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTSimpleDeclaration sdecl = getDeclaration(tu, 1);
+ assertEquals("int a", sdecl.getRawSignature());
+ IASTProblemDeclaration pdecl = getDeclaration(tu, 2);
+ sdecl = getDeclaration(tu, 3);
+ }
+ }
// typedef int tint;
- // int a()
+ // int a()
// tint b;
- public void testPrototypeWithoutSemi() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTSimpleDeclaration sdecl= getDeclaration(tu, 1);
- assertEquals("int a()", sdecl.getRawSignature());
- IASTProblemDeclaration pdecl= getDeclaration(tu, 2);
- sdecl= getDeclaration(tu, 3);
- }
- }
+ public void testPrototypeWithoutSemi() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTSimpleDeclaration sdecl = getDeclaration(tu, 1);
+ assertEquals("int a()", sdecl.getRawSignature());
+ IASTProblemDeclaration pdecl = getDeclaration(tu, 2);
+ sdecl = getDeclaration(tu, 3);
+ }
+ }
// void f() {
- // int a= 1
+ // int a= 1
// f()
- // }
- public void testExpressionWithoutSemi_314593() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTStatement stmt= getStatement(fdef, 0);
- assertEquals("int a= 1", stmt.getRawSignature());
- IASTProblemStatement pstmt= getStatement(fdef, 1);
- stmt= getStatement(fdef, 2);
- assertEquals("f()", stmt.getRawSignature());
- pstmt= getStatement(fdef, 3);
- }
- }
+ // }
+ public void testExpressionWithoutSemi_314593() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTStatement stmt = getStatement(fdef, 0);
+ assertEquals("int a= 1", stmt.getRawSignature());
+ IASTProblemStatement pstmt = getStatement(fdef, 1);
+ stmt = getStatement(fdef, 2);
+ assertEquals("f()", stmt.getRawSignature());
+ pstmt = getStatement(fdef, 3);
+ }
+ }
- // struct X {
- // int a;
- public void testIncompleteCompositeType() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTCompositeTypeSpecifier comp= getCompositeType(tu, 0);
- IASTProblemDeclaration pdecl= getDeclaration(tu, 1);
-
- IASTSimpleDeclaration sdecl= getDeclaration(comp, 0);
- }
- }
-
- // void func() {
- // int a;
- public void testIncompleteFunctionDefinition() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTProblemDeclaration pdecl= getDeclaration(tu, 1);
-
- IASTDeclarationStatement sdecl= getStatement(fdef, 0);
- }
- }
-
+ // struct X {
+ // int a;
+ public void testIncompleteCompositeType() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTCompositeTypeSpecifier comp = getCompositeType(tu, 0);
+ IASTProblemDeclaration pdecl = getDeclaration(tu, 1);
- // namespace ns {
- // int a;
- public void testIncompleteNamespace() throws Exception {
- final String comment= getAboveComment();
- IASTTranslationUnit tu= parse(comment, ParserLanguage.CPP, false, false);
- ICPPASTNamespaceDefinition ns= getDeclaration(tu, 0);
- IASTProblemDeclaration pdecl= getDeclaration(tu, 1);
+ IASTSimpleDeclaration sdecl = getDeclaration(comp, 0);
+ }
+ }
- IASTSimpleDeclaration sdecl= getDeclaration(ns, 0);
- }
+ // void func() {
+ // int a;
+ public void testIncompleteFunctionDefinition() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTProblemDeclaration pdecl = getDeclaration(tu, 1);
- // extern "C" {
- // int a;
- public void testIncompleteLinkageSpec() throws Exception {
- final String comment= getAboveComment();
- IASTTranslationUnit tu= parse(comment, ParserLanguage.CPP, false, false);
- ICPPASTLinkageSpecification ls= getDeclaration(tu, 0);
- IASTProblemDeclaration pdecl= getDeclaration(tu, 1);
+ IASTDeclarationStatement sdecl = getStatement(fdef, 0);
+ }
+ }
- IASTSimpleDeclaration sdecl= getDeclaration(ls, 0);
- }
+ // namespace ns {
+ // int a;
+ public void testIncompleteNamespace() throws Exception {
+ final String comment = getAboveComment();
+ IASTTranslationUnit tu = parse(comment, ParserLanguage.CPP, false, false);
+ ICPPASTNamespaceDefinition ns = getDeclaration(tu, 0);
+ IASTProblemDeclaration pdecl = getDeclaration(tu, 1);
- // void test() {
- // int a= offsetof(struct mystruct, singlechar);
- // }
- public void testRangeOfProblemNode_Bug238151() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTProblemStatement pdecl= getStatement(fdef, 0);
- assertEquals("int a= offsetof(struct mystruct, singlechar);", pdecl.getRawSignature());
- }
- }
-
- // int f(){
- // if( 12 A )
- // return -1;
- // int v;
- // }
- public void testProblemInIfExpression_Bug100321() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTIfStatement ifstmt= getStatement(fdef, 0);
- assertInstance(ifstmt.getConditionExpression(), IASTProblemExpression.class);
- assertEquals("12 A", ifstmt.getConditionExpression().getRawSignature());
- assertInstance(ifstmt.getThenClause(), IASTReturnStatement.class);
- }
- }
-
- // _MYMACRO_ myType foo();
- // _MYMACRO_ myType foo() {}
- // extern void foo2() _MYMACRO_;
- public void testUndefinedMacrosInFunctionDeclarations_Bug234085() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTProblemDeclaration pd= getDeclaration(tu, 0);
- assertEquals("_MYMACRO_", pd.getRawSignature());
- IASTSimpleDeclaration sdecl= getDeclaration(tu, 1);
- assertEquals("myType foo();", sdecl.getRawSignature());
-
- pd= getDeclaration(tu, 2);
- assertEquals("_MYMACRO_", pd.getRawSignature());
- IASTFunctionDefinition fdef= getDeclaration(tu, 3);
- assertEquals("myType foo() {}", fdef.getRawSignature());
+ IASTSimpleDeclaration sdecl = getDeclaration(ns, 0);
+ }
- sdecl= getDeclaration(tu, 4);
- assertEquals("extern void foo2()", sdecl.getRawSignature());
- pd= getDeclaration(tu, 5); // the missing semicolon
-
- if (lang == ParserLanguage.CPP) {
- pd= getDeclaration(tu, 6);
- assertEquals("_MYMACRO_;", pd.getRawSignature());
- } else {
- sdecl= getDeclaration(tu, 6);
- assertEquals("_MYMACRO_;", sdecl.getRawSignature());
- }
- }
- }
+ // extern "C" {
+ // int a;
+ public void testIncompleteLinkageSpec() throws Exception {
+ final String comment = getAboveComment();
+ IASTTranslationUnit tu = parse(comment, ParserLanguage.CPP, false, false);
+ ICPPASTLinkageSpecification ls = getDeclaration(tu, 0);
+ IASTProblemDeclaration pdecl = getDeclaration(tu, 1);
- // enum _T { I J, K }; // missing comma
- // int i;
- public void testEnumProblem() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTSimpleDeclaration e= getDeclaration(tu, 0);
- IASTProblemDeclaration p= getDeclaration(tu, 1);
- assertEquals("J, K };", p.getRawSignature());
- IASTSimpleDeclaration s= getDeclaration(tu, 2);
- assertEquals("int i;", s.getRawSignature());
- }
- }
+ IASTSimpleDeclaration sdecl = getDeclaration(ls, 0);
+ }
+
+ // void test() {
+ // int a= offsetof(struct mystruct, singlechar);
+ // }
+ public void testRangeOfProblemNode_Bug238151() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTProblemStatement pdecl = getStatement(fdef, 0);
+ assertEquals("int a= offsetof(struct mystruct, singlechar);", pdecl.getRawSignature());
+ }
+ }
+
+ // int f(){
+ // if( 12 A )
+ // return -1;
+ // int v;
+ // }
+ public void testProblemInIfExpression_Bug100321() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTIfStatement ifstmt = getStatement(fdef, 0);
+ assertInstance(ifstmt.getConditionExpression(), IASTProblemExpression.class);
+ assertEquals("12 A", ifstmt.getConditionExpression().getRawSignature());
+ assertInstance(ifstmt.getThenClause(), IASTReturnStatement.class);
+ }
+ }
+
+ // _MYMACRO_ myType foo();
+ // _MYMACRO_ myType foo() {}
+ // extern void foo2() _MYMACRO_;
+ public void testUndefinedMacrosInFunctionDeclarations_Bug234085() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTProblemDeclaration pd = getDeclaration(tu, 0);
+ assertEquals("_MYMACRO_", pd.getRawSignature());
+ IASTSimpleDeclaration sdecl = getDeclaration(tu, 1);
+ assertEquals("myType foo();", sdecl.getRawSignature());
+
+ pd = getDeclaration(tu, 2);
+ assertEquals("_MYMACRO_", pd.getRawSignature());
+ IASTFunctionDefinition fdef = getDeclaration(tu, 3);
+ assertEquals("myType foo() {}", fdef.getRawSignature());
+
+ sdecl = getDeclaration(tu, 4);
+ assertEquals("extern void foo2()", sdecl.getRawSignature());
+ pd = getDeclaration(tu, 5); // the missing semicolon
+
+ if (lang == ParserLanguage.CPP) {
+ pd = getDeclaration(tu, 6);
+ assertEquals("_MYMACRO_;", pd.getRawSignature());
+ } else {
+ sdecl = getDeclaration(tu, 6);
+ assertEquals("_MYMACRO_;", sdecl.getRawSignature());
+ }
+ }
+ }
+
+ // enum _T { I J, K }; // missing comma
+ // int i;
+ public void testEnumProblem() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTSimpleDeclaration e = getDeclaration(tu, 0);
+ IASTProblemDeclaration p = getDeclaration(tu, 1);
+ assertEquals("J, K };", p.getRawSignature());
+ IASTSimpleDeclaration s = getDeclaration(tu, 2);
+ assertEquals("int i;", s.getRawSignature());
+ }
+ }
+
+ // class A {
+ // enum _T { I J, K }; // missing comma
+ // int i;
+ // };
+ public void testEnumError_Bug72685() throws Exception {
+ final String comment = getAboveComment();
+ IASTTranslationUnit tu = parse(comment, ParserLanguage.CPP, false, false);
+ IASTCompositeTypeSpecifier ct = getCompositeType(tu, 0);
+ IASTSimpleDeclaration e = getDeclaration(ct, 0);
+ IASTProblemDeclaration p = getDeclaration(ct, 1);
+ assertEquals("J, K };", p.getRawSignature());
+ IASTSimpleDeclaration s = getDeclaration(ct, 2);
+ assertEquals("int i;", s.getRawSignature());
+ }
- // class A {
- // enum _T { I J, K }; // missing comma
- // int i;
- // };
- public void testEnumError_Bug72685() throws Exception {
- final String comment= getAboveComment();
- IASTTranslationUnit tu= parse(comment, ParserLanguage.CPP, false, false);
- IASTCompositeTypeSpecifier ct= getCompositeType(tu, 0);
- IASTSimpleDeclaration e= getDeclaration(ct, 0);
- IASTProblemDeclaration p= getDeclaration(ct, 1);
- assertEquals("J, K };", p.getRawSignature());
- IASTSimpleDeclaration s= getDeclaration(ct, 2);
- assertEquals("int i;", s.getRawSignature());
- }
-
-
// #define XX() .
// int c;
// XX(
// );
// int d;
public void testErrorRecovery_273759() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.C, false, false);
- IASTSimpleDeclaration s= getDeclaration(tu, 0);
- IASTProblemDeclaration p= getDeclaration(tu, 1);
- s= getDeclaration(tu, 2);
-
- tu= parse(getAboveComment(), ParserLanguage.CPP, false, false);
- s= getDeclaration(tu, 0);
- p= getDeclaration(tu, 1);
- s= getDeclaration(tu, 2);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, false, false);
+ IASTSimpleDeclaration s = getDeclaration(tu, 0);
+ IASTProblemDeclaration p = getDeclaration(tu, 1);
+ s = getDeclaration(tu, 2);
+
+ tu = parse(getAboveComment(), ParserLanguage.CPP, false, false);
+ s = getDeclaration(tu, 0);
+ p = getDeclaration(tu, 1);
+ s = getDeclaration(tu, 2);
}
-
+
// TINT* f(TINT* p) {
// TINT* f1(TINT* p) {
// TINT* f2(TINT* p) {
@@ -314,8 +312,8 @@ public class FaultToleranceTests extends AST2TestBase {
// TINT* f29(TINT* p) {
// }
public void testPerformanceIssue_364108() throws Exception {
- final String comment= getAboveComment();
- parse(comment, ParserLanguage.CPP, false, false);
- parse(comment, ParserLanguage.C, false, false);
+ final String comment = getAboveComment();
+ parse(comment, ParserLanguage.CPP, false, false);
+ parse(comment, ParserLanguage.C, false, 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 4da8b229797..531cb5bd75f 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
@@ -49,7 +49,7 @@ public class GCCCompleteParseExtensionsTest extends AST2TestBase {
CNameResolver resolver = new CNameResolver();
tu.accept(resolver);
if (resolver.numProblemBindings > 0)
- throw new ParserException(" there are " + resolver.numProblemBindings + " ProblemBindings on the tu"); //$NON-NLS-2$
+ throw new ParserException(" there are " + resolver.numProblemBindings + " ProblemBindings on the tu"); //$NON-NLS-2$
if (resolver.numNullBindings > 0)
throw new ParserException("Expected no null bindings, encountered " + resolver.numNullBindings);
return tu;
@@ -61,43 +61,49 @@ public class GCCCompleteParseExtensionsTest extends AST2TestBase {
CPPNameResolver resolver = new CPPNameResolver();
tu.accept(resolver);
if (resolver.numProblemBindings > 0)
- throw new ParserException(" there are " + resolver.numProblemBindings + " ProblemBindings on the tu"); //$NON-NLS-2$
+ throw new ParserException(" there are " + resolver.numProblemBindings + " ProblemBindings on the tu"); //$NON-NLS-2$
if (resolver.numNullBindings > 0)
throw new ParserException("Expected no null bindings, encountered " + resolver.numNullBindings);
return tu;
}
- public void testBug39695() throws Exception {
- parseGCC("int a = __alignof__ (int);").getDeclarations();
- }
+ public void testBug39695() throws Exception {
+ parseGCC("int a = __alignof__ (int);").getDeclarations();
+ }
- public void testBug39684() throws Exception {
- IASTDeclaration bar = parseGCC("typeof(foo(1)) bar () { return foo(1); }").getDeclarations()[0];
+ public void testBug39684() throws Exception {
+ IASTDeclaration bar = parseGCC("typeof(foo(1)) bar () { return foo(1); }").getDeclarations()[0];
assertTrue(bar instanceof CASTFunctionDefinition);
- CFunction barFunc = (CFunction)((CASTFunctionDefinition)bar).getDeclarator().getName().resolveBinding();
+ CFunction barFunc = (CFunction) ((CASTFunctionDefinition) bar).getDeclarator().getName().resolveBinding();
IFunctionType type = barFunc.getType();
- // TODO Devin typeof declSpec has 0 length, also doesn't seem to have a type for typeof... raise a bug
-// IASTSimpleTypeSpecifier simpleTypeSpec = ((IASTSimpleTypeSpecifier)bar.getReturnType().getTypeSpecifier());
-// assertEquals(simpleTypeSpec.getType(), IASTGCCSimpleTypeSpecifier.Type.TYPEOF);
- }
+ // TODO Devin typeof declSpec has 0 length, also doesn't seem to have a type for typeof... raise a bug
+ // IASTSimpleTypeSpecifier simpleTypeSpec = ((IASTSimpleTypeSpecifier)bar.getReturnType().getTypeSpecifier());
+ // assertEquals(simpleTypeSpec.getType(), IASTGCCSimpleTypeSpecifier.Type.TYPEOF);
+ }
- public void testBug39698A() throws Exception {
- IASTDeclaration[] decls = parseGPP("int a=0; \n int b=1; \n int c = a <? b;").getDeclarations();
- assertEquals(ASTStringUtil.getExpressionString((IASTExpression) ((IASTEqualsInitializer)((IASTSimpleDeclaration)decls[2]).getDeclarators()[0].getInitializer()).getInitializerClause()), "a <? b");
- }
+ public void testBug39698A() throws Exception {
+ IASTDeclaration[] decls = parseGPP("int a=0; \n int b=1; \n int c = a <? b;").getDeclarations();
+ assertEquals(ASTStringUtil.getExpressionString(
+ (IASTExpression) ((IASTEqualsInitializer) ((IASTSimpleDeclaration) decls[2]).getDeclarators()[0]
+ .getInitializer()).getInitializerClause()),
+ "a <? b");
+ }
- public void testBug39698B() throws Exception {
- IASTDeclaration[] decls = parseGPP("int a=0; \n int b=1; \n int c = a >? b;").getDeclarations();
- assertEquals(ASTStringUtil.getExpressionString((IASTExpression) ((IASTEqualsInitializer)((IASTSimpleDeclaration)decls[2]).getDeclarators()[0].getInitializer()).getInitializerClause()), "a >? b");
- }
+ public void testBug39698B() throws Exception {
+ IASTDeclaration[] decls = parseGPP("int a=0; \n int b=1; \n int c = a >? b;").getDeclarations();
+ assertEquals(ASTStringUtil.getExpressionString(
+ (IASTExpression) ((IASTEqualsInitializer) ((IASTSimpleDeclaration) decls[2]).getDeclarators()[0]
+ .getInitializer()).getInitializerClause()),
+ "a >? b");
+ }
public void testPredefinedSymbol_bug69791() throws Exception {
parseGPP("typedef __builtin_va_list __gnuc_va_list; \n").getDeclarations();
parseGCC("typedef __builtin_va_list __gnuc_va_list; \n").getDeclarations();
}
- public void testBug39697() throws Exception {
+ public void testBug39697() throws Exception {
Writer writer = new StringWriter();
writer.write("__asm__( \"CODE\" );\n");
writer.write("__inline__ int foo() { return 4; }\n");
@@ -106,29 +112,33 @@ public class GCCCompleteParseExtensionsTest extends AST2TestBase {
writer.write("__signed__ int signedInt;\n");
IASTDeclaration[] decls = parseGCC(writer.toString()).getDeclarations();
- assertEquals(((IASTASMDeclaration)decls[0]).getAssembly(), "\"CODE\"");
- assertTrue(((IASTFunctionDefinition)decls[1]).getDeclSpecifier().isInline());
- assertTrue(((IASTSimpleDeclaration)decls[2]).getDeclSpecifier().isConst());
- assertTrue(((IASTSimpleDeclaration)decls[3]).getDeclSpecifier().isVolatile());
- assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[4]).getDeclSpecifier()).isSigned());
-
- writer = new StringWriter();
- writer.write("int * __restrict__ resPointer1;\n");
- writer.write("int * __restrict resPointer2;\n");
- decls = parseGCC(writer.toString()).getDeclarations();
- assertTrue(((ICASTPointer)((IASTSimpleDeclaration)decls[0]).getDeclarators()[0].getPointerOperators()[0]).isRestrict());
- assertTrue(((ICASTPointer)((IASTSimpleDeclaration)decls[1]).getDeclarators()[0].getPointerOperators()[0]).isRestrict());
-
- writer = new StringWriter();
- writer.write("int * __restrict__ resPointer1;\n");
- writer.write("int * __restrict resPointer2;\n");
- decls = parseGPP(writer.toString()).getDeclarations();
- assertTrue(((IASTPointer)((IASTSimpleDeclaration)decls[0]).getDeclarators()[0].getPointerOperators()[0]).isRestrict());
- assertTrue(((IASTPointer)((IASTSimpleDeclaration)decls[1]).getDeclarators()[0].getPointerOperators()[0]).isRestrict());
+ assertEquals(((IASTASMDeclaration) decls[0]).getAssembly(), "\"CODE\"");
+ assertTrue(((IASTFunctionDefinition) decls[1]).getDeclSpecifier().isInline());
+ assertTrue(((IASTSimpleDeclaration) decls[2]).getDeclSpecifier().isConst());
+ assertTrue(((IASTSimpleDeclaration) decls[3]).getDeclSpecifier().isVolatile());
+ assertTrue(((ICASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[4]).getDeclSpecifier()).isSigned());
+
+ writer = new StringWriter();
+ writer.write("int * __restrict__ resPointer1;\n");
+ writer.write("int * __restrict resPointer2;\n");
+ decls = parseGCC(writer.toString()).getDeclarations();
+ assertTrue(((ICASTPointer) ((IASTSimpleDeclaration) decls[0]).getDeclarators()[0].getPointerOperators()[0])
+ .isRestrict());
+ assertTrue(((ICASTPointer) ((IASTSimpleDeclaration) decls[1]).getDeclarators()[0].getPointerOperators()[0])
+ .isRestrict());
+
+ writer = new StringWriter();
+ writer.write("int * __restrict__ resPointer1;\n");
+ writer.write("int * __restrict resPointer2;\n");
+ decls = parseGPP(writer.toString()).getDeclarations();
+ assertTrue(((IASTPointer) ((IASTSimpleDeclaration) decls[0]).getDeclarators()[0].getPointerOperators()[0])
+ .isRestrict());
+ assertTrue(((IASTPointer) ((IASTSimpleDeclaration) decls[1]).getDeclarators()[0].getPointerOperators()[0])
+ .isRestrict());
}
public void testBug73954A() throws Exception {
- StringWriter writer = new StringWriter();
+ StringWriter writer = new StringWriter();
writer.write("void f(){ \n");
writer.write(" __builtin_expect( 23, 2); \n");
writer.write(" __builtin_prefetch( (const void *)0, 1, 2); \n");
@@ -164,212 +174,212 @@ public class GCCCompleteParseExtensionsTest extends AST2TestBase {
writer.write(" __builtin_powil (0, 0); \n");
writer.write("} \n");
- parseGCC(writer.toString());
+ parseGCC(writer.toString());
}
- public void testBug39686() throws Exception {
- Writer code = new StringWriter();
- code.write("__complex__ double x; // complex double\n");
- code.write("__complex__ short int a; // complex short int\n");
- code.write("__complex__ float y = 2.5fi; // 2.5 imaginary float literal\n");
- code.write("__complex__ int z = 3i; // imaginary intege r literal\n");
- code.write("double v = __real__ x; // real part of expression\n");
- code.write("double w = __imag__ x; // imaginary part of expression\n");
- parseGCC(code.toString());
- }
+ public void testBug39686() throws Exception {
+ Writer code = new StringWriter();
+ code.write("__complex__ double x; // complex double\n");
+ code.write("__complex__ short int a; // complex short int\n");
+ code.write("__complex__ float y = 2.5fi; // 2.5 imaginary float literal\n");
+ code.write("__complex__ int z = 3i; // imaginary intege r literal\n");
+ code.write("double v = __real__ x; // real part of expression\n");
+ code.write("double w = __imag__ x; // imaginary part of expression\n");
+ parseGCC(code.toString());
+ }
public void testBug39551B() throws Exception {
- //this used to be 99.99 * __I__, but I don't know where the __I__ came from, its not in C99, nor in GCC
+ //this used to be 99.99 * __I__, but I don't know where the __I__ came from, its not in C99, nor in GCC
IASTDeclaration decl = parseGCC("_Imaginary double id = 99.99 * 1i;").getDeclarations()[0];
// TODO Devin does ICPPASTSimpleDeclSpecifier need something for isImaginary ?
// assertEquals(variable.getName(), "id");
-// assertTrue(((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).isImaginary());
+ // assertTrue(((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).isImaginary());
+ }
+
+ public void testBug39681() throws Exception {
+ Writer code = new StringWriter();
+ code.write("double\n");
+ code.write("foo (double a, double b)\n");
+ code.write("{\n");
+ code.write(" double square (double z) { return z * z; }\n");
+ code.write(" return square (a) + square (b);\n");
+ code.write("}\n");
+ parseGCC(code.toString());
}
- public void testBug39681() throws Exception {
- Writer code = new StringWriter();
- code.write("double\n");
- code.write("foo (double a, double b)\n");
- code.write("{\n");
- code.write(" double square (double z) { return z * z; }\n");
- code.write(" return square (a) + square (b);\n");
- code.write("}\n");
- parseGCC(code.toString());
- }
-
- public void testBug39677() throws Exception {
+ public void testBug39677() throws Exception {
parseGPP("class B { public: B(); int a;}; B::B() : a(({ 1; })) {}");
- Writer writer = new StringWriter();
- writer.write("int foo(); class B { public: B(); int a;};");
- writer.write("B::B() : a(( { int y = foo (); int z;\n");
- writer.write("if (y > 0) z = y;\n");
- writer.write("else z = - y;\n");
- writer.write("z; })) {}\n");
+ Writer writer = new StringWriter();
+ writer.write("int foo(); class B { public: B(); int a;};");
+ writer.write("B::B() : a(( { int y = foo (); int z;\n");
+ writer.write("if (y > 0) z = y;\n");
+ writer.write("else z = - y;\n");
+ writer.write("z; })) {}\n");
parseGPP(writer.toString());
- writer = new StringWriter();
- writer.write("int x = ({ int foo(); int y = foo (); int z;\n");
- writer.write("if (y > 0) z = y;\n");
- writer.write("else z = - y;\n");
- writer.write("z; });\n");
+ writer = new StringWriter();
+ writer.write("int x = ({ int foo(); int y = foo (); int z;\n");
+ writer.write("if (y > 0) z = y;\n");
+ writer.write("else z = - y;\n");
+ writer.write("z; });\n");
parseGPP(writer.toString());
- writer = new StringWriter();
- writer.write("int foo(); \n");
- writer.write("typeof({ int y = foo (); \n");
- writer.write(" int z; \n");
- writer.write(" if (y > 0) z = y; \n");
- writer.write(" else z = - y; \n");
- writer.write(" z; \n");
- writer.write(" }) zoot; \n");
-
- parseGPP(writer.toString()); // TODO Devin raised bug 93980
- }
-
- public void testBug75401() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#define va_list __builtin_va_list \n");
- writer.write("#define va_arg(v,l) __builtin_va_arg(v,l) \n");
- writer.write("#define va_start(v,l) __builtin_va_start(v,l) \n");
- writer.write("#define va_end(v) __builtin_va_end(v) \n");
- writer.write("void variadic(int first, ...) { \n");
- writer.write(" va_list v; \n");
- writer.write(" va_start(v, first); \n");
- writer.write(" long l = va_arg(v, long); \n");
- writer.write(" va_end(v); \n");
- writer.write("} \n");
-
- parseGCC(writer.toString());
- parseGPP(writer.toString());
- }
-
- public void testBug73954B() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#define foo(x) \\\n");
- writer.write(" __builtin_choose_expr( 1, foo_d(x), (void)0 ) \n");
- writer.write("int foo_d( int x ); \n");
- writer.write("int main() { \n");
- writer.write(" if( __builtin_constant_p(1) && \n");
- writer.write(" __builtin_types_compatible_p( 1, 'c') ) \n");
- writer.write(" foo(1); \n");
- writer.write("} \n");
-
- parseGCC(writer.toString());
- }
+ writer = new StringWriter();
+ writer.write("int foo(); \n");
+ writer.write("typeof({ int y = foo (); \n");
+ writer.write(" int z; \n");
+ writer.write(" if (y > 0) z = y; \n");
+ writer.write(" else z = - y; \n");
+ writer.write(" z; \n");
+ writer.write(" }) zoot; \n");
+
+ parseGPP(writer.toString()); // TODO Devin raised bug 93980
+ }
+
+ public void testBug75401() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#define va_list __builtin_va_list \n");
+ writer.write("#define va_arg(v,l) __builtin_va_arg(v,l) \n");
+ writer.write("#define va_start(v,l) __builtin_va_start(v,l) \n");
+ writer.write("#define va_end(v) __builtin_va_end(v) \n");
+ writer.write("void variadic(int first, ...) { \n");
+ writer.write(" va_list v; \n");
+ writer.write(" va_start(v, first); \n");
+ writer.write(" long l = va_arg(v, long); \n");
+ writer.write(" va_end(v); \n");
+ writer.write("} \n");
+
+ parseGCC(writer.toString());
+ parseGPP(writer.toString());
+ }
+
+ public void testBug73954B() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#define foo(x) \\\n");
+ writer.write(" __builtin_choose_expr( 1, foo_d(x), (void)0 ) \n");
+ writer.write("int foo_d( int x ); \n");
+ writer.write("int main() { \n");
+ writer.write(" if( __builtin_constant_p(1) && \n");
+ writer.write(" __builtin_types_compatible_p( 1, 'c') ) \n");
+ writer.write(" foo(1); \n");
+ writer.write("} \n");
+
+ parseGCC(writer.toString());
+ }
public void testGNUExternalTemplate_bug71603() throws Exception {
parseGPP("template <typename T> \n class A {}; \n extern template class A<int>; \n").getDeclarations();
}
public void testBug74190_g_assert_1() throws Exception {
- Writer writer = new StringWriter();
- writer.write("void log( int ); \n");
- writer.write("void f() { \n");
- writer.write(" int a = 1; \n");
- writer.write(" (void)({ if( a ){ } \n");
- writer.write(" else{ log( a ); } \n");
- writer.write(" }); \n");
- writer.write("} \n");
-
- parseGCC(writer.toString());
- parseGPP(writer.toString());
+ Writer writer = new StringWriter();
+ writer.write("void log( int ); \n");
+ writer.write("void f() { \n");
+ writer.write(" int a = 1; \n");
+ writer.write(" (void)({ if( a ){ } \n");
+ writer.write(" else{ log( a ); } \n");
+ writer.write(" }); \n");
+ writer.write("} \n");
+
+ parseGCC(writer.toString());
+ parseGPP(writer.toString());
}
public void testBug74190_g_return_if_fail() throws Exception {
- Writer writer = new StringWriter();
- writer.write("void f() { \n");
- writer.write(" (void)({ if( ( ({ 0; }) ) ) \n");
- writer.write(" { } \n");
- writer.write(" }); \n");
- writer.write("} \n");
-
- parseGCC(writer.toString());
- parseGPP(writer.toString());
+ Writer writer = new StringWriter();
+ writer.write("void f() { \n");
+ writer.write(" (void)({ if( ( ({ 0; }) ) ) \n");
+ writer.write(" { } \n");
+ writer.write(" }); \n");
+ writer.write("} \n");
+
+ parseGCC(writer.toString());
+ parseGPP(writer.toString());
}
- public void testBug95635() throws Exception{
- StringWriter writer = new StringWriter();
- writer.write("void f(){ \n");
- writer.write(" char a[10]; \n");
- writer.write(" __builtin_va_list b; \n");
- writer.write(" __builtin_abort(); \n");
- writer.write(" __builtin_exit(1); \n");
- writer.write(" __builtin__Exit(1); \n");
- writer.write(" __builtin__exit(1); \n");
- writer.write(" __builtin_conj(1); \n");
- writer.write(" __builtin_conjf(1); \n");
- writer.write(" __builtin_conjl(1); \n");
- writer.write(" __builtin_creal(1); \n");
- writer.write(" __builtin_crealf(1); \n");
- writer.write(" __builtin_creall(1); \n");
- writer.write(" __builtin_cimag(1); \n");
- writer.write(" __builtin_cimagf(1); \n");
- writer.write(" __builtin_cimagl(1); \n");
- writer.write(" __builtin_imaxabs(1); \n");
- writer.write(" __builtin_llabs(1); \n");
- writer.write(" __builtin_vscanf(\"\",b);\n");
- writer.write(" __builtin_vsnprintf(a, 1, \"\", b); \n");
- writer.write(" __builtin_vsscanf(\"\", \"\", b);\n");
- writer.write(" __builtin_cosf(1); \n");
- writer.write(" __builtin_cosl(1); \n");
- writer.write(" __builtin_expf(1); \n");
- writer.write(" __builtin_expl(1); \n");
- writer.write(" __builtin_fabsf(1); \n");
- writer.write(" __builtin_fabsl(1); \n");
- writer.write(" __builtin_logf(1); \n");
- writer.write(" __builtin_logl(1); \n");
- writer.write(" __builtin_sinf(1); \n");
- writer.write(" __builtin_sinl(1); \n");
- writer.write(" __builtin_sqrtf(1); \n");
- writer.write(" __builtin_sqrtl(1); \n");
- writer.write(" __builtin_abs(1); \n");
- writer.write(" __builtin_cos(1); \n");
- writer.write(" __builtin_exp(1); \n");
- writer.write(" __builtin_fabs(1); \n");
- writer.write(" __builtin_fprintf((void*)0, \"\");\n");
- writer.write(" __builtin_fputs(\"\", (void*)0);\n");
- writer.write(" __builtin_labs(1); \n");
- writer.write(" __builtin_log(1); \n");
- writer.write(" __builtin_memcmp((void*)0, (void*)0, 1);\n");
- writer.write(" __builtin_memcpy((void*)0,(void*)0, 1);\n");
- writer.write(" __builtin_memset((void*)0, 1, 1);\n");
- writer.write(" __builtin_printf(\"\"); \n");
- writer.write(" __builtin_putchar(1); \n");
- writer.write(" __builtin_puts(\"\"); \n");
- writer.write(" __builtin_scanf(\"\"); \n");
- writer.write(" __builtin_sin(1); \n");
- writer.write(" __builtin_snprintf(a, 1, \"\");\n");
- writer.write(" __builtin_sprintf(a, \"\");\n");
- writer.write(" __builtin_sqrt(1); \n");
- writer.write(" __builtin_sscanf(\"\", \"\"); \n");
- writer.write(" __builtin_strcat(a, \"\"); \n");
- writer.write(" __builtin_strchr(\"\", 1); \n");
- writer.write(" __builtin_strcmp(\"\", \"\"); \n");
- writer.write(" __builtin_strcpy(a, \"\"); \n");
- writer.write(" __builtin_strcspn(\"\", \"\");\n");
- writer.write(" __builtin_strlen(\"\"); \n");
- writer.write(" __builtin_strncat(a, \"\", 1);\n");
- writer.write(" __builtin_strncmp(\"\", \"\", 1);\n");
- writer.write(" __builtin_strncpy(a, \"\", 1);\n");
- writer.write(" __builtin_strpbrk(\"\", \"\");\n");
- writer.write(" __builtin_strrchr(\"\", 1); \n");
- writer.write(" __builtin_strspn(\"\", \"\"); \n");
- writer.write(" __builtin_strstr(\"\", \"\"); \n");
- writer.write(" __builtin_strstr(\"\", \"\"); \n");
- writer.write(" __builtin_vprintf(a, b);\n");
- writer.write(" __builtin_vsprintf(a, \"\", b); \n");
- writer.write(" __builtin_isgreater(1.0,1.0); \n");
- writer.write(" __builtin_isgreaterequal(1.0,1.0);\n");
- writer.write(" __builtin_isless(1.0,1.0); \n");
- writer.write(" __builtin_islessequal(1.0,1.0); \n");
- writer.write(" __builtin_islessgreater(1.0,1.0); \n");
- writer.write(" __builtin_isunordered(1.0,1.0); \n");
- writer.write("} \n");
-
- final String code = writer.toString();
+ public void testBug95635() throws Exception {
+ StringWriter writer = new StringWriter();
+ writer.write("void f(){ \n");
+ writer.write(" char a[10]; \n");
+ writer.write(" __builtin_va_list b; \n");
+ writer.write(" __builtin_abort(); \n");
+ writer.write(" __builtin_exit(1); \n");
+ writer.write(" __builtin__Exit(1); \n");
+ writer.write(" __builtin__exit(1); \n");
+ writer.write(" __builtin_conj(1); \n");
+ writer.write(" __builtin_conjf(1); \n");
+ writer.write(" __builtin_conjl(1); \n");
+ writer.write(" __builtin_creal(1); \n");
+ writer.write(" __builtin_crealf(1); \n");
+ writer.write(" __builtin_creall(1); \n");
+ writer.write(" __builtin_cimag(1); \n");
+ writer.write(" __builtin_cimagf(1); \n");
+ writer.write(" __builtin_cimagl(1); \n");
+ writer.write(" __builtin_imaxabs(1); \n");
+ writer.write(" __builtin_llabs(1); \n");
+ writer.write(" __builtin_vscanf(\"\",b);\n");
+ writer.write(" __builtin_vsnprintf(a, 1, \"\", b); \n");
+ writer.write(" __builtin_vsscanf(\"\", \"\", b);\n");
+ writer.write(" __builtin_cosf(1); \n");
+ writer.write(" __builtin_cosl(1); \n");
+ writer.write(" __builtin_expf(1); \n");
+ writer.write(" __builtin_expl(1); \n");
+ writer.write(" __builtin_fabsf(1); \n");
+ writer.write(" __builtin_fabsl(1); \n");
+ writer.write(" __builtin_logf(1); \n");
+ writer.write(" __builtin_logl(1); \n");
+ writer.write(" __builtin_sinf(1); \n");
+ writer.write(" __builtin_sinl(1); \n");
+ writer.write(" __builtin_sqrtf(1); \n");
+ writer.write(" __builtin_sqrtl(1); \n");
+ writer.write(" __builtin_abs(1); \n");
+ writer.write(" __builtin_cos(1); \n");
+ writer.write(" __builtin_exp(1); \n");
+ writer.write(" __builtin_fabs(1); \n");
+ writer.write(" __builtin_fprintf((void*)0, \"\");\n");
+ writer.write(" __builtin_fputs(\"\", (void*)0);\n");
+ writer.write(" __builtin_labs(1); \n");
+ writer.write(" __builtin_log(1); \n");
+ writer.write(" __builtin_memcmp((void*)0, (void*)0, 1);\n");
+ writer.write(" __builtin_memcpy((void*)0,(void*)0, 1);\n");
+ writer.write(" __builtin_memset((void*)0, 1, 1);\n");
+ writer.write(" __builtin_printf(\"\"); \n");
+ writer.write(" __builtin_putchar(1); \n");
+ writer.write(" __builtin_puts(\"\"); \n");
+ writer.write(" __builtin_scanf(\"\"); \n");
+ writer.write(" __builtin_sin(1); \n");
+ writer.write(" __builtin_snprintf(a, 1, \"\");\n");
+ writer.write(" __builtin_sprintf(a, \"\");\n");
+ writer.write(" __builtin_sqrt(1); \n");
+ writer.write(" __builtin_sscanf(\"\", \"\"); \n");
+ writer.write(" __builtin_strcat(a, \"\"); \n");
+ writer.write(" __builtin_strchr(\"\", 1); \n");
+ writer.write(" __builtin_strcmp(\"\", \"\"); \n");
+ writer.write(" __builtin_strcpy(a, \"\"); \n");
+ writer.write(" __builtin_strcspn(\"\", \"\");\n");
+ writer.write(" __builtin_strlen(\"\"); \n");
+ writer.write(" __builtin_strncat(a, \"\", 1);\n");
+ writer.write(" __builtin_strncmp(\"\", \"\", 1);\n");
+ writer.write(" __builtin_strncpy(a, \"\", 1);\n");
+ writer.write(" __builtin_strpbrk(\"\", \"\");\n");
+ writer.write(" __builtin_strrchr(\"\", 1); \n");
+ writer.write(" __builtin_strspn(\"\", \"\"); \n");
+ writer.write(" __builtin_strstr(\"\", \"\"); \n");
+ writer.write(" __builtin_strstr(\"\", \"\"); \n");
+ writer.write(" __builtin_vprintf(a, b);\n");
+ writer.write(" __builtin_vsprintf(a, \"\", b); \n");
+ writer.write(" __builtin_isgreater(1.0,1.0); \n");
+ writer.write(" __builtin_isgreaterequal(1.0,1.0);\n");
+ writer.write(" __builtin_isless(1.0,1.0); \n");
+ writer.write(" __builtin_islessequal(1.0,1.0); \n");
+ writer.write(" __builtin_islessgreater(1.0,1.0); \n");
+ writer.write(" __builtin_isunordered(1.0,1.0); \n");
+ writer.write("} \n");
+
+ final String code = writer.toString();
parseGCC(code);
- parseGPP(code);
- }
+ parseGPP(code);
+ }
// typedef int size_t; // will be defined in <stddef.h>
// struct S {int m;};
@@ -380,7 +390,7 @@ public class GCCCompleteParseExtensionsTest extends AST2TestBase {
// gcc with __GNUC__ >= 4 defines:
// #define offsetof(type, field) __builtin_offsetof(type, field)
- String code= getAboveComment();
+ String code = getAboveComment();
parseGCC(code);
parseGPP(code);
}
@@ -424,35 +434,35 @@ public class GCCCompleteParseExtensionsTest extends AST2TestBase {
// __int128 a;
// unsigned __int128 b;
public void test__int128() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseGCC(code);
parseGPP(code);
}
// __float128 f;
public void test__float128() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseGCC(code);
parseGPP(code);
}
-
+
// _Decimal32 x;
public void test_Decimal32() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseGCC(code);
parseGPP(code);
}
// _Decimal64 x;
public void test_Decimal64() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseGCC(code);
parseGPP(code);
}
// _Decimal128 x;
public void test_Decimal128() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseGCC(code);
parseGPP(code);
}
@@ -460,7 +470,7 @@ public class GCCCompleteParseExtensionsTest extends AST2TestBase {
// struct waldo {
// } __attribute__((__aligned__((1))));
public void test__attribute__aligned_bug400204() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseGCC(code);
parseGPP(code);
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCTests.java
index 6f57514f2e6..08a5881f029 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCTests.java
@@ -34,7 +34,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
*/
public class GCCTests extends AST2TestBase {
- public GCCTests() {
+ public GCCTests() {
}
public GCCTests(String name) {
@@ -42,148 +42,148 @@ public class GCCTests extends AST2TestBase {
}
public void testGCC20000113() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("struct x { \n");
- buffer.append(" unsigned x1:1; \n");
- buffer.append(" unsigned x2:2; \n");
- buffer.append(" unsigned x3:3; \n");
- buffer.append("}; \n");
- buffer.append("foobar(int x, int y, int z) { \n");
- buffer.append(" struct x a = {x, y, z}; \n");
- buffer.append(" struct x b = {x, y, z}; \n");
- buffer.append(" struct x *c = &b; \n");
- buffer.append(" c->x3 += (a.x2 - a.x1) * c->x2; \n");
- buffer.append(" if (a.x1 != 1 || c->x3 != 5) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
-
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 33);
- ICompositeType x = (ICompositeType) collector.getName(0).resolveBinding();
- IField x1 = (IField) collector.getName(1).resolveBinding();
- IField x2 = (IField) collector.getName(2).resolveBinding();
- IField x3 = (IField) collector.getName(3).resolveBinding();
- IVariable vx = (IVariable) collector.getName(5).resolveBinding();
- IVariable vy = (IVariable) collector.getName(6).resolveBinding();
- IVariable vz = (IVariable) collector.getName(7).resolveBinding();
- IVariable a = (IVariable) collector.getName(9).resolveBinding();
- IVariable b = (IVariable) collector.getName(14).resolveBinding();
- IVariable c = (IVariable) collector.getName(19).resolveBinding();
-
- assertInstances(collector, x, 4);
- assertInstances(collector, x1, 3);
- assertInstances(collector, x2, 3);
- assertInstances(collector, x3, 3);
- assertInstances(collector, vx, 3);
- assertInstances(collector, vy, 3);
- assertInstances(collector, vz, 3);
- assertInstances(collector, a, 4);
- assertInstances(collector, b, 2);
- assertInstances(collector, c, 4);
- }
-
- public void testGCC20000205() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("static int f(int a) { \n");
- buffer.append(" if (a == 0) \n");
- buffer.append(" return 0; \n");
- buffer.append(" do \n");
- buffer.append(" if (a & 128) \n");
- buffer.append(" return 1; \n");
- buffer.append(" while (f(0)); \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
-
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 5);
- IFunction f = (IFunction) collector.getName(0).resolveBinding();
- IVariable a = (IVariable) collector.getName(1).resolveBinding();
-
- assertInstances(collector, f, 2);
- assertInstances(collector, a, 3);
- }
-
- public void testGCC20000217() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("unsigned short int showbug(unsigned short int * a, \n");
- buffer.append(" unsigned short int * b) { \n");
- buffer.append(" *a += *b - 8; \n");
- buffer.append(" return (*a >= 8); \n");
- buffer.append("} \n");
- buffer.append("int main() { \n");
- buffer.append(" unsigned short int x = 0; \n");
- buffer.append(" unsigned short int y = 10; \n");
- buffer.append(" if (showbug(&x, &y) != 0) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 12);
-
- IFunction showBug = (IFunction) collector.getName(0).resolveBinding();
- IVariable a = (IVariable) collector.getName(1).resolveBinding();
- IVariable b = (IVariable) collector.getName(2).resolveBinding();
- IVariable x = (IVariable) collector.getName(7).resolveBinding();
- IVariable y = (IVariable) collector.getName(8).resolveBinding();
-
- assertInstances(collector, showBug, 2);
- assertInstances(collector, a, 3);
- assertInstances(collector, b, 2);
- assertInstances(collector, x, 2);
- assertInstances(collector, y, 2);
- }
-
- public void testGCC20000224() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("int loop_1 = 100; \n");
- buffer.append("int loop_2 = 7; \n");
- buffer.append("int flag = 0; \n");
- buffer.append("int test(void) { \n");
- buffer.append(" int i; \n");
- buffer.append(" int counter = 0; \n");
- buffer.append(" while (loop_1 > counter) { \n");
- buffer.append(" if (flag & 1) { \n");
- buffer.append(" for (i = 0; i < loop_2; i++) { \n");
- buffer.append(" counter++; \n");
- buffer.append(" } \n");
- buffer.append(" } \n");
- buffer.append(" flag++; \n");
- buffer.append(" } \n");
- buffer.append(" return 1; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 16);
- IVariable loop1 = (IVariable) collector.getName(0).resolveBinding();
- IVariable loop2 = (IVariable) collector.getName(1).resolveBinding();
- IVariable flag = (IVariable) collector.getName(2).resolveBinding();
- IVariable i = (IVariable) collector.getName(5).resolveBinding();
- IVariable counter = (IVariable) collector.getName(6).resolveBinding();
-
- assertInstances(collector, loop1, 2);
- assertInstances(collector, loop2, 2);
- assertInstances(collector, flag, 3);
- assertInstances(collector, i, 4);
- assertInstances(collector, counter, 3);
- }
-
- public void testGCC20000225() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("struct x { \n");
+ buffer.append(" unsigned x1:1; \n");
+ buffer.append(" unsigned x2:2; \n");
+ buffer.append(" unsigned x3:3; \n");
+ buffer.append("}; \n");
+ buffer.append("foobar(int x, int y, int z) { \n");
+ buffer.append(" struct x a = {x, y, z}; \n");
+ buffer.append(" struct x b = {x, y, z}; \n");
+ buffer.append(" struct x *c = &b; \n");
+ buffer.append(" c->x3 += (a.x2 - a.x1) * c->x2; \n");
+ buffer.append(" if (a.x1 != 1 || c->x3 != 5) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 33);
+ ICompositeType x = (ICompositeType) collector.getName(0).resolveBinding();
+ IField x1 = (IField) collector.getName(1).resolveBinding();
+ IField x2 = (IField) collector.getName(2).resolveBinding();
+ IField x3 = (IField) collector.getName(3).resolveBinding();
+ IVariable vx = (IVariable) collector.getName(5).resolveBinding();
+ IVariable vy = (IVariable) collector.getName(6).resolveBinding();
+ IVariable vz = (IVariable) collector.getName(7).resolveBinding();
+ IVariable a = (IVariable) collector.getName(9).resolveBinding();
+ IVariable b = (IVariable) collector.getName(14).resolveBinding();
+ IVariable c = (IVariable) collector.getName(19).resolveBinding();
+
+ assertInstances(collector, x, 4);
+ assertInstances(collector, x1, 3);
+ assertInstances(collector, x2, 3);
+ assertInstances(collector, x3, 3);
+ assertInstances(collector, vx, 3);
+ assertInstances(collector, vy, 3);
+ assertInstances(collector, vz, 3);
+ assertInstances(collector, a, 4);
+ assertInstances(collector, b, 2);
+ assertInstances(collector, c, 4);
+ }
+
+ public void testGCC20000205() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("static int f(int a) { \n");
+ buffer.append(" if (a == 0) \n");
+ buffer.append(" return 0; \n");
+ buffer.append(" do \n");
+ buffer.append(" if (a & 128) \n");
+ buffer.append(" return 1; \n");
+ buffer.append(" while (f(0)); \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 5);
+ IFunction f = (IFunction) collector.getName(0).resolveBinding();
+ IVariable a = (IVariable) collector.getName(1).resolveBinding();
+
+ assertInstances(collector, f, 2);
+ assertInstances(collector, a, 3);
+ }
+
+ public void testGCC20000217() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("unsigned short int showbug(unsigned short int * a, \n");
+ buffer.append(" unsigned short int * b) { \n");
+ buffer.append(" *a += *b - 8; \n");
+ buffer.append(" return (*a >= 8); \n");
+ buffer.append("} \n");
+ buffer.append("int main() { \n");
+ buffer.append(" unsigned short int x = 0; \n");
+ buffer.append(" unsigned short int y = 10; \n");
+ buffer.append(" if (showbug(&x, &y) != 0) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 12);
+
+ IFunction showBug = (IFunction) collector.getName(0).resolveBinding();
+ IVariable a = (IVariable) collector.getName(1).resolveBinding();
+ IVariable b = (IVariable) collector.getName(2).resolveBinding();
+ IVariable x = (IVariable) collector.getName(7).resolveBinding();
+ IVariable y = (IVariable) collector.getName(8).resolveBinding();
+
+ assertInstances(collector, showBug, 2);
+ assertInstances(collector, a, 3);
+ assertInstances(collector, b, 2);
+ assertInstances(collector, x, 2);
+ assertInstances(collector, y, 2);
+ }
+
+ public void testGCC20000224() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int loop_1 = 100; \n");
+ buffer.append("int loop_2 = 7; \n");
+ buffer.append("int flag = 0; \n");
+ buffer.append("int test(void) { \n");
+ buffer.append(" int i; \n");
+ buffer.append(" int counter = 0; \n");
+ buffer.append(" while (loop_1 > counter) { \n");
+ buffer.append(" if (flag & 1) { \n");
+ buffer.append(" for (i = 0; i < loop_2; i++) { \n");
+ buffer.append(" counter++; \n");
+ buffer.append(" } \n");
+ buffer.append(" } \n");
+ buffer.append(" flag++; \n");
+ buffer.append(" } \n");
+ buffer.append(" return 1; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 16);
+ IVariable loop1 = (IVariable) collector.getName(0).resolveBinding();
+ IVariable loop2 = (IVariable) collector.getName(1).resolveBinding();
+ IVariable flag = (IVariable) collector.getName(2).resolveBinding();
+ IVariable i = (IVariable) collector.getName(5).resolveBinding();
+ IVariable counter = (IVariable) collector.getName(6).resolveBinding();
+
+ assertInstances(collector, loop1, 2);
+ assertInstances(collector, loop2, 2);
+ assertInstances(collector, flag, 3);
+ assertInstances(collector, i, 4);
+ assertInstances(collector, counter, 3);
+ }
+
+ public void testGCC20000225() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("int main() { \n");
buffer.append(" int nResult, b = 0, i = -1; \n");
@@ -200,642 +200,641 @@ public class GCCTests extends AST2TestBase {
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 11);
- IVariable nResult = (IVariable) collector.getName(1).resolveBinding();
- IVariable b = (IVariable) collector.getName(2).resolveBinding();
- IVariable i = (IVariable) collector.getName(3).resolveBinding();
-
- assertInstances(collector, nResult, 3);
- assertInstances(collector, b, 3);
- assertInstances(collector, i, 4);
- }
-
- public void testGCC20000227() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("static const unsigned char f[] = \"\\0\\377\"; \n");
- buffer.append("static const unsigned char g[] = \"\\0y\"; \n");
- buffer.append("int main() { \n");
- buffer.append(" if (sizeof f != 3 || sizeof g != 3) \n");
- buffer.append(" return -1; \n");
- buffer.append(" if (f[0] != g[0]) \n");
- buffer.append(" return -1; \n");
- buffer.append(" if (f[1] != g[1] || f[2] != g[2]) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 11);
+ IVariable nResult = (IVariable) collector.getName(1).resolveBinding();
+ IVariable b = (IVariable) collector.getName(2).resolveBinding();
+ IVariable i = (IVariable) collector.getName(3).resolveBinding();
+
+ assertInstances(collector, nResult, 3);
+ assertInstances(collector, b, 3);
+ assertInstances(collector, i, 4);
+ }
+
+ public void testGCC20000227() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("static const unsigned char f[] = \"\\0\\377\"; \n");
+ buffer.append("static const unsigned char g[] = \"\\0y\"; \n");
+ buffer.append("int main() { \n");
+ buffer.append(" if (sizeof f != 3 || sizeof g != 3) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" if (f[0] != g[0]) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" if (f[1] != g[1] || f[2] != g[2]) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 11);
+ IVariable f = (IVariable) collector.getName(0).resolveBinding();
+ IVariable g = (IVariable) collector.getName(1).resolveBinding();
+
+ assertInstances(collector, f, 5);
+ assertInstances(collector, g, 5);
+ }
+
+ public void testGCC20000313() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("unsigned int buggy(unsigned int *param) { \n");
+ buffer.append(" unsigned int accu, zero = 0, borrow; \n");
+ buffer.append(" accu = - *param; \n");
+ buffer.append(" borrow = - (accu > zero); \n");
+ buffer.append(" return borrow; \n");
+ buffer.append("} \n");
+ buffer.append("int main(void) { \n");
+ buffer.append(" unsigned int param = 1; \n");
+ buffer.append(" unsigned int borrow = buggy (&param); \n");
+ buffer.append(" if (param != 0) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" if (borrow +1 != 0) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 19);
+ IFunction buggy = (IFunction) collector.getName(0).resolveBinding();
+ IParameter param = (IParameter) collector.getName(1).resolveBinding();
+ IVariable accu = (IVariable) collector.getName(2).resolveBinding();
+ IVariable zero = (IVariable) collector.getName(3).resolveBinding();
+ IVariable borrow = (IVariable) collector.getName(4).resolveBinding();
+ IVariable param2 = (IVariable) collector.getName(13).resolveBinding();
+ IVariable borrow2 = (IVariable) collector.getName(14).resolveBinding();
+
+ assertInstances(collector, buggy, 2);
+ assertInstances(collector, param, 2);
+ assertInstances(collector, accu, 3);
+ assertInstances(collector, zero, 2);
+ assertInstances(collector, borrow, 3);
+ assertInstances(collector, param2, 3);
+ assertInstances(collector, borrow2, 2);
+ }
+
+ public void testGCC20000314_1() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int main() { \n");
+ buffer.append(" long winds = 0; \n");
+ buffer.append(" while (winds != 0) { \n");
+ buffer.append(" if (*(char*)winds) \n");
+ buffer.append(" break; \n");
+ buffer.append(" } \n");
+ buffer.append(" if (winds == 0 || winds != 0 || *(char*) winds) \n");
+ buffer.append(" return 0; \n");
+ buffer.append(" return -1; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 7);
+ IVariable winds = (IVariable) collector.getName(1).resolveBinding();
+
+ assertInstances(collector, winds, 6);
+ }
+
+ public void testGCC20000314_2() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("typedef unsigned long long uint64; \n");
+ buffer.append("const uint64 bigconst = 1ULL << 34; \n");
+ buffer.append("int a = 1; \n");
+ buffer.append("static uint64 getmask(void) { \n");
+ buffer.append(" if (a) return bigconst; \n");
+ buffer.append(" else return 0; \n");
+ buffer.append("} \n");
+ buffer.append("main() { \n");
+ buffer.append(" uint64 f = getmask(); \n");
+ buffer.append(" if (sizeof (long long) == 8 && f != bigconst) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 15);
+ ITypedef uint64 = (ITypedef) collector.getName(0).resolveBinding();
+ IVariable bigconst = (IVariable) collector.getName(2).resolveBinding();
+ IVariable a = (IVariable) collector.getName(3).resolveBinding();
+ IFunction getmask = (IFunction) collector.getName(5).resolveBinding();
+ IVariable f = (IVariable) collector.getName(11).resolveBinding();
+
+ assertInstances(collector, uint64, 4);
+ assertInstances(collector, bigconst, 3);
+ assertInstances(collector, a, 2);
+ assertInstances(collector, getmask, 2);
+ assertInstances(collector, f, 2);
+ }
+
+ public void testGCC20000403() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("extern unsigned long aa[], bb[]; \n");
+ buffer.append("int seqgt(unsigned long a, unsigned short win, unsigned long b); \n");
+ buffer.append("int seqgt2 (unsigned long a, unsigned short win, unsigned long b); \n");
+ buffer.append("main() { \n");
+ buffer.append(" if (!seqgt(*aa, 0x1000, *bb) || !seqgt2(*aa, 0x1000, *bb)) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+ buffer.append("int seqgt(unsigned long a, unsigned short win, unsigned long b) { \n");
+ buffer.append(" return (long) ((a + win) - b) > 0; \n");
+ buffer.append("} \n");
+ buffer.append("int seqgt2(unsigned long a, unsigned short win, unsigned long b) { \n");
+ buffer.append(" long l = ((a + win) - b); \n");
+ buffer.append(" return 1 > 0; \n");
+ buffer.append("} \n");
+ buffer.append("unsigned long aa[] = { (1UL << (sizeof(long) *8 - 1)) = 0xfff }; \n");
+ buffer.append("unsigned long bb[] = { (1UL << (sizeof(long) *8 - 1)) = 0xfff }; \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 34);
+ IVariable aa = (IVariable) collector.getName(0).resolveBinding();
+ IVariable bb = (IVariable) collector.getName(1).resolveBinding();
+ IFunction seqgt = (IFunction) collector.getName(2).resolveBinding();
+ IParameter a1 = (IParameter) collector.getName(3).resolveBinding();
+ IParameter win1 = (IParameter) collector.getName(4).resolveBinding();
+ IParameter b1 = (IParameter) collector.getName(5).resolveBinding();
+ IFunction seqgt2 = (IFunction) collector.getName(6).resolveBinding();
+ IParameter a2 = (IParameter) collector.getName(7).resolveBinding();
+ IParameter win2 = (IParameter) collector.getName(8).resolveBinding();
+ IParameter b2 = (IParameter) collector.getName(9).resolveBinding();
+
+ assertInstances(collector, aa, 4);
+ assertInstances(collector, bb, 4);
+ assertInstances(collector, seqgt, 3);
+ assertInstances(collector, a1, 3);
+ assertInstances(collector, win1, 3);
+ assertInstances(collector, b1, 3);
+ assertInstances(collector, seqgt2, 3);
+ assertInstances(collector, a2, 3);
+ assertInstances(collector, win2, 3);
+ assertInstances(collector, b2, 3);
+ }
+
+ public void testGCC20000412_1() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("short int i = -1; \n");
+ buffer.append("const char * const wordlist[207]; \n");
+ buffer.append("const char * const * foo(void) { \n");
+ buffer.append(" register const char * const *wordptr = &wordlist[207u + i]; \n");
+ buffer.append(" return wordptr; \n");
+ buffer.append("} \n");
+ buffer.append("int main() { \n");
+ buffer.append(" if (foo() != &wordlist[206]) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 11);
+ IVariable i = (IVariable) collector.getName(0).resolveBinding();
+ IVariable wordlist = (IVariable) collector.getName(1).resolveBinding();
+ IFunction foo = (IFunction) collector.getName(2).resolveBinding();
+ IVariable wordptr = (IVariable) collector.getName(4).resolveBinding();
+
+ assertInstances(collector, i, 2);
+ assertInstances(collector, wordlist, 3);
+ assertInstances(collector, foo, 2);
+ assertInstances(collector, wordptr, 2);
+ }
+
+ public void testGCC20000412_2() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int f(int a, int *y) { \n");
+ buffer.append(" int x = a; \n");
+ buffer.append(" if (a == 0) return *y; \n");
+ buffer.append(" return f(a-1, &x); \n");
+ buffer.append("} \n");
+ buffer.append("int main(int argc, char** argv) { \n");
+ buffer.append(" if (f(100, (int *) 0) != 1) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 14);
+ IFunction f = (IFunction) collector.getName(0).resolveBinding();
+ IParameter a = (IParameter) collector.getName(1).resolveBinding();
+ IParameter y = (IParameter) collector.getName(2).resolveBinding();
+ IVariable x = (IVariable) collector.getName(3).resolveBinding();
+
+ assertInstances(collector, f, 3);
+ assertInstances(collector, a, 4);
+ assertInstances(collector, y, 2);
+ assertInstances(collector, x, 2);
+ }
+
+ public void testGCC20000412_3() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("typedef struct { \n");
+ buffer.append(" char y; \n");
+ buffer.append(" char x[32]; \n");
+ buffer.append("} X; \n");
+ buffer.append("int z(void) { \n");
+ buffer.append(" X xxx; \n");
+ buffer.append(" xxx.x[0] = xxx.x[31] = '0'; \n");
+ buffer.append(" xxx.y = 0xf; \n");
+ buffer.append(" return f(xxx, xxx); \n");
+ buffer.append("} \n");
+ buffer.append("int main (void) { \n");
+ buffer.append(" int val; \n");
+ buffer.append(" val = z(); \n");
+ buffer.append(" if (val != 0x60) return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+ buffer.append("int f(X x, X y) { \n");
+ buffer.append(" if (x.y != y.y) \n");
+ buffer.append(" return 'F'; \n");
+ buffer.append(" return x.x[0] + y.x[0]; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 36);
+ IField y = (IField) collector.getName(1).resolveBinding();
+ IField x = (IField) collector.getName(2).resolveBinding();
+ ITypedef X = (ITypedef) collector.getName(3).resolveBinding();
+ IFunction z = (IFunction) collector.getName(4).resolveBinding();
+ IVariable xxx = (IVariable) collector.getName(7).resolveBinding();
+ IVariable val = (IVariable) collector.getName(19).resolveBinding();
+ IParameter px = (IParameter) collector.getName(25).resolveBinding();
+ IParameter py = (IParameter) collector.getName(27).resolveBinding();
+
+ assertInstances(collector, y, 4);
+ assertInstances(collector, x, 5);
+ assertInstances(collector, X, 4);
+ assertInstances(collector, z, 2);
+ assertInstances(collector, xxx, 6);
+ assertInstances(collector, val, 3);
+ assertInstances(collector, px, 3);
+ assertInstances(collector, py, 3);
+ }
+
+ public void testGCC20000412_4() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("void f(int i, int j, int radius, int width, int N) { \n");
+ buffer.append(" const int diff = i - radius; \n");
+ buffer.append(" const int lowk = (diff > 0 ? diff : 0); \n");
+ buffer.append(" int k; \n");
+ buffer.append(" for (k = lowk; k <= 2; k++) { \n");
+ buffer.append(" int idx = ((k-i+radius) * width - j + radius); \n");
+ buffer.append(" if (idx < 0) return -1; \n");
+ buffer.append(" } \n");
+ buffer.append(" for (k = lowk; k <= 2; k++) ; \n");
+ buffer.append("} \n");
+ buffer.append("int main (int argc, char** argv) { \n");
+ buffer.append(" int exc_rad = 2; \n");
+ buffer.append(" int N = 8; \n");
+ buffer.append(" int i; \n");
+ buffer.append(" for (i = 1; i < 4; i++) \n");
+ buffer.append(" f(i, 1, exc_rad, 2*exc_rad + 1, N); \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 43);
+ IFunction f = (IFunction) collector.getName(0).resolveBinding();
+ IParameter i1 = (IParameter) collector.getName(1).resolveBinding();
+ IParameter j = (IParameter) collector.getName(2).resolveBinding();
+ IParameter radius = (IParameter) collector.getName(3).resolveBinding();
+ IParameter width = (IParameter) collector.getName(4).resolveBinding();
+ IParameter N1 = (IParameter) collector.getName(5).resolveBinding();
+ IVariable diff = (IVariable) collector.getName(6).resolveBinding();
+ IVariable lowk = (IVariable) collector.getName(9).resolveBinding();
+ IVariable k = (IVariable) collector.getName(12).resolveBinding();
+ IVariable idx = (IVariable) collector.getName(17).resolveBinding();
+ IVariable exc_rad = (IVariable) collector.getName(32).resolveBinding();
+ IVariable N2 = (IVariable) collector.getName(33).resolveBinding();
+ IVariable i2 = (IVariable) collector.getName(34).resolveBinding();
+
+ assertInstances(collector, f, 2);
+ assertInstances(collector, i1, 3);
+ assertInstances(collector, j, 2);
+ assertInstances(collector, radius, 4);
+ assertInstances(collector, width, 2);
+ assertInstances(collector, N1, 1);
+ assertInstances(collector, diff, 3);
+ assertInstances(collector, lowk, 3);
+ assertInstances(collector, k, 8);
+ assertInstances(collector, idx, 2);
+ assertInstances(collector, exc_rad, 3);
+ assertInstances(collector, N2, 2);
+ assertInstances(collector, i2, 5);
+ }
+
+ public void testGCC20000412_5() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int main(void) { \n");
+ buffer.append(" struct { \n");
+ buffer.append(" int node; \n");
+ buffer.append(" int type; \n");
+ buffer.append(" } lastglob[1] = { { 0, 1 } }; \n");
+ buffer.append(" if (lastglob[0].node != 0 || lastglob[0].type != 1) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 11);
- IVariable f = (IVariable) collector.getName(0).resolveBinding();
- IVariable g = (IVariable) collector.getName(1).resolveBinding();
-
- assertInstances(collector, f, 5);
- assertInstances(collector, g, 5);
- }
-
- public void testGCC20000313() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("unsigned int buggy(unsigned int *param) { \n");
- buffer.append(" unsigned int accu, zero = 0, borrow; \n");
- buffer.append(" accu = - *param; \n");
- buffer.append(" borrow = - (accu > zero); \n");
- buffer.append(" return borrow; \n");
- buffer.append("} \n");
- buffer.append("int main(void) { \n");
- buffer.append(" unsigned int param = 1; \n");
- buffer.append(" unsigned int borrow = buggy (&param); \n");
- buffer.append(" if (param != 0) \n");
- buffer.append(" return -1; \n");
- buffer.append(" if (borrow +1 != 0) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 19);
- IFunction buggy = (IFunction) collector.getName(0).resolveBinding();
- IParameter param = (IParameter) collector.getName(1).resolveBinding();
- IVariable accu = (IVariable) collector.getName(2).resolveBinding();
- IVariable zero = (IVariable) collector.getName(3).resolveBinding();
- IVariable borrow = (IVariable) collector.getName(4).resolveBinding();
- IVariable param2 = (IVariable) collector.getName(13).resolveBinding();
- IVariable borrow2 = (IVariable) collector.getName(14).resolveBinding();
-
- assertInstances(collector, buggy, 2);
- assertInstances(collector, param, 2);
- assertInstances(collector, accu, 3);
- assertInstances(collector, zero, 2);
- assertInstances(collector, borrow, 3);
- assertInstances(collector, param2, 3);
- assertInstances(collector, borrow2, 2);
- }
-
- public void testGCC20000314_1() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("int main() { \n");
- buffer.append(" long winds = 0; \n");
- buffer.append(" while (winds != 0) { \n");
- buffer.append(" if (*(char*)winds) \n");
- buffer.append(" break; \n");
- buffer.append(" } \n");
- buffer.append(" if (winds == 0 || winds != 0 || *(char*) winds) \n");
- buffer.append(" return 0; \n");
- buffer.append(" return -1; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 7);
- IVariable winds = (IVariable) collector.getName(1).resolveBinding();
-
- assertInstances(collector, winds, 6);
- }
-
- public void testGCC20000314_2() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("typedef unsigned long long uint64; \n");
- buffer.append("const uint64 bigconst = 1ULL << 34; \n");
- buffer.append("int a = 1; \n");
- buffer.append("static uint64 getmask(void) { \n");
- buffer.append(" if (a) return bigconst; \n");
- buffer.append(" else return 0; \n");
- buffer.append("} \n");
- buffer.append("main() { \n");
- buffer.append(" uint64 f = getmask(); \n");
- buffer.append(" if (sizeof (long long) == 8 && f != bigconst) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 15);
- ITypedef uint64 = (ITypedef) collector.getName(0).resolveBinding();
- IVariable bigconst = (IVariable) collector.getName(2).resolveBinding();
- IVariable a = (IVariable) collector.getName(3).resolveBinding();
- IFunction getmask = (IFunction) collector.getName(5).resolveBinding();
- IVariable f = (IVariable) collector.getName(11).resolveBinding();
-
- assertInstances(collector, uint64, 4);
- assertInstances(collector, bigconst, 3);
- assertInstances(collector, a, 2);
- assertInstances(collector, getmask, 2);
- assertInstances(collector, f, 2);
- }
-
- public void testGCC20000403() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("extern unsigned long aa[], bb[]; \n");
- buffer.append("int seqgt(unsigned long a, unsigned short win, unsigned long b); \n");
- buffer.append("int seqgt2 (unsigned long a, unsigned short win, unsigned long b); \n");
- buffer.append("main() { \n");
- buffer.append(" if (!seqgt(*aa, 0x1000, *bb) || !seqgt2(*aa, 0x1000, *bb)) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
- buffer.append("int seqgt(unsigned long a, unsigned short win, unsigned long b) { \n");
- buffer.append(" return (long) ((a + win) - b) > 0; \n");
- buffer.append("} \n");
- buffer.append("int seqgt2(unsigned long a, unsigned short win, unsigned long b) { \n");
- buffer.append(" long l = ((a + win) - b); \n");
- buffer.append(" return 1 > 0; \n");
- buffer.append("} \n");
- buffer.append("unsigned long aa[] = { (1UL << (sizeof(long) *8 - 1)) = 0xfff }; \n");
- buffer.append("unsigned long bb[] = { (1UL << (sizeof(long) *8 - 1)) = 0xfff }; \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 34);
- IVariable aa = (IVariable) collector.getName(0).resolveBinding();
- IVariable bb = (IVariable) collector.getName(1).resolveBinding();
- IFunction seqgt = (IFunction) collector.getName(2).resolveBinding();
- IParameter a1 = (IParameter) collector.getName(3).resolveBinding();
- IParameter win1 = (IParameter) collector.getName(4).resolveBinding();
- IParameter b1 = (IParameter) collector.getName(5).resolveBinding();
- IFunction seqgt2 = (IFunction) collector.getName(6).resolveBinding();
- IParameter a2 = (IParameter) collector.getName(7).resolveBinding();
- IParameter win2 = (IParameter) collector.getName(8).resolveBinding();
- IParameter b2 = (IParameter) collector.getName(9).resolveBinding();
-
- assertInstances(collector, aa, 4);
- assertInstances(collector, bb, 4);
- assertInstances(collector, seqgt, 3);
- assertInstances(collector, a1, 3);
- assertInstances(collector, win1, 3);
- assertInstances(collector, b1, 3);
- assertInstances(collector, seqgt2, 3);
- assertInstances(collector, a2, 3);
- assertInstances(collector, win2, 3);
- assertInstances(collector, b2, 3);
- }
-
- public void testGCC20000412_1 () throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("short int i = -1; \n");
- buffer.append("const char * const wordlist[207]; \n");
- buffer.append("const char * const * foo(void) { \n");
- buffer.append(" register const char * const *wordptr = &wordlist[207u + i]; \n");
- buffer.append(" return wordptr; \n");
- buffer.append("} \n");
- buffer.append("int main() { \n");
- buffer.append(" if (foo() != &wordlist[206]) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 11);
- IVariable i = (IVariable) collector.getName(0).resolveBinding();
- IVariable wordlist = (IVariable) collector.getName(1).resolveBinding();
- IFunction foo = (IFunction) collector.getName(2).resolveBinding();
- IVariable wordptr = (IVariable) collector.getName(4).resolveBinding();
-
- assertInstances(collector, i, 2);
- assertInstances(collector, wordlist, 3);
- assertInstances(collector, foo, 2);
- assertInstances(collector, wordptr, 2);
- }
-
- public void testGCC20000412_2() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("int f(int a, int *y) { \n");
- buffer.append(" int x = a; \n");
- buffer.append(" if (a == 0) return *y; \n");
- buffer.append(" return f(a-1, &x); \n");
- buffer.append("} \n");
- buffer.append("int main(int argc, char** argv) { \n");
- buffer.append(" if (f(100, (int *) 0) != 1) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 14);
- IFunction f = (IFunction) collector.getName(0).resolveBinding();
- IParameter a = (IParameter) collector.getName(1).resolveBinding();
- IParameter y = (IParameter) collector.getName(2).resolveBinding();
- IVariable x = (IVariable) collector.getName(3).resolveBinding();
-
- assertInstances(collector, f, 3);
- assertInstances(collector, a, 4);
- assertInstances(collector, y, 2);
- assertInstances(collector, x, 2);
- }
-
- public void testGCC20000412_3() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("typedef struct { \n");
- buffer.append(" char y; \n");
- buffer.append(" char x[32]; \n");
- buffer.append("} X; \n");
- buffer.append("int z(void) { \n");
- buffer.append(" X xxx; \n");
- buffer.append(" xxx.x[0] = xxx.x[31] = '0'; \n");
- buffer.append(" xxx.y = 0xf; \n");
- buffer.append(" return f(xxx, xxx); \n");
- buffer.append("} \n");
- buffer.append("int main (void) { \n");
- buffer.append(" int val; \n");
- buffer.append(" val = z(); \n");
- buffer.append(" if (val != 0x60) return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
- buffer.append("int f(X x, X y) { \n");
- buffer.append(" if (x.y != y.y) \n");
- buffer.append(" return 'F'; \n");
- buffer.append(" return x.x[0] + y.x[0]; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 36);
- IField y = (IField) collector.getName(1).resolveBinding();
- IField x = (IField) collector.getName(2).resolveBinding();
- ITypedef X = (ITypedef) collector.getName(3).resolveBinding();
- IFunction z = (IFunction) collector.getName(4).resolveBinding();
- IVariable xxx = (IVariable) collector.getName(7).resolveBinding();
- IVariable val = (IVariable) collector.getName(19).resolveBinding();
- IParameter px = (IParameter) collector.getName(25).resolveBinding();
- IParameter py = (IParameter) collector.getName(27).resolveBinding();
-
- assertInstances(collector, y, 4);
- assertInstances(collector, x, 5);
- assertInstances(collector, X, 4);
- assertInstances(collector, z, 2);
- assertInstances(collector, xxx, 6);
- assertInstances(collector, val, 3);
- assertInstances(collector, px, 3);
- assertInstances(collector, py, 3);
- }
-
- public void testGCC20000412_4() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("void f(int i, int j, int radius, int width, int N) { \n");
- buffer.append(" const int diff = i - radius; \n");
- buffer.append(" const int lowk = (diff > 0 ? diff : 0); \n");
- buffer.append(" int k; \n");
- buffer.append(" for (k = lowk; k <= 2; k++) { \n");
- buffer.append(" int idx = ((k-i+radius) * width - j + radius); \n");
- buffer.append(" if (idx < 0) return -1; \n");
- buffer.append(" } \n");
- buffer.append(" for (k = lowk; k <= 2; k++) ; \n");
- buffer.append("} \n");
- buffer.append("int main (int argc, char** argv) { \n");
- buffer.append(" int exc_rad = 2; \n");
- buffer.append(" int N = 8; \n");
- buffer.append(" int i; \n");
- buffer.append(" for (i = 1; i < 4; i++) \n");
- buffer.append(" f(i, 1, exc_rad, 2*exc_rad + 1, N); \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 43);
- IFunction f = (IFunction) collector.getName(0).resolveBinding();
- IParameter i1 = (IParameter) collector.getName(1).resolveBinding();
- IParameter j = (IParameter) collector.getName(2).resolveBinding();
- IParameter radius = (IParameter) collector.getName(3).resolveBinding();
- IParameter width = (IParameter) collector.getName(4).resolveBinding();
- IParameter N1 = (IParameter) collector.getName(5).resolveBinding();
- IVariable diff = (IVariable) collector.getName(6).resolveBinding();
- IVariable lowk = (IVariable) collector.getName(9).resolveBinding();
- IVariable k = (IVariable) collector.getName(12).resolveBinding();
- IVariable idx = (IVariable) collector.getName(17).resolveBinding();
- IVariable exc_rad = (IVariable) collector.getName(32).resolveBinding();
- IVariable N2 = (IVariable) collector.getName(33).resolveBinding();
- IVariable i2 = (IVariable) collector.getName(34).resolveBinding();
-
- assertInstances(collector, f, 2);
- assertInstances(collector, i1, 3);
- assertInstances(collector, j, 2);
- assertInstances(collector, radius, 4);
- assertInstances(collector, width, 2);
- assertInstances(collector, N1, 1);
- assertInstances(collector, diff, 3);
- assertInstances(collector, lowk, 3);
- assertInstances(collector, k, 8);
- assertInstances(collector, idx, 2);
- assertInstances(collector, exc_rad, 3);
- assertInstances(collector, N2, 2);
- assertInstances(collector, i2, 5);
- }
-
- public void testGCC20000412_5() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("int main(void) { \n");
- buffer.append(" struct { \n");
- buffer.append(" int node; \n");
- buffer.append(" int type; \n");
- buffer.append(" } lastglob[1] = { { 0, 1 } }; \n");
- buffer.append(" if (lastglob[0].node != 0 || lastglob[0].type != 1) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 10);
- IField node = (IField) collector.getName(3).resolveBinding();
- IField type = (IField) collector.getName(4).resolveBinding();
- IVariable lastglob = (IVariable) collector.getName(5).resolveBinding();
-
- assertInstances(collector, node, 2);
- assertInstances(collector, type, 2);
- assertInstances(collector, lastglob, 3);
- }
-
- public void testGCC20000419() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("struct foo { int a, b, c; }; \n");
- buffer.append("void brother(int a, int b, int c) { \n");
- buffer.append(" if (a) return; \n");
- buffer.append("} \n");
- buffer.append("void sister(struct foo f, int b, int c) { \n");
- buffer.append(" brother((f.b == b), b, c); \n");
- buffer.append("} \n");
- buffer.append("int main() { \n");
- buffer.append(" struct foo f = { 7, 8, 9 }; \n");
- buffer.append(" sister(f, 1, 2); \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 25);
- ICompositeType foo = (ICompositeType) collector.getName(0).resolveBinding();
- IField fa = (IField) collector.getName(1).resolveBinding();
- IField fb = (IField) collector.getName(2).resolveBinding();
- IField fc = (IField) collector.getName(3).resolveBinding();
- IFunction brother = (IFunction) collector.getName(4).resolveBinding();
- IParameter pa = (IParameter) collector.getName(5).resolveBinding();
- IParameter pb = (IParameter) collector.getName(6).resolveBinding();
- IParameter pc = (IParameter) collector.getName(7).resolveBinding();
- IFunction sister = (IFunction) collector.getName(9).resolveBinding();
- IParameter sf = (IParameter) collector.getName(11).resolveBinding();
- IParameter sb = (IParameter) collector.getName(12).resolveBinding();
- IParameter sc = (IParameter) collector.getName(13).resolveBinding();
- IVariable f = (IVariable) collector.getName(22).resolveBinding();
-
- assertInstances(collector, foo, 3);
- assertInstances(collector, fa, 1);
- assertInstances(collector, fb, 2);
- assertInstances(collector, fc, 1);
- assertInstances(collector, brother, 2);
- assertInstances(collector, pa, 2);
- assertInstances(collector, pb, 1);
- assertInstances(collector, pc, 1);
- assertInstances(collector, sister, 2);
- assertInstances(collector, sf, 2);
- assertInstances(collector, sb, 3);
- assertInstances(collector, sc, 2);
- assertInstances(collector, f, 2);
- }
-
- public void testGCC20000503() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("unsigned long sub(int a) { \n");
- buffer.append(" return ((0 > a - 2) ? 0 : a - 2) * sizeof(long); \n");
- buffer.append("} \n");
- buffer.append("main() { \n");
- buffer.append(" return (sub(0) != 0); \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 6);
- IFunction sub = (IFunction) collector.getName(0).resolveBinding();
- IParameter a = (IParameter) collector.getName(1).resolveBinding();
-
- assertInstances(collector, sub, 2);
- assertInstances(collector, a, 3);
- }
-
- public void testGCC20000511() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("int f(int value, int expect) { \n");
- buffer.append(" return (value == expect); \n");
- buffer.append("} \n");
- buffer.append("main() { \n");
- buffer.append(" int a = 7, b = 6, c = 4, d = 7, e = 2; \n");
- buffer.append(" f(a || b % c, 1); \n");
- buffer.append(" f(a ? b % c : 0, 2); \n");
- buffer.append(" f(a = b % c, 2); \n");
- buffer.append(" f(a *= b % c, 4); \n");
- buffer.append(" f(a /= b % c, 2); \n");
- buffer.append(" f(a %= b % c, 0); \n");
- buffer.append(" f(a += b % c, 2); \n");
- buffer.append(" f(d || c && e, 1); \n");
- buffer.append(" f(d ? c && e : 0, 1); \n");
- buffer.append(" f(d = c && e, 1); \n");
- buffer.append(" f(d *= c && e, 1); \n");
- buffer.append(" f(d %= c && e, 0); \n");
- buffer.append(" f(d += c && e, 1); \n");
- buffer.append(" f(d -= c && e, 0); \n");
- buffer.append(" f(d || c || e, 1); \n");
- buffer.append(" f(d ? c || e : 0, 0); \n");
- buffer.append(" f(d = c || e, 1); \n");
- buffer.append(" f(d *= c || e, 1); \n");
- buffer.append(" f(d %= c || e, 0); \n");
- buffer.append(" f(d += c || e, 1); \n");
- buffer.append(" f(d -= c || e, 0); \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 95);
- IFunction f = (IFunction) collector.getName(0).resolveBinding();
- IParameter v = (IParameter) collector.getName(1).resolveBinding();
- IParameter ex = (IParameter) collector.getName(2).resolveBinding();
- IVariable a = (IVariable) collector.getName(6).resolveBinding();
- IVariable b = (IVariable) collector.getName(7).resolveBinding();
- IVariable c = (IVariable) collector.getName(8).resolveBinding();
- IVariable d = (IVariable) collector.getName(9).resolveBinding();
- IVariable e = (IVariable) collector.getName(10).resolveBinding();
-
-
- assertInstances(collector, f, 22);
- assertInstances(collector, v, 2);
- assertInstances(collector, ex, 2);
- assertInstances(collector, a, 8);
- assertInstances(collector, b, 8);
- assertInstances(collector, c, 22);
- assertInstances(collector, d, 15);
- assertInstances(collector, e, 15);
- }
-
- public void testGCC20000603() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("struct s1 { double d; }; \n");
- buffer.append("struct s2 { double d; }; \n");
- buffer.append("double f(struct s1 * a, struct s2 *b) { \n");
- buffer.append(" a->d = 1.0; \n");
- buffer.append(" return b->d + 1.0; \n");
- buffer.append("} \n");
- buffer.append("int main() { \n");
- buffer.append(" struct s1 a; \n");
- buffer.append(" a.d = 0.0; \n");
- buffer.append(" if (f(&a, (struct s2 *)&a) != 2.0) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 22);
- ICompositeType s1 = (ICompositeType) collector.getName(0).resolveBinding();
- IField d1 = (IField) collector.getName(1).resolveBinding();
- ICompositeType s2 = (ICompositeType) collector.getName(2).resolveBinding();
- IField d2 = (IField) collector.getName(3).resolveBinding();
- IFunction f = (IFunction) collector.getName(4).resolveBinding();
- IParameter pa = (IParameter) collector.getName(6).resolveBinding();
- IParameter pb = (IParameter) collector.getName(8).resolveBinding();
- IVariable a = (IVariable) collector.getName(15).resolveBinding();
-
- assertInstances(collector, s1, 3);
- assertInstances(collector, s2, 3);
- assertInstances(collector, d1, 3);
- assertInstances(collector, d2, 2);
- assertInstances(collector, f, 2);
- assertInstances(collector, pa, 2);
- assertInstances(collector, pb, 2);
- assertInstances(collector, a, 4);
- }
-
- public void testGCC20000605_2() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("struct F { int i; }; \n");
- buffer.append("void f1(struct F *x, struct F * y) { \n");
- buffer.append(" int timeout = 0; \n");
- buffer.append(" for (; ((const struct F*)x)->i < y->i; x->i++) \n");
- buffer.append(" if (++timeout > 5) \n");
- buffer.append(" return; \n");
- buffer.append("} \n");
- buffer.append("main() { \n");
- buffer.append(" struct F x, y; \n");
- buffer.append(" x.i = 0; y.i = 1; \n");
- buffer.append(" f1(&x, &y); \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 27);
- ICompositeType F = (ICompositeType) collector.getName(0).resolveBinding();
- IField i = (IField) collector.getName(1).resolveBinding();
- IFunction f1 = (IFunction) collector.getName(2).resolveBinding();
- IParameter px = (IParameter) collector.getName(4).resolveBinding();
- IParameter py = (IParameter) collector.getName(6).resolveBinding();
- IVariable timeout = (IVariable) collector.getName(7).resolveBinding();
- IVariable x = (IVariable) collector.getName(18).resolveBinding();
- IVariable y = (IVariable) collector.getName(19).resolveBinding();
-
- assertInstances(collector, F, 5);
- assertInstances(collector, i, 6);
- assertInstances(collector, f1, 2);
- assertInstances(collector, px, 3);
- assertInstances(collector, py, 2);
- assertInstances(collector, timeout, 2);
- assertInstances(collector, x, 3);
- assertInstances(collector, y, 3);
- }
-
- public void testGCC20000605_3() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("struct F { int x; int y; }; \n");
- buffer.append("int main() { \n");
- buffer.append(" int timeout = 0, x = 0; \n");
- buffer.append(" while (1) { \n");
- buffer.append(" const struct F i = { x++, }; \n");
- buffer.append(" if (i.x > 0) \n");
- buffer.append(" break; \n");
- buffer.append(" if (++timeout > 5) \n");
- buffer.append(" goto die; \n");
- buffer.append(" } \n");
- buffer.append(" die: return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 14);
- ICompositeType F = (ICompositeType) collector.getName(0).resolveBinding();
- IField fx = (IField) collector.getName(1).resolveBinding();
- IField fy = (IField) collector.getName(2).resolveBinding();
- IVariable timeout = (IVariable) collector.getName(4).resolveBinding();
- IVariable x = (IVariable) collector.getName(5).resolveBinding();
- IVariable i = (IVariable) collector.getName(7).resolveBinding();
- ILabel die = (ILabel) collector.getName(13).resolveBinding();
-
- assertInstances(collector, F, 2);
- assertInstances(collector, fx, 2);
- assertInstances(collector, fy, 1);
- assertInstances(collector, timeout, 2);
- assertInstances(collector, x, 2);
- assertInstances(collector, i, 2);
- assertInstances(collector, die, 2);
- }
-
- public void testGCCenum_2() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("enum foo { FOO, BAR }; \n");
- buffer.append("int main() { \n");
- buffer.append(" int i; \n");
- buffer.append(" for (i = BAR; i >= FOO; --i) \n");
- buffer.append(" if (i == -1) return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 11);
- IEnumeration foo = (IEnumeration) collector.getName(0).resolveBinding();
- IEnumerator FOO = (IEnumerator) collector.getName(1).resolveBinding();
- IEnumerator BAR = (IEnumerator) collector.getName(2).resolveBinding();
- IVariable i = (IVariable) collector.getName(4).resolveBinding();
-
- assertInstances(collector, foo, 1);
- assertInstances(collector, FOO, 2);
- assertInstances(collector, BAR, 2);
- assertInstances(collector, i, 5);
- }
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 10);
+ IField node = (IField) collector.getName(3).resolveBinding();
+ IField type = (IField) collector.getName(4).resolveBinding();
+ IVariable lastglob = (IVariable) collector.getName(5).resolveBinding();
+
+ assertInstances(collector, node, 2);
+ assertInstances(collector, type, 2);
+ assertInstances(collector, lastglob, 3);
+ }
+
+ public void testGCC20000419() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("struct foo { int a, b, c; }; \n");
+ buffer.append("void brother(int a, int b, int c) { \n");
+ buffer.append(" if (a) return; \n");
+ buffer.append("} \n");
+ buffer.append("void sister(struct foo f, int b, int c) { \n");
+ buffer.append(" brother((f.b == b), b, c); \n");
+ buffer.append("} \n");
+ buffer.append("int main() { \n");
+ buffer.append(" struct foo f = { 7, 8, 9 }; \n");
+ buffer.append(" sister(f, 1, 2); \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 25);
+ ICompositeType foo = (ICompositeType) collector.getName(0).resolveBinding();
+ IField fa = (IField) collector.getName(1).resolveBinding();
+ IField fb = (IField) collector.getName(2).resolveBinding();
+ IField fc = (IField) collector.getName(3).resolveBinding();
+ IFunction brother = (IFunction) collector.getName(4).resolveBinding();
+ IParameter pa = (IParameter) collector.getName(5).resolveBinding();
+ IParameter pb = (IParameter) collector.getName(6).resolveBinding();
+ IParameter pc = (IParameter) collector.getName(7).resolveBinding();
+ IFunction sister = (IFunction) collector.getName(9).resolveBinding();
+ IParameter sf = (IParameter) collector.getName(11).resolveBinding();
+ IParameter sb = (IParameter) collector.getName(12).resolveBinding();
+ IParameter sc = (IParameter) collector.getName(13).resolveBinding();
+ IVariable f = (IVariable) collector.getName(22).resolveBinding();
+
+ assertInstances(collector, foo, 3);
+ assertInstances(collector, fa, 1);
+ assertInstances(collector, fb, 2);
+ assertInstances(collector, fc, 1);
+ assertInstances(collector, brother, 2);
+ assertInstances(collector, pa, 2);
+ assertInstances(collector, pb, 1);
+ assertInstances(collector, pc, 1);
+ assertInstances(collector, sister, 2);
+ assertInstances(collector, sf, 2);
+ assertInstances(collector, sb, 3);
+ assertInstances(collector, sc, 2);
+ assertInstances(collector, f, 2);
+ }
+
+ public void testGCC20000503() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("unsigned long sub(int a) { \n");
+ buffer.append(" return ((0 > a - 2) ? 0 : a - 2) * sizeof(long); \n");
+ buffer.append("} \n");
+ buffer.append("main() { \n");
+ buffer.append(" return (sub(0) != 0); \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 6);
+ IFunction sub = (IFunction) collector.getName(0).resolveBinding();
+ IParameter a = (IParameter) collector.getName(1).resolveBinding();
+
+ assertInstances(collector, sub, 2);
+ assertInstances(collector, a, 3);
+ }
+
+ public void testGCC20000511() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int f(int value, int expect) { \n");
+ buffer.append(" return (value == expect); \n");
+ buffer.append("} \n");
+ buffer.append("main() { \n");
+ buffer.append(" int a = 7, b = 6, c = 4, d = 7, e = 2; \n");
+ buffer.append(" f(a || b % c, 1); \n");
+ buffer.append(" f(a ? b % c : 0, 2); \n");
+ buffer.append(" f(a = b % c, 2); \n");
+ buffer.append(" f(a *= b % c, 4); \n");
+ buffer.append(" f(a /= b % c, 2); \n");
+ buffer.append(" f(a %= b % c, 0); \n");
+ buffer.append(" f(a += b % c, 2); \n");
+ buffer.append(" f(d || c && e, 1); \n");
+ buffer.append(" f(d ? c && e : 0, 1); \n");
+ buffer.append(" f(d = c && e, 1); \n");
+ buffer.append(" f(d *= c && e, 1); \n");
+ buffer.append(" f(d %= c && e, 0); \n");
+ buffer.append(" f(d += c && e, 1); \n");
+ buffer.append(" f(d -= c && e, 0); \n");
+ buffer.append(" f(d || c || e, 1); \n");
+ buffer.append(" f(d ? c || e : 0, 0); \n");
+ buffer.append(" f(d = c || e, 1); \n");
+ buffer.append(" f(d *= c || e, 1); \n");
+ buffer.append(" f(d %= c || e, 0); \n");
+ buffer.append(" f(d += c || e, 1); \n");
+ buffer.append(" f(d -= c || e, 0); \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 95);
+ IFunction f = (IFunction) collector.getName(0).resolveBinding();
+ IParameter v = (IParameter) collector.getName(1).resolveBinding();
+ IParameter ex = (IParameter) collector.getName(2).resolveBinding();
+ IVariable a = (IVariable) collector.getName(6).resolveBinding();
+ IVariable b = (IVariable) collector.getName(7).resolveBinding();
+ IVariable c = (IVariable) collector.getName(8).resolveBinding();
+ IVariable d = (IVariable) collector.getName(9).resolveBinding();
+ IVariable e = (IVariable) collector.getName(10).resolveBinding();
+
+ assertInstances(collector, f, 22);
+ assertInstances(collector, v, 2);
+ assertInstances(collector, ex, 2);
+ assertInstances(collector, a, 8);
+ assertInstances(collector, b, 8);
+ assertInstances(collector, c, 22);
+ assertInstances(collector, d, 15);
+ assertInstances(collector, e, 15);
+ }
+
+ public void testGCC20000603() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("struct s1 { double d; }; \n");
+ buffer.append("struct s2 { double d; }; \n");
+ buffer.append("double f(struct s1 * a, struct s2 *b) { \n");
+ buffer.append(" a->d = 1.0; \n");
+ buffer.append(" return b->d + 1.0; \n");
+ buffer.append("} \n");
+ buffer.append("int main() { \n");
+ buffer.append(" struct s1 a; \n");
+ buffer.append(" a.d = 0.0; \n");
+ buffer.append(" if (f(&a, (struct s2 *)&a) != 2.0) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 22);
+ ICompositeType s1 = (ICompositeType) collector.getName(0).resolveBinding();
+ IField d1 = (IField) collector.getName(1).resolveBinding();
+ ICompositeType s2 = (ICompositeType) collector.getName(2).resolveBinding();
+ IField d2 = (IField) collector.getName(3).resolveBinding();
+ IFunction f = (IFunction) collector.getName(4).resolveBinding();
+ IParameter pa = (IParameter) collector.getName(6).resolveBinding();
+ IParameter pb = (IParameter) collector.getName(8).resolveBinding();
+ IVariable a = (IVariable) collector.getName(15).resolveBinding();
+
+ assertInstances(collector, s1, 3);
+ assertInstances(collector, s2, 3);
+ assertInstances(collector, d1, 3);
+ assertInstances(collector, d2, 2);
+ assertInstances(collector, f, 2);
+ assertInstances(collector, pa, 2);
+ assertInstances(collector, pb, 2);
+ assertInstances(collector, a, 4);
+ }
+
+ public void testGCC20000605_2() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("struct F { int i; }; \n");
+ buffer.append("void f1(struct F *x, struct F * y) { \n");
+ buffer.append(" int timeout = 0; \n");
+ buffer.append(" for (; ((const struct F*)x)->i < y->i; x->i++) \n");
+ buffer.append(" if (++timeout > 5) \n");
+ buffer.append(" return; \n");
+ buffer.append("} \n");
+ buffer.append("main() { \n");
+ buffer.append(" struct F x, y; \n");
+ buffer.append(" x.i = 0; y.i = 1; \n");
+ buffer.append(" f1(&x, &y); \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 27);
+ ICompositeType F = (ICompositeType) collector.getName(0).resolveBinding();
+ IField i = (IField) collector.getName(1).resolveBinding();
+ IFunction f1 = (IFunction) collector.getName(2).resolveBinding();
+ IParameter px = (IParameter) collector.getName(4).resolveBinding();
+ IParameter py = (IParameter) collector.getName(6).resolveBinding();
+ IVariable timeout = (IVariable) collector.getName(7).resolveBinding();
+ IVariable x = (IVariable) collector.getName(18).resolveBinding();
+ IVariable y = (IVariable) collector.getName(19).resolveBinding();
+
+ assertInstances(collector, F, 5);
+ assertInstances(collector, i, 6);
+ assertInstances(collector, f1, 2);
+ assertInstances(collector, px, 3);
+ assertInstances(collector, py, 2);
+ assertInstances(collector, timeout, 2);
+ assertInstances(collector, x, 3);
+ assertInstances(collector, y, 3);
+ }
+
+ public void testGCC20000605_3() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("struct F { int x; int y; }; \n");
+ buffer.append("int main() { \n");
+ buffer.append(" int timeout = 0, x = 0; \n");
+ buffer.append(" while (1) { \n");
+ buffer.append(" const struct F i = { x++, }; \n");
+ buffer.append(" if (i.x > 0) \n");
+ buffer.append(" break; \n");
+ buffer.append(" if (++timeout > 5) \n");
+ buffer.append(" goto die; \n");
+ buffer.append(" } \n");
+ buffer.append(" die: return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 14);
+ ICompositeType F = (ICompositeType) collector.getName(0).resolveBinding();
+ IField fx = (IField) collector.getName(1).resolveBinding();
+ IField fy = (IField) collector.getName(2).resolveBinding();
+ IVariable timeout = (IVariable) collector.getName(4).resolveBinding();
+ IVariable x = (IVariable) collector.getName(5).resolveBinding();
+ IVariable i = (IVariable) collector.getName(7).resolveBinding();
+ ILabel die = (ILabel) collector.getName(13).resolveBinding();
+
+ assertInstances(collector, F, 2);
+ assertInstances(collector, fx, 2);
+ assertInstances(collector, fy, 1);
+ assertInstances(collector, timeout, 2);
+ assertInstances(collector, x, 2);
+ assertInstances(collector, i, 2);
+ assertInstances(collector, die, 2);
+ }
+
+ public void testGCCenum_2() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("enum foo { FOO, BAR }; \n");
+ buffer.append("int main() { \n");
+ buffer.append(" int i; \n");
+ buffer.append(" for (i = BAR; i >= FOO; --i) \n");
+ buffer.append(" if (i == -1) return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 11);
+ IEnumeration foo = (IEnumeration) collector.getName(0).resolveBinding();
+ IEnumerator FOO = (IEnumerator) collector.getName(1).resolveBinding();
+ IEnumerator BAR = (IEnumerator) collector.getName(2).resolveBinding();
+ IVariable i = (IVariable) collector.getName(4).resolveBinding();
+
+ assertInstances(collector, foo, 1);
+ assertInstances(collector, FOO, 2);
+ assertInstances(collector, BAR, 2);
+ assertInstances(collector, i, 5);
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ImageLocationTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ImageLocationTests.java
index 31785370c4f..01863280ad2 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ImageLocationTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ImageLocationTests.java
@@ -28,15 +28,15 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
*/
public class ImageLocationTests extends AST2TestBase {
- private static final int CODE = IASTImageLocation.REGULAR_CODE;
- private static final int MACRO = IASTImageLocation.MACRO_DEFINITION;
- private static final int MACRO_ARG = IASTImageLocation.ARGUMENT_TO_MACRO_EXPANSION;
+ private static final int CODE = IASTImageLocation.REGULAR_CODE;
+ private static final int MACRO = IASTImageLocation.MACRO_DEFINITION;
+ private static final int MACRO_ARG = IASTImageLocation.ARGUMENT_TO_MACRO_EXPANSION;
public static Test suite() {
- return suite(ImageLocationTests.class);
- }
+ return suite(ImageLocationTests.class);
+ }
- public ImageLocationTests() {
+ public ImageLocationTests() {
}
public ImageLocationTests(String name) {
@@ -45,13 +45,13 @@ public class ImageLocationTests extends AST2TestBase {
// int a;
public void testFileLocation() throws Exception {
- String code= getContents(1)[0].toString();
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
-
- IASTDeclaration declaration = tu.getDeclarations()[0];
- IASTName name= getName(declaration);
- IASTImageLocation loc= name.getImageLocation();
- assertLocation(CODE, code, "a", 0, loc);
+ String code = getContents(1)[0].toString();
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+
+ IASTDeclaration declaration = tu.getDeclarations()[0];
+ IASTName name = getName(declaration);
+ IASTImageLocation loc = name.getImageLocation();
+ assertLocation(CODE, code, "a", 0, loc);
}
// #define M result1
@@ -59,69 +59,69 @@ public class ImageLocationTests extends AST2TestBase {
// int M;
// int F();
public void testMacroLocation() throws Exception {
- String code= getContents(1)[0].toString();
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
-
- IASTDeclaration declaration = tu.getDeclarations()[0];
- IASTName name= getName(declaration);
- IASTImageLocation loc= name.getImageLocation();
- assertLocation(MACRO, code, "result1", 0, loc);
-
- declaration = tu.getDeclarations()[1];
- name= getName(declaration);
- loc= name.getImageLocation();
- assertLocation(MACRO, code, "result2", 0, loc);
+ String code = getContents(1)[0].toString();
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+
+ IASTDeclaration declaration = tu.getDeclarations()[0];
+ IASTName name = getName(declaration);
+ IASTImageLocation loc = name.getImageLocation();
+ assertLocation(MACRO, code, "result1", 0, loc);
+
+ declaration = tu.getDeclarations()[1];
+ name = getName(declaration);
+ loc = name.getImageLocation();
+ assertLocation(MACRO, code, "result2", 0, loc);
}
// #define M result
// #define F() M
// int F();
public void testIndirectMacroLocation() throws Exception {
- String code= getContents(1)[0].toString();
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
-
- IASTDeclaration declaration = tu.getDeclarations()[0];
- IASTName name= getName(declaration);
- IASTImageLocation loc= name.getImageLocation();
- assertLocation(MACRO, code, "result", 0, loc);
+ String code = getContents(1)[0].toString();
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+
+ IASTDeclaration declaration = tu.getDeclarations()[0];
+ IASTName name = getName(declaration);
+ IASTImageLocation loc = name.getImageLocation();
+ assertLocation(MACRO, code, "result", 0, loc);
}
-
// #define M result1
// #define F(x) x
// int F(result2);
// int F(M);
public void testMacroArgumentLocation() throws Exception {
- String code= getContents(1)[0].toString();
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
-
- IASTDeclaration declaration = tu.getDeclarations()[0];
- IASTName name= getName(declaration);
- IASTImageLocation loc= name.getImageLocation();
- assertLocation(MACRO_ARG, code, "result2", 0, loc);
-
- declaration = tu.getDeclarations()[1];
- name= getName(declaration);
- loc= name.getImageLocation();
- assertLocation(MACRO, code, "result1", 0, loc);
+ String code = getContents(1)[0].toString();
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+
+ IASTDeclaration declaration = tu.getDeclarations()[0];
+ IASTName name = getName(declaration);
+ IASTImageLocation loc = name.getImageLocation();
+ assertLocation(MACRO_ARG, code, "result2", 0, loc);
+
+ declaration = tu.getDeclarations()[1];
+ name = getName(declaration);
+ loc = name.getImageLocation();
+ assertLocation(MACRO, code, "result1", 0, loc);
}
private void assertLocation(int kind, String code, String name, int extra, IASTImageLocation loc) {
assertNotNull(loc);
assertEquals(kind, loc.getLocationKind());
assertEquals(code.indexOf(name), loc.getNodeOffset());
- assertEquals(name.length()-extra, loc.getNodeLength());
+ assertEquals(name.length() - extra, loc.getNodeLength());
}
private IASTName getName(IASTNode node) {
- final IASTName[] result= {null};
+ final IASTName[] result = { null };
node.accept(new ASTVisitor() {
{
- shouldVisitNames= true;
+ shouldVisitNames = true;
}
+
@Override
public int visit(IASTName name) {
- result[0]= name;
+ result[0] = name;
return PROCESS_ABORT;
}
});
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/LanguageExtensionsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/LanguageExtensionsTest.java
index 52dbc5e8689..174a818dab1 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/LanguageExtensionsTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/LanguageExtensionsTest.java
@@ -48,25 +48,25 @@ import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
* Testcases for non-gnu language extensions.
*/
public class LanguageExtensionsTest extends AST2TestBase {
-
- protected static final int SIZEOF_EXTENSION = 0x1;
+
+ protected static final int SIZEOF_EXTENSION = 0x1;
protected static final int FUNCTION_STYLE_ASM = 0x2;
protected static final int SLASH_PERCENT_COMMENT = 0x4;
public static TestSuite suite() {
return suite(LanguageExtensionsTest.class);
}
-
+
public LanguageExtensionsTest() {
super();
}
-
+
public LanguageExtensionsTest(String name) {
super(name);
}
-
+
private IASTTranslationUnit parse(ISourceCodeParser parser) {
- IASTTranslationUnit tu= parser.parse();
+ IASTTranslationUnit tu = parser.parse();
assertFalse(parser.encounteredError());
assertEquals(0, tu.getPreprocessorProblemsCount());
assertEquals(0, CPPVisitor.getProblems(tu).length);
@@ -76,8 +76,8 @@ public class LanguageExtensionsTest extends AST2TestBase {
protected IASTTranslationUnit parse(String code, IScannerExtensionConfiguration sext,
ICPPParserExtensionConfiguration pext) throws Exception {
FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
- IScanner scanner = new CPreprocessor(codeReader, new ScannerInfo(), ParserLanguage.CPP, NULL_LOG,
- sext, IncludeFileContentProvider.getSavedFilesProvider());
+ IScanner scanner = new CPreprocessor(codeReader, new ScannerInfo(), ParserLanguage.CPP, NULL_LOG, sext,
+ IncludeFileContentProvider.getSavedFilesProvider());
GNUCPPSourceParser parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, pext);
return parse(parser);
}
@@ -90,157 +90,143 @@ public class LanguageExtensionsTest extends AST2TestBase {
GNUCSourceParser parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, pext);
return parse(parser);
}
-
+
protected IASTTranslationUnit parseCPPWithExtension(String code, final int extensions) throws Exception {
- return parse(code,
- new GPPScannerExtensionConfiguration() {
- @Override
- public boolean supportSlashPercentComments() {
- return (extensions & SLASH_PERCENT_COMMENT) != 0;
- }
- },
- new GPPParserExtensionConfiguration() {
- @Override
- public boolean supportExtendedSizeofOperator() {
- return (extensions & SIZEOF_EXTENSION) != 0;
- }
- @Override
- public boolean supportFunctionStyleAssembler() {
- return (extensions & FUNCTION_STYLE_ASM) != 0;
- }
+ return parse(code, new GPPScannerExtensionConfiguration() {
+ @Override
+ public boolean supportSlashPercentComments() {
+ return (extensions & SLASH_PERCENT_COMMENT) != 0;
+ }
+ }, new GPPParserExtensionConfiguration() {
+ @Override
+ public boolean supportExtendedSizeofOperator() {
+ return (extensions & SIZEOF_EXTENSION) != 0;
}
- );
+
+ @Override
+ public boolean supportFunctionStyleAssembler() {
+ return (extensions & FUNCTION_STYLE_ASM) != 0;
+ }
+ });
}
protected IASTTranslationUnit parseCWithExtension(String code, final int extensions) throws Exception {
- return parse(code,
- new GCCScannerExtensionConfiguration() {
- @Override
- public boolean supportSlashPercentComments() {
- return (extensions & SLASH_PERCENT_COMMENT) != 0;
- }
- },
- new GCCParserExtensionConfiguration() {
- @Override
- public boolean supportExtendedSizeofOperator() {
- return (extensions & SIZEOF_EXTENSION) != 0;
- }
- @Override
- public boolean supportFunctionStyleAssembler() {
- return (extensions & FUNCTION_STYLE_ASM) != 0;
- }
+ return parse(code, new GCCScannerExtensionConfiguration() {
+ @Override
+ public boolean supportSlashPercentComments() {
+ return (extensions & SLASH_PERCENT_COMMENT) != 0;
+ }
+ }, new GCCParserExtensionConfiguration() {
+ @Override
+ public boolean supportExtendedSizeofOperator() {
+ return (extensions & SIZEOF_EXTENSION) != 0;
}
- );
+
+ @Override
+ public boolean supportFunctionStyleAssembler() {
+ return (extensions & FUNCTION_STYLE_ASM) != 0;
+ }
+ });
}
// parclass ExampleClass {
- // };
- public void testPOP_parclass() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(),
- POPCPPScannerExtensionConfiguration.getInstance(),
- POPCPPParserExtensionConfiguration.getInstance()
- );
- ICPPASTCompositeTypeSpecifier comp= getCompositeType(tu, 0);
- }
-
+ // };
+ public void testPOP_parclass() throws Exception {
+ IASTTranslationUnit tu = parse(getAboveComment(), POPCPPScannerExtensionConfiguration.getInstance(),
+ POPCPPParserExtensionConfiguration.getInstance());
+ ICPPASTCompositeTypeSpecifier comp = getCompositeType(tu, 0);
+ }
+
// parclass Table {
- // void sort([in, out, size=n] int *data, int n);
- // };
- public void testPOP_marshallingData() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(),
- POPCPPScannerExtensionConfiguration.getInstance(),
- POPCPPParserExtensionConfiguration.getInstance()
- );
- ICPPASTCompositeTypeSpecifier comp= getCompositeType(tu, 0);
- IASTSimpleDeclaration sd= getDeclaration(comp, 0);
- assertInstance(sd.getDeclarators()[0], IASTFunctionDeclarator.class);
- }
-
- // parclass Bird {
- // public:
- // Bird(float P) @{ od.power(P);
- // od.memory(100,60);
- // od.protocol("socket http"); };
- // };
- public void testPOP_objectDescriptor() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(),
- POPCPPScannerExtensionConfiguration.getInstance(),
- POPCPPParserExtensionConfiguration.getInstance()
- );
- ICPPASTCompositeTypeSpecifier comp= getCompositeType(tu, 0);
- IASTSimpleDeclaration sd= getDeclaration(comp, 1);
- assertInstance(sd.getDeclarators()[0], IASTFunctionDeclarator.class);
- }
-
- // @pack(Stack, Queue, List)
- // int a();
- public void testPOP_packDirective() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(),
- POPCPPScannerExtensionConfiguration.getInstance(),
- POPCPPParserExtensionConfiguration.getInstance()
- );
- IASTSimpleDeclaration sd= getDeclaration(tu, 0);
- assertInstance(sd.getDeclarators()[0], IASTFunctionDeclarator.class);
- }
-
-
-
- // void test() {
- // sizeof(int, 1);
- // sizeof(int, 2, 2);
- // }
- public void testSizeofExtension() throws Exception {
- IASTTranslationUnit tu= parseCWithExtension(getAboveComment(), SIZEOF_EXTENSION);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTUnaryExpression expr= getExpressionOfStatement(fdef, 0);
- assertEquals(IASTUnaryExpression.op_sizeof, expr.getOperator());
- assertInstance(expr.getOperand(), IASTExpressionList.class);
- expr= getExpressionOfStatement(fdef, 1);
- assertEquals(IASTUnaryExpression.op_sizeof, expr.getOperator());
- assertInstance(expr.getOperand(), IASTExpressionList.class);
-
- tu= parseCPPWithExtension(getAboveComment(), SIZEOF_EXTENSION);
- fdef= getDeclaration(tu, 0);
- expr= getExpressionOfStatement(fdef, 0);
- assertEquals(IASTUnaryExpression.op_sizeof, expr.getOperator());
- assertInstance(expr.getOperand(), IASTExpressionList.class);
- expr= getExpressionOfStatement(fdef, 1);
- assertEquals(IASTUnaryExpression.op_sizeof, expr.getOperator());
- assertInstance(expr.getOperand(), IASTExpressionList.class);
- }
-
- // asm volatile int a1() {
- // assembler code here
- // }
- // asm int a2() {
- // assembler code here
- // }
- // asm volatile a3(int) {
- // assembler code here
- // }
- // asm a4() {
- // assembler code here
- // }
- public void testFunctionStyleAssembler() throws Exception {
- IASTTranslationUnit tu= parseCWithExtension(getAboveComment(), FUNCTION_STYLE_ASM);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- fdef= getDeclaration(tu, 1);
- fdef= getDeclaration(tu, 2);
- fdef= getDeclaration(tu, 3);
-
- tu= parseCPPWithExtension(getAboveComment(), FUNCTION_STYLE_ASM);
- fdef= getDeclaration(tu, 0);
- fdef= getDeclaration(tu, 1);
- fdef= getDeclaration(tu, 2);
- fdef= getDeclaration(tu, 3);
- }
-
+ // void sort([in, out, size=n] int *data, int n);
+ // };
+ public void testPOP_marshallingData() throws Exception {
+ IASTTranslationUnit tu = parse(getAboveComment(), POPCPPScannerExtensionConfiguration.getInstance(),
+ POPCPPParserExtensionConfiguration.getInstance());
+ ICPPASTCompositeTypeSpecifier comp = getCompositeType(tu, 0);
+ IASTSimpleDeclaration sd = getDeclaration(comp, 0);
+ assertInstance(sd.getDeclarators()[0], IASTFunctionDeclarator.class);
+ }
+
+ // parclass Bird {
+ // public:
+ // Bird(float P) @{ od.power(P);
+ // od.memory(100,60);
+ // od.protocol("socket http"); };
+ // };
+ public void testPOP_objectDescriptor() throws Exception {
+ IASTTranslationUnit tu = parse(getAboveComment(), POPCPPScannerExtensionConfiguration.getInstance(),
+ POPCPPParserExtensionConfiguration.getInstance());
+ ICPPASTCompositeTypeSpecifier comp = getCompositeType(tu, 0);
+ IASTSimpleDeclaration sd = getDeclaration(comp, 1);
+ assertInstance(sd.getDeclarators()[0], IASTFunctionDeclarator.class);
+ }
+
+ // @pack(Stack, Queue, List)
+ // int a();
+ public void testPOP_packDirective() throws Exception {
+ IASTTranslationUnit tu = parse(getAboveComment(), POPCPPScannerExtensionConfiguration.getInstance(),
+ POPCPPParserExtensionConfiguration.getInstance());
+ IASTSimpleDeclaration sd = getDeclaration(tu, 0);
+ assertInstance(sd.getDeclarators()[0], IASTFunctionDeclarator.class);
+ }
+
+ // void test() {
+ // sizeof(int, 1);
+ // sizeof(int, 2, 2);
+ // }
+ public void testSizeofExtension() throws Exception {
+ IASTTranslationUnit tu = parseCWithExtension(getAboveComment(), SIZEOF_EXTENSION);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTUnaryExpression expr = getExpressionOfStatement(fdef, 0);
+ assertEquals(IASTUnaryExpression.op_sizeof, expr.getOperator());
+ assertInstance(expr.getOperand(), IASTExpressionList.class);
+ expr = getExpressionOfStatement(fdef, 1);
+ assertEquals(IASTUnaryExpression.op_sizeof, expr.getOperator());
+ assertInstance(expr.getOperand(), IASTExpressionList.class);
+
+ tu = parseCPPWithExtension(getAboveComment(), SIZEOF_EXTENSION);
+ fdef = getDeclaration(tu, 0);
+ expr = getExpressionOfStatement(fdef, 0);
+ assertEquals(IASTUnaryExpression.op_sizeof, expr.getOperator());
+ assertInstance(expr.getOperand(), IASTExpressionList.class);
+ expr = getExpressionOfStatement(fdef, 1);
+ assertEquals(IASTUnaryExpression.op_sizeof, expr.getOperator());
+ assertInstance(expr.getOperand(), IASTExpressionList.class);
+ }
+
+ // asm volatile int a1() {
+ // assembler code here
+ // }
+ // asm int a2() {
+ // assembler code here
+ // }
+ // asm volatile a3(int) {
+ // assembler code here
+ // }
+ // asm a4() {
+ // assembler code here
+ // }
+ public void testFunctionStyleAssembler() throws Exception {
+ IASTTranslationUnit tu = parseCWithExtension(getAboveComment(), FUNCTION_STYLE_ASM);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ fdef = getDeclaration(tu, 1);
+ fdef = getDeclaration(tu, 2);
+ fdef = getDeclaration(tu, 3);
+
+ tu = parseCPPWithExtension(getAboveComment(), FUNCTION_STYLE_ASM);
+ fdef = getDeclaration(tu, 0);
+ fdef = getDeclaration(tu, 1);
+ fdef = getDeclaration(tu, 2);
+ fdef = getDeclaration(tu, 3);
+ }
+
// /% a comment %/
// int a;
public void testSlashPercentComment() throws Exception {
- IASTTranslationUnit tu= parseCWithExtension(getAboveComment(), SLASH_PERCENT_COMMENT);
+ IASTTranslationUnit tu = parseCWithExtension(getAboveComment(), SLASH_PERCENT_COMMENT);
- IASTDeclaration d= getDeclaration(tu, 0);
+ IASTDeclaration d = getDeclaration(tu, 0);
assertEquals("int a;", d.getRawSignature());
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java
index d20a2d8bf06..15e5fc21154 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java
@@ -47,1484 +47,1475 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
* @author jcamelon
*/
public class QuickParser2Tests extends TestCase {
- private static final NullLogService NULL_LOG = new NullLogService();
+ private static final NullLogService NULL_LOG = new NullLogService();
- public QuickParser2Tests() {
- super();
- }
+ public QuickParser2Tests() {
+ super();
+ }
+
+ public QuickParser2Tests(String name) {
+ super(name);
+ }
- public QuickParser2Tests(String name) {
- super(name);
- }
-
- @Override
+ @Override
protected void setUp() throws Exception {
- CPPASTNameBase.sAllowRecursionBindings= false;
- CPPASTNameBase.sAllowNameComputation= false;
+ CPPASTNameBase.sAllowRecursionBindings = false;
+ CPPASTNameBase.sAllowNameComputation = false;
+ }
+
+ /**
+ * Test code: int x = 5; Purpose: to test the simple declaration in it's
+ * simplest form.
+ */
+ public void testIntGlobal() throws Exception {
+ // Parse and get the translation Unit
+ parse("int x = 5;");
}
/**
- * Test code: int x = 5; Purpose: to test the simple declaration in it's
- * simplest form.
- */
- public void testIntGlobal() throws Exception {
- // Parse and get the translation Unit
- parse("int x = 5;");
- }
-
- /**
- * Test code: class A { } a; Purpose: tests the use of a classSpecifier in
- */
- public void testEmptyClass() throws Exception {
- // Parse and get the translation unit
- Writer code = new StringWriter();
- code.write("class A { } a;");
- parse(code.toString());
- }
-
- /**
- * Test code: class A { public: int x; }; Purpose: tests a declaration in a
- * class scope.
- */
- public void testSimpleClassMember() throws Exception {
- // Parse and get the translaton unit
- Writer code = new StringWriter();
- code.write("class A { public: int x; };");
- parse(code.toString());
- }
-
- protected void parse(String code, boolean expectedToPass,
- ParserLanguage lang) throws Exception {
- parse(code, expectedToPass, lang, false);
- }
-
- protected void parse(String code, boolean expectedToPass) throws Exception {
- parse(code, expectedToPass, ParserLanguage.CPP);
- }
-
- /**
- * @param code
- */
- protected void parse(String code) throws Exception {
- parse(code, true, ParserLanguage.CPP);
- }
-
- public void testNamespaceDefinition() throws Exception {
- for (int i = 0; i < 2; ++i) {
- if (i == 0)
- parse("namespace KingJohn { int x; }");
- else
- parse("namespace { int x; }");
- }
- }
-
- public void testLinkageSpecification() throws Exception {
- for (int i = 0; i < 2; ++i) {
- if (i == 0)
- parse("extern \"C\" { int x(void); }");
- else
- parse("extern \"ADA\" int x(void);");
- }
- }
-
- public void testEnumSpecifier() throws Exception {
- Writer code = new StringWriter();
- code.write("enum { yo, go = 3, away };\n");
- code.write("enum hasAString { last = 666 };");
- parse(code.toString());
- }
-
- public void testTypedef() throws Exception {
- parse("typedef const struct A * const cpStructA;");
- }
-
- public void testUsingClauses() throws Exception {
- Writer code = new StringWriter();
- code.write("using namespace A::B::C;\n");
- code.write("using namespace C;\n");
- code.write("using B::f;\n");
- code.write("using ::f;\n");
- code.write("using typename crap::de::crap;");
- parse(code.toString());
- }
-
- /**
- * Test code: class A : public B, private C, virtual protected D { public:
- * int x, y; float a,b,c; } Purpose: tests a declaration in a class scope.
- */
- public void testSimpleClassMembers() throws Exception {
- // Parse and get the translaton unit
- Writer code = new StringWriter();
- code.write("class A : public B, private C, virtual protected D { public: int x, y; float a,b,c; };");
- parse(code.toString());
- }
-
- /**
- * Test code: int myFunction(void);
- */
- public void testSimpleFunctionDeclaration() throws Exception {
- // Parse and get the translaton unit
- Writer code = new StringWriter();
- code.write("void myFunction(void);");
- parse(code.toString());
- }
-
- /**
- * Test code: bool myFunction(int parm1 = 3 * 4, double parm2);
- *
- * @throws Exception
- */
- public void testFunctionDeclarationWithParameters() throws Exception {
- // Parse and get the translaton unit
- Writer code = new StringWriter();
- code.write("bool myFunction(int parm1 = 3 * 4, double parm2);");
- parse(code.toString());
- }
-
- public void testAssignmentExpressions() throws Exception {
- parse("int x = y = z = 5;");
- }
-
- public void testBug39348() throws Exception {
- parse("unsigned char a[sizeof (struct sss)];");
- }
-
- public void testBug39501() throws Exception {
- parse("struct A { A() throw (int); };");
- }
-
- public void testBug39349() throws Exception {
- parse("enum foo { foo1 = 0, foo2 = 0xffffffffffffffffULL, foo3 = 0xf0fffffffffffffeLLU };");
- }
-
- public void testBug39544() throws Exception {
- parse("wchar_t wc = L'X';");
- }
-
- public void testBug36290() throws Exception {
- parse("typedef void (A:: * pMethod) (void); ");
- parse("typedef void (boo) (void); ");
- parse("typedef void boo (void); ");
- }
-
- public void testBug36769B() throws Exception {
- parse("class X { operator int(); }; \n");
- parse("class X { operator int*(); }; \n");
- parse("class X { operator int&(); }; \n");
- parse("class X { operator A(); }; \n");
- parse("class X { operator A*(); }; \n");
- parse("class X { operator A&(); }; \n");
-
- parse("X::operator int() { } \n");
- parse("X::operator int*() { } \n");
- parse("X::operator int&() { } \n");
- parse("X::operator A() { } \n");
- parse("X::operator A*() { } \n");
- parse("X::operator A&() { } \n");
-
- parse("template <class A,B> class X<A,C> { operator int(); }; \n");
- parse("template <class A,B> class X<A,C> { operator int*(); }; \n");
- parse("template <class A,B> class X<A,C> { operator int&(); }; \n");
- parse("template <class A,B> class X<A,C> { operator A(); }; \n");
- parse("template <class A,B> class X<A,C> { operator A*(); }; \n");
- parse("template <class A,B> class X<A,C> { operator A&(); }; \n");
-
- parse("template <class A,B> X<A,C>::operator int() { }; \n");
- parse("template <class A,B> X<A,C>::operator int*() { }; \n");
- parse("template <class A,B> X<A,C>::operator int&() { }; \n");
- parse("template <class A,B> X<A,C>::operator A() { }; \n");
- parse("template <class A,B> X<A,C>::operator A*() { }; \n");
- parse("template <class A,B> X<A,C>::operator A&() { }; \n");
- }
+ * Test code: class A { } a; Purpose: tests the use of a classSpecifier in
+ */
+ public void testEmptyClass() throws Exception {
+ // Parse and get the translation unit
+ Writer code = new StringWriter();
+ code.write("class A { } a;");
+ parse(code.toString());
+ }
+
+ /**
+ * Test code: class A { public: int x; }; Purpose: tests a declaration in a
+ * class scope.
+ */
+ public void testSimpleClassMember() throws Exception {
+ // Parse and get the translaton unit
+ Writer code = new StringWriter();
+ code.write("class A { public: int x; };");
+ parse(code.toString());
+ }
+
+ protected void parse(String code, boolean expectedToPass, ParserLanguage lang) throws Exception {
+ parse(code, expectedToPass, lang, false);
+ }
+
+ protected void parse(String code, boolean expectedToPass) throws Exception {
+ parse(code, expectedToPass, ParserLanguage.CPP);
+ }
+
+ /**
+ * @param code
+ */
+ protected void parse(String code) throws Exception {
+ parse(code, true, ParserLanguage.CPP);
+ }
+
+ public void testNamespaceDefinition() throws Exception {
+ for (int i = 0; i < 2; ++i) {
+ if (i == 0)
+ parse("namespace KingJohn { int x; }");
+ else
+ parse("namespace { int x; }");
+ }
+ }
+
+ public void testLinkageSpecification() throws Exception {
+ for (int i = 0; i < 2; ++i) {
+ if (i == 0)
+ parse("extern \"C\" { int x(void); }");
+ else
+ parse("extern \"ADA\" int x(void);");
+ }
+ }
+
+ public void testEnumSpecifier() throws Exception {
+ Writer code = new StringWriter();
+ code.write("enum { yo, go = 3, away };\n");
+ code.write("enum hasAString { last = 666 };");
+ parse(code.toString());
+ }
+
+ public void testTypedef() throws Exception {
+ parse("typedef const struct A * const cpStructA;");
+ }
+
+ public void testUsingClauses() throws Exception {
+ Writer code = new StringWriter();
+ code.write("using namespace A::B::C;\n");
+ code.write("using namespace C;\n");
+ code.write("using B::f;\n");
+ code.write("using ::f;\n");
+ code.write("using typename crap::de::crap;");
+ parse(code.toString());
+ }
+
+ /**
+ * Test code: class A : public B, private C, virtual protected D { public:
+ * int x, y; float a,b,c; } Purpose: tests a declaration in a class scope.
+ */
+ public void testSimpleClassMembers() throws Exception {
+ // Parse and get the translaton unit
+ Writer code = new StringWriter();
+ code.write("class A : public B, private C, virtual protected D { public: int x, y; float a,b,c; };");
+ parse(code.toString());
+ }
+
+ /**
+ * Test code: int myFunction(void);
+ */
+ public void testSimpleFunctionDeclaration() throws Exception {
+ // Parse and get the translaton unit
+ Writer code = new StringWriter();
+ code.write("void myFunction(void);");
+ parse(code.toString());
+ }
+
+ /**
+ * Test code: bool myFunction(int parm1 = 3 * 4, double parm2);
+ *
+ * @throws Exception
+ */
+ public void testFunctionDeclarationWithParameters() throws Exception {
+ // Parse and get the translaton unit
+ Writer code = new StringWriter();
+ code.write("bool myFunction(int parm1 = 3 * 4, double parm2);");
+ parse(code.toString());
+ }
+
+ public void testAssignmentExpressions() throws Exception {
+ parse("int x = y = z = 5;");
+ }
+
+ public void testBug39348() throws Exception {
+ parse("unsigned char a[sizeof (struct sss)];");
+ }
+
+ public void testBug39501() throws Exception {
+ parse("struct A { A() throw (int); };");
+ }
+
+ public void testBug39349() throws Exception {
+ parse("enum foo { foo1 = 0, foo2 = 0xffffffffffffffffULL, foo3 = 0xf0fffffffffffffeLLU };");
+ }
+
+ public void testBug39544() throws Exception {
+ parse("wchar_t wc = L'X';");
+ }
+
+ public void testBug36290() throws Exception {
+ parse("typedef void (A:: * pMethod) (void); ");
+ parse("typedef void (boo) (void); ");
+ parse("typedef void boo (void); ");
+ }
+
+ public void testBug36769B() throws Exception {
+ parse("class X { operator int(); }; \n");
+ parse("class X { operator int*(); }; \n");
+ parse("class X { operator int&(); }; \n");
+ parse("class X { operator A(); }; \n");
+ parse("class X { operator A*(); }; \n");
+ parse("class X { operator A&(); }; \n");
+
+ parse("X::operator int() { } \n");
+ parse("X::operator int*() { } \n");
+ parse("X::operator int&() { } \n");
+ parse("X::operator A() { } \n");
+ parse("X::operator A*() { } \n");
+ parse("X::operator A&() { } \n");
+
+ parse("template <class A,B> class X<A,C> { operator int(); }; \n");
+ parse("template <class A,B> class X<A,C> { operator int*(); }; \n");
+ parse("template <class A,B> class X<A,C> { operator int&(); }; \n");
+ parse("template <class A,B> class X<A,C> { operator A(); }; \n");
+ parse("template <class A,B> class X<A,C> { operator A*(); }; \n");
+ parse("template <class A,B> class X<A,C> { operator A&(); }; \n");
+
+ parse("template <class A,B> X<A,C>::operator int() { }; \n");
+ parse("template <class A,B> X<A,C>::operator int*() { }; \n");
+ parse("template <class A,B> X<A,C>::operator int&() { }; \n");
+ parse("template <class A,B> X<A,C>::operator A() { }; \n");
+ parse("template <class A,B> X<A,C>::operator A*() { }; \n");
+ parse("template <class A,B> X<A,C>::operator A&() { }; \n");
+ }
// failing, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236856
- public void _testBug36932C() throws Exception {
- parse("X::X() : var(new int) {}");
- parse("X::X() : var(new int(5)) {}");
- parse("X::X() : var(new int(B)) {}");
- parse("X::X() : var(new int(B,C)) {}");
- parse("X::X() : var(new int[5]) {}");
- parse("X::X() : var(new int[5][10]) {}");
- parse("X::X() : var(new int[B]) {}");
- parse("X::X() : var(new int[B][C][D]) {}");
-
- parse("X::X() : var(new A) {}");
- parse("X::X() : var(new A(5)) {}");
- parse("X::X() : var(new A(B)) {}");
- parse("X::X() : var(new A(B,C)) {}");
- parse("X::X() : var(new A[5]) {}");
- parse("X::X() : var(new A[5][10]) {}");
- parse("X::X() : var(new A[B]) {}");
- parse("X::X() : var(new A[B][C][D]) {}");
-
- parse("X::X() : var(new (int)) {}");
- parse("X::X() : var(new (int)(5)) {}");
- parse("X::X() : var(new (int)(B)) {}");
- parse("X::X() : var(new (int)(B,C)) {}");
- parse("X::X() : var(new (int[5])) {}");
- parse("X::X() : var(new (int[5][10])) {}");
- parse("X::X() : var(new (int[B])) {}");
- parse("X::X() : var(new (int[B][C][D])) {}");
-
- parse("X::X() : var(new (A)) {}");
- parse("X::X() : var(new (A)(5)) {}");
- parse("X::X() : var(new (A)(B)) {}");
- parse("X::X() : var(new (A)(B,C)) {}");
- parse("X::X() : var(new (A[5])) {}");
- parse("X::X() : var(new (A[5][10])) {}");
- parse("X::X() : var(new (A[B])) {}");
- parse("X::X() : var(new (A[B][C][D])) {}");
-
- parse("X::X() : var(new (0) int) {}");
- parse("X::X() : var(new (0) int(5)) {}");
- parse("X::X() : var(new (0) int(B)) {}");
- parse("X::X() : var(new (0) int(B,C)) {}");
- parse("X::X() : var(new (0) int[5]) {}");
- parse("X::X() : var(new (0) int[5][10]) {}");
- parse("X::X() : var(new (0) int[B]) {}");
- parse("X::X() : var(new (0) int[B][C][D]) {}");
-
- parse("X::X() : var(new (0) A) {}");
- parse("X::X() : var(new (0) A(5)) {}");
- parse("X::X() : var(new (0) A(B)) {}");
- parse("X::X() : var(new (0) A(B,C)) {}");
- parse("X::X() : var(new (0) A[5]) {}");
- parse("X::X() : var(new (0) A[5][10]) {}");
- parse("X::X() : var(new (0) A[B]) {}");
- parse("X::X() : var(new (0) A[B][C][D]) {}");
-
- parse("X::X() : var(new (0) (int)) {}");
- parse("X::X() : var(new (0) (int)(5)) {}");
- parse("X::X() : var(new (0) (int)(B)) {}");
- parse("X::X() : var(new (0) (int)(B,C)) {}");
- parse("X::X() : var(new (0) (int[5])) {}");
- parse("X::X() : var(new (0) (int[5][10])) {}");
- parse("X::X() : var(new (0) (int[B])) {}");
- parse("X::X() : var(new (0) (int[B][C][D])) {}");
-
- parse("X::X() : var(new (0) (A)) {}");
- parse("X::X() : var(new (0) (A)(5)) {}");
- parse("X::X() : var(new (0) (A)(B)) {}");
- parse("X::X() : var(new (0) (A)(B,C)) {}");
- parse("X::X() : var(new (0) (A[5])) {}");
- parse("X::X() : var(new (0) (A[5][10])) {}");
- parse("X::X() : var(new (0) (A[B])) {}");
- parse("X::X() : var(new (0) (A[B][C][D])) {}");
-
- parse("X::X() : var(new (P) int) {}");
- parse("X::X() : var(new (P) int(5)) {}");
- parse("X::X() : var(new (P) int(B)) {}");
- parse("X::X() : var(new (P) int(B,C)) {}");
- parse("X::X() : var(new (P) int[5]) {}");
- parse("X::X() : var(new (P) int[5][10]) {}");
- parse("X::X() : var(new (P) int[B]) {}");
- parse("X::X() : var(new (P) int[B][C][D]) {}");
-
- parse("X::X() : var(new (P) A) {}");
- parse("X::X() : var(new (P) A(5)) {}");
- parse("X::X() : var(new (P) A(B)) {}");
- parse("X::X() : var(new (P) A(B,C)) {}");
- parse("X::X() : var(new (P) A[5]) {}");
- parse("X::X() : var(new (P) A[5][10]) {}");
- parse("X::X() : var(new (P) A[B]) {}");
- parse("X::X() : var(new (P) A[B][C][D]) {}");
-
- parse("X::X() : var(new (P) (int)) {}");
- parse("X::X() : var(new (P) (int)(5)) {}");
- parse("X::X() : var(new (P) (int)(B)) {}");
- parse("X::X() : var(new (P) (int)(B,C)) {}");
- parse("X::X() : var(new (P) (int[5])) {}");
- parse("X::X() : var(new (P) (int[5][10])) {}");
- parse("X::X() : var(new (P) (int[B])) {}");
- parse("X::X() : var(new (P) (int[B][C][D])) {}");
-
- parse("X::X() : var(new (P) (A)) {}");
- parse("X::X() : var(new (P) (A)(5)) {}");
- parse("X::X() : var(new (P) (A)(B)) {}");
- parse("X::X() : var(new (P) (A)(B,C)) {}");
- parse("X::X() : var(new (P) (A[5])) {}");
- parse("X::X() : var(new (P) (A[5][10])) {}");
- parse("X::X() : var(new (P) (A[B])) {}");
- parse("X::X() : var(new (P) (A[B][C][D])) {}");
- }
-
- public void testBugSingleton192() throws Exception {
- parse("int Test::* pMember_;");
- }
-
- public void testBug36931() throws Exception {
- parse("A::nested::nested(){}; ");
- parse("int A::nested::foo() {} ");
- parse("int A::nested::operator+() {} ");
- parse("A::nested::operator int() {} ");
- parse("static const int A::nested::i = 1; ");
-
- parse("template <class B,C> A<B>::nested::nested(){}; ");
- parse("template <class B,C> int A::nested<B,D>::foo() {} ");
- parse("template <class B,C> int A<B,C>::nested<C,B>::operator+() {} ");
- parse("template <class B,C> A::nested::operator int() {} ");
- }
-
- public void testBug37019() throws Exception {
- parse("static const A a(1, 0);");
- }
-
- public void testBug36766and36769A() throws Exception {
- Writer code = new StringWriter();
- code.write("template <class _CharT, class _Alloc>\n");
- code.write("rope<_CharT, _Alloc>::rope(size_t __n, _CharT __c,\n");
- code.write("const allocator_type& __a): _Base(__a)\n");
- code.write("{}\n");
- parse(code.toString());
- }
-
- public void testBug36766and36769B() throws Exception {
- Writer code = new StringWriter();
- code.write("template<class _CharT>\n");
- code.write("bool _Rope_insert_char_consumer<_CharT>::operator()\n");
- code.write("(const _CharT* __leaf, size_t __n)\n");
- code.write("{}\n");
- parse(code.toString());
- }
-
- public void testBug36766and36769C() throws Exception {
- //TODO - requires CPPVisitor
- Writer code = new StringWriter();
- code.write("template <class _CharT, class _Alloc>\n");
- code.write("_Rope_char_ref_proxy<_CharT, _Alloc>&\n");
- code
- .write("_Rope_char_ref_proxy<_CharT, _Alloc>::operator= (_CharT __c)\n");
- code.write("{}\n");
- parse(code.toString());
- }
-
- public void testBug36766and36769D() throws Exception {
- //TODO - requires CPPVisitor
- Writer code = new StringWriter();
- code.write("template <class _CharT, class _Alloc>\n");
- code.write("rope<_CharT, _Alloc>::~rope()\n");
- code.write("{}\n");
- parse(code.toString());
- }
-
- public void testBug36932A() throws Exception {
- parse("A::A() : var(new char[ (unsigned)bufSize ]) {}");
- }
+ public void _testBug36932C() throws Exception {
+ parse("X::X() : var(new int) {}");
+ parse("X::X() : var(new int(5)) {}");
+ parse("X::X() : var(new int(B)) {}");
+ parse("X::X() : var(new int(B,C)) {}");
+ parse("X::X() : var(new int[5]) {}");
+ parse("X::X() : var(new int[5][10]) {}");
+ parse("X::X() : var(new int[B]) {}");
+ parse("X::X() : var(new int[B][C][D]) {}");
+
+ parse("X::X() : var(new A) {}");
+ parse("X::X() : var(new A(5)) {}");
+ parse("X::X() : var(new A(B)) {}");
+ parse("X::X() : var(new A(B,C)) {}");
+ parse("X::X() : var(new A[5]) {}");
+ parse("X::X() : var(new A[5][10]) {}");
+ parse("X::X() : var(new A[B]) {}");
+ parse("X::X() : var(new A[B][C][D]) {}");
+
+ parse("X::X() : var(new (int)) {}");
+ parse("X::X() : var(new (int)(5)) {}");
+ parse("X::X() : var(new (int)(B)) {}");
+ parse("X::X() : var(new (int)(B,C)) {}");
+ parse("X::X() : var(new (int[5])) {}");
+ parse("X::X() : var(new (int[5][10])) {}");
+ parse("X::X() : var(new (int[B])) {}");
+ parse("X::X() : var(new (int[B][C][D])) {}");
+
+ parse("X::X() : var(new (A)) {}");
+ parse("X::X() : var(new (A)(5)) {}");
+ parse("X::X() : var(new (A)(B)) {}");
+ parse("X::X() : var(new (A)(B,C)) {}");
+ parse("X::X() : var(new (A[5])) {}");
+ parse("X::X() : var(new (A[5][10])) {}");
+ parse("X::X() : var(new (A[B])) {}");
+ parse("X::X() : var(new (A[B][C][D])) {}");
+
+ parse("X::X() : var(new (0) int) {}");
+ parse("X::X() : var(new (0) int(5)) {}");
+ parse("X::X() : var(new (0) int(B)) {}");
+ parse("X::X() : var(new (0) int(B,C)) {}");
+ parse("X::X() : var(new (0) int[5]) {}");
+ parse("X::X() : var(new (0) int[5][10]) {}");
+ parse("X::X() : var(new (0) int[B]) {}");
+ parse("X::X() : var(new (0) int[B][C][D]) {}");
+
+ parse("X::X() : var(new (0) A) {}");
+ parse("X::X() : var(new (0) A(5)) {}");
+ parse("X::X() : var(new (0) A(B)) {}");
+ parse("X::X() : var(new (0) A(B,C)) {}");
+ parse("X::X() : var(new (0) A[5]) {}");
+ parse("X::X() : var(new (0) A[5][10]) {}");
+ parse("X::X() : var(new (0) A[B]) {}");
+ parse("X::X() : var(new (0) A[B][C][D]) {}");
+
+ parse("X::X() : var(new (0) (int)) {}");
+ parse("X::X() : var(new (0) (int)(5)) {}");
+ parse("X::X() : var(new (0) (int)(B)) {}");
+ parse("X::X() : var(new (0) (int)(B,C)) {}");
+ parse("X::X() : var(new (0) (int[5])) {}");
+ parse("X::X() : var(new (0) (int[5][10])) {}");
+ parse("X::X() : var(new (0) (int[B])) {}");
+ parse("X::X() : var(new (0) (int[B][C][D])) {}");
+
+ parse("X::X() : var(new (0) (A)) {}");
+ parse("X::X() : var(new (0) (A)(5)) {}");
+ parse("X::X() : var(new (0) (A)(B)) {}");
+ parse("X::X() : var(new (0) (A)(B,C)) {}");
+ parse("X::X() : var(new (0) (A[5])) {}");
+ parse("X::X() : var(new (0) (A[5][10])) {}");
+ parse("X::X() : var(new (0) (A[B])) {}");
+ parse("X::X() : var(new (0) (A[B][C][D])) {}");
+
+ parse("X::X() : var(new (P) int) {}");
+ parse("X::X() : var(new (P) int(5)) {}");
+ parse("X::X() : var(new (P) int(B)) {}");
+ parse("X::X() : var(new (P) int(B,C)) {}");
+ parse("X::X() : var(new (P) int[5]) {}");
+ parse("X::X() : var(new (P) int[5][10]) {}");
+ parse("X::X() : var(new (P) int[B]) {}");
+ parse("X::X() : var(new (P) int[B][C][D]) {}");
+
+ parse("X::X() : var(new (P) A) {}");
+ parse("X::X() : var(new (P) A(5)) {}");
+ parse("X::X() : var(new (P) A(B)) {}");
+ parse("X::X() : var(new (P) A(B,C)) {}");
+ parse("X::X() : var(new (P) A[5]) {}");
+ parse("X::X() : var(new (P) A[5][10]) {}");
+ parse("X::X() : var(new (P) A[B]) {}");
+ parse("X::X() : var(new (P) A[B][C][D]) {}");
+
+ parse("X::X() : var(new (P) (int)) {}");
+ parse("X::X() : var(new (P) (int)(5)) {}");
+ parse("X::X() : var(new (P) (int)(B)) {}");
+ parse("X::X() : var(new (P) (int)(B,C)) {}");
+ parse("X::X() : var(new (P) (int[5])) {}");
+ parse("X::X() : var(new (P) (int[5][10])) {}");
+ parse("X::X() : var(new (P) (int[B])) {}");
+ parse("X::X() : var(new (P) (int[B][C][D])) {}");
+
+ parse("X::X() : var(new (P) (A)) {}");
+ parse("X::X() : var(new (P) (A)(5)) {}");
+ parse("X::X() : var(new (P) (A)(B)) {}");
+ parse("X::X() : var(new (P) (A)(B,C)) {}");
+ parse("X::X() : var(new (P) (A[5])) {}");
+ parse("X::X() : var(new (P) (A[5][10])) {}");
+ parse("X::X() : var(new (P) (A[B])) {}");
+ parse("X::X() : var(new (P) (A[B][C][D])) {}");
+ }
+
+ public void testBugSingleton192() throws Exception {
+ parse("int Test::* pMember_;");
+ }
+
+ public void testBug36931() throws Exception {
+ parse("A::nested::nested(){}; ");
+ parse("int A::nested::foo() {} ");
+ parse("int A::nested::operator+() {} ");
+ parse("A::nested::operator int() {} ");
+ parse("static const int A::nested::i = 1; ");
+
+ parse("template <class B,C> A<B>::nested::nested(){}; ");
+ parse("template <class B,C> int A::nested<B,D>::foo() {} ");
+ parse("template <class B,C> int A<B,C>::nested<C,B>::operator+() {} ");
+ parse("template <class B,C> A::nested::operator int() {} ");
+ }
+
+ public void testBug37019() throws Exception {
+ parse("static const A a(1, 0);");
+ }
+
+ public void testBug36766and36769A() throws Exception {
+ Writer code = new StringWriter();
+ code.write("template <class _CharT, class _Alloc>\n");
+ code.write("rope<_CharT, _Alloc>::rope(size_t __n, _CharT __c,\n");
+ code.write("const allocator_type& __a): _Base(__a)\n");
+ code.write("{}\n");
+ parse(code.toString());
+ }
+
+ public void testBug36766and36769B() throws Exception {
+ Writer code = new StringWriter();
+ code.write("template<class _CharT>\n");
+ code.write("bool _Rope_insert_char_consumer<_CharT>::operator()\n");
+ code.write("(const _CharT* __leaf, size_t __n)\n");
+ code.write("{}\n");
+ parse(code.toString());
+ }
+
+ public void testBug36766and36769C() throws Exception {
+ //TODO - requires CPPVisitor
+ Writer code = new StringWriter();
+ code.write("template <class _CharT, class _Alloc>\n");
+ code.write("_Rope_char_ref_proxy<_CharT, _Alloc>&\n");
+ code.write("_Rope_char_ref_proxy<_CharT, _Alloc>::operator= (_CharT __c)\n");
+ code.write("{}\n");
+ parse(code.toString());
+ }
+
+ public void testBug36766and36769D() throws Exception {
+ //TODO - requires CPPVisitor
+ Writer code = new StringWriter();
+ code.write("template <class _CharT, class _Alloc>\n");
+ code.write("rope<_CharT, _Alloc>::~rope()\n");
+ code.write("{}\n");
+ parse(code.toString());
+ }
+
+ public void testBug36932A() throws Exception {
+ parse("A::A() : var(new char[ (unsigned)bufSize ]) {}");
+ }
// failing, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236856
- public void _testBug36932B() throws Exception {
- parse(" p = new int; ");
- parse(" p = new int(5); ");
- parse(" p = new int(B); ");
- parse(" p = new int(B,C); ");
- parse(" p = new int[5]; ");
- parse(" p = new int[5][10]; ");
- parse(" p = new int[B]; ");
- parse(" p = new int[B][C][D]; ");
-
- parse(" p = new A; ");
- parse(" p = new A(5); ");
- parse(" p = new A(B); ");
- parse(" p = new A(B,C); ");
- parse(" p = new A[5]; ");
- parse(" p = new A[5][10]; ");
- parse(" p = new A[B]; ");
- parse(" p = new A[B][C][D]; ");
-
- parse(" p = new (int); ");
- parse(" p = new (int)(5); ");
- parse(" p = new (int)(B); ");
- parse(" p = new (int)(B,C); ");
- parse(" p = new (int[5]); ");
- parse(" p = new (int[5][10]); ");
- parse(" p = new (int[B]); ");
- parse(" p = new (int[B][C][D]); ");
-
- parse(" p = new (A); ");
- parse(" p = new (A)(5); ");
- parse(" p = new (A)(B); ");
- parse(" p = new (A)(B,C); ");
- parse(" p = new (A[5]); ");
- parse(" p = new (A[5][10]); ");
- parse(" p = new (A[B]); ");
- parse(" p = new (A[B][C][D]); ");
-
- parse(" p = new (0) int; ");
- parse(" p = new (0) int(5); ");
- parse(" p = new (0) int(B); ");
- parse(" p = new (0) int(B,C); ");
- parse(" p = new (0) int[5]; ");
- parse(" p = new (0) int[5][10]; ");
- parse(" p = new (0) int[B]; ");
- parse(" p = new (0) int[B][C][D]; ");
-
- parse(" p = new (0) A; ");
- parse(" p = new (0) A(5); ");
- parse(" p = new (0) A(B); ");
- parse(" p = new (0) A(B,C); ");
- parse(" p = new (0) A[5]; ");
- parse(" p = new (0) A[5][10]; ");
- parse(" p = new (0) A[B]; ");
- parse(" p = new (0) A[B][C][D]; ");
-
- parse(" p = new (0) (int); ");
- parse(" p = new (0) (int)(5); ");
- parse(" p = new (0) (int)(B); ");
- parse(" p = new (0) (int)(B,C); ");
- parse(" p = new (0) (int[5]); ");
- parse(" p = new (0) (int[5][10]); ");
- parse(" p = new (0) (int[B]); ");
- parse(" p = new (0) (int[B][C][D]); ");
-
- parse(" p = new (0) (A); ");
- parse(" p = new (0) (A)(5); ");
- parse(" p = new (0) (A)(B); ");
- parse(" p = new (0) (A)(B,C); ");
- parse(" p = new (0) (A[5]); ");
- parse(" p = new (0) (A[5][10]); ");
- parse(" p = new (0) (A[B]); ");
- parse(" p = new (0) (A[B][C][D]); ");
-
- parse(" p = new (P) int; ");
- parse(" p = new (P) int(5); ");
- parse(" p = new (P) int(B); ");
- parse(" p = new (P) int(B,C); ");
- parse(" p = new (P) int[5]; ");
- parse(" p = new (P) int[5][10]; ");
- parse(" p = new (P) int[B]; ");
- parse(" p = new (P) int[B][C][D]; ");
-
- parse(" p = new (P) A; ");
- parse(" p = new (P) A(5); ");
- parse(" p = new (P) A(B); ");
- parse(" p = new (P) A(B,C); ");
- parse(" p = new (P) A[5]; ");
- parse(" p = new (P) A[5][10]; ");
- parse(" p = new (P) A[B]; ");
- parse(" p = new (P) A[B][C][D]; ");
-
- parse(" p = new (P) (int); ");
- parse(" p = new (P) (int)(5); ");
- parse(" p = new (P) (int)(B); ");
- parse(" p = new (P) (int)(B,C); ");
- parse(" p = new (P) (int[5]); ");
- parse(" p = new (P) (int[5][10]); ");
- parse(" p = new (P) (int[B]); ");
- parse(" p = new (P) (int[B][C][D]); ");
-
- parse(" p = new (P) (A); ");
- parse(" p = new (P) (A)(5); ");
- parse(" p = new (P) (A)(B); ");
- parse(" p = new (P) (A)(B,C); ");
- parse(" p = new (P) (A[5]); ");
- parse(" p = new (P) (A[5][10]); ");
- parse(" p = new (P) (A[B]); ");
- parse(" p = new (P) (A[B][C][D]); ");
- }
-
- public void testBug36769A() throws Exception {
- parse("template <class A, B> cls<A, C>::operator otherType() const {}\n");
- parse("template <class A, B> cls<A, C>::cls() {}\n");
- parse("template <class A, B> cls<A, C>::~cls() {}\n");
- }
-
- public void testBug36714() throws Exception {
- Writer code = new StringWriter();
- code.write("unsigned long a = 0UL;\n");
- code.write("unsigned long a2 = 0L; \n");
- parse(code.toString());
- }
-
- public void testBugFunctor758() throws Exception {
- parse(
- "class Functor {"+
- "template <typename Fun> Functor(Fun fun) : spImpl_(new FunctorHandler<Functor, Fun>(fun)){}" +
- "};"
- );
- }
-
- public void testBug36932() throws Exception {
- parse("A::A(): b(new int(5)), b(new B), c(new int) {}");
- }
-
- public void testBug36704() throws Exception {
- Writer code = new StringWriter();
- code.write("template<typename T, typename U> class Typelist;");
- code.write("template<typename T> struct Length {};");
- code.write("template <class T, class U>\n");
- code.write("struct Length< Typelist<T, U> >\n");
- code.write("{\n");
- code.write("enum { value = 1 + Length<U>::value };\n");
- code.write("};\n");
- parse(code.toString());
- }
-
- public void testBug36699() throws Exception {
- Writer code = new StringWriter();
- code.write("template < template <class> class ThreadingModel = DEFAULT_THREADING,\n");
- code.write("std::size_t chunkSize = DEFAULT_CHUNK_SIZE,\n");
- code.write("std::size_t maxSmallObjectSize = MAX_SMALL_OBJECT_SIZE >\n");
- code.write("class SmallObject : public ThreadingModel<\n");
- code.write("SmallObject<ThreadingModel, chunkSize, maxSmallObjectSize> >\n");
- code.write("{};\n");
- parse(code.toString());
- }
-
- public void testBug36691() throws Exception {
- Writer code = new StringWriter();
- code.write("template <class T, class H>\n");
- code.write("typename H::template Rebind<T>::Result& Field(H& obj)\n");
- code.write("{ return obj; }\n");
- parse(code.toString());
- }
-
- public void testBug36702() throws Exception {
- Writer code = new StringWriter();
- code.write("void mad_decoder_init(struct mad_decoder *, void *,\n");
- code.write(" enum mad_flow (*)(void *, struct mad_stream *),\n");
- code.write(" enum mad_flow (*)(void *, struct mad_header const *),\n");
- code.write(" enum mad_flow (*)(void *,\n");
- code.write(" struct mad_stream const *,\n");
- code.write(" struct mad_frame *),\n");
- code.write(" enum mad_flow (*)(void *,\n");
- code.write(" struct mad_header const *,\n");
- code.write(" struct mad_pcm *),\n");
- code.write(" enum mad_flow (*)(void *,\n");
- code.write(" struct mad_stream *,\n");
- code.write(" struct mad_frame *),\n");
- code.write(" enum mad_flow (*)(void *, void *, unsigned int *)\n");
- code.write(");\n");
-
- parse(code.toString());
- }
-
- public void testBug36852() throws Exception {
- Writer code = new StringWriter();
- code.write("int CBT::senseToAllRect(double id_standardQuot = DOSE, double id_minToleranz =15.0,\n");
- code.write("double id_maxToleranz = 15.0, unsigned int iui_minY = 0, \n");
- code.write("unsigned int iui_maxY = HEIGHT);\n");
- parse(code.toString());
- }
-
- public void testBug36689() throws Exception {
- Writer code = new StringWriter();
- code.write("template\n");
- code.write("<\n");
- code.write("class AbstractFact,\n");
- code.write("template <class, class> class Creator = OpNewFactoryUnit,\n");
- code.write("class TList = typename AbstractFact::ProductList\n");
- code.write(">\n");
- code.write("class ConcreteFactory\n");
- code.write(": public GenLinearHierarchy<\n");
- code.write("typename TL::Reverse<TList>::Result, Creator, AbstractFact>\n");
- code.write("{\n");
- code.write("public:\n");
- code.write("typedef typename AbstractFact::ProductList ProductList;\n");
- code.write("typedef TList ConcreteProductList;\n");
- code.write("};\n");
- parse(code.toString());
- }
-
- public void testBug36707() throws Exception {
- parse("enum { exists = sizeof(typename H::Small) == sizeof((H::Test(H::MakeT()))) };");
- }
-
- public void testBug36717() throws Exception {
- parse("enum { eA = A::b };");
- }
-
- public void testBug36693() throws Exception {
- parse("FixedAllocator::Chunk* FixedAllocator::VicinityFind(void* p){}");
- }
-
- public void testWeirdExpression() throws Exception {
- parse("int x = rhs.spImpl_.get();");
- }
-
- public void testBug36696() throws Exception {
- Writer code = new StringWriter();
- code.write("template<typename T> class RefCounted {");
- code.write("template <typename P1> RefCounted(const RefCounted<P1>& rhs)\n");
- code.write(": pCount_(reinterpret_cast<const RefCounted&>(rhs).pCount_) {}\n");
- code.write("};");
- parse(code.toString());
- }
-
- public void testArrayOfPointerToFunctions() throws Exception {
- parse("unsigned char (*main_data)[MAD_BUFFER_MDLEN];");
- }
-
- public void testBug36073() throws Exception {
- StringWriter writer = new StringWriter();
- writer.write("class A{\n");
- writer.write("int x;\n");
- writer.write("public:\n");
- writer.write("A(const A&);\n");
- writer.write("};\n");
- writer.write("A::A(const A&v) : x(v.x) { }\n");
- parse(writer.toString());
- }
-
- public void testTemplateSpecialization() throws Exception {
- parse("template<> class stream<char> { /* ... */ };");
- }
-
- public void testTemplateInstantiation() throws Exception {
- parse("template class Array<char>;");
- }
-
- /**
- * Test code: "class A { int floor(double input), someInt; };"
- */
- public void testMultipleDeclarators() throws Exception {
- // Parse and get the translation unit
- parse("class A { int floor(double input), someInt; };");
- }
-
- public void testFunctionModifiers() throws Exception {
- parse("class A {virtual void foo(void) const throw (yay, nay, we::dont::care) = 0;};");
- }
-
- public void testArrays() throws Exception {
- parse("int x[5][];");
- }
-
- public void testElaboratedParms() throws Exception {
- parse("int x(struct A myA) { /* junk */ }");
- }
-
- public void testMemberDeclarations() throws Exception {
- Writer code = new StringWriter();
- code.write("class A {\n");
- code.write("public:\n");
- code.write(" int is0;\n");
- code.write("private:\n");
- code.write(" int is1;\n");
- code.write("protected:\n");
- code.write(" int is2;\n");
- code.write("};");
- parse(code.toString());
- }
-
- public void testPointerOperators() throws Exception {
- parse("int * x = 0, & y, * const * volatile * z;");
- }
-
- public void testBug26467() throws Exception {
- StringWriter code = new StringWriter();
- code.write("struct foo { int fooInt; char fooChar; };\n");
- code.write("typedef struct foo fooStruct;\n");
- code.write("typedef struct { int anonInt; char anonChar; } anonStruct;\n");
- parse(code.toString());
- }
-
- public void testASMDefinition() throws Exception {
- parse("asm(\"mov ep1 ds2\");");
- }
-
- public void testConstructorChain() throws Exception {
- //TODO - requires CPPVisitor in order to reduce ambiguities
- parse("TrafficLight_Actor::TrafficLight_Actor(RTController * rtg_rts, RTActorRef * rtg_ref) : RTActor(rtg_rts, rtg_ref), myId(0) {}");
- }
-
- public void testBug36237() throws Exception {
- parse("A::A():B((char *)0){}");
- }
-
- public void testBug36532() throws Exception {
- try {
- parse("template<int f() {\n");
- fail("We should not make it this far");
- } catch (ParserException pe) {
- } catch (Exception e) {
- fail("We should have gotten a ParserException rather than" + e);
- }
- }
-
- public void testPreprocessor() throws Exception {
- parse("#include <stdio.h>\n#define DEF VALUE\n");
- }
-
- public void testTemplateDeclarationOfFunction() throws Exception {
- parse("template<class A, typename B=C> A aTemplatedFunction(B bInstance);");
- }
-
- public void testTemplateDeclarationOfClass() throws Exception {
- parse("template<class T, typename Tibor = junk, class, typename, int x, float y,template <class Y> class, template<class A> class AClass> class myarray { /* ... */ };");
- }
-
- public void testBug35906() throws Exception {
- StringWriter code = new StringWriter();
- code.write("void TTest::MTest() {}\n");
- code.write("struct TTest::STest *TTest::FTest (int i) {}\n");
- parse(code.toString());
- }
-
- public void testBug36288() throws Exception {
- parse("int foo() {}\nlong foo2(){}");
- }
-
- public void testBug36250() throws Exception {
- parse("int f(int = 0);");
- }
-
- public void testBug36240() throws Exception {
- parse("A & A::operator=(A){}");
- }
-
- public void testBug36254() throws Exception {
- parse("unsigned i;\nvoid f(unsigned p1 = 0);");
- }
-
- public void testBug36432() throws Exception {
- Writer code = new StringWriter();
- code.write("#define CMD_GET \"g\"\n");
- code.write("#define CMD_ACTION \"a\"\n");
- code.write("#define CMD_QUIT \"q\"\n");
- code
- .write("static const memevent_cmd_func memevent_cmd_funcs[sizeof memevent_cmds - 1] = {\n");
- code.write("memevent_get,\n");
- code.write("memevent_action,\n");
- code.write("memevent_quit,\n");
- code.write("};\n");
- parse(code.toString());
- }
-
- public void testBug36594() throws Exception {
- parse("const int n = sizeof(A) / sizeof(B);");
- }
-
- public void testBug36794() throws Exception {
- parse("template<> class allocator<void> {};");
- }
-
- public void testBug36799() throws Exception {
- parse("static const int __WORD_BIT = int(CHAR_BIT*sizeof(unsigned int));");
- }
-
- public void testBug36764() throws Exception {
- parse("struct{ int x : 4; int y : 8; };");
- }
-
- public void testOrder() throws Exception {
- //TODO - requires CPPVisitor
- Writer code = new StringWriter();
- code.write("#define __SGI_STL_INTERNAL_ALGOBASE_H\n");
- code.write("#include <string.h>\n");
- code.write("template <class _Tp>\n");
- code.write("inline void swap(_Tp& __a, _Tp& __b) {\n");
- code.write("__STL_REQUIRES(_Tp, _Assignable);\n");
- code.write("_Tp __tmp = __a;\n");
- code.write("__a = __b;\n");
- code.write("__b = __tmp;\n");
- code.write("}\n");
- parse(code.toString());
- }
-
- public void testBug36771() throws Exception {
- Writer code = new StringWriter();
- code.write("#include /**/ \"foo.h\"\n");
-
- parse(code.toString());
- }
-
- public void testBug36811() throws Exception {
- Writer code = new StringWriter();
- code.write("using namespace std;\n");
- code.write("class Test {};");
- parse(code.toString());
- }
-
- public void testBug36708() throws Exception {
- parse("enum { isPointer = PointerTraits<T>::result };");
- }
-
- public void testBug36690() throws Exception {
- parse(
- "class Functor {" +
- "Functor(const Functor& rhs) : spImpl_(Impl::Clone(rhs.spImpl_.get())){}" +
- "};"
- );
- }
-
- public void testBug36703() throws Exception {
- parse("const std::type_info& Get() const;");
- }
-
- public void testBug36692() throws Exception {
- Writer code = new StringWriter();
- code.write("template <typename T, typename Destroyer>\n");
- code.write("void SetLongevity(T* pDynObject, unsigned int longevity,\n");
- code.write("Destroyer d = Private::Deleter<T>::Delete){}\n");
- parse(code.toString());
- }
-
- public void testBug36551() throws Exception {
- Writer code = new StringWriter();
- code.write("class TextFrame {\n");
- code.write("BAD_MACRO()\n");
- code.write("};");
- parse(code.toString(), false);
- }
-
-// public void testBug36247() throws Exception {
-// Writer code = new StringWriter();
-// code.write("class A {\n");
-// code.write("INLINE_DEF int f ();\n");
-// code.write("INLINE_DEF A g ();");
-// code.write("INLINE_DEF A * h ();");
-// code.write("INLINE_DEF A & unlock(void);");
-// code.write("};");
-// parse(code.toString());
-// }
-
- public void testStruct() throws Exception {
- StringWriter writer = new StringWriter();
- writer.write("struct mad_bitptr { unsigned char const *byte;\n");
- writer.write("unsigned short cache;\n unsigned short left;};");
- parse(writer.toString());
- }
-
- public void testBug36559() throws Exception {
- Writer code = new StringWriter();
- code.write("namespace myNameSpace {\n");
- code.write("template<typename T=short> class B {};\n");
- code.write("template<> class B<int> {};\n");
- code.write("}\n");
- parse(code.toString());
- }
-
- public void testPointersToFunctions() throws Exception {
- Writer code = new StringWriter();
- code.write("void (*name)(void);\n");
- code
- .write("static void * (* const orig_malloc_hook)(const char *file, int line, size_t size);\n");
-
- parse(code.toString());
- }
-
- public void testBug36600() throws Exception {
- parse("enum mad_flow (*input_func)(void *, struct mad_stream *);");
- }
-
- public void testBug36713() throws Exception {
- Writer code = new StringWriter();
- code.write("A (* const fPtr) (void *); \n");
- code.write("A (* const fPtr2) (A *); \n");
- parse(code.toString());
- }
-
- // K&R Test hasn't been ported from DOMTests
- // still need to figure out how to represent these in the AST
- // public void testOldKRFunctionDeclarations() throws Exception
- // {
- // // Parse and get the translaton unit
- // Writer code = new StringWriter();
- // code.write("bool myFunction(parm1, parm2, parm3)\n");
- // code.write("const char* parm1;\n");
- // code.write("int (*parm2)(float);\n");
- // code.write("{}");
- // TranslationUnit translationUnit = parse(code.toString());
- //
- // // Get the declaration
- // List declarations = translationUnit.getDeclarations();
- // assertEquals(1, declarations.size());
- // SimpleDeclaration simpleDeclaration =
- // (SimpleDeclaration)declarations.get(0);
- // assertEquals(simpleDeclaration.getDeclSpecifier().getType(),
- // DeclSpecifier.t_bool);
- // List declarators = simpleDeclaration.getDeclarators();
- // assertEquals(1, declarators.size());
- // Declarator functionDeclarator = (Declarator)declarators.get(0);
- // assertEquals(functionDeclarator.getName().toString(), "myFunction");
- //
- // ParameterDeclarationClause pdc = functionDeclarator.getParms();
- // assertNotNull(pdc);
- // List parameterDecls = pdc.getDeclarations();
- // assertEquals(3, parameterDecls.size());
- // ParameterDeclaration parm1 = (ParameterDeclaration)parameterDecls.get(0
- //);
- // assertNotNull(parm1.getDeclSpecifier().getName());
- // assertEquals("parm1", parm1.getDeclSpecifier().getName().toString());
- // List parm1Decls = parm1.getDeclarators();
- // assertEquals(1, parm1Decls.size());
- //
- // ParameterDeclaration parm2 = (ParameterDeclaration)parameterDecls.get(1
- //);
- // assertNotNull(parm2.getDeclSpecifier().getName());
- // assertEquals("parm2", parm2.getDeclSpecifier().getName().toString());
- // List parm2Decls = parm2.getDeclarators();
- // assertEquals(1, parm2Decls.size());
- //
- // ParameterDeclaration parm3 = (ParameterDeclaration)parameterDecls.get(2
- //);
- // assertNotNull(parm3.getDeclSpecifier().getName());
- // assertEquals("parm3", parm3.getDeclSpecifier().getName().toString());
- // List parm3Decls = parm3.getDeclarators();
- // assertEquals(1, parm3Decls.size());
- //
- // OldKRParameterDeclarationClause clause = pdc.getOldKRParms();
- // assertNotNull(clause);
- // assertEquals(clause.getDeclarations().size(), 2);
- // SimpleDeclaration decl1 =
- // (SimpleDeclaration)clause.getDeclarations().get(0);
- // assertEquals(decl1.getDeclarators().size(), 1);
- // assertTrue(decl1.getDeclSpecifier().isConst());
- // assertFalse(decl1.getDeclSpecifier().isVolatile());
- // assertEquals(decl1.getDeclSpecifier().getType(), DeclSpecifier.t_char);
- // Declarator declarator1 = (Declarator)decl1.getDeclarators().get(0);
- // assertEquals(declarator1.getName().toString(), "parm1");
- // List ptrOps1 = declarator1.getPointerOperators();
- // assertNotNull(ptrOps1);
- // assertEquals(1, ptrOps1.size());
- // PointerOperator po1 = (PointerOperator)ptrOps1.get(0);
- // assertNotNull(po1);
- // assertFalse(po1.isConst());
- // assertFalse(po1.isVolatile());
- // assertEquals(po1.getType(), PointerOperator.t_pointer);
- //
- // SimpleDeclaration declaration =
- // (SimpleDeclaration)clause.getDeclarations().get(1);
- // assertEquals(declaration.getDeclSpecifier().getType(),
- // DeclSpecifier.t_int);
- // assertEquals(declaration.getDeclarators().size(), 1);
- // assertNull(((Declarator)declaration.getDeclarators().get(0)).getName()
- //);
- // assertNotNull(
- // ((Declarator)declaration.getDeclarators().get(0)).getDeclarator());
- // assertEquals(
- // ((Declarator)declaration.getDeclarators().get(0)).getDeclarator().getName().toString(),
- // "parm2");
- // ParameterDeclarationClause clause2 =
- // ((Declarator)declaration.getDeclarators().get(0)).getParms();
- // assertEquals(clause2.getDeclarations().size(), 1);
- // assertEquals(
- // ((ParameterDeclaration)clause2.getDeclarations().get(0)).getDeclarators().size(),
- // 1);
- // assertNull(
- // ((Declarator)((ParameterDeclaration)clause2.getDeclarations().get(0)).getDeclarators().get(0)).getName()
- //);
- // assertEquals(
- // ((ParameterDeclaration)clause2.getDeclarations().get(0)).getDeclSpecifier().getType(),
- // DeclSpecifier.t_float);
- // }
-
- public void testPointersToMemberFunctions() throws Exception {
- parse("void (A::*name)(void);");
- }
-
- public void testBug39550() throws Exception {
- parse("double x = 0x1.fp1;");
- }
-
- // digraphs/trigraphs have been temporarily remove
- public void testBug39552A(int x) throws Exception {
- Writer code = new StringWriter();
- code.write("%:define glue(x, y) x %:%: y /* #define glue(x, y) x ## y. */\n");
- code.write("#ifndef glue\n");
- code.write("#error glue not defined!\n");
- code.write("#endif\n");
- code.write("%:define str(x) %:x /* #define str(x) #x */\n");
- code.write("int main (int argc, char *argv<::>) /* argv[] */\n");
- code.write("glue (<, %) /* { */\n");
- code.write(" /* di_str[] = */\n");
- code.write(" const char di_str glue(<, :)glue(:, >) = str(%:%:<::><%%>%:);\n");
- code.write(" /* Check the glue macro actually pastes, and that the spelling of\n");
- code.write(" all digraphs is preserved. */\n");
- code.write(" if (glue(strc, mp) (di_str, \"%:%:<::><%%>%:\"))\n");
- code.write(" err (\"Digraph spelling not preserved!\");\n");
- code.write(" return 0;\n");
- code.write("glue (%, >) /* } */\n");
-
- parse(code.toString());
- }
-
- // digraphs/trigraphs have been temporarily remove
- public void testBug39552B(int x) throws Exception {
- Writer code = new StringWriter();
-
- code.write("??=include <stdio.h>\n");
- code.write("??=define TWELVE 1??/\n");
- code.write("2\n");
- code.write("static const char str??(??) = \"0123456789??/n\";\n");
- code.write("int\n");
- code.write("main(void)\n");
- code.write("??<\n");
- code.write(" unsigned char x = 5;\n");
- code.write(" if (sizeof str != TWELVE)\n");
- code.write(" abort ();\n");
- code.write(" /* Test ^=, the only multi-character token to come from trigraphs. */\n");
- code.write(" x ??'= 3;\n");
- code.write(" if (x != 6)\n");
- code.write(" abort ();\n");
- code.write(" if ((5 ??! 3) != 7)\n");
- code.write(" abort ();\n");
- code.write(" return 0;\n");
- code.write("??>\n");
-
- parse(code.toString());
- }
-
- public void testBug39553() throws Exception {
- parse("#define COMP_INC \"foobar.h\" \n" + "#include COMP_INC\n"); //$NON-NLS-2$
- }
-
- public void testBug39537() throws Exception {
- parse("typedef foo<(U::id > 0)> foobar;");
- }
-
- public void testBug39546() throws Exception {
- parse("signed char c = (signed char) 0xffffffff;");
- }
-
- public void testIndirectDeclarators() throws Exception {
- parse("void (*x)(int);");
- }
-
- public void testBug39532() throws Exception {
- parse("class N1::N2::B : public A {};");
- }
-
- public void testBug39540() throws Exception {
- parse("class {} const null;");
- }
-
- public void testBug39530() throws Exception {
- parse("X sPassed(-1);");
- }
-
- public void testBug39526() throws Exception {
- parse("UnitList unit_list (String(\"keV\"));");
- }
-
- public void testBug39535() throws Exception {
- parse("namespace bar = foo;");
- }
-
- public void testBug39504B() throws Exception {
- parse("int y = sizeof (int*);");
- }
-
- public void testBug39505A() throws Exception {
- parse("int AD::* gp_down = static_cast<int AD::*>(gp_stat);");
- }
-
- public void testBug39505B() throws Exception {
- parse("int* gp_down = static_cast<int*>(gp_stat);");
- }
-
- public void testBug42985() throws Exception {
- parse("const int x = 4; int y = ::x;");
- }
-
- public void testBug40419() throws Exception {
- Writer code = new StringWriter();
- try {
- code.write("template <class T, class U> struct SuperSubclass {\n");
- code.write("enum { value = (::Loki::Conversion<const volatile U*, const volatile T*>::exists && \n");
- code.write("!::Loki::Conversion<const volatile T*, const volatile void*>::sameType) }; };");
- } catch (IOException e) {
- }
- parse(code.toString());
- }
-
- public void testBug39556() throws Exception {
- parse("int *restrict ip_fn (void);", true, ParserLanguage.C);
- }
-
- /**
- * Test code: struct Example { Example(); Example(int); ~Example();};
- * Purpose: tests a declaration in a class scope.
- */
- public void testBug43371() throws Exception {
- // Parse and get the translaton unit
- Writer code = new StringWriter();
- code.write("struct Example { Example(); Example(int); ~Example();};");
- parse(code.toString());
- }
-
- public void testBug43644() throws Exception {
- parse("void foo();{ int x; }", false);
- }
-
- public void testBug43062() throws Exception {
- parse("class X { operator short (); operator int unsigned(); operator int signed(); };");
- }
-
- public void testBug39531() throws Exception {
- parse("class AString { operator char const *() const; };");
- }
-
- public void testBug40007() throws Exception {
- parse("int y = #;", false);
- }
-
- public void testBug40759() throws Exception {
- parse("#define X SomeName \n class X {};");
- }
-
- public void testBug44633() throws Exception {
- Writer writer = new StringWriter();
- writer.write("template <typename T> class A {};\n");
- writer.write("class B { template <typename T> friend class A;\n");
- writer.write("void method();\n");
- writer.write("};\n");
- parse(writer.toString());
- }
-
- public void testBug39525() throws Exception {
- parse("C &(C::*DD)(const C &x) = &C::operator=;");
- }
-
- public void testBug41935() throws Exception {
- parse("namespace A { int x; } namespace B = A;");
- }
-
- public void testBug39528() throws Exception {
- Writer code = new StringWriter();
- try {
- code.write("struct B: public A {\n");
- code.write(" A a;\n");
- code.write(" B() try : A(1), a(2)\n");
- code.write(" { throw 1; }\n");
- code.write(" catch (...)\n");
- code.write(" { if (c != 3) r |= 1; }\n");
- code.write("};\n");
- } catch (IOException e) {
- }
- parse(code.toString());
- }
-
- public void testBug39538() throws Exception {
- parse("template C::operator int<float> ();");
- }
-
- public void testBug39536() throws Exception {
- Writer writer = new StringWriter();
- writer.write("template<class E>\n");
- writer.write("class X {\n");
- writer.write("X<E>(); // This fails \n");
- writer.write("inline X<E>(int); // This also fails \n");
- writer.write("inline ~X<E>(); // This works fine \n");
- writer.write("};\n");
- parse(writer.toString());
- }
-
- public void testBug39536A() throws Exception {
- parse("template<class E> class X { X<E>(); };");
- }
-
- public void testBug39536B() throws Exception {
- parse("template<class E> class X { inline X<E>(int); };");
- }
-
- public void testBug39542() throws Exception {
- parse("void f(int a, struct {int b[a];} c) {}");
- }
-
- //Here starts C99-specific section
- public void testBug39549() throws Exception {
- parse("struct X x = { .b = 40, .z = { sizeof(X), 42 }, .t[3] = 2, .t.f[3].x = A * B };", true, ParserLanguage.C);
- // with trailing commas
- parse("struct X x = { .b = 40, .z = { sizeof(X), 42,}, .t[3] = 2, .t.f[3].x = A * B ,};", true, ParserLanguage.C);
- }
-
- public void testBug39551A() throws Exception {
- parse("extern float _Complex conjf (float _Complex);", true, ParserLanguage.C);
- }
-
- public void testBug39551B() throws Exception {
- parse("_Imaginary double id = 99.99 * __I__;", true, ParserLanguage.C);
- }
-
- public void testCBool() throws Exception {
- parse("_Bool x;", true, ParserLanguage.C);
- }
-
- public void testBug39678() throws Exception {
- parse("char *s = L\"a\" \"b\";");
- }
-
- public void testBug43110() throws Exception {
- parse("void x(int y, ...);");
- }
-
- // public void testBug44370() throws Exception
- // {
- // parse("#define SWAP(x,y) {x|=y;y|=x;x|=y;}\n");
- // Iterator macros = quickParseCallback.getMacros();
- // assertNotNull(macros);
- // assertTrue(macros.hasNext());
- // IASTMacro swap = (IASTMacro) macros.next();
- // assertFalse(macros.hasNext());
- // assertEquals(swap.getName(), "SWAP");
- // assertEquals(swap.getMacroType(),
- // IMacroDescriptor.MacroType.FUNCTION_LIKE);
- // String[] params = swap.getParameters();
- // assertEquals(params.length, 2);
- // assertEquals(params[0], "x");
- // assertEquals(params[1], "y");
- // String completeSignature = swap.getCompleteSignature().trim();
- // assertEquals(completeSignature, "#define SWAP(x,y) {x|=y;y|=x;x|=y;}");
- //
- // assertEquals(swap.getExpansionSignature().trim(),"{x|=y;y|=x;x|=y;}");
- //
- // IToken[] tokens = swap.getTokenizedExpansion();
- // validateToken(tokens[0], IToken.tLBRACE);
- // validateIdentifier(tokens[1], "x");
- // validateToken(tokens[2], IToken.tBITORASSIGN);
- // validateIdentifier(tokens[3], "y");
- // validateToken(tokens[4], IToken.tSEMI);
- // validateIdentifier(tokens[5], "y");
- // validateToken(tokens[6], IToken.tBITORASSIGN);
- // validateIdentifier(tokens[7], "x");
- // validateToken(tokens[8], IToken.tSEMI);
- // validateIdentifier(tokens[9], "x");
- // validateToken(tokens[10], IToken.tBITORASSIGN);
- // validateIdentifier(tokens[11], "y");
- // validateToken(tokens[12], IToken.tSEMI);
- // validateToken(tokens[13], IToken.tRBRACE);
- // }
- // /**
- // * @param token
- // * @param string
- // */
- // private void validateIdentifier(IToken token, String identifierName) {
- // validateToken(token, IToken.tIDENTIFIER);
- // assertEquals(token.getImage(), identifierName);
- // }
- // /**
- // * @param token
- // * @param i
- // */
- // private void validateToken(IToken token, int signal) {
- // assertEquals(token.getType(), signal);
- // }
-
- public void testBug47752() throws Exception {
- //TODO requires CPPVisitor
- parse("void func(cFoo bar) try { } catch (const char * error){ }");
- }
-
- public void testBug47628() throws Exception {
- Writer writer = new StringWriter();
- writer.write("void h(char) { }\n");
- writer.write("void h(unsigned char) { }\n");
- writer.write("void h(signed char) { } // not shown in outline, parsed as char\n");
- parse(writer.toString());
- }
-
- public void testBug44336() throws Exception {
- parse("class A {}; typedef typename A foo;");
- }
-
- public void testBug39705() throws Exception {
- parse("#ident \"@(#)filename.c 1.3 90/02/12\"");
- }
-
- public void testBug45235() throws Exception {
- parse("class A { friend class B; friend void f(); }; ");
- }
-
- public void testBug59179() throws Exception {
- parse("class __decl main{ int main; };", false);
- }
-
- public void testBug57652() throws Exception {
- parse("struct file_operations driver_fops = { open: device_open, release: device_release };", true, ParserLanguage.C, true);
- }
-
- protected void parse(String code, boolean expectedToPass,
- ParserLanguage lang, boolean gcc) throws Exception {
+ public void _testBug36932B() throws Exception {
+ parse(" p = new int; ");
+ parse(" p = new int(5); ");
+ parse(" p = new int(B); ");
+ parse(" p = new int(B,C); ");
+ parse(" p = new int[5]; ");
+ parse(" p = new int[5][10]; ");
+ parse(" p = new int[B]; ");
+ parse(" p = new int[B][C][D]; ");
+
+ parse(" p = new A; ");
+ parse(" p = new A(5); ");
+ parse(" p = new A(B); ");
+ parse(" p = new A(B,C); ");
+ parse(" p = new A[5]; ");
+ parse(" p = new A[5][10]; ");
+ parse(" p = new A[B]; ");
+ parse(" p = new A[B][C][D]; ");
+
+ parse(" p = new (int); ");
+ parse(" p = new (int)(5); ");
+ parse(" p = new (int)(B); ");
+ parse(" p = new (int)(B,C); ");
+ parse(" p = new (int[5]); ");
+ parse(" p = new (int[5][10]); ");
+ parse(" p = new (int[B]); ");
+ parse(" p = new (int[B][C][D]); ");
+
+ parse(" p = new (A); ");
+ parse(" p = new (A)(5); ");
+ parse(" p = new (A)(B); ");
+ parse(" p = new (A)(B,C); ");
+ parse(" p = new (A[5]); ");
+ parse(" p = new (A[5][10]); ");
+ parse(" p = new (A[B]); ");
+ parse(" p = new (A[B][C][D]); ");
+
+ parse(" p = new (0) int; ");
+ parse(" p = new (0) int(5); ");
+ parse(" p = new (0) int(B); ");
+ parse(" p = new (0) int(B,C); ");
+ parse(" p = new (0) int[5]; ");
+ parse(" p = new (0) int[5][10]; ");
+ parse(" p = new (0) int[B]; ");
+ parse(" p = new (0) int[B][C][D]; ");
+
+ parse(" p = new (0) A; ");
+ parse(" p = new (0) A(5); ");
+ parse(" p = new (0) A(B); ");
+ parse(" p = new (0) A(B,C); ");
+ parse(" p = new (0) A[5]; ");
+ parse(" p = new (0) A[5][10]; ");
+ parse(" p = new (0) A[B]; ");
+ parse(" p = new (0) A[B][C][D]; ");
+
+ parse(" p = new (0) (int); ");
+ parse(" p = new (0) (int)(5); ");
+ parse(" p = new (0) (int)(B); ");
+ parse(" p = new (0) (int)(B,C); ");
+ parse(" p = new (0) (int[5]); ");
+ parse(" p = new (0) (int[5][10]); ");
+ parse(" p = new (0) (int[B]); ");
+ parse(" p = new (0) (int[B][C][D]); ");
+
+ parse(" p = new (0) (A); ");
+ parse(" p = new (0) (A)(5); ");
+ parse(" p = new (0) (A)(B); ");
+ parse(" p = new (0) (A)(B,C); ");
+ parse(" p = new (0) (A[5]); ");
+ parse(" p = new (0) (A[5][10]); ");
+ parse(" p = new (0) (A[B]); ");
+ parse(" p = new (0) (A[B][C][D]); ");
+
+ parse(" p = new (P) int; ");
+ parse(" p = new (P) int(5); ");
+ parse(" p = new (P) int(B); ");
+ parse(" p = new (P) int(B,C); ");
+ parse(" p = new (P) int[5]; ");
+ parse(" p = new (P) int[5][10]; ");
+ parse(" p = new (P) int[B]; ");
+ parse(" p = new (P) int[B][C][D]; ");
+
+ parse(" p = new (P) A; ");
+ parse(" p = new (P) A(5); ");
+ parse(" p = new (P) A(B); ");
+ parse(" p = new (P) A(B,C); ");
+ parse(" p = new (P) A[5]; ");
+ parse(" p = new (P) A[5][10]; ");
+ parse(" p = new (P) A[B]; ");
+ parse(" p = new (P) A[B][C][D]; ");
+
+ parse(" p = new (P) (int); ");
+ parse(" p = new (P) (int)(5); ");
+ parse(" p = new (P) (int)(B); ");
+ parse(" p = new (P) (int)(B,C); ");
+ parse(" p = new (P) (int[5]); ");
+ parse(" p = new (P) (int[5][10]); ");
+ parse(" p = new (P) (int[B]); ");
+ parse(" p = new (P) (int[B][C][D]); ");
+
+ parse(" p = new (P) (A); ");
+ parse(" p = new (P) (A)(5); ");
+ parse(" p = new (P) (A)(B); ");
+ parse(" p = new (P) (A)(B,C); ");
+ parse(" p = new (P) (A[5]); ");
+ parse(" p = new (P) (A[5][10]); ");
+ parse(" p = new (P) (A[B]); ");
+ parse(" p = new (P) (A[B][C][D]); ");
+ }
+
+ public void testBug36769A() throws Exception {
+ parse("template <class A, B> cls<A, C>::operator otherType() const {}\n");
+ parse("template <class A, B> cls<A, C>::cls() {}\n");
+ parse("template <class A, B> cls<A, C>::~cls() {}\n");
+ }
+
+ public void testBug36714() throws Exception {
+ Writer code = new StringWriter();
+ code.write("unsigned long a = 0UL;\n");
+ code.write("unsigned long a2 = 0L; \n");
+ parse(code.toString());
+ }
+
+ public void testBugFunctor758() throws Exception {
+ parse("class Functor {"
+ + "template <typename Fun> Functor(Fun fun) : spImpl_(new FunctorHandler<Functor, Fun>(fun)){}" + "};");
+ }
+
+ public void testBug36932() throws Exception {
+ parse("A::A(): b(new int(5)), b(new B), c(new int) {}");
+ }
+
+ public void testBug36704() throws Exception {
+ Writer code = new StringWriter();
+ code.write("template<typename T, typename U> class Typelist;");
+ code.write("template<typename T> struct Length {};");
+ code.write("template <class T, class U>\n");
+ code.write("struct Length< Typelist<T, U> >\n");
+ code.write("{\n");
+ code.write("enum { value = 1 + Length<U>::value };\n");
+ code.write("};\n");
+ parse(code.toString());
+ }
+
+ public void testBug36699() throws Exception {
+ Writer code = new StringWriter();
+ code.write("template < template <class> class ThreadingModel = DEFAULT_THREADING,\n");
+ code.write("std::size_t chunkSize = DEFAULT_CHUNK_SIZE,\n");
+ code.write("std::size_t maxSmallObjectSize = MAX_SMALL_OBJECT_SIZE >\n");
+ code.write("class SmallObject : public ThreadingModel<\n");
+ code.write("SmallObject<ThreadingModel, chunkSize, maxSmallObjectSize> >\n");
+ code.write("{};\n");
+ parse(code.toString());
+ }
+
+ public void testBug36691() throws Exception {
+ Writer code = new StringWriter();
+ code.write("template <class T, class H>\n");
+ code.write("typename H::template Rebind<T>::Result& Field(H& obj)\n");
+ code.write("{ return obj; }\n");
+ parse(code.toString());
+ }
+
+ public void testBug36702() throws Exception {
+ Writer code = new StringWriter();
+ code.write("void mad_decoder_init(struct mad_decoder *, void *,\n");
+ code.write(" enum mad_flow (*)(void *, struct mad_stream *),\n");
+ code.write(" enum mad_flow (*)(void *, struct mad_header const *),\n");
+ code.write(" enum mad_flow (*)(void *,\n");
+ code.write(" struct mad_stream const *,\n");
+ code.write(" struct mad_frame *),\n");
+ code.write(" enum mad_flow (*)(void *,\n");
+ code.write(" struct mad_header const *,\n");
+ code.write(" struct mad_pcm *),\n");
+ code.write(" enum mad_flow (*)(void *,\n");
+ code.write(" struct mad_stream *,\n");
+ code.write(" struct mad_frame *),\n");
+ code.write(" enum mad_flow (*)(void *, void *, unsigned int *)\n");
+ code.write(");\n");
+
+ parse(code.toString());
+ }
+
+ public void testBug36852() throws Exception {
+ Writer code = new StringWriter();
+ code.write("int CBT::senseToAllRect(double id_standardQuot = DOSE, double id_minToleranz =15.0,\n");
+ code.write("double id_maxToleranz = 15.0, unsigned int iui_minY = 0, \n");
+ code.write("unsigned int iui_maxY = HEIGHT);\n");
+ parse(code.toString());
+ }
+
+ public void testBug36689() throws Exception {
+ Writer code = new StringWriter();
+ code.write("template\n");
+ code.write("<\n");
+ code.write("class AbstractFact,\n");
+ code.write("template <class, class> class Creator = OpNewFactoryUnit,\n");
+ code.write("class TList = typename AbstractFact::ProductList\n");
+ code.write(">\n");
+ code.write("class ConcreteFactory\n");
+ code.write(": public GenLinearHierarchy<\n");
+ code.write("typename TL::Reverse<TList>::Result, Creator, AbstractFact>\n");
+ code.write("{\n");
+ code.write("public:\n");
+ code.write("typedef typename AbstractFact::ProductList ProductList;\n");
+ code.write("typedef TList ConcreteProductList;\n");
+ code.write("};\n");
+ parse(code.toString());
+ }
+
+ public void testBug36707() throws Exception {
+ parse("enum { exists = sizeof(typename H::Small) == sizeof((H::Test(H::MakeT()))) };");
+ }
+
+ public void testBug36717() throws Exception {
+ parse("enum { eA = A::b };");
+ }
+
+ public void testBug36693() throws Exception {
+ parse("FixedAllocator::Chunk* FixedAllocator::VicinityFind(void* p){}");
+ }
+
+ public void testWeirdExpression() throws Exception {
+ parse("int x = rhs.spImpl_.get();");
+ }
+
+ public void testBug36696() throws Exception {
+ Writer code = new StringWriter();
+ code.write("template<typename T> class RefCounted {");
+ code.write("template <typename P1> RefCounted(const RefCounted<P1>& rhs)\n");
+ code.write(": pCount_(reinterpret_cast<const RefCounted&>(rhs).pCount_) {}\n");
+ code.write("};");
+ parse(code.toString());
+ }
+
+ public void testArrayOfPointerToFunctions() throws Exception {
+ parse("unsigned char (*main_data)[MAD_BUFFER_MDLEN];");
+ }
+
+ public void testBug36073() throws Exception {
+ StringWriter writer = new StringWriter();
+ writer.write("class A{\n");
+ writer.write("int x;\n");
+ writer.write("public:\n");
+ writer.write("A(const A&);\n");
+ writer.write("};\n");
+ writer.write("A::A(const A&v) : x(v.x) { }\n");
+ parse(writer.toString());
+ }
+
+ public void testTemplateSpecialization() throws Exception {
+ parse("template<> class stream<char> { /* ... */ };");
+ }
+
+ public void testTemplateInstantiation() throws Exception {
+ parse("template class Array<char>;");
+ }
+
+ /**
+ * Test code: "class A { int floor(double input), someInt; };"
+ */
+ public void testMultipleDeclarators() throws Exception {
+ // Parse and get the translation unit
+ parse("class A { int floor(double input), someInt; };");
+ }
+
+ public void testFunctionModifiers() throws Exception {
+ parse("class A {virtual void foo(void) const throw (yay, nay, we::dont::care) = 0;};");
+ }
+
+ public void testArrays() throws Exception {
+ parse("int x[5][];");
+ }
+
+ public void testElaboratedParms() throws Exception {
+ parse("int x(struct A myA) { /* junk */ }");
+ }
+
+ public void testMemberDeclarations() throws Exception {
+ Writer code = new StringWriter();
+ code.write("class A {\n");
+ code.write("public:\n");
+ code.write(" int is0;\n");
+ code.write("private:\n");
+ code.write(" int is1;\n");
+ code.write("protected:\n");
+ code.write(" int is2;\n");
+ code.write("};");
+ parse(code.toString());
+ }
+
+ public void testPointerOperators() throws Exception {
+ parse("int * x = 0, & y, * const * volatile * z;");
+ }
+
+ public void testBug26467() throws Exception {
+ StringWriter code = new StringWriter();
+ code.write("struct foo { int fooInt; char fooChar; };\n");
+ code.write("typedef struct foo fooStruct;\n");
+ code.write("typedef struct { int anonInt; char anonChar; } anonStruct;\n");
+ parse(code.toString());
+ }
+
+ public void testASMDefinition() throws Exception {
+ parse("asm(\"mov ep1 ds2\");");
+ }
+
+ public void testConstructorChain() throws Exception {
+ //TODO - requires CPPVisitor in order to reduce ambiguities
+ parse("TrafficLight_Actor::TrafficLight_Actor(RTController * rtg_rts, RTActorRef * rtg_ref) : RTActor(rtg_rts, rtg_ref), myId(0) {}");
+ }
+
+ public void testBug36237() throws Exception {
+ parse("A::A():B((char *)0){}");
+ }
+
+ public void testBug36532() throws Exception {
+ try {
+ parse("template<int f() {\n");
+ fail("We should not make it this far");
+ } catch (ParserException pe) {
+ } catch (Exception e) {
+ fail("We should have gotten a ParserException rather than" + e);
+ }
+ }
+
+ public void testPreprocessor() throws Exception {
+ parse("#include <stdio.h>\n#define DEF VALUE\n");
+ }
+
+ public void testTemplateDeclarationOfFunction() throws Exception {
+ parse("template<class A, typename B=C> A aTemplatedFunction(B bInstance);");
+ }
+
+ public void testTemplateDeclarationOfClass() throws Exception {
+ parse("template<class T, typename Tibor = junk, class, typename, int x, float y,template <class Y> class, template<class A> class AClass> class myarray { /* ... */ };");
+ }
+
+ public void testBug35906() throws Exception {
+ StringWriter code = new StringWriter();
+ code.write("void TTest::MTest() {}\n");
+ code.write("struct TTest::STest *TTest::FTest (int i) {}\n");
+ parse(code.toString());
+ }
+
+ public void testBug36288() throws Exception {
+ parse("int foo() {}\nlong foo2(){}");
+ }
+
+ public void testBug36250() throws Exception {
+ parse("int f(int = 0);");
+ }
+
+ public void testBug36240() throws Exception {
+ parse("A & A::operator=(A){}");
+ }
+
+ public void testBug36254() throws Exception {
+ parse("unsigned i;\nvoid f(unsigned p1 = 0);");
+ }
+
+ public void testBug36432() throws Exception {
+ Writer code = new StringWriter();
+ code.write("#define CMD_GET \"g\"\n");
+ code.write("#define CMD_ACTION \"a\"\n");
+ code.write("#define CMD_QUIT \"q\"\n");
+ code.write("static const memevent_cmd_func memevent_cmd_funcs[sizeof memevent_cmds - 1] = {\n");
+ code.write("memevent_get,\n");
+ code.write("memevent_action,\n");
+ code.write("memevent_quit,\n");
+ code.write("};\n");
+ parse(code.toString());
+ }
+
+ public void testBug36594() throws Exception {
+ parse("const int n = sizeof(A) / sizeof(B);");
+ }
+
+ public void testBug36794() throws Exception {
+ parse("template<> class allocator<void> {};");
+ }
+
+ public void testBug36799() throws Exception {
+ parse("static const int __WORD_BIT = int(CHAR_BIT*sizeof(unsigned int));");
+ }
+
+ public void testBug36764() throws Exception {
+ parse("struct{ int x : 4; int y : 8; };");
+ }
+
+ public void testOrder() throws Exception {
+ //TODO - requires CPPVisitor
+ Writer code = new StringWriter();
+ code.write("#define __SGI_STL_INTERNAL_ALGOBASE_H\n");
+ code.write("#include <string.h>\n");
+ code.write("template <class _Tp>\n");
+ code.write("inline void swap(_Tp& __a, _Tp& __b) {\n");
+ code.write("__STL_REQUIRES(_Tp, _Assignable);\n");
+ code.write("_Tp __tmp = __a;\n");
+ code.write("__a = __b;\n");
+ code.write("__b = __tmp;\n");
+ code.write("}\n");
+ parse(code.toString());
+ }
+
+ public void testBug36771() throws Exception {
+ Writer code = new StringWriter();
+ code.write("#include /**/ \"foo.h\"\n");
+
+ parse(code.toString());
+ }
+
+ public void testBug36811() throws Exception {
+ Writer code = new StringWriter();
+ code.write("using namespace std;\n");
+ code.write("class Test {};");
+ parse(code.toString());
+ }
+
+ public void testBug36708() throws Exception {
+ parse("enum { isPointer = PointerTraits<T>::result };");
+ }
+
+ public void testBug36690() throws Exception {
+ parse("class Functor {" + "Functor(const Functor& rhs) : spImpl_(Impl::Clone(rhs.spImpl_.get())){}" + "};");
+ }
+
+ public void testBug36703() throws Exception {
+ parse("const std::type_info& Get() const;");
+ }
+
+ public void testBug36692() throws Exception {
+ Writer code = new StringWriter();
+ code.write("template <typename T, typename Destroyer>\n");
+ code.write("void SetLongevity(T* pDynObject, unsigned int longevity,\n");
+ code.write("Destroyer d = Private::Deleter<T>::Delete){}\n");
+ parse(code.toString());
+ }
+
+ public void testBug36551() throws Exception {
+ Writer code = new StringWriter();
+ code.write("class TextFrame {\n");
+ code.write("BAD_MACRO()\n");
+ code.write("};");
+ parse(code.toString(), false);
+ }
+
+ // public void testBug36247() throws Exception {
+ // Writer code = new StringWriter();
+ // code.write("class A {\n");
+ // code.write("INLINE_DEF int f ();\n");
+ // code.write("INLINE_DEF A g ();");
+ // code.write("INLINE_DEF A * h ();");
+ // code.write("INLINE_DEF A & unlock(void);");
+ // code.write("};");
+ // parse(code.toString());
+ // }
+
+ public void testStruct() throws Exception {
+ StringWriter writer = new StringWriter();
+ writer.write("struct mad_bitptr { unsigned char const *byte;\n");
+ writer.write("unsigned short cache;\n unsigned short left;};");
+ parse(writer.toString());
+ }
+
+ public void testBug36559() throws Exception {
+ Writer code = new StringWriter();
+ code.write("namespace myNameSpace {\n");
+ code.write("template<typename T=short> class B {};\n");
+ code.write("template<> class B<int> {};\n");
+ code.write("}\n");
+ parse(code.toString());
+ }
+
+ public void testPointersToFunctions() throws Exception {
+ Writer code = new StringWriter();
+ code.write("void (*name)(void);\n");
+ code.write("static void * (* const orig_malloc_hook)(const char *file, int line, size_t size);\n");
+
+ parse(code.toString());
+ }
+
+ public void testBug36600() throws Exception {
+ parse("enum mad_flow (*input_func)(void *, struct mad_stream *);");
+ }
+
+ public void testBug36713() throws Exception {
+ Writer code = new StringWriter();
+ code.write("A (* const fPtr) (void *); \n");
+ code.write("A (* const fPtr2) (A *); \n");
+ parse(code.toString());
+ }
+
+ // K&R Test hasn't been ported from DOMTests
+ // still need to figure out how to represent these in the AST
+ // public void testOldKRFunctionDeclarations() throws Exception
+ // {
+ // // Parse and get the translaton unit
+ // Writer code = new StringWriter();
+ // code.write("bool myFunction(parm1, parm2, parm3)\n");
+ // code.write("const char* parm1;\n");
+ // code.write("int (*parm2)(float);\n");
+ // code.write("{}");
+ // TranslationUnit translationUnit = parse(code.toString());
+ //
+ // // Get the declaration
+ // List declarations = translationUnit.getDeclarations();
+ // assertEquals(1, declarations.size());
+ // SimpleDeclaration simpleDeclaration =
+ // (SimpleDeclaration)declarations.get(0);
+ // assertEquals(simpleDeclaration.getDeclSpecifier().getType(),
+ // DeclSpecifier.t_bool);
+ // List declarators = simpleDeclaration.getDeclarators();
+ // assertEquals(1, declarators.size());
+ // Declarator functionDeclarator = (Declarator)declarators.get(0);
+ // assertEquals(functionDeclarator.getName().toString(), "myFunction");
+ //
+ // ParameterDeclarationClause pdc = functionDeclarator.getParms();
+ // assertNotNull(pdc);
+ // List parameterDecls = pdc.getDeclarations();
+ // assertEquals(3, parameterDecls.size());
+ // ParameterDeclaration parm1 = (ParameterDeclaration)parameterDecls.get(0
+ //);
+ // assertNotNull(parm1.getDeclSpecifier().getName());
+ // assertEquals("parm1", parm1.getDeclSpecifier().getName().toString());
+ // List parm1Decls = parm1.getDeclarators();
+ // assertEquals(1, parm1Decls.size());
+ //
+ // ParameterDeclaration parm2 = (ParameterDeclaration)parameterDecls.get(1
+ //);
+ // assertNotNull(parm2.getDeclSpecifier().getName());
+ // assertEquals("parm2", parm2.getDeclSpecifier().getName().toString());
+ // List parm2Decls = parm2.getDeclarators();
+ // assertEquals(1, parm2Decls.size());
+ //
+ // ParameterDeclaration parm3 = (ParameterDeclaration)parameterDecls.get(2
+ //);
+ // assertNotNull(parm3.getDeclSpecifier().getName());
+ // assertEquals("parm3", parm3.getDeclSpecifier().getName().toString());
+ // List parm3Decls = parm3.getDeclarators();
+ // assertEquals(1, parm3Decls.size());
+ //
+ // OldKRParameterDeclarationClause clause = pdc.getOldKRParms();
+ // assertNotNull(clause);
+ // assertEquals(clause.getDeclarations().size(), 2);
+ // SimpleDeclaration decl1 =
+ // (SimpleDeclaration)clause.getDeclarations().get(0);
+ // assertEquals(decl1.getDeclarators().size(), 1);
+ // assertTrue(decl1.getDeclSpecifier().isConst());
+ // assertFalse(decl1.getDeclSpecifier().isVolatile());
+ // assertEquals(decl1.getDeclSpecifier().getType(), DeclSpecifier.t_char);
+ // Declarator declarator1 = (Declarator)decl1.getDeclarators().get(0);
+ // assertEquals(declarator1.getName().toString(), "parm1");
+ // List ptrOps1 = declarator1.getPointerOperators();
+ // assertNotNull(ptrOps1);
+ // assertEquals(1, ptrOps1.size());
+ // PointerOperator po1 = (PointerOperator)ptrOps1.get(0);
+ // assertNotNull(po1);
+ // assertFalse(po1.isConst());
+ // assertFalse(po1.isVolatile());
+ // assertEquals(po1.getType(), PointerOperator.t_pointer);
+ //
+ // SimpleDeclaration declaration =
+ // (SimpleDeclaration)clause.getDeclarations().get(1);
+ // assertEquals(declaration.getDeclSpecifier().getType(),
+ // DeclSpecifier.t_int);
+ // assertEquals(declaration.getDeclarators().size(), 1);
+ // assertNull(((Declarator)declaration.getDeclarators().get(0)).getName()
+ //);
+ // assertNotNull(
+ // ((Declarator)declaration.getDeclarators().get(0)).getDeclarator());
+ // assertEquals(
+ // ((Declarator)declaration.getDeclarators().get(0)).getDeclarator().getName().toString(),
+ // "parm2");
+ // ParameterDeclarationClause clause2 =
+ // ((Declarator)declaration.getDeclarators().get(0)).getParms();
+ // assertEquals(clause2.getDeclarations().size(), 1);
+ // assertEquals(
+ // ((ParameterDeclaration)clause2.getDeclarations().get(0)).getDeclarators().size(),
+ // 1);
+ // assertNull(
+ // ((Declarator)((ParameterDeclaration)clause2.getDeclarations().get(0)).getDeclarators().get(0)).getName()
+ //);
+ // assertEquals(
+ // ((ParameterDeclaration)clause2.getDeclarations().get(0)).getDeclSpecifier().getType(),
+ // DeclSpecifier.t_float);
+ // }
+
+ public void testPointersToMemberFunctions() throws Exception {
+ parse("void (A::*name)(void);");
+ }
+
+ public void testBug39550() throws Exception {
+ parse("double x = 0x1.fp1;");
+ }
+
+ // digraphs/trigraphs have been temporarily remove
+ public void testBug39552A(int x) throws Exception {
+ Writer code = new StringWriter();
+ code.write("%:define glue(x, y) x %:%: y /* #define glue(x, y) x ## y. */\n");
+ code.write("#ifndef glue\n");
+ code.write("#error glue not defined!\n");
+ code.write("#endif\n");
+ code.write("%:define str(x) %:x /* #define str(x) #x */\n");
+ code.write("int main (int argc, char *argv<::>) /* argv[] */\n");
+ code.write("glue (<, %) /* { */\n");
+ code.write(" /* di_str[] = */\n");
+ code.write(" const char di_str glue(<, :)glue(:, >) = str(%:%:<::><%%>%:);\n");
+ code.write(" /* Check the glue macro actually pastes, and that the spelling of\n");
+ code.write(" all digraphs is preserved. */\n");
+ code.write(" if (glue(strc, mp) (di_str, \"%:%:<::><%%>%:\"))\n");
+ code.write(" err (\"Digraph spelling not preserved!\");\n");
+ code.write(" return 0;\n");
+ code.write("glue (%, >) /* } */\n");
+
+ parse(code.toString());
+ }
+
+ // digraphs/trigraphs have been temporarily remove
+ public void testBug39552B(int x) throws Exception {
+ Writer code = new StringWriter();
+
+ code.write("??=include <stdio.h>\n");
+ code.write("??=define TWELVE 1??/\n");
+ code.write("2\n");
+ code.write("static const char str??(??) = \"0123456789??/n\";\n");
+ code.write("int\n");
+ code.write("main(void)\n");
+ code.write("??<\n");
+ code.write(" unsigned char x = 5;\n");
+ code.write(" if (sizeof str != TWELVE)\n");
+ code.write(" abort ();\n");
+ code.write(" /* Test ^=, the only multi-character token to come from trigraphs. */\n");
+ code.write(" x ??'= 3;\n");
+ code.write(" if (x != 6)\n");
+ code.write(" abort ();\n");
+ code.write(" if ((5 ??! 3) != 7)\n");
+ code.write(" abort ();\n");
+ code.write(" return 0;\n");
+ code.write("??>\n");
+
+ parse(code.toString());
+ }
+
+ public void testBug39553() throws Exception {
+ parse("#define COMP_INC \"foobar.h\" \n" + "#include COMP_INC\n"); //$NON-NLS-2$
+ }
+
+ public void testBug39537() throws Exception {
+ parse("typedef foo<(U::id > 0)> foobar;");
+ }
+
+ public void testBug39546() throws Exception {
+ parse("signed char c = (signed char) 0xffffffff;");
+ }
+
+ public void testIndirectDeclarators() throws Exception {
+ parse("void (*x)(int);");
+ }
+
+ public void testBug39532() throws Exception {
+ parse("class N1::N2::B : public A {};");
+ }
+
+ public void testBug39540() throws Exception {
+ parse("class {} const null;");
+ }
+
+ public void testBug39530() throws Exception {
+ parse("X sPassed(-1);");
+ }
+
+ public void testBug39526() throws Exception {
+ parse("UnitList unit_list (String(\"keV\"));");
+ }
+
+ public void testBug39535() throws Exception {
+ parse("namespace bar = foo;");
+ }
+
+ public void testBug39504B() throws Exception {
+ parse("int y = sizeof (int*);");
+ }
+
+ public void testBug39505A() throws Exception {
+ parse("int AD::* gp_down = static_cast<int AD::*>(gp_stat);");
+ }
+
+ public void testBug39505B() throws Exception {
+ parse("int* gp_down = static_cast<int*>(gp_stat);");
+ }
+
+ public void testBug42985() throws Exception {
+ parse("const int x = 4; int y = ::x;");
+ }
+
+ public void testBug40419() throws Exception {
+ Writer code = new StringWriter();
+ try {
+ code.write("template <class T, class U> struct SuperSubclass {\n");
+ code.write("enum { value = (::Loki::Conversion<const volatile U*, const volatile T*>::exists && \n");
+ code.write("!::Loki::Conversion<const volatile T*, const volatile void*>::sameType) }; };");
+ } catch (IOException e) {
+ }
+ parse(code.toString());
+ }
+
+ public void testBug39556() throws Exception {
+ parse("int *restrict ip_fn (void);", true, ParserLanguage.C);
+ }
+
+ /**
+ * Test code: struct Example { Example(); Example(int); ~Example();};
+ * Purpose: tests a declaration in a class scope.
+ */
+ public void testBug43371() throws Exception {
+ // Parse and get the translaton unit
+ Writer code = new StringWriter();
+ code.write("struct Example { Example(); Example(int); ~Example();};");
+ parse(code.toString());
+ }
+
+ public void testBug43644() throws Exception {
+ parse("void foo();{ int x; }", false);
+ }
+
+ public void testBug43062() throws Exception {
+ parse("class X { operator short (); operator int unsigned(); operator int signed(); };");
+ }
+
+ public void testBug39531() throws Exception {
+ parse("class AString { operator char const *() const; };");
+ }
+
+ public void testBug40007() throws Exception {
+ parse("int y = #;", false);
+ }
+
+ public void testBug40759() throws Exception {
+ parse("#define X SomeName \n class X {};");
+ }
+
+ public void testBug44633() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("template <typename T> class A {};\n");
+ writer.write("class B { template <typename T> friend class A;\n");
+ writer.write("void method();\n");
+ writer.write("};\n");
+ parse(writer.toString());
+ }
+
+ public void testBug39525() throws Exception {
+ parse("C &(C::*DD)(const C &x) = &C::operator=;");
+ }
+
+ public void testBug41935() throws Exception {
+ parse("namespace A { int x; } namespace B = A;");
+ }
+
+ public void testBug39528() throws Exception {
+ Writer code = new StringWriter();
+ try {
+ code.write("struct B: public A {\n");
+ code.write(" A a;\n");
+ code.write(" B() try : A(1), a(2)\n");
+ code.write(" { throw 1; }\n");
+ code.write(" catch (...)\n");
+ code.write(" { if (c != 3) r |= 1; }\n");
+ code.write("};\n");
+ } catch (IOException e) {
+ }
+ parse(code.toString());
+ }
+
+ public void testBug39538() throws Exception {
+ parse("template C::operator int<float> ();");
+ }
+
+ public void testBug39536() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("template<class E>\n");
+ writer.write("class X {\n");
+ writer.write("X<E>(); // This fails \n");
+ writer.write("inline X<E>(int); // This also fails \n");
+ writer.write("inline ~X<E>(); // This works fine \n");
+ writer.write("};\n");
+ parse(writer.toString());
+ }
+
+ public void testBug39536A() throws Exception {
+ parse("template<class E> class X { X<E>(); };");
+ }
+
+ public void testBug39536B() throws Exception {
+ parse("template<class E> class X { inline X<E>(int); };");
+ }
+
+ public void testBug39542() throws Exception {
+ parse("void f(int a, struct {int b[a];} c) {}");
+ }
+
+ //Here starts C99-specific section
+ public void testBug39549() throws Exception {
+ parse("struct X x = { .b = 40, .z = { sizeof(X), 42 }, .t[3] = 2, .t.f[3].x = A * B };", true,
+ ParserLanguage.C);
+ // with trailing commas
+ parse("struct X x = { .b = 40, .z = { sizeof(X), 42,}, .t[3] = 2, .t.f[3].x = A * B ,};", true,
+ ParserLanguage.C);
+ }
+
+ public void testBug39551A() throws Exception {
+ parse("extern float _Complex conjf (float _Complex);", true, ParserLanguage.C);
+ }
+
+ public void testBug39551B() throws Exception {
+ parse("_Imaginary double id = 99.99 * __I__;", true, ParserLanguage.C);
+ }
+
+ public void testCBool() throws Exception {
+ parse("_Bool x;", true, ParserLanguage.C);
+ }
+
+ public void testBug39678() throws Exception {
+ parse("char *s = L\"a\" \"b\";");
+ }
+
+ public void testBug43110() throws Exception {
+ parse("void x(int y, ...);");
+ }
+
+ // public void testBug44370() throws Exception
+ // {
+ // parse("#define SWAP(x,y) {x|=y;y|=x;x|=y;}\n");
+ // Iterator macros = quickParseCallback.getMacros();
+ // assertNotNull(macros);
+ // assertTrue(macros.hasNext());
+ // IASTMacro swap = (IASTMacro) macros.next();
+ // assertFalse(macros.hasNext());
+ // assertEquals(swap.getName(), "SWAP");
+ // assertEquals(swap.getMacroType(),
+ // IMacroDescriptor.MacroType.FUNCTION_LIKE);
+ // String[] params = swap.getParameters();
+ // assertEquals(params.length, 2);
+ // assertEquals(params[0], "x");
+ // assertEquals(params[1], "y");
+ // String completeSignature = swap.getCompleteSignature().trim();
+ // assertEquals(completeSignature, "#define SWAP(x,y) {x|=y;y|=x;x|=y;}");
+ //
+ // assertEquals(swap.getExpansionSignature().trim(),"{x|=y;y|=x;x|=y;}");
+ //
+ // IToken[] tokens = swap.getTokenizedExpansion();
+ // validateToken(tokens[0], IToken.tLBRACE);
+ // validateIdentifier(tokens[1], "x");
+ // validateToken(tokens[2], IToken.tBITORASSIGN);
+ // validateIdentifier(tokens[3], "y");
+ // validateToken(tokens[4], IToken.tSEMI);
+ // validateIdentifier(tokens[5], "y");
+ // validateToken(tokens[6], IToken.tBITORASSIGN);
+ // validateIdentifier(tokens[7], "x");
+ // validateToken(tokens[8], IToken.tSEMI);
+ // validateIdentifier(tokens[9], "x");
+ // validateToken(tokens[10], IToken.tBITORASSIGN);
+ // validateIdentifier(tokens[11], "y");
+ // validateToken(tokens[12], IToken.tSEMI);
+ // validateToken(tokens[13], IToken.tRBRACE);
+ // }
+ // /**
+ // * @param token
+ // * @param string
+ // */
+ // private void validateIdentifier(IToken token, String identifierName) {
+ // validateToken(token, IToken.tIDENTIFIER);
+ // assertEquals(token.getImage(), identifierName);
+ // }
+ // /**
+ // * @param token
+ // * @param i
+ // */
+ // private void validateToken(IToken token, int signal) {
+ // assertEquals(token.getType(), signal);
+ // }
+
+ public void testBug47752() throws Exception {
+ //TODO requires CPPVisitor
+ parse("void func(cFoo bar) try { } catch (const char * error){ }");
+ }
+
+ public void testBug47628() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("void h(char) { }\n");
+ writer.write("void h(unsigned char) { }\n");
+ writer.write("void h(signed char) { } // not shown in outline, parsed as char\n");
+ parse(writer.toString());
+ }
+
+ public void testBug44336() throws Exception {
+ parse("class A {}; typedef typename A foo;");
+ }
+
+ public void testBug39705() throws Exception {
+ parse("#ident \"@(#)filename.c 1.3 90/02/12\"");
+ }
+
+ public void testBug45235() throws Exception {
+ parse("class A { friend class B; friend void f(); }; ");
+ }
+
+ public void testBug59179() throws Exception {
+ parse("class __decl main{ int main; };", false);
+ }
+
+ public void testBug57652() throws Exception {
+ parse("struct file_operations driver_fops = { open: device_open, release: device_release };", true,
+ ParserLanguage.C, true);
+ }
+
+ protected void parse(String code, boolean expectedToPass, ParserLanguage lang, boolean gcc) throws Exception {
FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
- IScannerInfo scannerInfo = new ScannerInfo();
- IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
- ISourceCodeParser parser2 = null;
- if (lang == ParserLanguage.CPP) {
- ICPPParserExtensionConfiguration config = null;
- if (gcc)
- config = new GPPParserExtensionConfiguration();
- else
- config = new ANSICPPParserExtensionConfiguration();
- parser2 = new GNUCPPSourceParser(scanner, ParserMode.QUICK_PARSE, NULL_LOG, config);
- } else {
- ICParserExtensionConfiguration config = null;
- if (gcc)
- config = new GCCParserExtensionConfiguration();
- else
- config = new ANSICParserExtensionConfiguration();
-
- parser2 = new GNUCSourceParser(scanner, ParserMode.QUICK_PARSE, NULL_LOG, config);
- }
- IASTTranslationUnit tu = parser2.parse();
- if (parser2.encounteredError() && expectedToPass)
- throw new ParserException("FAILURE");
- if (expectedToPass) {
- if (lang == ParserLanguage.C) {
- IASTProblem[] problems = CVisitor.getProblems(tu);
- assertEquals(problems.length, 0);
- } else if (lang == ParserLanguage.CPP) {
- IASTProblem[] problems = CPPVisitor.getProblems(tu);
- assertEquals(problems.length, 0);
- }
- }
- }
-
- public void testBug60142() throws Exception {
- parse("unsigned long var;");
- }
-
- public void testBug61431() throws Exception {
- for (int i = 0; i < 2; ++i) {
- ParserLanguage language = (i == 0) ? ParserLanguage.C : ParserLanguage.CPP;
- parse("int k[][] = { {0, {1}, {2,3}};", false, language);
- }
- }
-
- public void testBadIdentifier() throws Exception {
- parse("class 0302 { private: int stinks; };", false);
- }
-
- public void testBug67622() throws Exception {
- parse("const char * x = __FILE__;");
- }
-
- public void testBug68116() throws Exception {
- StringBuilder buffer = new StringBuilder("char dummy[] = \"0123456789");
- for (int i = 0; i < 5000; ++i)
- buffer.append("0123456789");
- buffer.append("\";");
- parse(buffer.toString());
- }
-
- public void testBug69161() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#define MACRO(s) s\n ");
- writer.write("char *testQueries[] =\n");
- writer.write("{\n");
- writer.write("MACRO(\",\"),\n");
- writer.write("MACRO(\"(\"),\n");
- writer.write("MACRO(\")\")\n");
- writer.write("};\n");
- parse(writer.toString());
- }
-
- public void testBug73524() throws Exception {
- Writer writer = new StringWriter();
- writer.write("static char fmt_1002[] = \"(/,\\002At iterate\\002,i5,4x,\\002f= \\002,1p,d12\\\r\n");
- writer.write(".5,4x,\\002|proj g|= \\002,1p,d12.5)\";");
- parse(writer.toString(), true, ParserLanguage.C);
- }
-
- public void testBug39694() throws Exception {
- parse("int ab$cd = 1;");
- }
-
- public void testBug39704A() throws Exception {
- StringWriter writer = new StringWriter();
- writer.write("#define __declspec(x) __attribute__((x))");
- writer.write("__declspec (dllimport) int foo;");
- parse(writer.toString());
- }
-
- public void testBug39704D() throws Exception {
- StringWriter writer = new StringWriter();
- writer.write("#define __declspec(x) __attribute__((x))");
- writer.write("__declspec(dllexport) int func1 (int a) {}");
- parse(writer.toString());
- }
-
- public void testBug39695() throws Exception {
- parse("int a = __alignof__ (int);", true, ParserLanguage.CPP, true);
- }
-
- public void testBug39684() throws Exception {
- parse("typeof(foo(1)) bar () { return foo(1); }", true, ParserLanguage.CPP, true);
- }
-
- public void testBug39703() throws Exception {
- Writer code = new StringWriter();
- code.write("/* __extension__ enables GNU C mode for the duration of the declaration. */\n");
- code.write("__extension__ struct G {\n");
- code.write(" struct { char z; };\n");
- code.write(" char g;\n");
- code.write("};\n");
- parse(code.toString(), true, ParserLanguage.CPP, true);
- }
-
- public void testBug39698A() throws Exception {
- parse("int c = a <? b;", true, ParserLanguage.CPP, true);
- }
-
- public void testBug39698B() throws Exception {
- parse("int c = a >? b;", true, ParserLanguage.CPP, true);
- }
-
- public void testBug39554() throws Exception {
- parse("_Pragma(\"foobar\")", true, ParserLanguage.C);
- }
-
- public void testBug39704B() throws Exception {
- parse("extern int (* import) (void) __attribute__((dllimport));", true, ParserLanguage.CPP, true);
- }
-
- public void testBug39704C() throws Exception {
- parse("int func2 (void) __attribute__((dllexport));", true, ParserLanguage.CPP, true);
- }
-
- public void testBug39686() throws Exception {
- Writer code = new StringWriter();
- code.write("__complex__ double x; // complex double\n");
- code.write("__complex__ short int a; // complex short int\n");
- code.write("__complex__ float y = 2.5fi; // 2.5 imaginary float literal\n");
- code.write("__complex__ int a = 3i; // imaginary intege r literal\n");
- code.write("double v = __real__ x; // real part of expression\n");
- code.write("double w = __imag__ x; // imaginary part of expression\n");
- parse(code.toString(), true, ParserLanguage.C, true);
- }
-
- public void testBug39681() throws Exception {
- Writer code = new StringWriter();
- code.write("double\n");
- code.write("foo (double a, double b)\n");
- code.write("{\n");
- code.write(" double square (double z) { return z * z; }\n");
- code.write(" return square (a) + square (b);\n");
- code.write("}\n");
- parse(code.toString());
- }
-
- public void testBug39677() throws Exception {
- parse("B::B() : a(({ 1; })) {}", true, ParserLanguage.CPP, true);
- Writer writer = new StringWriter();
- writer.write("B::B() : a(({ int y = foo (); int z;\n");
- writer.write("if (y > 0) z = y;\n");
- writer.write("else z = - y;\n");
- writer.write("z; })) {}\n");
- parse(writer.toString(), true, ParserLanguage.CPP, true);
- writer = new StringWriter();
- writer.write("int x = ({ int y = foo (); int z;\n");
- writer.write("if (y > 0) z = y;\n");
- writer.write("else z = - y;\n");
- writer.write("z; });\n");
- parse(writer.toString(), true, ParserLanguage.CPP, true);
- writer = new StringWriter();
- writer.write("typeof({ int y = foo (); int z;\n");
- writer.write("if (y > 0) z = y;\n");
- writer.write("else z = - y;\n");
- writer.write("z; }) zoot;\n");
- parse(writer.toString(), true, ParserLanguage.CPP, true);
- }
-
- public void testBug39701A() throws Exception {
- parse("extern template int max (int, int);", true, ParserLanguage.CPP, true);
- }
-
- public void testBug39701B() throws Exception {
- parse("inline template class Foo<int>;", true, ParserLanguage.CPP, true);
- }
-
- public void testBug39701C() throws Exception {
- parse("static template class Foo<int>;", true, ParserLanguage.CPP, true);
- }
+ IScannerInfo scannerInfo = new ScannerInfo();
+ IScanner scanner = AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
+ ISourceCodeParser parser2 = null;
+ if (lang == ParserLanguage.CPP) {
+ ICPPParserExtensionConfiguration config = null;
+ if (gcc)
+ config = new GPPParserExtensionConfiguration();
+ else
+ config = new ANSICPPParserExtensionConfiguration();
+ parser2 = new GNUCPPSourceParser(scanner, ParserMode.QUICK_PARSE, NULL_LOG, config);
+ } else {
+ ICParserExtensionConfiguration config = null;
+ if (gcc)
+ config = new GCCParserExtensionConfiguration();
+ else
+ config = new ANSICParserExtensionConfiguration();
+
+ parser2 = new GNUCSourceParser(scanner, ParserMode.QUICK_PARSE, NULL_LOG, config);
+ }
+ IASTTranslationUnit tu = parser2.parse();
+ if (parser2.encounteredError() && expectedToPass)
+ throw new ParserException("FAILURE");
+ if (expectedToPass) {
+ if (lang == ParserLanguage.C) {
+ IASTProblem[] problems = CVisitor.getProblems(tu);
+ assertEquals(problems.length, 0);
+ } else if (lang == ParserLanguage.CPP) {
+ IASTProblem[] problems = CPPVisitor.getProblems(tu);
+ assertEquals(problems.length, 0);
+ }
+ }
+ }
+
+ public void testBug60142() throws Exception {
+ parse("unsigned long var;");
+ }
+
+ public void testBug61431() throws Exception {
+ for (int i = 0; i < 2; ++i) {
+ ParserLanguage language = (i == 0) ? ParserLanguage.C : ParserLanguage.CPP;
+ parse("int k[][] = { {0, {1}, {2,3}};", false, language);
+ }
+ }
+
+ public void testBadIdentifier() throws Exception {
+ parse("class 0302 { private: int stinks; };", false);
+ }
+
+ public void testBug67622() throws Exception {
+ parse("const char * x = __FILE__;");
+ }
+
+ public void testBug68116() throws Exception {
+ StringBuilder buffer = new StringBuilder("char dummy[] = \"0123456789");
+ for (int i = 0; i < 5000; ++i)
+ buffer.append("0123456789");
+ buffer.append("\";");
+ parse(buffer.toString());
+ }
+
+ public void testBug69161() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#define MACRO(s) s\n ");
+ writer.write("char *testQueries[] =\n");
+ writer.write("{\n");
+ writer.write("MACRO(\",\"),\n");
+ writer.write("MACRO(\"(\"),\n");
+ writer.write("MACRO(\")\")\n");
+ writer.write("};\n");
+ parse(writer.toString());
+ }
+
+ public void testBug73524() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("static char fmt_1002[] = \"(/,\\002At iterate\\002,i5,4x,\\002f= \\002,1p,d12\\\r\n");
+ writer.write(".5,4x,\\002|proj g|= \\002,1p,d12.5)\";");
+ parse(writer.toString(), true, ParserLanguage.C);
+ }
+
+ public void testBug39694() throws Exception {
+ parse("int ab$cd = 1;");
+ }
+
+ public void testBug39704A() throws Exception {
+ StringWriter writer = new StringWriter();
+ writer.write("#define __declspec(x) __attribute__((x))");
+ writer.write("__declspec (dllimport) int foo;");
+ parse(writer.toString());
+ }
+
+ public void testBug39704D() throws Exception {
+ StringWriter writer = new StringWriter();
+ writer.write("#define __declspec(x) __attribute__((x))");
+ writer.write("__declspec(dllexport) int func1 (int a) {}");
+ parse(writer.toString());
+ }
+
+ public void testBug39695() throws Exception {
+ parse("int a = __alignof__ (int);", true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39684() throws Exception {
+ parse("typeof(foo(1)) bar () { return foo(1); }", true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39703() throws Exception {
+ Writer code = new StringWriter();
+ code.write("/* __extension__ enables GNU C mode for the duration of the declaration. */\n");
+ code.write("__extension__ struct G {\n");
+ code.write(" struct { char z; };\n");
+ code.write(" char g;\n");
+ code.write("};\n");
+ parse(code.toString(), true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39698A() throws Exception {
+ parse("int c = a <? b;", true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39698B() throws Exception {
+ parse("int c = a >? b;", true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39554() throws Exception {
+ parse("_Pragma(\"foobar\")", true, ParserLanguage.C);
+ }
+
+ public void testBug39704B() throws Exception {
+ parse("extern int (* import) (void) __attribute__((dllimport));", true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39704C() throws Exception {
+ parse("int func2 (void) __attribute__((dllexport));", true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39686() throws Exception {
+ Writer code = new StringWriter();
+ code.write("__complex__ double x; // complex double\n");
+ code.write("__complex__ short int a; // complex short int\n");
+ code.write("__complex__ float y = 2.5fi; // 2.5 imaginary float literal\n");
+ code.write("__complex__ int a = 3i; // imaginary intege r literal\n");
+ code.write("double v = __real__ x; // real part of expression\n");
+ code.write("double w = __imag__ x; // imaginary part of expression\n");
+ parse(code.toString(), true, ParserLanguage.C, true);
+ }
+
+ public void testBug39681() throws Exception {
+ Writer code = new StringWriter();
+ code.write("double\n");
+ code.write("foo (double a, double b)\n");
+ code.write("{\n");
+ code.write(" double square (double z) { return z * z; }\n");
+ code.write(" return square (a) + square (b);\n");
+ code.write("}\n");
+ parse(code.toString());
+ }
+
+ public void testBug39677() throws Exception {
+ parse("B::B() : a(({ 1; })) {}", true, ParserLanguage.CPP, true);
+ Writer writer = new StringWriter();
+ writer.write("B::B() : a(({ int y = foo (); int z;\n");
+ writer.write("if (y > 0) z = y;\n");
+ writer.write("else z = - y;\n");
+ writer.write("z; })) {}\n");
+ parse(writer.toString(), true, ParserLanguage.CPP, true);
+ writer = new StringWriter();
+ writer.write("int x = ({ int y = foo (); int z;\n");
+ writer.write("if (y > 0) z = y;\n");
+ writer.write("else z = - y;\n");
+ writer.write("z; });\n");
+ parse(writer.toString(), true, ParserLanguage.CPP, true);
+ writer = new StringWriter();
+ writer.write("typeof({ int y = foo (); int z;\n");
+ writer.write("if (y > 0) z = y;\n");
+ writer.write("else z = - y;\n");
+ writer.write("z; }) zoot;\n");
+ parse(writer.toString(), true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39701A() throws Exception {
+ parse("extern template int max (int, int);", true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39701B() throws Exception {
+ parse("inline template class Foo<int>;", true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39701C() throws Exception {
+ parse("static template class Foo<int>;", true, ParserLanguage.CPP, true);
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticTestBase.java
index f2cad1b1f41..3cd2404c478 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticTestBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticTestBase.java
@@ -46,71 +46,74 @@ public class SemanticTestBase extends BaseTestCase {
public SemanticTestBase() {
super();
}
+
public SemanticTestBase(String name) {
super(name);
}
-
- protected static class CommonCTypes {
- public static IType pointerToVoid = pointerTo(CBasicType.VOID);
- public static IType pointerToConstVoid = pointerTo(constOf(CBasicType.VOID));
- public static IType pointerToInt = pointerTo(CBasicType.INT);
- public static IType pointerToConstInt = pointerTo(constOf(CBasicType.INT));
- public static IType pointerToVolatileInt = pointerTo(volatileOf(CBasicType.INT));
- public static IType pointerToConstVolatileInt = pointerTo(constVolatileOf(CBasicType.INT));
-
- private static IType pointerTo(IType type) {
- return new CPointerType(type, 0);
- }
- private static IType constOf(IType type) {
- return new CQualifierType(type, true, false, false);
- }
- private static IType volatileOf(IType type) {
- return new CQualifierType(type, false, true, false);
- }
- private static IType constVolatileOf(IType type) {
- return new CQualifierType(type, true, true, false);
- }
- }
-
- protected static class CommonCPPTypes {
- public static IType char_ = CPPBasicType.CHAR;
- public static IType int_ = CPPBasicType.INT;
- public static IType void_ = CPPBasicType.VOID;
- public static IType constChar = constOf(char_);
- public static IType constInt = constOf(int_);
- public static IType pointerToInt = pointerTo(int_);
- public static IType pointerToConstChar = pointerTo(constChar);
- public static IType pointerToConstInt = pointerTo(constInt);
- public static IType referenceToInt = referenceTo(int_);
- public static IType referenceToConstInt = referenceTo(constInt);
- public static IType rvalueReferenceToInt = rvalueReferenceTo(int_);
- public static IType rvalueReferenceToConstInt = rvalueReferenceTo(constInt);
-
- private static IType pointerTo(IType type) {
- return new CPPPointerType(type);
- }
-
- private static IType constOf(IType type) {
- return new CPPQualifierType(type, true, false);
- }
-
- private static IType referenceTo(IType type) {
- return new CPPReferenceType(type, false);
- }
-
- private static IType rvalueReferenceTo(IType type) {
- return new CPPReferenceType(type, true);
- }
- }
-
+
+ protected static class CommonCTypes {
+ public static IType pointerToVoid = pointerTo(CBasicType.VOID);
+ public static IType pointerToConstVoid = pointerTo(constOf(CBasicType.VOID));
+ public static IType pointerToInt = pointerTo(CBasicType.INT);
+ public static IType pointerToConstInt = pointerTo(constOf(CBasicType.INT));
+ public static IType pointerToVolatileInt = pointerTo(volatileOf(CBasicType.INT));
+ public static IType pointerToConstVolatileInt = pointerTo(constVolatileOf(CBasicType.INT));
+
+ private static IType pointerTo(IType type) {
+ return new CPointerType(type, 0);
+ }
+
+ private static IType constOf(IType type) {
+ return new CQualifierType(type, true, false, false);
+ }
+
+ private static IType volatileOf(IType type) {
+ return new CQualifierType(type, false, true, false);
+ }
+
+ private static IType constVolatileOf(IType type) {
+ return new CQualifierType(type, true, true, false);
+ }
+ }
+
+ protected static class CommonCPPTypes {
+ public static IType char_ = CPPBasicType.CHAR;
+ public static IType int_ = CPPBasicType.INT;
+ public static IType void_ = CPPBasicType.VOID;
+ public static IType constChar = constOf(char_);
+ public static IType constInt = constOf(int_);
+ public static IType pointerToInt = pointerTo(int_);
+ public static IType pointerToConstChar = pointerTo(constChar);
+ public static IType pointerToConstInt = pointerTo(constInt);
+ public static IType referenceToInt = referenceTo(int_);
+ public static IType referenceToConstInt = referenceTo(constInt);
+ public static IType rvalueReferenceToInt = rvalueReferenceTo(int_);
+ public static IType rvalueReferenceToConstInt = rvalueReferenceTo(constInt);
+
+ private static IType pointerTo(IType type) {
+ return new CPPPointerType(type);
+ }
+
+ private static IType constOf(IType type) {
+ return new CPPQualifierType(type, true, false);
+ }
+
+ private static IType referenceTo(IType type) {
+ return new CPPReferenceType(type, false);
+ }
+
+ private static IType rvalueReferenceTo(IType type) {
+ return new CPPReferenceType(type, true);
+ }
+ }
+
protected static void assertSameType(IType expected, IType actual) {
assertNotNull(expected);
assertNotNull(actual);
- assertTrue("Expected same types, but the types were: '" +
- ASTTypeUtil.getType(expected, false) + "' and '" + ASTTypeUtil.getType(actual, false) + "'",
- expected.isSameType(actual));
+ assertTrue("Expected same types, but the types were: '" + ASTTypeUtil.getType(expected, false) + "' and '"
+ + ASTTypeUtil.getType(actual, false) + "'", expected.isSameType(actual));
}
-
+
protected static SizeAndAlignment getSizeAndAlignment(IType type, IASTNode lookupPoint) {
try {
CPPSemantics.pushLookupPoint(lookupPoint);
@@ -124,71 +127,71 @@ public class SemanticTestBase extends BaseTestCase {
protected String contents;
protected IASTTranslationUnit tu;
- public BindingAssertionHelper(String contents, IASTTranslationUnit tu) {
- this.contents = contents;
- this.tu = tu;
+ public BindingAssertionHelper(String contents, IASTTranslationUnit tu) {
+ this.contents = contents;
+ this.tu = tu;
}
- public IASTTranslationUnit getTranslationUnit() {
- return tu;
- }
+ public IASTTranslationUnit getTranslationUnit() {
+ return tu;
+ }
public IProblemBinding assertProblem(String section, int len) {
- if (len <= 0)
- len= section.length() + len;
- IBinding binding= binding(section, len);
- assertTrue("Non-ProblemBinding for name: " + section.substring(0, len),
- binding instanceof IProblemBinding);
- return (IProblemBinding) binding;
- }
-
- public IProblemBinding assertProblem(String context, int len, int problemId) {
- IProblemBinding problemBinding = assertProblem(context, len);
- assertEquals(problemId, problemBinding.getID());
- return problemBinding;
- }
-
- public IProblemBinding assertProblem(String context, String name) {
- IBinding binding= binding(context, name);
- assertTrue("Non-ProblemBinding for name: " + name, binding instanceof IProblemBinding);
- return (IProblemBinding) binding;
- }
-
- public IProblemBinding assertProblem(String context, String name, int problemId) {
- IProblemBinding problemBinding = assertProblem(context, name);
- assertEquals(problemId, problemBinding.getID());
- return problemBinding;
- }
-
- public <T extends IBinding> T assertNonProblem(String section, int len) {
- if (len <= 0)
- len= section.length() + len;
- IBinding binding= binding(section, len);
- if (binding instanceof IProblemBinding) {
- IProblemBinding problem= (IProblemBinding) binding;
- fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID()) + ")");
- }
- if (binding == null) {
- fail("Null binding resolved for name: " + section.substring(0, len));
- }
- return (T) binding;
- }
-
- private int getIdentifierOffset(String str) {
- for (int i = 0; i < str.length(); ++i) {
- if (Character.isJavaIdentifierPart(str.charAt(i)))
- return i;
- }
- fail("Didn't find identifier in \"" + str + "\"");
- return -1;
- }
-
- private int getIdentifierLength(String str, int offset) {
- int i;
- for (i = offset; i < str.length() && Character.isJavaIdentifierPart(str.charAt(i)); ++i) {
- }
- return i;
- }
+ if (len <= 0)
+ len = section.length() + len;
+ IBinding binding = binding(section, len);
+ assertTrue("Non-ProblemBinding for name: " + section.substring(0, len), binding instanceof IProblemBinding);
+ return (IProblemBinding) binding;
+ }
+
+ public IProblemBinding assertProblem(String context, int len, int problemId) {
+ IProblemBinding problemBinding = assertProblem(context, len);
+ assertEquals(problemId, problemBinding.getID());
+ return problemBinding;
+ }
+
+ public IProblemBinding assertProblem(String context, String name) {
+ IBinding binding = binding(context, name);
+ assertTrue("Non-ProblemBinding for name: " + name, binding instanceof IProblemBinding);
+ return (IProblemBinding) binding;
+ }
+
+ public IProblemBinding assertProblem(String context, String name, int problemId) {
+ IProblemBinding problemBinding = assertProblem(context, name);
+ assertEquals(problemId, problemBinding.getID());
+ return problemBinding;
+ }
+
+ public <T extends IBinding> T assertNonProblem(String section, int len) {
+ if (len <= 0)
+ len = section.length() + len;
+ IBinding binding = binding(section, len);
+ if (binding instanceof IProblemBinding) {
+ IProblemBinding problem = (IProblemBinding) binding;
+ fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID())
+ + ")");
+ }
+ if (binding == null) {
+ fail("Null binding resolved for name: " + section.substring(0, len));
+ }
+ return (T) binding;
+ }
+
+ private int getIdentifierOffset(String str) {
+ for (int i = 0; i < str.length(); ++i) {
+ if (Character.isJavaIdentifierPart(str.charAt(i)))
+ return i;
+ }
+ fail("Didn't find identifier in \"" + str + "\"");
+ return -1;
+ }
+
+ private int getIdentifierLength(String str, int offset) {
+ int i;
+ for (i = offset; i < str.length() && Character.isJavaIdentifierPart(str.charAt(i)); ++i) {
+ }
+ return i;
+ }
public IProblemBinding assertProblemOnFirstIdentifier(String section) {
int offset = getIdentifierOffset(section);
@@ -209,20 +212,20 @@ public class SemanticTestBase extends BaseTestCase {
}
public void assertNoName(String section, int len) {
- IASTName name= findName(section, len);
+ IASTName name = findName(section, len);
if (name != null) {
String selection = section.substring(0, len);
fail("Found unexpected \"" + selection + "\": " + name.resolveBinding());
}
- }
-
- /**
- * Asserts that there is exactly one name at the given location and that
- * it resolves to the given type of binding.
- */
- public IASTImplicitName assertImplicitName(String section, int len, Class<?> bindingClass) {
- IASTName name = findImplicitName(section, len);
- final String selection = section.substring(0, len);
+ }
+
+ /**
+ * Asserts that there is exactly one name at the given location and that
+ * it resolves to the given type of binding.
+ */
+ public IASTImplicitName assertImplicitName(String section, int len, Class<?> bindingClass) {
+ IASTName name = findImplicitName(section, len);
+ final String selection = section.substring(0, len);
assertNotNull("Did not find \"" + selection + "\"", name);
assertInstance(name, IASTImplicitName.class);
@@ -241,171 +244,170 @@ public class SemanticTestBase extends BaseTestCase {
assertTrue(found);
}
- assertEquals(selection, name.getRawSignature());
- IBinding binding = name.resolveBinding();
- assertNotNull(binding);
- assertInstance(binding, bindingClass);
- return (IASTImplicitName) name;
- }
-
- public void assertNoImplicitName(String section, int len) {
- IASTName name = findImplicitName(section, len);
- final String selection = section.substring(0, len);
- assertNull("found name \"" + selection + "\"", name);
- }
-
- public IASTImplicitName[] getImplicitNames(String section) {
- return getImplicitNames(section, section.length());
- }
-
- public IASTImplicitName[] getImplicitNames(String section, int len) {
- IASTName name = findImplicitName(section, len);
- IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
+ assertEquals(selection, name.getRawSignature());
+ IBinding binding = name.resolveBinding();
+ assertNotNull(binding);
+ assertInstance(binding, bindingClass);
+ return (IASTImplicitName) name;
+ }
+
+ public void assertNoImplicitName(String section, int len) {
+ IASTName name = findImplicitName(section, len);
+ final String selection = section.substring(0, len);
+ assertNull("found name \"" + selection + "\"", name);
+ }
+
+ public IASTImplicitName[] getImplicitNames(String section) {
+ return getImplicitNames(section, section.length());
+ }
+
+ public IASTImplicitName[] getImplicitNames(String section, int len) {
+ IASTName name = findImplicitName(section, len);
+ IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
IASTImplicitName[] implicits = owner.getImplicitNames();
return implicits;
- }
-
- public IASTImplicitDestructorName[] getImplicitDestructorNames(String section) {
- return getImplicitDestructorNames(section, section.length());
- }
-
- public IASTImplicitDestructorName[] getImplicitDestructorNames(String section, int len) {
- final int offset = contents.indexOf(section);
- assertTrue(offset >= 0);
- IASTNodeSelector selector = tu.getNodeSelector(null);
- IASTNode enclosingNode = selector.findEnclosingNode(offset, len);
- if (!(enclosingNode instanceof IASTImplicitDestructorNameOwner))
- return IASTImplicitDestructorName.EMPTY_NAME_ARRAY;
- return ((IASTImplicitDestructorNameOwner) enclosingNode).getImplicitDestructorNames();
- }
-
- public IASTName findName(String section, int len) {
- final int offset = contents.indexOf(section);
- assertTrue("Section \"" + section + "\" not found", offset >= 0);
- IASTNodeSelector selector = tu.getNodeSelector(null);
- return selector.findName(offset, len);
- }
-
- public IASTName findName(String context, String name) {
- if (context == null) {
- context = contents;
- }
- int offset = contents.indexOf(context);
- assertTrue("Context \"" + context + "\" not found", offset >= 0);
- int nameOffset = context.indexOf(name);
- assertTrue("Name \"" + name + "\" not found", nameOffset >= 0);
- IASTNodeSelector selector = tu.getNodeSelector(null);
- return selector.findName(offset + nameOffset, name.length());
- }
-
- public IASTName findName(String name) {
- return findName(contents, name);
- }
-
- public IASTImplicitName findImplicitName(String section, int len) {
- final int offset = contents.indexOf(section);
- assertTrue(offset >= 0);
- IASTNodeSelector selector = tu.getNodeSelector(null);
- return selector.findImplicitName(offset, len);
- }
-
- public <T extends IASTNode> T assertNode(String context, String nodeText, Class... cs) {
- if (context == null) {
- context = contents;
- }
- int offset = contents.indexOf(context);
- assertTrue("Context \"" + context + "\" not found", offset >= 0);
- int nodeOffset = context.indexOf(nodeText);
- assertTrue("Node \"" + nodeText + "\" not found", nodeOffset >= 0);
- IASTNodeSelector selector = tu.getNodeSelector(null);
- IASTNode node = selector.findNode(offset + nodeOffset, nodeText.length());
- return assertType(node, cs);
- }
-
- public <T extends IASTNode> T assertNode(String nodeText, Class... cs) {
- return assertNode(contents, nodeText, cs);
- }
-
- private String renderProblemID(int i) {
- try {
- for (Field field : IProblemBinding.class.getDeclaredFields()) {
- if (field.getName().startsWith("SEMANTIC_")) {
- if (field.getType() == int.class) {
- Integer ci= (Integer) field.get(null);
- if (ci.intValue() == i) {
- return field.getName();
- }
- }
- }
- }
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- return "Unknown problem ID";
- }
-
- public <T extends IBinding> T assertNonProblem(String section, int len, Class... cs) {
- if (len <= 0)
- len += section.length();
- IBinding binding= binding(section, len);
- assertTrue("ProblemBinding for name: " + section.substring(0, len),
- !(binding instanceof IProblemBinding));
- return assertType(binding, cs);
- }
-
- public <T extends IBinding> T assertNonProblem(String section, Class... cs) {
- return assertNonProblem(section, section.length(), cs);
- }
-
- public <T extends IBinding> T assertNonProblem(String context, String name, Class... cs) {
- IBinding binding= binding(context, name);
- assertTrue("ProblemBinding for name: " + name, !(binding instanceof IProblemBinding));
- return assertType(binding, cs);
- }
-
- public void assertVariableType(String variableName, IType expectedType) {
- IVariable var = assertNonProblem(variableName);
- assertSameType(expectedType, var.getType());
- }
-
- public void assertVariableTypeProblem(String variableName) {
- IVariable var = assertNonProblem(variableName);
- assertInstance(var.getType(), IProblemType.class);
- }
-
- public void assertVariableValue(String variableName, long expectedValue) {
- IVariable var = assertNonProblem(variableName);
- BaseTestCase.assertVariableValue(var, expectedValue);
- }
+ }
+
+ public IASTImplicitDestructorName[] getImplicitDestructorNames(String section) {
+ return getImplicitDestructorNames(section, section.length());
+ }
+
+ public IASTImplicitDestructorName[] getImplicitDestructorNames(String section, int len) {
+ final int offset = contents.indexOf(section);
+ assertTrue(offset >= 0);
+ IASTNodeSelector selector = tu.getNodeSelector(null);
+ IASTNode enclosingNode = selector.findEnclosingNode(offset, len);
+ if (!(enclosingNode instanceof IASTImplicitDestructorNameOwner))
+ return IASTImplicitDestructorName.EMPTY_NAME_ARRAY;
+ return ((IASTImplicitDestructorNameOwner) enclosingNode).getImplicitDestructorNames();
+ }
+
+ public IASTName findName(String section, int len) {
+ final int offset = contents.indexOf(section);
+ assertTrue("Section \"" + section + "\" not found", offset >= 0);
+ IASTNodeSelector selector = tu.getNodeSelector(null);
+ return selector.findName(offset, len);
+ }
+
+ public IASTName findName(String context, String name) {
+ if (context == null) {
+ context = contents;
+ }
+ int offset = contents.indexOf(context);
+ assertTrue("Context \"" + context + "\" not found", offset >= 0);
+ int nameOffset = context.indexOf(name);
+ assertTrue("Name \"" + name + "\" not found", nameOffset >= 0);
+ IASTNodeSelector selector = tu.getNodeSelector(null);
+ return selector.findName(offset + nameOffset, name.length());
+ }
+
+ public IASTName findName(String name) {
+ return findName(contents, name);
+ }
+
+ public IASTImplicitName findImplicitName(String section, int len) {
+ final int offset = contents.indexOf(section);
+ assertTrue(offset >= 0);
+ IASTNodeSelector selector = tu.getNodeSelector(null);
+ return selector.findImplicitName(offset, len);
+ }
+
+ public <T extends IASTNode> T assertNode(String context, String nodeText, Class... cs) {
+ if (context == null) {
+ context = contents;
+ }
+ int offset = contents.indexOf(context);
+ assertTrue("Context \"" + context + "\" not found", offset >= 0);
+ int nodeOffset = context.indexOf(nodeText);
+ assertTrue("Node \"" + nodeText + "\" not found", nodeOffset >= 0);
+ IASTNodeSelector selector = tu.getNodeSelector(null);
+ IASTNode node = selector.findNode(offset + nodeOffset, nodeText.length());
+ return assertType(node, cs);
+ }
+
+ public <T extends IASTNode> T assertNode(String nodeText, Class... cs) {
+ return assertNode(contents, nodeText, cs);
+ }
+
+ private String renderProblemID(int i) {
+ try {
+ for (Field field : IProblemBinding.class.getDeclaredFields()) {
+ if (field.getName().startsWith("SEMANTIC_")) {
+ if (field.getType() == int.class) {
+ Integer ci = (Integer) field.get(null);
+ if (ci.intValue() == i) {
+ return field.getName();
+ }
+ }
+ }
+ }
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ return "Unknown problem ID";
+ }
+
+ public <T extends IBinding> T assertNonProblem(String section, int len, Class... cs) {
+ if (len <= 0)
+ len += section.length();
+ IBinding binding = binding(section, len);
+ assertTrue("ProblemBinding for name: " + section.substring(0, len), !(binding instanceof IProblemBinding));
+ return assertType(binding, cs);
+ }
+
+ public <T extends IBinding> T assertNonProblem(String section, Class... cs) {
+ return assertNonProblem(section, section.length(), cs);
+ }
+
+ public <T extends IBinding> T assertNonProblem(String context, String name, Class... cs) {
+ IBinding binding = binding(context, name);
+ assertTrue("ProblemBinding for name: " + name, !(binding instanceof IProblemBinding));
+ return assertType(binding, cs);
+ }
+
+ public void assertVariableType(String variableName, IType expectedType) {
+ IVariable var = assertNonProblem(variableName);
+ assertSameType(expectedType, var.getType());
+ }
+
+ public void assertVariableTypeProblem(String variableName) {
+ IVariable var = assertNonProblem(variableName);
+ assertInstance(var.getType(), IProblemType.class);
+ }
+
+ public void assertVariableValue(String variableName, long expectedValue) {
+ IVariable var = assertNonProblem(variableName);
+ BaseTestCase.assertVariableValue(var, expectedValue);
+ }
public <T, U extends T> U assertType(T obj, Class... cs) {
- for (Class c : cs) {
- assertInstance(obj, c);
- }
- return (U) obj;
+ for (Class c : cs) {
+ assertInstance(obj, c);
+ }
+ return (U) obj;
}
- private IBinding binding(String section, int len) {
- IASTName astName = findName(section, len);
- final String selection = section.substring(0, len);
+ private IBinding binding(String section, int len) {
+ IASTName astName = findName(section, len);
+ final String selection = section.substring(0, len);
assertNotNull("No AST name for \"" + selection + "\"", astName);
- assertEquals(selection, astName.getRawSignature());
+ assertEquals(selection, astName.getRawSignature());
- IBinding binding = astName.resolveBinding();
- assertNotNull("No binding for " + astName.getRawSignature(), binding);
+ IBinding binding = astName.resolveBinding();
+ assertNotNull("No binding for " + astName.getRawSignature(), binding);
- return astName.resolveBinding();
- }
+ return astName.resolveBinding();
+ }
- private IBinding binding(String context, String name) {
- IASTName astName = findName(context, name);
+ private IBinding binding(String context, String name) {
+ IASTName astName = findName(context, name);
assertNotNull("No AST name for \"" + name + "\"", astName);
- assertEquals(name, astName.getRawSignature());
+ assertEquals(name, astName.getRawSignature());
- IBinding binding = astName.resolveBinding();
- assertNotNull("No binding for " + astName.getRawSignature(), binding);
+ IBinding binding = astName.resolveBinding();
+ assertNotNull("No binding for " + astName.getRawSignature(), binding);
- return astName.resolveBinding();
- }
+ return astName.resolveBinding();
+ }
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticsTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticsTests.java
index 9272b92d59c..64c81fa054d 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticsTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticsTests.java
@@ -25,9 +25,12 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
*/
public class SemanticsTests extends AST2TestBase {
- public SemanticsTests() {}
- public SemanticsTests(String name) { super(name); }
-
+ public SemanticsTests() {
+ }
+
+ public SemanticsTests(String name) {
+ super(name);
+ }
// class A {};
// class B {};
@@ -62,7 +65,7 @@ public class SemanticsTests extends AST2TestBase {
// void operator +(X x) {} // Addition
// A operator +=(int y) {} // Addition with assignment
// B operator -(X x) {} // Subtraction
- // void operator -=(int y) {} // Subtraction with assignment
+ // void operator -=(int y) {} // Subtraction with assignment
// void operator ->*(int z){} // ptr-to-member selection
// void operator /(int x) {} // division
// void operator /=(int y) {} // division with assignment
@@ -85,29 +88,31 @@ public class SemanticsTests extends AST2TestBase {
// void operator()(int a, int b, int c) {} // function call
//
// void operator[](int i) {} // subscripting
- //
+ //
// operator A(); // conversion
// operator B(); // conversion
// };
public void testConversionOperators() throws Exception {
// Test getDeclaredConversionOperators()
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
- ICPPClassType c= ba.assertNonProblem("X {", 1, ICPPClassType.class);
- ICPPMethod[] cops= SemanticUtil.getDeclaredConversionOperators(c);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
+ ICPPClassType c = ba.assertNonProblem("X {", 1, ICPPClassType.class);
+ ICPPMethod[] cops = SemanticUtil.getDeclaredConversionOperators(c);
assertEquals(2, cops.length);
- Set actual= new HashSet();
- actual.add(cops[0].getName()); actual.add(cops[1].getName());
- Set expected= new HashSet();
- expected.add("operator A"); expected.add("operator B");
+ Set actual = new HashSet();
+ actual.add(cops[0].getName());
+ actual.add(cops[1].getName());
+ Set expected = new HashSet();
+ expected.add("operator A");
+ expected.add("operator B");
assertEquals(expected, actual);
// Test isConversionOperator()
- ICPPMethod[] dms= c.getDeclaredMethods();
+ ICPPMethod[] dms = c.getDeclaredMethods();
assertEquals(48, dms.length);
-
- for(ICPPMethod method : dms) {
- String name= method.getName();
- boolean isConvOp= name.equals("operator A") || name.equals("operator B");
+
+ for (ICPPMethod method : dms) {
+ String name = method.getName();
+ boolean isConvOp = name.equals("operator A") || name.equals("operator B");
assertEquals(isConvOp, SemanticUtil.isConversionOperator(method));
}
}
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 b6d188ae877..f72697dba37 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
@@ -22,41 +22,27 @@ import org.eclipse.cdt.internal.core.pdom.indexer.TodoTaskParser;
import org.eclipse.cdt.internal.core.pdom.indexer.TodoTaskParser.Task;
public class TaskParserTest extends AST2TestBase {
-
+
public static TestSuite suite() {
return suite(TaskParserTest.class);
}
public void testTaskParser() throws Exception {
- final char[][] taskTags = new char[][] {
- "TODO".toCharArray(),
- "TODO(my name):".toCharArray(),
- "FIXME".toCharArray()
- };
- final int PRIORITY_LOW = 1;
- final int PRIORITY_NORMAL = 2;
- final int PRIORITY_HIGH = 3;
- final int[] taskPriorities = new int[] {
- PRIORITY_LOW,
- PRIORITY_NORMAL,
- PRIORITY_HIGH
- };
+ final char[][] taskTags = new char[][] { "TODO".toCharArray(), "TODO(my name):".toCharArray(),
+ "FIXME".toCharArray() };
+ final int PRIORITY_LOW = 1;
+ final int PRIORITY_NORMAL = 2;
+ final int PRIORITY_HIGH = 3;
+ final int[] taskPriorities = new int[] { PRIORITY_LOW, PRIORITY_NORMAL, PRIORITY_HIGH };
final boolean isTaskCaseSensitive = true;
-
- 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\";";
+
+ 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);
- TodoTaskParser parser = new TodoTaskParser(taskTags, taskPriorities, isTaskCaseSensitive);
+ TodoTaskParser parser = new TodoTaskParser(taskTags, taskPriorities, isTaskCaseSensitive);
Task[] tasks = parser.parse(tu.getComments());
-
+
assertEquals(6, tasks.length);
assertEquals("TODO", tasks[0].getTag());
assertEquals("tag 1", tasks[0].getMessage());
@@ -64,17 +50,17 @@ public class TaskParserTest extends AST2TestBase {
assertEquals(1, tasks[0].getLineNumber());
assertEquals(3, tasks[0].getStart());
assertEquals(13, tasks[0].getEnd());
-
+
assertEquals("FIXME", tasks[1].getTag());
assertEquals("tag 2", tasks[1].getMessage());
assertEquals(PRIORITY_HIGH, tasks[1].getPriority());
assertEquals(2, tasks[1].getLineNumber());
-
+
assertEquals("TODO(my name):", tasks[2].getTag());
assertEquals("tag 3", tasks[2].getMessage());
assertEquals(PRIORITY_NORMAL, tasks[2].getPriority());
assertEquals(5, tasks[2].getLineNumber());
-
+
assertEquals("TODO", tasks[3].getTag());
assertEquals("(his name): tag 4", tasks[3].getMessage());
assertEquals(PRIORITY_LOW, tasks[3].getPriority());
@@ -84,7 +70,7 @@ public class TaskParserTest extends AST2TestBase {
assertEquals("tag 5", tasks[4].getMessage());
assertEquals(PRIORITY_LOW, tasks[4].getPriority());
assertEquals(8, tasks[4].getLineNumber());
-
+
assertEquals("FIXME", tasks[5].getTag());
assertEquals("tag 5", tasks[5].getMessage());
assertEquals(PRIORITY_HIGH, tasks[5].getPriority());
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TestLexerLog.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TestLexerLog.java
index ce182e83f4c..a818a6fc9e6 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TestLexerLog.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TestLexerLog.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
import java.util.ArrayList;
@@ -19,12 +19,12 @@ import org.eclipse.cdt.internal.core.parser.scanner.AbstractCharArray;
import org.eclipse.cdt.internal.core.parser.scanner.ILexerLog;
public class TestLexerLog implements ILexerLog {
- private ArrayList fComments= new ArrayList();
- private ArrayList fProblems= new ArrayList();
+ private ArrayList fComments = new ArrayList();
+ private ArrayList fProblems = new ArrayList();
private String fInput;
-
+
public void setInput(String input) {
- fInput= input;
+ fInput = input;
}
@Override
@@ -40,7 +40,7 @@ public class TestLexerLog implements ILexerLog {
public String createString(int problemID, String image) {
return String.valueOf(problemID) + ":" + image;
}
-
+
public void clear() {
fComments.clear();
fProblems.clear();
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TypeTraitsTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TypeTraitsTests.java
index 6ff2b1458ba..9d620b3868b 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TypeTraitsTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TypeTraitsTests.java
@@ -40,7 +40,7 @@ public class TypeTraitsTests extends AST2TestBase {
}
protected BindingAssertionHelper getAssertionHelper() throws ParserException, IOException {
- String code= getAboveComment();
+ String code = getAboveComment();
return new AST2AssertionHelper(code, true);
}
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 31e81dd4ebd..852cbdcb42c 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
@@ -46,9 +46,8 @@ public class VariableReadWriteFlagsTest extends AST2TestBase {
}
int getReadWriteFlags(IASTName variable) {
- return isCPP ?
- CPPVariableReadWriteFlags.getReadWriteFlags(variable) :
- CVariableReadWriteFlags.getReadWriteFlags(variable);
+ return isCPP ? CPPVariableReadWriteFlags.getReadWriteFlags(variable)
+ : CVariableReadWriteFlags.getReadWriteFlags(variable);
}
private String flagsToString(int flags) {
@@ -79,12 +78,12 @@ public class VariableReadWriteFlagsTest extends AST2TestBase {
}
protected AssertionHelper getCAssertionHelper() throws ParserException, IOException {
- String code= getAboveComment();
+ String code = getAboveComment();
return new AssertionHelper(code, false);
}
protected AssertionHelper getCPPAssertionHelper() throws ParserException, IOException {
- String code= getAboveComment();
+ String code = getAboveComment();
return new AssertionHelper(code, true);
}
@@ -218,7 +217,7 @@ public class VariableReadWriteFlagsTest extends AST2TestBase {
a.assertReadWriteFlags("ap->m()", "ap", READ);
a.assertReadWriteFlags("(*ap).m()", "ap", READ);
}
-
+
// void variadic(...);
// void test() {
// int waldo;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaIndexTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaIndexTests.java
index 61a39836f60..25013a2e934 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaIndexTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaIndexTests.java
@@ -20,9 +20,9 @@ public class GenericLambdaIndexTests extends IndexBindingResolutionTestBase {
public GenericLambdaIndexTests() {
setStrategy(new SinglePDOMTestStrategy(true));
}
-
+
// auto Identity = [](auto a){ return a; };
-
+
// auto three = Identity(3);
// auto hello = Identity("hello");
public void testBasicCall() throws Exception {
@@ -30,10 +30,10 @@ public class GenericLambdaIndexTests extends IndexBindingResolutionTestBase {
helper.assertVariableType("three", CommonCPPTypes.int_);
helper.assertVariableType("hello", CommonCPPTypes.pointerToConstChar);
}
-
+
// // Adapted from the example in [expr.prim.lambda] p7 in the standard.
// auto Identity = [](auto a){ return a; };
-
+
// void f1(int(*)(int));
// void f2(char(*)(int));
// void g(int(*)(int));
@@ -55,7 +55,7 @@ public class GenericLambdaIndexTests extends IndexBindingResolutionTestBase {
IFunction hCall = helper.assertNonProblem("h(Id", "h");
assertSame(h1, hCall);
}
-
+
// template <typename... T>
// struct tuple {};
//
@@ -70,7 +70,7 @@ public class GenericLambdaIndexTests extends IndexBindingResolutionTestBase {
// Cat bar(tuple<int, char, float>);
//
// void waldo(Cat);
-
+
// int main() {
// waldo(foo(L(42, 'x')));
// waldo(bar(L(42, 'x', 42.0f)));
@@ -78,7 +78,7 @@ public class GenericLambdaIndexTests extends IndexBindingResolutionTestBase {
public void testVariadicAutoParameter() throws Exception {
checkBindings();
}
-
+
// // Adapted from the example in [expr.prim.lambda] p6 in the standard.
// namespace std {
// struct ostream {
@@ -100,7 +100,7 @@ public class GenericLambdaIndexTests extends IndexBindingResolutionTestBase {
// });
// auto q = p(1, 'a', 3.14);
// void waldo(const std::ostream&);
-
+
// int main() {
// waldo(q());
// }
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaTests.java
index 1622e92d62f..dd16e67f70d 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaTests.java
@@ -25,7 +25,7 @@ public class GenericLambdaTests extends AST2CPPTestBase {
helper.assertVariableType("three", CommonCPPTypes.int_);
helper.assertVariableType("hello", CommonCPPTypes.pointerToConstChar);
}
-
+
// // Adapted from the example in [expr.prim.lambda] p7 in the standard.
// auto Identity = [](auto a){ return a; };
// void f1(int(*)(int));
@@ -52,7 +52,7 @@ public class GenericLambdaTests extends AST2CPPTestBase {
assertSame(h1, hCall);
helper.assertNonProblem("j([]", "j");
}
-
+
// template <typename... T>
// struct tuple {};
//
@@ -75,7 +75,7 @@ public class GenericLambdaTests extends AST2CPPTestBase {
public void testVariadicAutoParameter() throws Exception {
parseAndCheckBindings();
}
-
+
// // Adapted from the example in [expr.prim.lambda] p6 in the standard.
// namespace std {
// struct ostream {
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/InitCaptureTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/InitCaptureTests.java
index 85b7dfcdc2c..2e38a3f274f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/InitCaptureTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/InitCaptureTests.java
@@ -24,7 +24,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int main() {
// [var1 { 3 }] { }();
// }
- public void testLambdaInitCaptures_413527_1a() throws Exception {
+ public void testLambdaInitCaptures_413527_1a() throws Exception {
parseAndCheckBindings();
}
@@ -32,7 +32,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int var2 {};
// [var1 { 3 }, var2] { }();
// }
- public void testLambdaInitCaptures_413527_1b() throws Exception {
+ public void testLambdaInitCaptures_413527_1b() throws Exception {
parseAndCheckBindings();
}
@@ -40,7 +40,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int var2 {};
// [var1 { 3 }, var2] { }();
// }
- public void testLambdaInitCaptures_413527_1c() throws Exception {
+ public void testLambdaInitCaptures_413527_1c() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableType("var2", CommonCPPTypes.int_);
helper.assertVariableType("var1", CommonCPPTypes.int_);
@@ -49,7 +49,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int main() {
// [var1(3)] { }();
// }
- public void testLambdaInitCaptures_413527_2a() throws Exception {
+ public void testLambdaInitCaptures_413527_2a() throws Exception {
parseAndCheckBindings();
}
@@ -57,7 +57,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int var2 { };
// [var1(3), var2] { }();
// }
- public void testLambdaInitCaptures_413527_2b() throws Exception {
+ public void testLambdaInitCaptures_413527_2b() throws Exception {
parseAndCheckBindings();
}
@@ -65,7 +65,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int var2 { };
// [var1(3), var2] { }();
// }
- public void testLambdaInitCaptures_413527_2c() throws Exception {
+ public void testLambdaInitCaptures_413527_2c() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableType("var2", CommonCPPTypes.int_);
helper.assertVariableType("var1", CommonCPPTypes.int_);
@@ -75,7 +75,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int var2 { };
// [var1( { 3, 3 } ), var2] { }();
// }
- public void testLambdaInitCaptures_413527_2d() throws Exception {
+ public void testLambdaInitCaptures_413527_2d() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableType("var2", CommonCPPTypes.int_);
// #include <initalizer_list> missing
@@ -85,7 +85,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int main() {
// [var1 = 3] { }();
// }
- public void testLambdaInitCaptures_413527_3a() throws Exception {
+ public void testLambdaInitCaptures_413527_3a() throws Exception {
parseAndCheckBindings();
}
@@ -93,7 +93,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int var2 { };
// [var1 = 3, var2] { }();
// }
- public void testLambdaInitCaptures_413527_3b() throws Exception {
+ public void testLambdaInitCaptures_413527_3b() throws Exception {
parseAndCheckBindings();
}
@@ -101,7 +101,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int var2 { };
// [var1 = 3, var2] { }();
// }
- public void testLambdaInitCaptures_413527_3c() throws Exception {
+ public void testLambdaInitCaptures_413527_3c() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableType("var2", CommonCPPTypes.int_);
helper.assertVariableType("var1", CommonCPPTypes.int_);
@@ -115,7 +115,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int var2 { };
// [var1 = { 3, 4 }, var2] { }();
// }
- public void testLambdaInitCaptures_413527_3d() throws Exception {
+ public void testLambdaInitCaptures_413527_3d() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableType("var2", CommonCPPTypes.int_);
// #include <initalizer_list> missing
@@ -127,7 +127,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// auto var3 = var1;
// }();
// }
- public void testLambdaInitCaptures_413527_4a() throws Exception {
+ public void testLambdaInitCaptures_413527_4a() throws Exception {
parseAndCheckBindings();
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableType("var1", CommonCPPTypes.int_);
@@ -139,7 +139,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// var1++;
// }();
// }
- public void testLambdaInitCaptures_413527_4b() throws Exception {
+ public void testLambdaInitCaptures_413527_4b() throws Exception {
parseAndCheckBindings();
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableType("var1", CommonCPPTypes.int_);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionIndexTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionIndexTests.java
index 7f5857379c5..ebcbd0e93ff 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionIndexTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionIndexTests.java
@@ -16,22 +16,22 @@ public class ReturnTypeDeductionIndexTests extends IndexBindingResolutionTestBas
public ReturnTypeDeductionIndexTests() {
setStrategy(new SinglePDOMTestStrategy(true));
}
-
+
// struct A {
// auto f();
// };
// auto A::f() { return 42; }
-
+
// auto waldo = A().f();
public void testOutOfLineMethod1() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableType("waldo", CommonCPPTypes.int_);
}
-
+
// struct A {
// auto f();
// };
-
+
// auto A::f() { return 42; }
// auto waldo = A().f();
public void _testOutOfLineMethod2() throws Exception {
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionTests.java
index bbf15374815..904d90a17ae 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionTests.java
@@ -26,19 +26,19 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
ICPPFunction f = bh.assertNonProblem(functionName);
return f.getType().getReturnType();
}
-
+
private void assertReturnType(String functionName, IType returnType) throws Exception {
assertSameType(getReturnType(functionName), returnType);
}
-
+
private void assertReturnTypeProblem(String functionName) throws Exception {
assertInstance(getReturnType(functionName), IProblemType.class);
}
-
+
private void assertReturnTypeValid(String functionName) throws Exception {
assertFalse(getReturnType(functionName) instanceof IProblemType);
}
-
+
private IType getLambdaReturnType(String lambdaName) throws Exception {
BindingAssertionHelper bh = getAssertionHelper();
ICPPVariable lambda = bh.assertNonProblem(lambdaName);
@@ -47,20 +47,20 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
ICPPFunction f = ((CPPClosureType) lambdaType).getFunctionCallOperator();
return f.getType().getReturnType();
}
-
+
private void assertLambdaReturnType(String lambdaName, IType returnType) throws Exception {
assertSameType(getLambdaReturnType(lambdaName), returnType);
}
-
+
private void assertLambdaReturnTypeValid(String lambdaName) throws Exception {
assertFalse(getLambdaReturnType(lambdaName) instanceof IProblemType);
}
-
+
// auto f() { return 42; }
public void testSingleReturn() throws Exception {
assertReturnType("f", CommonCPPTypes.int_);
}
-
+
// auto f(int x) {
// if (x < 10)
// return 42;
@@ -70,7 +70,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
public void testMultipleReturnsSameType() throws Exception {
assertReturnType("f", CommonCPPTypes.int_);
}
-
+
// struct S {};
// auto f(const S& s, bool c) {
// if (c)
@@ -81,7 +81,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
public void testMultipleReturnsDifferingByConst() throws Exception {
assertReturnTypeValid("f");
}
-
+
// auto f(int x) {
// if (x < 10)
// return 42;
@@ -98,7 +98,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
public void testFullyRecursiveFunction() throws Exception {
assertReturnTypeProblem("f");
}
-
+
// auto sum(int i) {
// if (i == 1)
// return i;
@@ -108,7 +108,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
public void testPartiallyRecursiveFunction() throws Exception {
assertReturnType("sum", CommonCPPTypes.int_);
}
-
+
// template <typename T>
// auto f(T t) {
// return t;
@@ -119,7 +119,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
ITypedef t = bh.assertNonProblem("fint_t");
assertSameType(t, CommonCPPTypes.int_);
}
-
+
// template <typename T> auto f(T t) { return t; }
// template <typename T> auto f(T* t) { return *t; }
// void g() { int (*p)(int*) = &f; }
@@ -129,7 +129,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
ICPPTemplateInstance fi = bh.assertNonProblem("f;", 1);
assertSame(f2, fi.getSpecializedBinding());
}
-
+
// struct A { static int i; };
// auto& f1() { return A::i; }
// auto&& f2() { return A::i; }
@@ -143,7 +143,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
assertReturnType("f4", CommonCPPTypes.referenceToConstInt);
assertReturnType("f5", CommonCPPTypes.rvalueReferenceToConstInt);
}
-
+
// struct A { static int i; };
// auto* f1() { return &A::i; }
// const auto* f2() { return &A::i; }
@@ -151,7 +151,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
assertReturnType("f1", CommonCPPTypes.pointerToInt);
assertReturnType("f2", CommonCPPTypes.pointerToConstInt);
}
-
+
// auto f1() {}
// auto& f2() {}
// auto* f3() {}
@@ -160,7 +160,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
assertReturnTypeProblem("f2");
assertReturnTypeProblem("f3");
}
-
+
// struct A { static int i; };
// auto f1() -> auto { return 42; }
// auto f2() -> auto& { return A::i; }
@@ -180,7 +180,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
assertReturnType("f7", CommonCPPTypes.pointerToInt);
assertReturnType("f8", CommonCPPTypes.pointerToConstInt);
}
-
+
// int i;
// auto f1 = []() -> auto { return 42; };
// auto f2 = []() -> auto& { return i; };
@@ -192,7 +192,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
assertLambdaReturnType("f3", CommonCPPTypes.referenceToInt);
assertLambdaReturnType("f4", CommonCPPTypes.rvalueReferenceToInt);
}
-
+
// struct S {};
// auto f = [](const S& s, bool c) {
// if (c)
@@ -203,7 +203,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
public void testLambdaWithMultipleReturnsDifferingByConst() throws Exception {
assertLambdaReturnTypeValid("f");
}
-
+
// struct A {
// virtual auto f() { return 42; }
// virtual decltype(auto) g() { return 42; }
@@ -212,12 +212,12 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
assertReturnTypeProblem("f");
assertReturnTypeProblem("g");
}
-
+
// auto f() { return {1, 2, 3}; }
public void testInitializerList() throws Exception {
assertReturnTypeProblem("f");
}
-
+
// int f(int);
// int g(int);
// template <typename T>
@@ -237,14 +237,14 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
BindingAssertionHelper bh = getAssertionHelper();
bh.assertNonProblem("foo(cond", "foo");
}
-
+
// decltype(auto) f() { return 42; }
- // decltype(auto) g(int* arg) { return *arg; }
+ // decltype(auto) g(int* arg) { return *arg; }
public void testDecltypeAuto() throws Exception {
assertReturnType("f", CommonCPPTypes.int_);
assertReturnType("g", CommonCPPTypes.referenceToInt);
}
-
+
// auto f() -> decltype(auto) { return 42; }
// auto g(int* arg) -> decltype(auto) { return *arg; }
// auto L1 = []() -> decltype(auto) { return 42; };
@@ -255,7 +255,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
assertLambdaReturnType("L1", CommonCPPTypes.int_);
assertLambdaReturnType("L2", CommonCPPTypes.referenceToInt);
}
-
+
// int i;
// decltype(auto)& f() { return i; }
// decltype(auto)* g() { return &i; }
@@ -267,14 +267,14 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
assertReturnTypeProblem("f2");
assertReturnTypeProblem("g2");
}
-
+
// auto f();
// auto waldo = f();
public void testUseWithoutDefinition() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableTypeProblem("waldo");
}
-
+
// auto f();
// auto f() { return 42; }
// auto waldo = f();
@@ -282,7 +282,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableType("waldo", CommonCPPTypes.int_);
}
-
+
// auto f();
// auto waldo = f();
// auto f() { return 42; }
@@ -292,7 +292,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableTypeProblem("waldo");
}
-
+
// auto f() { return 42; }
// int f();
public void testRedeclaration() throws Exception {
@@ -303,7 +303,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
ICPPFunction intFunction = helper.assertNonProblem("int f", "f");
assertNotSame(autoFunction, intFunction);
}
-
+
// struct A {
// auto f();
// };
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/VariableTemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/VariableTemplateTests.java
index 00b057adc73..599d01d92ad 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/VariableTemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/VariableTemplateTests.java
@@ -120,8 +120,8 @@ public class VariableTemplateTests extends AST2CPPTestBase {
BindingAssertionHelper ah = getAssertionHelper(ParserLanguage.CPP);
ICPPFieldTemplate template = ah.assertNonProblem("pi<int>", "pi", ICPPFieldTemplate.class);
- ICPPVariableInstance inst = ah.assertNonProblem("pi<int>", "pi<int>",
- ICPPVariableInstance.class, ICPPField.class);
+ ICPPVariableInstance inst = ah.assertNonProblem("pi<int>", "pi<int>", ICPPVariableInstance.class,
+ ICPPField.class);
assertEquals("3", inst.getInitialValue().toString());
assertEquals(template, inst.getSpecializedBinding());
@@ -159,8 +159,8 @@ public class VariableTemplateTests extends AST2CPPTestBase {
BindingAssertionHelper ah = getAssertionHelper(ParserLanguage.CPP);
ICPPFieldTemplate template = ah.assertNonProblem("pi<int>", "pi", ICPPFieldTemplate.class);
- ICPPVariableInstance inst = ah.assertNonProblem("pi<int> = ", "pi<int>",
- ICPPVariableInstance.class, ICPPField.class);
+ ICPPVariableInstance inst = ah.assertNonProblem("pi<int> = ", "pi<int>", ICPPVariableInstance.class,
+ ICPPField.class);
ICPPVariableInstance ref = ah.assertNonProblem("pi<int>;", "pi<int>", ICPPVariableInstance.class);
assertEquals("4", inst.getInitialValue().toString());
@@ -284,8 +284,8 @@ public class VariableTemplateTests extends AST2CPPTestBase {
BindingAssertionHelper ah = getAssertionHelper(ParserLanguage.CPP);
- ICPPFieldTemplate template = ah.assertNonProblem("once = ", "once",
- ICPPField.class, ICPPTemplateDefinition.class);
+ ICPPFieldTemplate template = ah.assertNonProblem("once = ", "once", ICPPField.class,
+ ICPPTemplateDefinition.class);
CPPFieldTemplateSpecialization useName = ah.assertNonProblem("S<Vec>::once<int>", "once");
ICPPVariableInstance useId = ah.assertNonProblem("S<Vec>::once<int>", ICPPField.class);
@@ -320,7 +320,7 @@ public class VariableTemplateTests extends AST2CPPTestBase {
// struct meta {
// static const bool value = true;
// };
- //
+ //
// template <typename T>
// constexpr bool var = meta<T>::value;
//
@@ -334,7 +334,7 @@ public class VariableTemplateTests extends AST2CPPTestBase {
// }
public void test_bug494216() throws Exception {
parseAndCheckBindings();
-
+
BindingAssertionHelper ah = getAssertionHelper(ParserLanguage.CPP);
ICPPVariable waldo = ah.assertNonProblem("waldo");
IType type = waldo.getType();
@@ -343,7 +343,7 @@ public class VariableTemplateTests extends AST2CPPTestBase {
assertEquals(1, args.length);
assertValue(args[0].getNonTypeValue(), 1);
}
-
+
// template<typename T, typename = class _, typename... P>
// constexpr bool type_in_pack{type_in_pack<T, P...>};
//
@@ -357,14 +357,14 @@ public class VariableTemplateTests extends AST2CPPTestBase {
// constexpr bool waldo2 = type_in_pack<int, float, char>;
public void testStackOverflow_513429() throws Exception {
parseAndCheckBindings();
-
+
BindingAssertionHelper ah = getAssertionHelper(ParserLanguage.CPP);
ICPPVariable waldo1 = ah.assertNonProblem("waldo1");
assertVariableValue(waldo1, 1);
ICPPVariable waldo2 = ah.assertNonProblem("waldo2");
assertVariableValue(waldo2, 0);
}
-
+
// template <typename R>
// auto L = []{ return R{}; };
//
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/AllConstexprEvalTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/AllConstexprEvalTests.java
index 7284ccabbfd..16deda4065f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/AllConstexprEvalTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/AllConstexprEvalTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ArrayTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ArrayTests.java
index a8d9c991062..7d33789eed2 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ArrayTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ArrayTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,15 +15,25 @@ import junit.framework.TestSuite;
public class ArrayTests extends TestBase {
public static class NonIndexing extends ArrayTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends ArrayTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f() {
// int foo[3][2] { {1,2}, {2, 3},{ 4, 5} };
// return foo[2][1];
@@ -33,7 +43,7 @@ public class ArrayTests extends TestBase {
public void testInitializationOfMultiDimensionalArrays() throws Exception {
assertEvaluationEquals(5);
}
-
+
// constexpr int f() {
// int foo[3] { 1, 2, 3 };
// foo[1] = foo[0] + foo[2];
@@ -44,7 +54,7 @@ public class ArrayTests extends TestBase {
public void testAssignmentOfArrays() throws Exception {
assertEvaluationEquals(4);
}
-
+
// constexpr int f() {
// int foo[3][2] { {1,2}, {2, 3},{ 4, 5} };
// foo[0][1] = 3;
@@ -55,17 +65,17 @@ public class ArrayTests extends TestBase {
public void testAssignmentOfMultiDimensionalArrays() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int a[2][2] { { 1, 2 }, { 3, 4 } };
// constexpr int f() {
// return a[0][0];
// }
-
+
// constexpr auto x = f();
public void testGlobalArrayAccessValue() throws Exception {
assertEvaluationEquals(1);
}
-
+
// constexpr int f() {
// int x[2][2] { { 1, 2 }, { 3, 4 } };
// int &xref { x[1][1] };
@@ -74,23 +84,23 @@ public class ArrayTests extends TestBase {
// xref = xref * xref2;
// return x[1][1];
// }
-
+
// constexpr auto x = f();
public void testReferenceToArrayCell() throws Exception {
assertEvaluationEquals(25);
}
-
+
// constexpr int f() {
// int bar[2] { 3, 7 };
// (*bar)++;
// return bar[0];
// }
-
+
// constexpr int x = f();
public void testPointerDereferencingOnArrayName() throws Exception {
assertEvaluationEquals(4);
}
-
+
// class S {
// int arr[4];
// public:
@@ -104,12 +114,12 @@ public class ArrayTests extends TestBase {
// int *ptr = s.getPtr();
// return *ptr;
// }
-
+
// constexpr int x = f();
public void testPointerToArrayReturnedFromMemberFunction1() throws Exception {
assertEvaluationEquals(5);
}
-
+
// class S {
// int arr[4];
// public:
@@ -124,7 +134,7 @@ public class ArrayTests extends TestBase {
// ptr += 2;
// return *ptr;
// }
-
+
// constexpr int x = f();
public void testPointerToArrayReturnedFromMemberFunction2() throws Exception {
assertEvaluationEquals(9);
@@ -152,35 +162,35 @@ public class ArrayTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testPointerToArrayReturnedFromMemberFunction3() throws Exception {
assertEvaluationEquals(32);
}
-
+
// constexpr int f() {
// int arr[] = {1, 2, 3};
// int (&arrRef)[3] = arr;
// return arrRef[2];
// }
-
+
// constexpr int x = f();
public void testReferenceToArray1() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int f() {
// int arr[] = {1, 2, 3};
// int (&arrRef)[3] = arr;
// arrRef[2] *= 2;
// return arr[2];
// }
-
+
// constexpr int x = f();
public void testReferenceToArray2() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr int f() {
// int arr[] = {1, 2, 3};
// int (&arrRef)[3] = arr;
@@ -189,24 +199,24 @@ public class ArrayTests extends TestBase {
// }
// return arr[2];
// }
-
+
// constexpr int x = f();
public void testReferenceToArray3() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr int f() {
// int bar[2][2] { { 3, 5 }, {7, 11 } };
// int * bar_ptr { bar[1] };
// (*bar_ptr)++;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerArithmeticsOnMultidimensionalArray() throws Exception {
assertEvaluationEquals(8);
}
-
+
// constexpr void g(int * array) {
// array[0] = 1337;
// }
@@ -215,12 +225,12 @@ public class ArrayTests extends TestBase {
// g(bar);
// return bar[0];
// }
-
+
// constexpr int x = f();
public void testPassArrayToFunctionAsPointerAndModifyCell() throws Exception {
assertEvaluationEquals(1337);
}
-
+
// constexpr void g(int array[2][2]) {
// array[1][0] = 1337;
// }
@@ -229,17 +239,17 @@ public class ArrayTests extends TestBase {
// g(bar);
// return bar[1][0];
// }
-
+
// constexpr int x = f();
public void testPassMultiDimensionalArrayToFunctionAsPointerAndModifyCell() throws Exception {
assertEvaluationEquals(1337);
}
-
+
// constexpr int f() {
// int foo[] { 1, 2, 3, 4, 5 };
// return foo[2];
// }
-
+
// constexpr int x = f();
public void testInitializationOfArrays() throws Exception {
assertEvaluationEquals(3);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryExpressionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryExpressionTests.java
index 282150cd325..abe0a57b9fa 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryExpressionTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryExpressionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,15 +15,25 @@ import junit.framework.TestSuite;
public class BinaryExpressionTests extends TestBase {
public static class NonIndexing extends BinaryExpressionTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends BinaryExpressionTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr bool f() {
// bool a { true };
// return a && false;
@@ -33,24 +43,24 @@ public class BinaryExpressionTests extends TestBase {
public void testSimpleBooleanValues() throws Exception {
assertEvaluationEquals(false);
}
-
+
// constexpr int f() {
// int x = 5;
// (x=3)++;
// return x;
// }
-
+
// constexpr auto x = f();
public void testAssignmentReturnsLValue() throws Exception {
assertEvaluationEquals(4);
}
-
+
// constexpr int addTwice(int op1, int op2) {
// op1 += op2;
// op1 += op2;
// return op1;
// }
-
+
// constexpr int x = addTwice(2, 5);
public void testBinaryExpressionSequence() throws Exception {
assertEvaluationEquals(12);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryOperatorOverloadingTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryOperatorOverloadingTests.java
index 0369528592c..2052811815a 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryOperatorOverloadingTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryOperatorOverloadingTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,15 +15,25 @@ import junit.framework.TestSuite;
public class BinaryOperatorOverloadingTests extends TestBase {
public static class NonIndexing extends BinaryOperatorOverloadingTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends BinaryOperatorOverloadingTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// struct S {
// constexpr S(int x):x{x} {}
// constexpr int operator+(S const& other) {
@@ -42,9 +52,9 @@ public class BinaryOperatorOverloadingTests extends TestBase {
// constexpr int x = f();
public void testOverloadedPlusOperatorAsMemberFunction() throws Exception {
- assertEvaluationEquals(12);
+ assertEvaluationEquals(12);
}
-
+
// struct S {
// constexpr S(int x):x{x} {}
// constexpr S operator*(S const& other) {
@@ -62,9 +72,9 @@ public class BinaryOperatorOverloadingTests extends TestBase {
// constexpr int x = f();
public void testOverloadedMultiplicationOperatorAsMemberFunction() throws Exception {
- assertEvaluationEquals(12);
+ assertEvaluationEquals(12);
}
-
+
// struct S {
// constexpr S(int x, int y):x{x}, y{y} {}
// int x, y;
@@ -82,9 +92,9 @@ public class BinaryOperatorOverloadingTests extends TestBase {
// constexpr int x = f();
public void testOverloadedPlusOperatorAsNonMemberFunction() throws Exception {
- assertEvaluationEquals(14);
+ assertEvaluationEquals(14);
}
-
+
// struct S {
// constexpr S(int x, int y):x{x*2}, y{y+1} {
// }
@@ -100,7 +110,7 @@ public class BinaryOperatorOverloadingTests extends TestBase {
// S result{s1 + s2};
// return result.y;
// }
-
+
// constexpr int x = f();
public void testOverloadedOperatorPlusComplex1() throws Exception {
assertEvaluationEquals(24);
@@ -121,12 +131,12 @@ public class BinaryOperatorOverloadingTests extends TestBase {
// S result = s1 + s2;
// return result.x;
// }
-
+
// constexpr int x = f();
public void testOverloadedOperatorPlusComplex2() throws Exception {
assertEvaluationEquals(24);
}
-
+
// struct S {
// constexpr S(int x, int y):x{x*2}, y{y+1} {
// }
@@ -141,12 +151,12 @@ public class BinaryOperatorOverloadingTests extends TestBase {
// S result{s1 + s2};
// return result.y;
// }
-
+
// constexpr int x = f();
public void testOverloadedOperatorPlusComplex3() throws Exception {
assertEvaluationEquals(24);
}
-
+
// class Point {
// int x, y;
// public:
@@ -160,12 +170,12 @@ public class BinaryOperatorOverloadingTests extends TestBase {
// Point p2{2,4};
// return p1 == p2 ? 20 : 40;
// }
-
+
// constexpr int x = f();
public void testOverloadedOperatorEquals() throws Exception {
assertEvaluationEquals(20);
}
-
+
// class Point {
// int x, y;
// public:
@@ -183,7 +193,7 @@ public class BinaryOperatorOverloadingTests extends TestBase {
// p1 = p2;
// return p1.getY();
// }
-
+
// constexpr int x = f();
public void testOverloadedOperatorAssign() throws Exception {
assertEvaluationEquals(10);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/CStringValueTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/CStringValueTests.java
index 40c743eb8a0..12cf893691d 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/CStringValueTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/CStringValueTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,72 +15,82 @@ import junit.framework.TestSuite;
public class CStringValueTests extends TestBase {
public static class NonIndexing extends CStringValueTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends CStringValueTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr auto x = "Hello, World!";
public void testWithoutPrefix() throws Exception {
assertEvaluationEquals("Hello, World!");
}
-
+
// constexpr auto y = "Hello, World!";
// constexpr auto x = y;
public void testStringAssignment() throws Exception {
assertEvaluationEquals("Hello, World!");
}
-
+
// constexpr auto x = L"Hello, World!";
public void testLPrefix() throws Exception {
assertEvaluationEquals("Hello, World!");
}
-
+
// constexpr auto x = u8"Hello, World!";
public void testu8Prefix() throws Exception {
assertEvaluationEquals("Hello, World!");
}
-
+
// constexpr auto x = u"Hello, World!";
public void testuPrefix() throws Exception {
assertEvaluationEquals("Hello, World!");
}
-
+
// constexpr auto x = U"Hello, World!";
public void testUPrefix() throws Exception {
assertEvaluationEquals("Hello, World!");
}
-
+
//constexpr auto x = R"(This is
//a "raw" \n\n
// literal\0end)";
public void testRawStringLiteral() throws Exception {
assertEvaluationEquals("This is\na \"raw\" \\n\\n\n\tliteral\\0end");
}
-
+
//constexpr auto x = R"ab(This is)"
//a "raw" literal)ab";
public void testRawStringLiteralWithDelimiter() throws Exception {
assertEvaluationEquals("This is)\"\na \"raw\" literal");
}
-
+
// constexpr auto x = "line 1\n"
// "line 2\n"
// "line 3";
public void testCStringLiteralConcatenation() throws Exception {
assertEvaluationEquals("line 1\nline 2\nline 3");
}
-
+
// constexpr auto x = "PI = \u03C0";
public void test16bitUnicodeEscapeSequence() throws Exception {
assertEvaluationEquals("PI = \u03C0");
}
-
+
// constexpr int len(const char *str) {
// int len = 0;
// while(str[len] != '\0') {
@@ -97,5 +107,5 @@ public class CStringValueTests extends TestBase {
// constexpr int x = f();
public void testCStringParam() throws Exception {
assertEvaluationEquals(5);
- }
+ }
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ClassTemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ClassTemplateTests.java
index 23fb769cfb6..85853da3d15 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ClassTemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ClassTemplateTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,15 +15,25 @@ import junit.framework.TestSuite;
public class ClassTemplateTests extends TestBase {
public static class NonIndexing extends ClassTemplateTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends ClassTemplateTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// template<typename T>
// struct Point {
// T x;
@@ -36,12 +46,12 @@ public class ClassTemplateTests extends TestBase {
// Point<int> a{3,4} ;
// return a.len();
// }
-
+
// constexpr int x = f();
public void testInstantiationOfClassTemplate() throws Exception {
assertEvaluationEquals(25);
}
-
+
// template<int X>
// struct Multiplier {
// int y;
@@ -53,12 +63,12 @@ public class ClassTemplateTests extends TestBase {
// Multiplier<5> m{7};
// return m.product();
// }
-
+
// constexpr int x = f();
public void testInstantiationOfClassTemplateWithNontypeTemplateParameter1() throws Exception {
assertEvaluationEquals(35);
}
-
+
// template<int X, int Y>
// struct Multiplier {
// int x = X;
@@ -71,12 +81,12 @@ public class ClassTemplateTests extends TestBase {
// Multiplier<5, 7> m{};
// return m.product();
// }
-
+
// constexpr int x = f();
public void testInstantiationOfClassTemplateWithNontypeTemplateParameter2() throws Exception {
assertEvaluationEquals(35);
}
-
+
// template<int X, int Y>
// struct Adder {
// constexpr int sum() {
@@ -96,7 +106,7 @@ public class ClassTemplateTests extends TestBase {
public void testAliasTemplate1() throws Exception {
assertEvaluationEquals(17);
}
-
+
// template<int T>
// struct X {
// constexpr int get() const {
@@ -110,12 +120,12 @@ public class ClassTemplateTests extends TestBase {
// S<5> s{};
// return s.get();
// }
-
+
// constexpr int x = f();
public void testInstantiationOfBaseClassTemplate1() throws Exception {
assertEvaluationEquals(10);
}
-
+
// template<int T>
// struct X {
// int x = 2*T;
@@ -134,10 +144,10 @@ public class ClassTemplateTests extends TestBase {
public void testInstantiationOfBaseClassTemplate2() throws Exception {
assertEvaluationEquals(30);
}
-
+
// template<int I>
// struct S {
- // constexpr S():x{I*2} {}
+ // constexpr S():x{I*2} {}
// int x;
// };
//
@@ -145,7 +155,7 @@ public class ClassTemplateTests extends TestBase {
// S<5> s{};
// return s.x;
// }
-
+
// constexpr int x = f();
public void testTemplateArgumentInMemberInitializerList() throws Exception {
assertEvaluationEquals(10);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ConstructorTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ConstructorTests.java
index 37db3e108d1..bd597e750b2 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ConstructorTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ConstructorTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -17,18 +17,33 @@ import junit.framework.TestSuite;
public class ConstructorTests extends TestBase {
public static class NonIndexing extends ConstructorTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends ConstructorTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
+ }
+
+ public ConstructorTests() {
+ setStrategy(new NonIndexingTestStrategy());
}
-
- public ConstructorTests() {setStrategy(new NonIndexingTestStrategy()); }
- public static TestSuite suite() {return suite(NonIndexing.class);}
-
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
+
// struct S {
// int x;
// constexpr S(int i) : x{i*i} {}
@@ -37,12 +52,12 @@ public class ConstructorTests extends TestBase {
// S s(5);
// return s.x;
// }
-
+
// constexpr auto x = f();
public void testConstexprConstructorChainInitializers() throws Exception {
assertEvaluationEquals(25);
}
-
+
// struct S {
// int x;
// constexpr S(int i) : x{i*i} { x++; }
@@ -51,12 +66,12 @@ public class ConstructorTests extends TestBase {
// S s(5);
// return s.x;
// }
-
+
// constexpr auto x = f();
public void testConstexprConstructorConstructorBody() throws Exception {
assertEvaluationEquals(26);
}
-
+
// struct S {
// int x;
// constexpr S(int i) : x{i*i} { x++; }
@@ -65,12 +80,12 @@ public class ConstructorTests extends TestBase {
// S s = S(5);
// return s.x;
// }
-
+
// constexpr auto x = f();
public void testConstexprConstructorCopyConstruction() throws Exception {
assertEvaluationEquals(26);
}
-
+
// struct S {
// int x;
// constexpr S(int i) : x{i*i} { x++; }
@@ -79,14 +94,14 @@ public class ConstructorTests extends TestBase {
// S s = S(5);
// return s.x;
// }
-
+
// constexpr auto var = f();
public void testIdempotence() throws Exception {
// Querying a value a second time should produce the same result.
assertEvaluationEquals(26);
assertEvaluationEquals(26);
}
-
+
// struct S {
// int x;
// constexpr S() : x{5} { x++; x++; }
@@ -95,12 +110,12 @@ public class ConstructorTests extends TestBase {
// S s;
// return s.x;
// }
-
+
// constexpr auto x = f();
public void testConstexprConstructorDefaultConstruction() throws Exception {
assertEvaluationEquals(7);
}
-
+
// struct Base {
// int base_member;
// constexpr Base(int i) : base_member(i) {}
@@ -113,12 +128,12 @@ public class ConstructorTests extends TestBase {
// Derived t(1);
// return t.base_member + t.derived_member;
// }
-
+
// constexpr auto x = f();
public void testConstexprConstructorInheritance() throws Exception {
assertEvaluationEquals(3);
}
-
+
// struct point {
// int x, y;
// };
@@ -127,12 +142,12 @@ public class ConstructorTests extends TestBase {
// point p{2,3};
// return p.y;
// }
-
+
// constexpr int x = f();
public void testInitializationOfCompositeValues() throws Exception {
assertEvaluationEquals(3);
}
-
+
// struct T {
// constexpr T(int i):x{2*i} {}
// constexpr int get() const { return x; }
@@ -145,12 +160,12 @@ public class ConstructorTests extends TestBase {
// S s;
// return s.t.get();
// }
-
+
// constexpr int x = f();
public void testNestedConstructorCall() throws Exception {
assertEvaluationEquals(4);
}
-
+
// struct S {
// constexpr int get() const {
// return x + y;
@@ -162,12 +177,12 @@ public class ConstructorTests extends TestBase {
// constexpr int f(S s) {
// return s.get();
// }
-
+
// constexpr int x = f(S{});
public void testImplicitConstructorOfLiteralTypeWithImplicitDestructorIsConstexpr() throws Exception {
assertEvaluationEquals(6);
}
-
+
// struct S {
// constexpr int get() const {
// return x + y;
@@ -180,12 +195,12 @@ public class ConstructorTests extends TestBase {
// constexpr int f(S s) {
// return s.get();
// }
-
+
// constexpr int x = f(S{});
public void testImplicitConstructorOfLiteralTypeWithDefaultedDestructorIsConstexpr() throws Exception {
assertEvaluationEquals(6);
}
-
+
// struct S {
// constexpr int get() const {
// return x + y;
@@ -198,12 +213,12 @@ public class ConstructorTests extends TestBase {
// constexpr int f(S s) {
// return s.get();
// }
-
+
// constexpr int x = f(S{});
public void testImplicitConstructorOfLiteralTypeWithUserDefinedDestructorIsNotConstexpr() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// struct S {
// int x = 2;
// int y = 4;
@@ -211,12 +226,12 @@ public class ConstructorTests extends TestBase {
// constexpr int f(S s) {
// return s.x;
// }
-
+
// constexpr int x = f(S{});
public void testImplicitConstructorOfAggregateTypeIsConstexpr() throws Exception {
assertEvaluationEquals(2);
}
-
+
// struct S {
// S() {}
// int x = 2;
@@ -225,12 +240,12 @@ public class ConstructorTests extends TestBase {
// constexpr int f(S s) {
// return s.x;
// }
-
+
// constexpr int x = f(S{});
public void testUserDefinedDefaultConstructorIsNotConstexpr() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// struct S {
// constexpr S(int x):x{x+1} {
// }
@@ -240,12 +255,12 @@ public class ConstructorTests extends TestBase {
// S s(5);
// return s.x;
// }
-
+
// constexpr int x = f();
public void testCtorCall() throws Exception {
assertEvaluationEquals(6);
}
-
+
// struct S {
// constexpr S(int x):x{x} {
// }
@@ -263,7 +278,7 @@ public class ConstructorTests extends TestBase {
public void testArgumentEvaluation() throws Exception {
assertEvaluationEquals(50);
}
-
+
// struct B {
// int x, y;
// };
@@ -275,12 +290,12 @@ public class ConstructorTests extends TestBase {
// A a{1, 2, 3, { 4, 5 } };
// return a.b.y;
// }
-
+
// constexpr int x = f();
public void testInitializationOfNestedCompositeValues() throws Exception {
assertEvaluationEquals(5);
}
-
+
// struct point {
// int x, y;
// };
@@ -295,7 +310,7 @@ public class ConstructorTests extends TestBase {
public void testAssignmentOfCompositeValues() throws Exception {
assertEvaluationEquals(9);
}
-
+
// struct B {
// int x, y;
// };
@@ -308,13 +323,13 @@ public class ConstructorTests extends TestBase {
// A a{1, 2, 3, { 4, 5 } };
// a.b.y = a.k + a.b.x; // 3 + 4
// return a.b.y;
- // }
-
+ // }
+
// constexpr int x = f();
public void testAssignmentOfNestedCompositeValues() throws Exception {
assertEvaluationEquals(7);
}
-
+
// struct S {
// int x = 1, y = 3;
// };
@@ -323,12 +338,12 @@ public class ConstructorTests extends TestBase {
// s.x++;
// return s.x;
// }
-
+
// constexpr auto x = f();
public void testStructDefaultInitialization() throws Exception {
assertEvaluationEquals(2);
}
-
+
// struct S {
// int x = 1, y = 3;
// };
@@ -337,12 +352,12 @@ public class ConstructorTests extends TestBase {
// s.x++;
// return s.x;
// }
-
+
// constexpr auto x = f();
public void testStructDefaultInitializationOverride() throws Exception {
assertEvaluationEquals(6);
}
-
+
// struct T {
// int a = 7;
// };
@@ -355,12 +370,12 @@ public class ConstructorTests extends TestBase {
// s.t.a++;
// return s.t.a;
// }
-
+
// constexpr auto x = f();
public void testNestedStructDefaultInitialization() throws Exception {
assertEvaluationEquals(8);
}
-
+
// struct S {
// constexpr S(int x, int y):x{x}, y{y*2} {}
// constexpr int getY() const {
@@ -373,22 +388,22 @@ public class ConstructorTests extends TestBase {
// constexpr S f() {
// return S{3, 5};
// }
-
+
// constexpr int x = f().getY();
public void testSimpleTypeConstructorExpression2() throws Exception {
assertEvaluationEquals(10);
}
-
+
// struct S {
// int x, y;
// };
// constexpr S s{1,5};
-
+
// constexpr int x = s.y;
public void testInitialValueOfComposite() throws Exception {
assertEvaluationEquals(5);
}
-
+
// struct Point {
// constexpr Point(int x, int y):x{x}, y{y*2} {
// }
@@ -398,12 +413,12 @@ public class ConstructorTests extends TestBase {
// Point p{5, 6};
// return p.y;
// }
-
+
// constexpr int x = f();
public void testCtorInitializerList() throws Exception {
assertEvaluationEquals(12);
}
-
+
// struct Point {
// constexpr Point(int x, int y):x{x}, y{y*2} {
// }
@@ -413,12 +428,12 @@ public class ConstructorTests extends TestBase {
// Point p(5, 6);
// return p.y;
// }
-
+
// constexpr int x = f();
public void testCtorConstructorInitializer() throws Exception {
assertEvaluationEquals(12);
}
-
+
// struct Point {
// constexpr Point(int x, int y):x{x}, y{y*2} {
// }
@@ -428,12 +443,12 @@ public class ConstructorTests extends TestBase {
// Point p = {5, 6};
// return p.y;
// }
-
+
// constexpr int x = f();
public void testCtorEqualsInitializer() throws Exception {
assertEvaluationEquals(12);
}
-
+
// struct S {
// constexpr S(int x):x{x*2} {
// }
@@ -443,12 +458,12 @@ public class ConstructorTests extends TestBase {
// S s = 6;
// return s.x;
// }
-
+
// constexpr int x = f();
public void testCtorImplicitConversion() throws Exception {
assertEvaluationEquals(12);
}
-
+
// struct Point {
// constexpr Point(int x, int y):x{x}, y{y*2} {
// }
@@ -459,12 +474,12 @@ public class ConstructorTests extends TestBase {
// Point p2 = p1;
// return p2.y;
// }
-
+
// constexpr int x = f();
public void testCtorLvalueCopyConstruction() throws Exception {
assertEvaluationEquals(12);
}
-
+
// struct Point {
// constexpr Point(int x, int y):x{x}, y{y*2} {
// }
@@ -474,12 +489,12 @@ public class ConstructorTests extends TestBase {
// Point p = Point{5, 6};
// return p.y;
// }
-
+
// constexpr int x = f();
public void testCtorRvalueCopyConstruction() throws Exception {
assertEvaluationEquals(12);
}
-
+
// struct T {
// int y = 7, z = 11;
// };
@@ -493,22 +508,22 @@ public class ConstructorTests extends TestBase {
// s.t.z++;
// return s.t.y + s.t.z;
// }
-
+
// constexpr auto x = f();
public void testNestedStructDefaultInitializationOverride() throws Exception {
assertEvaluationEquals(22);
}
-
- // struct T {
+
+ // struct T {
// int member;
// constexpr T(int i) : member(i) {}
// };
-
+
// constexpr auto x = T(2).member;
public void testFundamentalTypeDirectInitializationWithParenthesis() throws Exception {
assertEvaluationEquals(2);
}
-
+
// struct Base {
// int x = 5;
// };
@@ -519,15 +534,15 @@ public class ConstructorTests extends TestBase {
// Derived d{};
// return d.x;
// }
-
+
// constexpr int x = f();
public void testInheritedMemberVariable1() throws Exception {
assertEvaluationEquals(5);
}
-
+
// struct X {
// constexpr X(int y):y{2*y} {}
- // int y;
+ // int y;
// };
// struct Base {
// X x{5};
@@ -539,12 +554,12 @@ public class ConstructorTests extends TestBase {
// Derived d{};
// return d.n;
// }
-
+
// constexpr int x = f();
public void testInheritedMemberVariable2() throws Exception {
assertEvaluationEquals(20);
}
-
+
// struct S {
// constexpr S(int x):x{x} {
// }
@@ -565,7 +580,7 @@ public class ConstructorTests extends TestBase {
// int value = 42;
// };
// constexpr S waldo{23};
-
+
// constexpr int x = waldo.value;
public void testDirectInitializedVariable_510151() throws Exception {
assertEvaluationEquals(23);
@@ -575,7 +590,7 @@ public class ConstructorTests extends TestBase {
// int value = 42;
// };
// constexpr S waldo{};
-
+
// constexpr int x = waldo.value;
public void testDirectDefaultInitializedVariable_510151() throws Exception {
assertEvaluationEquals(42);
@@ -585,7 +600,7 @@ public class ConstructorTests extends TestBase {
// int value = 42;
// };
// constexpr S waldo;
-
+
// constexpr int x = waldo.value;
public void testDefaultInitializedVariable_510151() throws Exception {
assertEvaluationEquals(42);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/DoWhileStatementTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/DoWhileStatementTests.java
index ed0d30398c2..c0f21f23527 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/DoWhileStatementTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/DoWhileStatementTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -17,15 +17,25 @@ import junit.framework.TestSuite;
public class DoWhileStatementTests extends TestBase {
public static class NonIndexing extends DoWhileStatementTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends DoWhileStatementTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// int i { 0 };
@@ -35,12 +45,12 @@ public class DoWhileStatementTests extends TestBase {
// } while (i <= n);
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testDoWhile() throws Exception {
assertEvaluationEquals(55);
}
-
+
// constexpr int f() {
// int sum { 0 };
// do {
@@ -48,12 +58,12 @@ public class DoWhileStatementTests extends TestBase {
// } while (true);
// return sum;
// }
-
+
// constexpr int x = f();
public void testDoWhileInfiniteLoop() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int sum { 0 };
// do {
@@ -61,12 +71,12 @@ public class DoWhileStatementTests extends TestBase {
// } while (true);
// return sum;
// }
-
+
// constexpr int x = f();
public void testDoWhileReturn() throws Exception {
assertEvaluationEquals(42);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// do
@@ -74,12 +84,12 @@ public class DoWhileStatementTests extends TestBase {
// while(n > 0);
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testDoWhileWithNonCompoundBodyStatement() throws Exception {
assertEvaluationEquals(10);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// do
@@ -87,7 +97,7 @@ public class DoWhileStatementTests extends TestBase {
// while(n > 0);
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testDoWhileWithReturnInNonCompoundBodyStatement() throws Exception {
assertEvaluationEquals(42);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FloatingPointValueTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FloatingPointValueTests.java
index d5aee57ebae..d17f8b3b7ed 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FloatingPointValueTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FloatingPointValueTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,98 +15,108 @@ import junit.framework.TestSuite;
public class FloatingPointValueTests extends TestBase {
public static class NonIndexing extends FloatingPointValueTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends FloatingPointValueTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr auto x = 2.5;
public void testDoubleLiteral() throws Exception {
assertEvaluationEquals(2.5);
}
-
+
// constexpr auto x = .5f;
public void testFloatLiteral() throws Exception {
assertEvaluationEquals(0.5);
}
-
+
// constexpr auto x = 2.l;
public void testLongDoubleLiteral() throws Exception {
assertEvaluationEquals(2.0);
}
-
+
// constexpr auto x = 123.456e-67;
public void testDoubleLiteralWithScientificNotation() throws Exception {
assertEvaluationEquals(123.456e-67);
}
-
+
// constexpr auto x = .1E4f;
public void testFloatLiteralWithScientificNotation() throws Exception {
assertEvaluationEquals(.1E4f);
}
-
+
// constexpr double f() {
// double x = 5.5;
// double y = 2.1;
// return x * 4 + y / 3;
// }
-
+
// constexpr double x = f();
public void testBinaryOperationsWithFloatingPointNumbers() throws Exception {
assertEvaluationEquals(22.7);
}
-
+
// constexpr bool f() {
// double x = 5.0;
// int y = 5;
// return x == y;
// }
-
+
// constexpr bool x = f();
public void testComparisonBetweenFloatingPointValueAndIntegralValue1() throws Exception {
assertEvaluationEquals(true);
}
-
+
// constexpr bool f() {
// double x = 5.1;
// int y = 5;
// return x == y;
// }
-
+
// constexpr bool x = f();
public void testComparisonBetweenFloatingPointValueAndIntegralValue2() throws Exception {
assertEvaluationEquals(false);
}
-
+
// constexpr auto x = float{} + float();
public void testFloatDefaultValue() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto f() {
// float x{};
// return x;
// }
-
+
// constexpr auto x = f();
public void testFloatValueInitialization() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto x = double{} + double();
public void testDoubleDefaultValue() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto f() {
// double x{};
// return x;
// }
-
+
// constexpr auto x = f();
public void testDoubleValueInitialization() throws Exception {
assertEvaluationEquals(0);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ForStatementTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ForStatementTests.java
index 8184b64b920..81257e33b9e 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ForStatementTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ForStatementTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -17,15 +17,25 @@ import junit.framework.TestSuite;
public class ForStatementTests extends TestBase {
public static class NonIndexing extends ForStatementTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends ForStatementTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// for (int i = 0; i <= n; i++) {
@@ -33,12 +43,12 @@ public class ForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testSimpleIndexBasedForLoop() throws Exception {
assertEvaluationEquals(55);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// for (int i = 0; i <= n; i++) {
@@ -47,12 +57,12 @@ public class ForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testReturnInIndexBasedForLoop() throws Exception {
assertEvaluationEquals(42);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// for (int i = 0; true; i++) {
@@ -60,12 +70,12 @@ public class ForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testInfiniteLoopInIndexBasedForLoop() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// int i { 0 };
@@ -74,12 +84,12 @@ public class ForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testIndexBasedForLoopWithEmptyInitializationStatement() throws Exception {
assertEvaluationEquals(45);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// for (int i = 0; i < n;) {
@@ -87,36 +97,36 @@ public class ForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testIndexBasedForLoopWithEmptyIterationSequence() throws Exception {
assertEvaluationEquals(45);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// for (int i = 0; i <= n; i++)
// sum += i;
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testIndexBasedForLoopWithNonCompoundBodyStatement() throws Exception {
assertEvaluationEquals(55);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// for (int i = 0; i <= n; i++)
// return 42;
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testIndexBasedForLoopWithReturnInNonCompoundBodyStatement() throws Exception {
assertEvaluationEquals(42);
}
-
+
// constexpr int f() {
// int sum = 0;
// for(int i = 0; i < 10; ++i) {
@@ -126,12 +136,12 @@ public class ForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testIndexBasedForLoopWithContinueStatement() throws Exception {
assertEvaluationEquals(10);
}
-
+
// constexpr int f() {
// int sum = 0;
// int arr[] = {1,2,3,4,5,6,7,8,9,10};
@@ -143,12 +153,12 @@ public class ForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testIndexBasedForLoopWithNestedContinueStatement() throws Exception {
assertEvaluationEquals(30);
}
-
+
// constexpr int f() {
// int sum = 0;
// int arr[] = {1,2,3,4,5,6,7,8,9,10};
@@ -160,12 +170,12 @@ public class ForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testIndexBasedForLoopWithNestedBreakStatement() throws Exception {
assertEvaluationEquals(15);
}
-
+
// constexpr int triple(int x) {
// return x * 3;
// }
@@ -176,12 +186,12 @@ public class ForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testDeclarationInForStatementCondition1() throws Exception {
assertEvaluationEquals(30);
}
-
+
// constexpr int f() {
// int count = 0;
// for(;;) {
@@ -191,18 +201,18 @@ public class ForStatementTests extends TestBase {
// }
// return count;
// }
-
+
// constexpr int x = f();
public void testInfiniteForLoop() throws Exception {
assertEvaluationEquals(12);
}
-
+
// constexpr int fac(int n) {
// int result = 1;
// for(int i = 1; i <= n; result *= i++);
// return result;
// }
-
+
// constexpr int x = fac(5);
public void testForLoopWithNullStatementAsBody() throws Exception {
assertEvaluationEquals(120);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTemplateTests.java
index 3c4f6b35917..24e530ba9e8 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTemplateTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,25 +15,35 @@ import junit.framework.TestSuite;
public class FunctionTemplateTests extends TestBase {
public static class NonIndexing extends FunctionTemplateTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends FunctionTemplateTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// template<typename T>
// constexpr T add(T a, T b) {
// return a + b;
// }
-
+
// constexpr auto x = add(5.5, 6.3);
public void testImplicitTemplateInstantiation() throws Exception {
assertEvaluationEquals(11.8);
}
-
+
// class Integer {
// int i;
// public:
@@ -45,23 +55,23 @@ public class FunctionTemplateTests extends TestBase {
// T t{10};
// return t.get();
// }
-
+
// constexpr int x = f<Integer>();
public void testExplicitTemplateInstantiation() throws Exception {
assertEvaluationEquals(10);
}
-
+
// template<int I>
// constexpr int f() {
// int result = I * 4;
// return result;
// }
-
+
// constexpr int x = f<5>();
public void testTemplateWithNonTypeTemplateParameter() throws Exception {
assertEvaluationEquals(20);
}
-
+
// template<typename T>
// constexpr T sum(T v) {
// return v;
@@ -70,22 +80,22 @@ public class FunctionTemplateTests extends TestBase {
// constexpr T sum(T first, Args... args) {
// return first + sum(args...);
// }
-
+
// constexpr int x = sum(1,2,3,4,5);
public void testVariadicTemplate() throws Exception {
assertEvaluationEquals(15);
}
-
+
// template<typename... Args>
// constexpr int count(Args... args) {
// return sizeof...(args);
// }
-
+
// constexpr int x = count(1,2,3,4,5);
public void testParameterPackSizeof() throws Exception {
assertEvaluationEquals(5);
}
-
+
// class Integer {
// int i;
// public:
@@ -104,12 +114,12 @@ public class FunctionTemplateTests extends TestBase {
// }
// return total.get();
// }
-
+
// constexpr int x = fac(Integer{5});
public void testTemplateInstantiationOfForLoop() throws Exception {
assertEvaluationEquals(120);
}
-
+
// class Integer {
// int i;
// public:
@@ -129,23 +139,23 @@ public class FunctionTemplateTests extends TestBase {
// } while (i <= n);
// return sum.get();
// }
-
+
// constexpr int x = f(Integer{10});
public void testTemplateInstantiationOfDoWhileLoop() throws Exception {
assertEvaluationEquals(55);
}
-
+
// template<typename T>
// constexpr T add(T a, T b) {
// ;
// return a + b;
// }
-
+
// constexpr auto x = add(5.5, 6.3);
public void testNullStatementInFunctionTemplate() throws Exception {
assertEvaluationEquals(11.8);
}
-
+
// class Integer {
// int i;
// public:
@@ -155,7 +165,7 @@ public class FunctionTemplateTests extends TestBase {
// constexpr Integer& operator++() { ++i; return *this; }
// constexpr Integer& operator*=(Integer const& rhs) { i *= rhs.i; return *this; }
// };
- //
+ //
// template<typename T>
// constexpr int fac(T n) {
// T total{1};
@@ -166,12 +176,12 @@ public class FunctionTemplateTests extends TestBase {
// }
// return total.get();
// }
-
+
// constexpr int x = fac(Integer{5});
public void testTemplateInstantiationOfWhileLoop() throws Exception {
assertEvaluationEquals(120);
}
-
+
// template<typename T>
// constexpr T div(T a, T b) {
// if(b > 0) {
@@ -179,24 +189,24 @@ public class FunctionTemplateTests extends TestBase {
// }
// return -1;
// }
-
+
// constexpr auto x = div(11.5, 2.0);
public void testTemplateInstantiationOfIfStatement() throws Exception {
assertEvaluationEquals(5.75);
}
-
+
// constexpr int count(int first) { return 1; }
// constexpr int count(double first) { return 4; }
// template<typename T, typename... Args>
// constexpr int count(T first, Args... args) {
// return count(first) + count(args...);
// }
-
+
// constexpr int x = count(1, 0.5, 3.4, 5, 2.2);
public void testVariadicTemplateWithVaryingTypes() throws Exception {
assertEvaluationEquals(14);
}
-
+
// template<typename... Args>
// constexpr int sum(Args... args) {
// int sum = 0;
@@ -205,12 +215,12 @@ public class FunctionTemplateTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr long long x = sum(1,2,3,4,5);
public void testExpansionOfVariadicTemplateParameterIntoInitializerList() throws Exception {
assertEvaluationEquals(15);
}
-
+
// template<typename... Args>
// constexpr int sum(Args... args) {
// int sum = 0;
@@ -219,12 +229,12 @@ public class FunctionTemplateTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr long long x = sum(1,2,3,4,5);
public void testExpressionInVariadicTemplateParameterExpansion1() throws Exception {
assertEvaluationEquals(30);
}
-
+
// template<typename... Indices>
// constexpr int sumOfPrimes(Indices... indices) {
// // all prime numbers below 100
@@ -235,12 +245,12 @@ public class FunctionTemplateTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = sumOfPrimes(0, 4, 9, 11, 19);
public void testExpressionInVariadicTemplateParameterExpansion2() throws Exception {
assertEvaluationEquals(150);
}
-
+
// template<unsigned... Ints>
// class index_sequence{};
//
@@ -254,12 +264,12 @@ public class FunctionTemplateTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = sumOfPrimes(index_sequence<0, 4, 9, 11, 19>{});
public void testIndexSequence1() throws Exception {
assertEvaluationEquals(150);
}
-
+
// template<typename T, int size>
// constexpr int getArrayLength(T(&)[size]){
// return size;
@@ -268,12 +278,12 @@ public class FunctionTemplateTests extends TestBase {
// int arr[10]{};
// return getArrayLength(arr);
// }
-
+
// constexpr int x = f();
public void testFunctionTemplateWithArrayParameter1() throws Exception {
assertEvaluationEquals(10);
}
-
+
// template<typename T, int size>
// constexpr void doubleArrayContents(T(&arr)[size]) {
// for(int i = 0; i < size; i++) {
@@ -285,12 +295,12 @@ public class FunctionTemplateTests extends TestBase {
// doubleArrayContents(arr);
// return arr[3];
// }
-
+
// constexpr int x = f();
public void testFunctionTemplateWithArrayParameter2() throws Exception {
assertEvaluationEquals(8);
}
-
+
// struct S {
// constexpr S(int n):x{n*2} {}
// constexpr int get() { return x; }
@@ -300,14 +310,14 @@ public class FunctionTemplateTests extends TestBase {
// template<int N>
// constexpr int f() {
// S s{N};
- // return s.get();
+ // return s.get();
// }
-
+
// constexpr int x = f<10>();
public void testInstantiationOfConstructorInFunctionTemplate1() throws Exception {
assertEvaluationEquals(20);
}
-
+
// struct Number {
// constexpr Number(int):isFP{false} {}
// constexpr Number(double):isFP{true} {}
@@ -318,13 +328,13 @@ public class FunctionTemplateTests extends TestBase {
// template<typename T>
// constexpr bool f() {
// Number n{T{}};
- // return n.isFloatingPoint();
+ // return n.isFloatingPoint();
// }
// constexpr bool x = f<double>();
public void testInstantiationOfConstructorInFunctionTemplate2() throws Exception {
assertEvaluationEquals(true);
}
-
+
// template<int A, int B>
// struct Adder {
// constexpr int sum() {
@@ -344,12 +354,12 @@ public class FunctionTemplateTests extends TestBase {
// return 4;
// }
// }
-
+
// constexpr int x = f<9,2>();
public void testInstantiationOfSwitchStatement() throws Exception {
assertEvaluationEquals(2);
}
-
+
// template<typename T>
// constexpr int f() {
// typedef T myType;
@@ -357,12 +367,12 @@ public class FunctionTemplateTests extends TestBase {
// x *= 5;
// return x;
// }
-
+
// constexpr int x = f<int>();
public void testInstantiationOfTypedefDeclaration() throws Exception {
assertEvaluationEquals(25);
}
-
+
// template<typename T>
// constexpr int f() {
// using myint = T;
@@ -370,7 +380,7 @@ public class FunctionTemplateTests extends TestBase {
// x *= 5;
// return x;
// }
-
+
// constexpr int x = f<int>();
public void testInstantiationOfAliasDeclaration() throws Exception {
assertEvaluationEquals(25);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTests.java
index 58a276b0643..63fb951fef9 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -22,15 +22,25 @@ import junit.framework.TestSuite;
public class FunctionTests extends TestBase {
public static class NonIndexing extends FunctionTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends FunctionTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// struct S {
// int x;
// };
@@ -41,33 +51,33 @@ public class FunctionTests extends TestBase {
// S s{5};
// return g(s);
// }
-
+
// constexpr int x = f();
public void testAccessMemberOfCompositeParameter() throws Exception {
assertEvaluationEquals(5);
}
-
+
// constexpr int function(int n) { return n > 0 ? n + function(n-1) : n; }
-
+
// constexpr int x = function(10);
public void testRecursion() throws Exception {
assertEvaluationEquals(55);
}
-
- // constexpr int helper(int n) {
+
+ // constexpr int helper(int n) {
// int m = 5;
// return m + n;
// }
- // constexpr int function() {
+ // constexpr int function() {
// int value = helper(5);
// return value + helper(5);
// }
-
+
// constexpr int x = function();
public void testEvaluationOfConstexprFunctionCalls() throws Exception {
assertEvaluationEquals(20);
}
-
+
// constexpr int g(int i) {
// i++;
// return i;
@@ -84,7 +94,7 @@ public class FunctionTests extends TestBase {
public void testFunctionReturnValueIsCopiedAndNotReferenced() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr void incr(int x) {
// x = x + 1;
// }
@@ -93,12 +103,12 @@ public class FunctionTests extends TestBase {
// incr(a);
// return a;
// }
-
+
// constexpr auto x = f();
public void testPassingIntByValue() throws Exception {
assertEvaluationEquals(5);
}
-
+
// constexpr void incr(int &x) {
// x++;
// }
@@ -107,12 +117,12 @@ public class FunctionTests extends TestBase {
// incr(a);
// return a;
// }
-
+
// constexpr auto x = f();
public void testPassingIntByReference1() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr void incr(int &x, int &y) {
// x++;
// y++;
@@ -122,12 +132,12 @@ public class FunctionTests extends TestBase {
// incr(a, a);
// return a;
// }
-
+
// constexpr auto x = f();
public void testPassingIntByReference2() throws Exception {
assertEvaluationEquals(7);
}
-
+
// struct S {
// int x;
// };
@@ -139,12 +149,12 @@ public class FunctionTests extends TestBase {
// g(s);
// return s.x;
// }
-
+
// constexpr int x = f();
public void testPassingCompositeByValue() throws Exception {
assertEvaluationEquals(5);
}
-
+
// struct Point { int x, y; };
// constexpr void incr(Point &point) {
// point.x++;
@@ -154,12 +164,12 @@ public class FunctionTests extends TestBase {
// incr(p);
// return p.x;
// }
-
+
// constexpr auto x = f();
public void testPassingCompositeByReference() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int a[2][2] { { 1, 2 }, { 3, 4 } };
// constexpr int const * g() {
// return a[0];
@@ -167,12 +177,12 @@ public class FunctionTests extends TestBase {
// constexpr int f() {
// return g()[1];
// }
-
+
// constexpr auto x = f();
public void testPointerReturnValue() throws Exception {
assertEvaluationEquals(2);
- }
-
+ }
+
// int const y { 5 };
// constexpr int const & g() {
// return y;
@@ -180,12 +190,12 @@ public class FunctionTests extends TestBase {
// constexpr int f() {
// return g() + 1;
// }
-
+
// constexpr auto x = f();
public void testReferenceReturnValue() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr void side_effect(int array[], int length) {
// for (int i = 0; i < length; ++i) {
// array[i]++;
@@ -196,12 +206,12 @@ public class FunctionTests extends TestBase {
// side_effect(array, 4);
// return array[0];
// }
-
+
// constexpr auto x = f();
public void testSideEffectsOnArrayParameter() throws Exception {
- assertEvaluationEquals(2);
+ assertEvaluationEquals(2);
}
-
+
// constexpr int f(int a) {
// {
// int a = 5;
@@ -209,48 +219,48 @@ public class FunctionTests extends TestBase {
// }
// return a;
// }
-
+
// constexpr int x = f(10);
public void testBlockScopeValueLookup1() throws Exception {
assertEvaluationEquals(5);
}
-
+
// constexpr int f(int a) {
// {
// int a = 5;
// }
// return a;
// }
-
+
// constexpr int x = f(10);
public void testBlockScopeValueLookup2() throws Exception {
assertEvaluationEquals(10);
}
-
+
// char foo();
// constexpr int almost = sizeof(foo());
-
+
// constexpr int x = almost;
public void testSizeofCallToRegularFunction() throws Exception {
assertEvaluationEquals(1);
}
-
+
// int f() {
// return 5;
// }
-
+
// int x = f();
public void testNonConstexprFunctionDoesntStoreBodyExecution() throws Exception {
IASTInitializerClause clause = getLastDeclarationInitializer();
- IASTFunctionCallExpression funcExpr = (IASTFunctionCallExpression)clause;
- IASTIdExpression idExpr = (IASTIdExpression)funcExpr.getFunctionNameExpression();
- ICPPFunction function = (ICPPFunction)idExpr.getName().resolveBinding();
+ IASTFunctionCallExpression funcExpr = (IASTFunctionCallExpression) clause;
+ IASTIdExpression idExpr = (IASTIdExpression) funcExpr.getFunctionNameExpression();
+ ICPPFunction function = (ICPPFunction) idExpr.getName().resolveBinding();
ICPPExecution bodyExec = CPPFunction.getFunctionBodyExecution(function);
assertNull(bodyExec);
}
// // Empty header file
-
+
// struct A {
// A() {}
// A& m(int p) {
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IfStatementTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IfStatementTests.java
index 94e53607466..e8c32fe5320 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IfStatementTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IfStatementTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,34 +15,44 @@ import junit.framework.TestSuite;
public class IfStatementTests extends TestBase {
public static class NonIndexing extends IfStatementTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends IfStatementTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f() {
// if (true) {
// return 1;
- // }
+ // }
// return 0;
// }
-
+
// constexpr int x = f();
public void testSimpleIfTrueBranch() throws Exception {
assertEvaluationEquals(1);
}
-
+
// constexpr int f() {
// if (false) {
// return 1;
- // }
+ // }
// return 0;
// }
-
+
// constexpr int x = f();
public void testSimpleIfFalseBranch() throws Exception {
assertEvaluationEquals(0);
@@ -55,12 +65,12 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f();
public void testIfElseTrueBranch() throws Exception {
assertEvaluationEquals(1);
}
-
+
// constexpr int f() {
// if (false) {
// return 1;
@@ -68,12 +78,12 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f();
public void testSimpleIfElseFalseBranch() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr int f() {
// if (false) {
// return 1;
@@ -83,12 +93,12 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f();
public void testNestedIfTrueBranch() throws Exception {
assertEvaluationEquals(2);
}
-
+
// constexpr int f() {
// if (false) {
// return 1;
@@ -98,35 +108,35 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f();
public void testNestedIfFalseBranch() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr int f() {
// if (true)
// return 1;
// return 0;
// }
-
+
// constexpr int x = f();
public void testIfStatementWithNonCompoundThenClause() throws Exception {
assertEvaluationEquals(1);
}
-
+
// constexpr int f() {
// if (false)
// return 1;
// else
// return 0;
// }
-
+
// constexpr int x = f();
public void testIfStatementWithNonCompoundElseClause() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr int f() {
// int i;
// if (true) {
@@ -136,12 +146,12 @@ public class IfStatementTests extends TestBase {
// }
// return i;
// }
-
+
// constexpr int x = f();
public void testIfStatementWithNonReturnClauses() throws Exception {
assertEvaluationEquals(10);
}
-
+
// constexpr int f() {
// int i;
// if (false)
@@ -150,12 +160,12 @@ public class IfStatementTests extends TestBase {
// i = 20;
// return i;
// }
-
+
// constexpr int x = f();
public void testIfStatementWithNonReturnClausesAndNonCompoundElseClause() throws Exception {
assertEvaluationEquals(20);
}
-
+
// constexpr int f(int y) {
// if(int x = y*2) {
// return 14 / x;
@@ -163,12 +173,12 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f(1);
public void testDeclarationInIfStatementCondition1() throws Exception {
assertEvaluationEquals(7);
}
-
+
// constexpr int f(int y) {
// if(int x = y*2) {
// return 14 / x;
@@ -176,12 +186,12 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f(0);
public void testDeclarationInIfStatementCondition2() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr int g(int x) {
// return x * 2;
// }
@@ -192,12 +202,12 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f(1);
public void testDeclarationInIfStatementCondition3() throws Exception {
assertEvaluationEquals(7);
}
-
+
// constexpr int g(int x) {
// return x * 2;
// }
@@ -208,12 +218,12 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f(1);
public void testInitStatementInIfStatementCondition1() throws Exception {
assertEvaluationEquals(7);
}
-
+
// constexpr int g(int x) {
// return x * 2;
// }
@@ -224,12 +234,12 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f(1);
public void testInitStatementInIfStatementCondition2() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr int g(int x) {
// return x * 2;
// }
@@ -240,12 +250,12 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f();
public void testInitStatementInIfStatementCondition3() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr int g(int x) {
// return x * 2;
// }
@@ -257,7 +267,7 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f(1);
public void testEmptyInitStatementInIfStatementCondition1() throws Exception {
assertEvaluationEquals(7);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IntegralValueTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IntegralValueTests.java
index 729db619cff..641fdfc411f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IntegralValueTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IntegralValueTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -17,95 +17,105 @@ import junit.framework.TestSuite;
public class IntegralValueTests extends TestBase {
public static class NonIndexing extends IntegralValueTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends IntegralValueTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr auto x = int{} + int();
public void testIntDefaultValue() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto f() {
// int x{};
// return x;
// }
-
+
// constexpr auto x = f();
public void testIntValueInitialization() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto x = long{} + long();
public void testLongDefaultValue() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto f() {
// long x{};
// return x;
// }
-
+
// constexpr auto x = f();
public void testLongValueInitialization() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto x = short{} + short();
public void testShortDefaultValue() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto f() {
// short x{};
// return x;
// }
-
+
// constexpr auto x = f();
public void testShortValueInitialization() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto x = bool{} + bool();
public void testBooleanDefaulValue() throws Exception {
assertEvaluationEquals(false);
}
-
+
// constexpr auto f() {
// bool x{};
// return x;
// }
-
+
// constexpr auto x = f();
public void testBoolValueInitialization() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto x = char{} + char();
public void testCharDefaultValue() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto f() {
// char x{'c'};
// return x;
// }
-
+
// constexpr auto x = f();
public void testCharValueInitialization() throws Exception {
assertEvaluationEquals('c');
}
-
+
// constexpr int mul(int op1, int op2) {
// int result = op1 * op2;
// return result;
// }
-
+
// constexpr int x = mul(2, 5);
public void testDeclarationWithEqualsInitializerInSequence() throws Exception {
assertEvaluationEquals(10);
@@ -116,145 +126,145 @@ public class IntegralValueTests extends TestBase {
// int intermediate2 { op2 };
// return intermediate1 * intermediate2;
// }
-
+
// constexpr int x = mul(2, 5);
public void testDeclarationWithDefaultInitializationInSequence() throws Exception {
assertEvaluationEquals(10);
}
-
+
// constexpr int f() {
// int i(5);
// i++;
// return i;
// }
-
+
// constexpr int x = f();
public void testDirectInitializationOnFundamentalTypes() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr int f() {
// int invalid;
// return invalid;
// }
-
+
// constexpr int x = f();
public void testUseOfUninitializedVariableIsError() throws Exception {
assertEvaluationEquals(IntegralValue.UNKNOWN);
}
-
+
// constexpr auto f() {
// int x = 1, y = 1, z = 1;
// return x + y + z;
// }
-
+
// constexpr auto x = f();
public void testDeclarationWithMultipleDeclarators() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int f() {
// int i{5};
// i++;
// return i;
// }
-
+
// constexpr int x = f();
public void testSimpleTypeConstructionInitializerList() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr int f() {
// int i(5);
// i++;
// return i;
// }
-
+
// constexpr int x = f();
public void testSimpleTypeConstructionConstructorInitializer() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr int f() {
// int i = 5;
// i++;
// return i;
// }
-
+
// constexpr int x = f();
public void testSimpleTypeConstructionEqualsInitializer1() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr int f() {
// int i = {5};
// i++;
// return i;
// }
-
+
// constexpr int x = f();
public void testSimpleTypeConstructionEqualsInitializer2() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr int f() {
// int a { 3 };
// int b = a;
// b++;
// return a + b;
// }
-
+
// constexpr int x = f();
public void testCopyInitialization() throws Exception {
assertEvaluationEquals(7);
}
-
- // constexpr int f() {
- // int y = 0, x = 5;
- // x++;
- // return x;
+
+ // constexpr int f() {
+ // int y = 0, x = 5;
+ // x++;
+ // return x;
// }
-
+
// constexpr auto x = f();
public void testMultipleDeclaratorsInOneDeclaration() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr int f() {
// return int{5};
// }
-
+
// constexpr int x = f();
public void testSimpleTypeConstructorExpression1() throws Exception {
assertEvaluationEquals(5);
}
-
+
// constexpr int f() {
// int a { 1 }; // declaration
// a = ++a * ++a; // assignment / side effects
// return a; // returns 6
// }
-
+
// constexpr auto x = f();
public void testSideEffects2() throws Exception {
- assertEvaluationEquals(6);
+ assertEvaluationEquals(6);
}
-
+
// constexpr int x = 2;
-
+
// constexpr int y = x * 4;
public void testAccessGlobalVariableFromGlobalConstexpr() throws Exception {
assertEvaluationEquals(8);
}
-
+
// constexpr int x = 2;
// constexpr int f() { return x * 4; }
-
+
// constexpr int y = f();
public void testAccessGlobalVariableFromConstexprFunction() throws Exception {
assertEvaluationEquals(8);
}
-
+
// constexpr int x = 0x2a;
public void testHexLiteral() throws Exception {
assertEvaluationEquals(42);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberFunctionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberFunctionTests.java
index fa4ac9b99db..a9d192722f4 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberFunctionTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberFunctionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,15 +15,25 @@ import junit.framework.TestSuite;
public class MemberFunctionTests extends TestBase {
public static class NonIndexing extends MemberFunctionTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends MemberFunctionTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// struct S {
// int x, y;
// constexpr int member() {
@@ -34,12 +44,12 @@ public class MemberFunctionTests extends TestBase {
// S s{3,7};
// return s.member();
// }
-
+
// constexpr auto x = f();
public void testMemberFunctionCall() throws Exception {
assertEvaluationEquals(4);
}
-
+
// struct S {
// int x, y;
// constexpr int member() {
@@ -51,12 +61,12 @@ public class MemberFunctionTests extends TestBase {
// S s{3,7};
// return s.member();
// }
-
+
// constexpr auto x = f();
public void testMemberFunctionWithImplicitThis() throws Exception {
- assertEvaluationEquals(8);
+ assertEvaluationEquals(8);
}
-
+
// class Point {
// int x, y;
// public:
@@ -69,12 +79,12 @@ public class MemberFunctionTests extends TestBase {
// Point p{4,5};
// return p.getY();
// }
-
+
// constexpr int x = f();
public void testExternallyDefinedMemberFunction() throws Exception {
assertEvaluationEquals(5);
}
-
+
// class S {
// int x;
// public:
@@ -88,12 +98,12 @@ public class MemberFunctionTests extends TestBase {
// s.inc();
// return s.get();
// }
-
+
// constexpr int x = f();
public void testPlusEqualsWithinMemberFunction() throws Exception {
assertEvaluationEquals(50);
}
-
+
// class Point {
// int x, y;
// public:
@@ -104,12 +114,12 @@ public class MemberFunctionTests extends TestBase {
// Point p{10,40};
// return p.getY();
// }
-
+
// constexpr int x = f();
public void testMemberAccessThroughThisPointer() throws Exception {
assertEvaluationEquals(40);
}
-
+
// struct S {
// int x, y;
// constexpr int member() {
@@ -125,12 +135,12 @@ public class MemberFunctionTests extends TestBase {
// S s{3,7};
// return s.member();
// }
-
+
// constexpr auto x = f();
public void testNestedMemberFunctionCallsWithImplicitThis() throws Exception {
- assertEvaluationEquals(8);
+ assertEvaluationEquals(8);
}
-
+
// struct S {
// constexpr S(int x, int y):x{x}, y{y*2} {}
// constexpr int getY() const {
@@ -140,15 +150,15 @@ public class MemberFunctionTests extends TestBase {
// int x;
// int y;
// };
- //
+ //
// constexpr S s{3, 5};
// constexpr int f() { return s.getY(); }
-
+
// constexpr int x = f();
public void testGlobalMemberFunctionCallFromConstexprFunction() throws Exception {
assertEvaluationEquals(10);
}
-
+
// struct S {
// constexpr S(int x, int y):x{x}, y{y*2} {}
// constexpr int getY() const {
@@ -157,14 +167,14 @@ public class MemberFunctionTests extends TestBase {
// private:
// int x;
// int y;
- // };
+ // };
// constexpr S s{3, 5};
-
+
// constexpr int x = s.getY();
public void testGlobalMemberFunctionCallFromGlobalConstexpr() throws Exception {
assertEvaluationEquals(10);
}
-
+
// struct S {
// constexpr S(int x, int y):x{x}, y{y} {}
// constexpr int add(S const& other) const {
@@ -182,6 +192,6 @@ public class MemberFunctionTests extends TestBase {
// constexpr int x = f();
public void testManualAddMemberFunction() throws Exception {
- assertEvaluationEquals(15);
+ assertEvaluationEquals(15);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberVariableTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberVariableTests.java
index ad118ebbe07..ab09b0b55ff 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberVariableTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberVariableTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,27 +15,37 @@ import junit.framework.TestSuite;
public class MemberVariableTests extends TestBase {
public static class NonIndexing extends MemberVariableTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends MemberVariableTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// struct Point { int x, y; };
// constexpr int f() {
// Point p{ 2, 4 };
// p.x++;
// return p.x;
// }
-
+
// constexpr auto x = f();
public void testIncrementOnCompositeValues() throws Exception {
assertEvaluationEquals(3);
}
-
+
// struct S {
// int x, y;
// };
@@ -43,51 +53,51 @@ public class MemberVariableTests extends TestBase {
// const S s{3,7};
// return s.y;
// }
-
+
// constexpr auto x = f();
public void testMemberAccessWithConstObject() throws Exception {
assertEvaluationEquals(7);
}
-
- // struct S {
- // int x, y;
- // };
- // constexpr S s{5, 6};
- // constexpr int f() { return s.y; }
-
- // constexpr auto x = f();
- public void testGlobalMemberAccessFromConstexprFunction() throws Exception {
- assertEvaluationEquals(6);
- }
-
+
// struct S {
// int x, y;
// };
// constexpr S s{5, 6};
-
+ // constexpr int f() { return s.y; }
+
+ // constexpr auto x = f();
+ public void testGlobalMemberAccessFromConstexprFunction() throws Exception {
+ assertEvaluationEquals(6);
+ }
+
+ // struct S {
+ // int x, y;
+ // };
+ // constexpr S s{5, 6};
+
// constexpr auto x = s.y;
public void testGlobalMemberAccessFromGlobalConstexpr() throws Exception {
assertEvaluationEquals(6);
}
-
+
// struct T {
// constexpr T(int x):x{2*x}{}
// int x;
// };
// struct S {
- // T t{5};
+ // T t{5};
// int i = t.x * 2;
// };
// constexpr int f() {
// S s{};
// return s.i;
// }
-
+
// constexpr int x = f();
- public void testFieldDependsOnOtherField() throws Exception {
- assertEvaluationEquals(20);
- }
-
+ public void testFieldDependsOnOtherField() throws Exception {
+ assertEvaluationEquals(20);
+ }
+
// class S {
// int arr[4]{2,4,6,8};
// public:
@@ -100,21 +110,21 @@ public class MemberVariableTests extends TestBase {
// int *ptr = s.getPtr()+2;
// return *ptr;
// }
-
+
// constexpr int x = f();
- public void testMemberInitializationWithoutUserDefinedCtor() throws Exception {
- assertEvaluationEquals(6);
- }
-
+ public void testMemberInitializationWithoutUserDefinedCtor() throws Exception {
+ assertEvaluationEquals(6);
+ }
+
// struct S {
- // static const int x = 5;
+ // static const int x = 5;
// };
// constexpr int f() {
// return S::x;
// }
// constexpr int x = f();
- public void testAccessOfStaticField() throws Exception {
- assertEvaluationEquals(5);
- }
+ public void testAccessOfStaticField() throws Exception {
+ assertEvaluationEquals(5);
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/PointerTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/PointerTests.java
index 6be5c882c20..789684cc470 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/PointerTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/PointerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -17,27 +17,37 @@ import junit.framework.TestSuite;
public class PointerTests extends TestBase {
public static class NonIndexing extends PointerTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends PointerTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f() {
// int bar[2] { 3, 7 };
// int * bar_ptr { bar };
// bar_ptr++;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerArithmeticsPostFixIncr() throws Exception {
assertEvaluationEquals(7);
}
-
+
// constexpr int f() {
// int bar[2] { 3, 7 };
// int * bar_ptr { bar };
@@ -45,42 +55,42 @@ public class PointerTests extends TestBase {
// bar_ptr--;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerArithmeticsPostFixDecr() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int f() {
// int n { 0 };
// int * nPtr { &n };
// nPtr++;
// return *nPtr;
// }
-
+
// constexpr int x = f();
public void testDereferencingOfPointerToInvalidMemoryShouldFail() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 2 };
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerArithmeticInDeclaration() throws Exception {
assertEvaluationEquals(7);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar };
// int * bar_ptr2 { bar + 3 };
// return bar_ptr2 - bar_ptr;
// }
-
+
// constexpr int x = f();
public void testSubtractionOfPointersToSameArrayShouldYieldDistance() throws Exception {
assertEvaluationEquals(3);
@@ -92,60 +102,60 @@ public class PointerTests extends TestBase {
// bar_ptr = bar_ptr + 1;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerAddition() throws Exception {
assertEvaluationEquals(5);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar };
// bar_ptr += 2;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerAdditionAndAssignment() throws Exception {
assertEvaluationEquals(7);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 2};
// bar_ptr = bar_ptr - 2;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerSubtraction() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 2 };
// bar_ptr -= 2;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerSubtractionAndAssignment() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar };
// int * bar_ptr2 { bar_ptr };
// return *bar_ptr2;
// }
-
+
// constexpr int x = f();
public void testPointerDeclarationFromPointer() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar };
@@ -153,48 +163,48 @@ public class PointerTests extends TestBase {
// bar_ptr++;
// return *bar_ptr2;
// }
-
+
// constexpr int x = f();
public void testPointersHaveSeparatePositions() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar };
// int * bar_ptr2 { bar_ptr + 1 };
// return *bar_ptr2;
// }
-
+
// constexpr int x = f();
public void testPointerAdditionInDeclaration() throws Exception {
assertEvaluationEquals(5);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 3 };
// int * bar_ptr2 { bar_ptr - 1 };
// return *bar_ptr2;
// }
-
+
// constexpr int x = f();
public void testPointerSubtractionInDeclaration() throws Exception {
assertEvaluationEquals(7);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 3 };
// bar_ptr++;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testDereferencingOnePastTheEndPointerIsInvalid() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 3 };
@@ -202,12 +212,13 @@ public class PointerTests extends TestBase {
// bar_ptr--;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
- public void testDereferencingIncrementedOnePastTheEndAndThenDecrementedBackInRageAgainPointerIsValid() throws Exception {
+ public void testDereferencingIncrementedOnePastTheEndAndThenDecrementedBackInRageAgainPointerIsValid()
+ throws Exception {
assertEvaluationEquals(11);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 3 };
@@ -215,24 +226,25 @@ public class PointerTests extends TestBase {
// bar_ptr -= 2;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
- public void testDereferencingIncrementedTWOPastTheEndAndThenDecrementedBackInRageAgainPointerIsInvalid() throws Exception {
+ public void testDereferencingIncrementedTWOPastTheEndAndThenDecrementedBackInRageAgainPointerIsInvalid()
+ throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar };
// bar_ptr--;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerWithNegativePositionIsInvalid() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar };
@@ -240,70 +252,70 @@ public class PointerTests extends TestBase {
// bar_ptr++;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerThatOnceHasNegativePositionStaysInvalid() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 4 };
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerDeclaredOnePastTheEndIsInvalid() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 4 };
// bar_ptr--;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerDeclaredOnePastTheEndAndThenDecrementedBackInRageAgainIsValid() throws Exception {
assertEvaluationEquals(11);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 5 };
// bar_ptr -= 2;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerDeclaredTwoPastTheEndAndThenDecrementedBackInRageAgainStaysInvalid() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar - 1 };
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerDeclaredWithNegativePositionIsInvalid() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar - 1 };
// bar_ptr++;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerDelcaredWithNegativePositionStaysInvalid() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int a { 1 }; // declaration
// int b { 2 };
@@ -311,10 +323,10 @@ public class PointerTests extends TestBase {
// ptr = &b;
// return *ptr;
// }
-
+
// constexpr auto x = f();
public void testPointerAssignment() throws Exception {
- assertEvaluationEquals(2);
+ assertEvaluationEquals(2);
}
// constexpr auto f() {
@@ -323,12 +335,12 @@ public class PointerTests extends TestBase {
// *x_ptr = 2;
// return *x_ptr;
// }
-
+
// constexpr auto x = f();
public void testPointerValueAssignment() throws Exception {
- assertEvaluationEquals(2);
+ assertEvaluationEquals(2);
}
-
+
// struct S {
// int x, y;
// };
@@ -338,19 +350,19 @@ public class PointerTests extends TestBase {
// *s_ptr = 3;
// return *s_ptr;
// }
-
+
// constexpr auto x = f();
public void testPointerToStructMember() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int f() {
// int a { 5 };
// int * aPtr { &a };
// (*aPtr)++;
// return a;
// }
-
+
// constexpr auto x = f();
public void testPointer() throws Exception {
assertEvaluationEquals(6);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/RangeBasedForStatementTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/RangeBasedForStatementTests.java
index 9cccef19a19..35d5b3af90f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/RangeBasedForStatementTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/RangeBasedForStatementTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -17,15 +17,25 @@ import junit.framework.TestSuite;
public class RangeBasedForStatementTests extends TestBase {
public static class NonIndexing extends RangeBasedForStatementTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends RangeBasedForStatementTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int sum { 0 };
@@ -34,12 +44,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testSimpleRangeBasedForLoop() throws Exception {
assertEvaluationEquals(26);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int sum { 0 };
@@ -48,12 +58,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testReturnInRangeBasedForLoop() throws Exception {
assertEvaluationEquals(42);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int sum { 0 };
@@ -65,12 +75,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopReferences() throws Exception {
assertEvaluationEquals(30);
- }
-
+ }
+
// constexpr void incr(int & i) {
// i++;
// }
@@ -85,12 +95,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testPassReferenceObtainedFromRangeBasedForLoopToFunctionAndModify() throws Exception {
assertEvaluationEquals(30);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int sum { 0 };
@@ -98,12 +108,12 @@ public class RangeBasedForStatementTests extends TestBase {
// sum += i;
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopWithNonCompoundBodyStatement() throws Exception {
assertEvaluationEquals(26);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int sum { 0 };
@@ -111,12 +121,12 @@ public class RangeBasedForStatementTests extends TestBase {
// return 42;
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopWithReturnInNonCompoundBodyStatement() throws Exception {
assertEvaluationEquals(42);
}
-
+
// class Range {
// int arr[5];
// public:
@@ -132,12 +142,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopOverCustomType() throws Exception {
assertEvaluationEquals(15);
}
-
+
// class Range {
// int arr[5];
// public:
@@ -160,12 +170,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopThatModifiesElementsInCustomType() throws Exception {
assertEvaluationEquals(20);
}
-
+
// class Range {
// int arr1[5];
// int arr2[5];
@@ -184,12 +194,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopOverNonConstRangeChoosesNonConstBeginEnd() throws Exception {
assertEvaluationEquals(15);
}
-
+
// class Range {
// int arr1[5];
// int arr2[5];
@@ -208,12 +218,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopOverConstRangeChoosesConstBeginEnd() throws Exception {
assertEvaluationEquals(40);
}
-
+
// class Range {
// int arr1[5];
// int arr2[5];
@@ -233,12 +243,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopOverConstRefRangeChoosesConstBeginEnd() throws Exception {
assertEvaluationEquals(40);
}
-
+
// class Range {
// int arr[5];
// public:
@@ -254,12 +264,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopOverCustomTypeWithInvalidBeginMemberFunction() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// class Range {
// int arr[5];
// public:
@@ -275,12 +285,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopOverCustomTypeWithBeginMemberFunctionWithDefaultParameterValue() throws Exception {
assertEvaluationEquals(15);
}
-
+
// namespace ns {
// class Vec {
// public:
@@ -300,12 +310,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testDoesArgumentDependentLookupIfBeginEndMemberFunctionsDontExist() throws Exception {
assertEvaluationEquals(15);
}
-
+
// namespace ns {
// class Vec {
// public:
@@ -328,12 +338,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testChoosesMemberFunctionsOverFreeFunctions() throws Exception {
assertEvaluationEquals(40);
}
-
+
// namespace ns {
// class Vec {
// public:
@@ -353,12 +363,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testDoesntMixMemberFunctionsAndFreeFunctions() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// namespace ns {
// class Vec {
// int arr[5];
@@ -381,12 +391,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testWorksWithBeginEndTemplates() throws Exception {
assertEvaluationEquals(15);
}
-
+
// constexpr int f() {
// int sum = 0;
// for(auto x : {1,2,3,4,5}) {
@@ -394,7 +404,7 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopOverInitializerList() throws Exception {
assertEvaluationEquals(15);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ReferenceTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ReferenceTests.java
index 3de42ce94b2..7a790030299 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ReferenceTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ReferenceTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,39 +15,49 @@ import junit.framework.TestSuite;
public class ReferenceTests extends TestBase {
public static class NonIndexing extends ReferenceTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends ReferenceTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f() {
// int a { 1 };
// int &aRef { a };
// aRef++;
// return a;
// }
-
+
// constexpr int x = f();
public void testSideEffectsOnReferences() throws Exception {
assertEvaluationEquals(2);
}
-
+
// constexpr int f() {
// int a { 1 };
// int &aRef { a };
// aRef = aRef + 1;
// return a;
// }
-
+
// constexpr int x = f();
public void testAssignmentsOnReferences() throws Exception {
assertEvaluationEquals(2);
}
-
+
// constexpr int f() {
// int a { 1 };
// int &aRef { a };
@@ -55,12 +65,12 @@ public class ReferenceTests extends TestBase {
// aRefRef++;
// return a;
// }
-
+
// constexpr auto x = f();
public void testSideEffectsOnNestedReferences() throws Exception {
assertEvaluationEquals(2);
}
-
+
// constexpr int f() {
// int a { 1 };
// int &aRef { a };
@@ -68,7 +78,7 @@ public class ReferenceTests extends TestBase {
// aRefRef = aRef + aRefRef;
// return a;
// }
-
+
// constexpr auto x = f();
public void testAssignmentOnNestedReferences() throws Exception {
assertEvaluationEquals(2);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/SwitchStatementTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/SwitchStatementTests.java
index c71c89fea78..678263064f1 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/SwitchStatementTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/SwitchStatementTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,15 +15,25 @@ import junit.framework.TestSuite;
public class SwitchStatementTests extends TestBase {
public static class NonIndexing extends SwitchStatementTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends SwitchStatementTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f() {
// int x { 1 };
// switch (x) {
@@ -35,12 +45,12 @@ public class SwitchStatementTests extends TestBase {
// return -1;
// }
// }
-
+
// constexpr int x = f();
public void testSwitchFirstCase() throws Exception {
assertEvaluationEquals(1);
}
-
+
// constexpr int f() {
// int x { 2 };
// switch (x) {
@@ -52,12 +62,12 @@ public class SwitchStatementTests extends TestBase {
// return -1;
// }
// }
-
+
// constexpr int x = f();
public void testSwitchMiddleCase() throws Exception {
assertEvaluationEquals(2);
}
-
+
// constexpr int f() {
// int x { 3 };
// switch (x) {
@@ -69,12 +79,12 @@ public class SwitchStatementTests extends TestBase {
// return -1;
// }
// }
-
+
// constexpr int x = f();
public void testSwitchDefault() throws Exception {
assertEvaluationEquals(-1);
}
-
+
// constexpr int f() {
// int x { 1 };
// switch (x) {
@@ -85,12 +95,12 @@ public class SwitchStatementTests extends TestBase {
// return -1;
// }
// }
-
+
// constexpr int x = f();
public void testSwitchFallThrough() throws Exception {
assertEvaluationEquals(2);
}
-
+
// constexpr int f() {
// int x { 1 };
// int y = 10;
@@ -100,12 +110,12 @@ public class SwitchStatementTests extends TestBase {
// y--;
// return y;
// }
-
+
// constexpr int x = f();
public void testSwitchWithOnlyOneClause1() throws Exception {
assertEvaluationEquals(10);
}
-
+
// constexpr int f() {
// int x { 0 };
// int y = 10;
@@ -115,13 +125,12 @@ public class SwitchStatementTests extends TestBase {
// y--;
// return y;
// }
-
+
// constexpr int x = f();
public void testSwitchWithOnlyOneClause2() throws Exception {
assertEvaluationEquals(9);
}
-
-
+
// constexpr int f() {
// int x { 2 };
// int y = 2;
@@ -137,12 +146,12 @@ public class SwitchStatementTests extends TestBase {
// }
// return y;
// }
-
+
// constexpr int x = f();
public void testSwitchBreak() throws Exception {
assertEvaluationEquals(20);
}
-
+
// constexpr int f() {
// int x { 3 };
// int y = 2;
@@ -156,12 +165,12 @@ public class SwitchStatementTests extends TestBase {
// }
// return y;
// }
-
+
// constexpr int x = f();
public void testSwitchNoMatchingCaseAndNoDefault() throws Exception {
assertEvaluationEquals(2);
}
-
+
// class Point {
// int x, y;
// public:
@@ -172,7 +181,7 @@ public class SwitchStatementTests extends TestBase {
// int x { 2 };
// int y = 5;
// constexpr Point p{4, 1};
- //
+ //
// switch (x) {
// case 1:
// y = 10;
@@ -183,12 +192,12 @@ public class SwitchStatementTests extends TestBase {
// }
// return y;
// }
-
+
// constexpr int x = f();
public void testSwitchCaseConstants() throws Exception {
assertEvaluationEquals(20);
}
-
+
// constexpr int triple(int x) {
// return x * 3;
// }
@@ -204,12 +213,12 @@ public class SwitchStatementTests extends TestBase {
// return 4;
// }
// }
-
+
// constexpr int x = f(5);
public void testDeclarationInSwitchStatementController() throws Exception {
assertEvaluationEquals(3);
}
-
+
// enum Color { RED, GREEN, BLUE };
// constexpr int f(Color color) {
// switch(color) {
@@ -221,12 +230,12 @@ public class SwitchStatementTests extends TestBase {
// return 3;
// }
// }
-
+
// constexpr int x = f(BLUE);
public void testSwitchOnEnumValue() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int f() {
// int arr[] = {1,2,1,3,5,6,1,2,0};
// int sum{};
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TestBase.java
index ad94d5cac35..3083093cf5d 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TestBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TestBase.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -154,8 +154,9 @@ public class TestBase extends IndexBindingResolutionTestBase {
@Override
public void setUp() throws Exception {
CTestPlugin plugin = CTestPlugin.getDefault();
- StringBuilder[] builders = TestSourceReader.getContentsForTest(plugin.getBundle(), "parser", TestBase.this.getClass(), getName(), 2);
- if(builders.length == 2) {
+ StringBuilder[] builders = TestSourceReader.getContentsForTest(plugin.getBundle(), "parser",
+ TestBase.this.getClass(), getName(), 2);
+ if (builders.length == 2) {
builders[0].append(builders[1].toString());
}
testData = new StringBuilder[] { builders[0] };
@@ -178,7 +179,8 @@ public class TestBase extends IndexBindingResolutionTestBase {
}
protected static IASTTranslationUnit parse(String code) throws ParserException {
- IScanner scanner = createScanner(FileContent.create(TEST_CODE, code.toCharArray()), ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, SCANNER_INFO);
+ IScanner scanner = createScanner(FileContent.create(TEST_CODE, code.toCharArray()), ParserLanguage.CPP,
+ ParserMode.COMPLETE_PARSE, SCANNER_INFO);
AbstractGNUSourceCodeParser parser = null;
ICPPParserExtensionConfiguration config = new ANSICPPParserExtensionConfiguration();
parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TypeAliasTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TypeAliasTests.java
index f545c766a1d..f8bfe848d71 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TypeAliasTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TypeAliasTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,34 +15,44 @@ import junit.framework.TestSuite;
public class TypeAliasTests extends TestBase {
public static class NonIndexing extends TypeAliasTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends TypeAliasTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f() {
// typedef int myint;
// myint x = 5;
// x *= 5;
// return x;
// }
-
+
// constexpr int x = f();
public void testTypedefDeclaration() throws Exception {
assertEvaluationEquals(25);
}
-
+
// constexpr int f() {
// using myint = int;
// myint x = 5;
// x *= 5;
// return x;
// }
-
+
// constexpr int x = f();
public void testAliasDeclaration() throws Exception {
assertEvaluationEquals(25);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryExpressionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryExpressionTests.java
index bdc7ee5d418..d75d427392b 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryExpressionTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryExpressionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,124 +15,134 @@ import junit.framework.TestSuite;
public class UnaryExpressionTests extends TestBase {
public static class NonIndexing extends UnaryExpressionTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends UnaryExpressionTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int doubleIncrement(int n) {
// ++n;
// ++n;
// return n;
// }
-
+
// constexpr int x = doubleIncrement(0);
public void testSimpleSequence() throws Exception {
assertEvaluationEquals(2);
}
-
- // constexpr int function() {
+
+ // constexpr int function() {
// int n { 0 };
// int m { n++ };
// int o { n++ };
// return n;
// }
-
+
// constexpr int x = function();
public void testAssignmentWithPostfixIncrSideEffects() throws Exception {
assertEvaluationEquals(2);
}
-
- // constexpr int function() {
+
+ // constexpr int function() {
// int n { 0 };
// int m { n-- };
// int o { n-- };
// return n;
// }
-
+
// constexpr int x = function();
public void testAssignmentWithPostfixDecrSideEffects() throws Exception {
assertEvaluationEquals(-2);
}
-
- // constexpr int function() {
+
+ // constexpr int function() {
// int n { 0 };
// int m { --n };
// int o { --n };
// return n;
// }
-
+
// constexpr int x = function();
public void testAssignmentWithPrefixDecrSideEffects() throws Exception {
assertEvaluationEquals(-2);
}
-
- // constexpr int function() {
+
+ // constexpr int function() {
// int n { 0 };
// int m { ++n };
// int o { ++n };
// return n;
// }
-
+
// constexpr int x = function();
public void testAssignmentWithPrefixIncrSideEffects() throws Exception {
assertEvaluationEquals(2);
}
-
- // constexpr int function() {
+
+ // constexpr int function() {
// int n { 0 };
// return n++;
// }
-
+
// constexpr int x = function();
public void testPostfixIncrSemantics() throws Exception {
assertEvaluationEquals(0);
}
-
- // constexpr int function() {
+
+ // constexpr int function() {
// int n { 0 };
// return n++;
// }
-
+
// constexpr int x = function();
public void testPostfixDecrSemantics() throws Exception {
assertEvaluationEquals(0);
}
-
- // constexpr int function() {
+
+ // constexpr int function() {
// int n { 0 };
// return ++n;
// }
-
+
// constexpr int x = function();
public void testPrefixIncrSemantics() throws Exception {
assertEvaluationEquals(1);
}
-
- // constexpr int function() {
+
+ // constexpr int function() {
// int n { 0 };
// return --n;
// }
-
+
// constexpr int x = function();
public void testPrefixDecrSemantics() throws Exception {
assertEvaluationEquals(-1);
}
-
+
// constexpr int f() {
- // int x = 2;
- // ++(++x);
- // return x;
- // }
-
- // constexpr int x = f();
- public void testPrefixIncrementReturnsLvalue() throws Exception {
- assertEvaluationEquals(4);
- }
+ // int x = 2;
+ // ++(++x);
+ // return x;
+ // }
+
+ // constexpr int x = f();
+ public void testPrefixIncrementReturnsLvalue() throws Exception {
+ assertEvaluationEquals(4);
+ }
// struct BooleanConvertible {
// bool value;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryOperatorOverloadingTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryOperatorOverloadingTests.java
index c7d54535b1d..854f2abafca 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryOperatorOverloadingTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryOperatorOverloadingTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,15 +15,25 @@ import junit.framework.TestSuite;
public class UnaryOperatorOverloadingTests extends TestBase {
public static class NonIndexing extends UnaryOperatorOverloadingTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends UnaryOperatorOverloadingTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// class Point {
// int x, y;
// public:
@@ -41,12 +51,12 @@ public class UnaryOperatorOverloadingTests extends TestBase {
// ++p;
// return p.getY();
// }
-
+
// constexpr int x = f();
public void testPrefixIncrementAsMemberFunction() throws Exception {
- assertEvaluationEquals(6);
+ assertEvaluationEquals(6);
}
-
+
// class Point {
// int x, y;
// friend constexpr Point& operator++(Point&);
@@ -56,21 +66,21 @@ public class UnaryOperatorOverloadingTests extends TestBase {
// return y;
// }
// };
- //
+ //
// constexpr Point& operator++(Point& p) {
// ++p.x;
// ++p.y;
// return p;
// }
- //
+ //
// constexpr int f() {
// Point p{4,5};
// ++p;
// return p.getY();
// }
-
+
// constexpr int x = f();
public void testPrefixIncrementAsNonMemberFunction() throws Exception {
- assertEvaluationEquals(6);
+ assertEvaluationEquals(6);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UserDefinedLiteralTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UserDefinedLiteralTests.java
index febe4402ea7..cf32d1a7a2f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UserDefinedLiteralTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UserDefinedLiteralTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -17,24 +17,34 @@ import junit.framework.TestSuite;
public class UserDefinedLiteralTests extends TestBase {
public static class NonIndexing extends UserDefinedLiteralTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends UserDefinedLiteralTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr unsigned long long operator"" _min(unsigned long long minutes) {
// return minutes * 60;
// }
-
+
// constexpr auto x = 25_min;
public void testUserDefinedIntegerLiteral() throws Exception {
- assertEvaluationEquals(1500);
+ assertEvaluationEquals(1500);
}
-
+
// constexpr unsigned long long operator"" _capitals(const char* str, unsigned long size) {
// unsigned long long count = 0;
// for(int i = 0; i < size; ++i) {
@@ -44,12 +54,12 @@ public class UserDefinedLiteralTests extends TestBase {
// }
// return count;
// }
-
+
// constexpr auto x = "HAllO"_capitals;
public void testUserDefinedStringLiteral() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr bool operator "" _v(char c) {
// switch(c) {
// case 'a':
@@ -62,21 +72,21 @@ public class UserDefinedLiteralTests extends TestBase {
// return false;
// }
// }
-
+
// constexpr auto x = 'a'_v;
public void testUserDefinedCharacterLiteral() throws Exception {
assertEvaluationEquals(true);
}
-
+
// constexpr long double operator"" _deg(long double deg) {
// return deg * 3.141592 / 180;
// }
-
+
// constexpr auto x = 100.0_deg;
public void testUserDefinedFloatingPointLiteral() throws Exception {
assertEvaluationEquals(1.74533);
}
-
+
// constexpr unsigned long long operator "" _l(const char *str) {
// int l = 0;
// while(str[l] != '\0') {
@@ -84,13 +94,13 @@ public class UserDefinedLiteralTests extends TestBase {
// }
// return l;
// }
-
+
// constexpr auto x = 20000_l;
public void testFallbackToRawLiteralOperator() throws Exception {
assertEvaluationEquals(5);
}
-
- // template <char... STR>
+
+ // template <char... STR>
// constexpr unsigned operator"" _l() {
// return 5;
// }
@@ -99,96 +109,96 @@ public class UserDefinedLiteralTests extends TestBase {
public void testRawLiteralOperatorTemplate() throws Exception {
assertEvaluationEquals(5);
}
-
+
// constexpr unsigned operator "" _l(unsigned long long x) {
// return 10;
- // }
+ // }
// constexpr unsigned operator "" _l(const char *str) {
// return 20;
// }
-
+
// constexpr int x = 120_l;
public void testChoosesCookedLiteralOverRawLiteralOperatorIfAvailable() throws Exception {
assertEvaluationEquals(10);
}
-
+
// constexpr unsigned operator "" _l(unsigned long long x) {
// return 10;
- // }
- // template <char... STR>
+ // }
+ // template <char... STR>
// constexpr unsigned operator"" _l() {
// return 20;
// }
-
+
// constexpr int x = 120_l;
public void testChoosesCookedLiteralOverRawLiteralTemplateIfAvailable() throws Exception {
assertEvaluationEquals(10);
}
-
+
// constexpr unsigned operator "" _l(long double x) {
// return 10;
- // }
+ // }
// constexpr unsigned operator "" _l(const char *str) {
// return 20;
// }
-
+
// constexpr int x = 120_l;
public void testFallsBackToRawLiteralOperatorIfParameterTypeDoesntMatchUnsignedLongLong() throws Exception {
assertEvaluationEquals(20);
}
-
+
// constexpr unsigned operator "" _l(long double x) {
// return 10;
- // }
- // template <char... STR>
+ // }
+ // template <char... STR>
// constexpr unsigned operator"" _l() {
// return 20;
// }
-
+
// constexpr int x = 120_l;
public void testFallsBackToRawLiteralOperatorTemplateIfParameterTypeDoesntMatchUnsignedLongLong() throws Exception {
assertEvaluationEquals(20);
}
-
+
// constexpr unsigned operator "" _l(unsigned long long x) {
// return 10;
- // }
+ // }
// constexpr unsigned operator "" _l(const char *str) {
// return 20;
// }
-
+
// constexpr int x = 120.0_l;
public void testFallsBackToRawLiteralOperatorIfParameterTypeDoesntMatchLongDouble() throws Exception {
assertEvaluationEquals(20);
}
-
+
// constexpr unsigned operator "" _l(unsigned long long x) {
// return 10;
- // }
- // template <char... STR>
+ // }
+ // template <char... STR>
// constexpr unsigned operator"" _l() {
// return 20;
// }
-
+
// constexpr int x = 120.0_l;
public void testFallsBackToRawLiteralOperatorTemplateIfParameterTypeDoesntMatchLongDouble() throws Exception {
assertEvaluationEquals(20);
}
-
+
// constexpr unsigned operator "" _l(const char *str) {
// return 20;
// }
-
+
// constexpr int x = "hello"_l;
public void testIgnoresRawLiteralOperatorForUserDefinedStringLiterals() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
- // template <char... STR>
+
+ // template <char... STR>
// constexpr unsigned operator"" _l() {
// return 20;
// }
-
+
// constexpr int x = "hello"_l;
public void testIgnoresRawLiteralOperatorTemplateForUserDefinedStringLiterals() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/WhileStatementTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/WhileStatementTests.java
index 223baf61f5f..ba5c5fe33e8 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/WhileStatementTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/WhileStatementTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -17,15 +17,25 @@ import junit.framework.TestSuite;
public class WhileStatementTests extends TestBase {
public static class NonIndexing extends WhileStatementTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends WhileStatementTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// while (n > 0) {
@@ -34,12 +44,12 @@ public class WhileStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testWhileLoopWithConditionalExpression() throws Exception {
assertEvaluationEquals(55);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// while (true) {
@@ -48,12 +58,12 @@ public class WhileStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testEvalShouldAbortOnWhileWitInfiniteLoop() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// while (true) {
@@ -62,36 +72,36 @@ public class WhileStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testReturnInWhileStatement() throws Exception {
assertEvaluationEquals(42);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// while (n > 0)
// sum += n--;
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testWhileLoopWithNonCompoundBodyStatement() throws Exception {
assertEvaluationEquals(55);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// while (n > 0)
// return 42;
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testWhileLoopWithReturnInNonCompoundBodyStatement() throws Exception {
assertEvaluationEquals(42);
}
-
+
// constexpr int triple(int x) {
// return x * 3;
// }
@@ -102,7 +112,7 @@ public class WhileStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f(4);
public void testDeclarationInWhileStatementCondition1() throws Exception {
assertEvaluationEquals(30);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx17/LambdaExpressionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx17/LambdaExpressionTests.java
index dcc80902367..398a6ef19c9 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx17/LambdaExpressionTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx17/LambdaExpressionTests.java
@@ -25,7 +25,7 @@ public class LambdaExpressionTests extends AST2CPPTestBase {
// [*this] { }();
// }
// };
- public void testLambdaCaptures_535196_1() throws Exception {
+ public void testLambdaCaptures_535196_1() throws Exception {
parseAndCheckBindings();
}
@@ -36,7 +36,7 @@ public class LambdaExpressionTests extends AST2CPPTestBase {
// [*this] { bar(); }();
// }
// };
- public void testLambdaCaptures_535196_2() throws Exception {
+ public void testLambdaCaptures_535196_2() throws Exception {
parseAndCheckBindings();
}
@@ -47,7 +47,7 @@ public class LambdaExpressionTests extends AST2CPPTestBase {
// [m = 3, *this] { bar(m); }();
// }
// };
- public void testLambdaCaptures_535196_3() throws Exception {
+ public void testLambdaCaptures_535196_3() throws Exception {
parseAndCheckBindings();
}
}

Back to the top