From b41dac654cf3f52a146e33337665f3bd0cf36399 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sun, 18 Jan 2009 04:19:26 +0000 Subject: [PATCH] Test case for bug 261417. --- .../cdt/core/parser/tests/ast2/AST2Tests.java | 462 +++++++++--------- 1 file changed, 235 insertions(+), 227 deletions(-) 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 cbcd3b12ba7..6e658c1366b 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 @@ -127,21 +127,19 @@ public class AST2Tests extends AST2BaseTest { super(name); } - - - protected IASTTranslationUnit parseAndCheckBindings( String code ) throws Exception { + protected IASTTranslationUnit parseAndCheckBindings(String code) throws Exception { return parseAndCheckBindings(code, ParserLanguage.C); } public void testBug75189() throws Exception { - parseAndCheckBindings( "struct A{};\n typedef int (*F) (struct A*);" ); //$NON-NLS-1$ - parseAndCheckBindings( "struct A{};\n typedef int (*F) (A*);", ParserLanguage.CPP ); //$NON-NLS-1$ + parseAndCheckBindings("struct A{};\n typedef int (*F) (struct A*);"); //$NON-NLS-1$ + parseAndCheckBindings("struct A{};\n typedef int (*F) (A*);", ParserLanguage.CPP); //$NON-NLS-1$ } public void testBug75340() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings( "void f(int i = 0, int * p = 0);"); //$NON-NLS-1$ + IASTTranslationUnit tu = parseAndCheckBindings("void f(int i = 0, int * p = 0);"); //$NON-NLS-1$ IASTSimpleDeclaration sd = (IASTSimpleDeclaration) tu.getDeclarations()[0]; - assertEquals( ASTSignatureUtil.getParameterSignature( sd.getDeclarators()[0] ), "(int, int *)" ); //$NON-NLS-1$ + assertEquals(ASTSignatureUtil.getParameterSignature(sd.getDeclarators()[0]), "(int, int *)"); //$NON-NLS-1$ } // int *p1; int *p2; @@ -155,7 +153,7 @@ public class AST2Tests extends AST2BaseTest { // MyStruct.b = 1; // } public void testBug78103() throws Exception { - parseAndCheckBindings( getAboveComment() ); + parseAndCheckBindings(getAboveComment()); } // int m(int); @@ -171,10 +169,10 @@ public class AST2Tests extends AST2BaseTest { // int ((*zzz3)) (char); // int (*(zzz4)) (char); public void testBug40768() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.C ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); CNameCollector col = new CNameCollector(); tu.accept(col); - assertNoProblemBindings( col ); + assertNoProblemBindings(col); } // int x; @@ -184,7 +182,7 @@ public class AST2Tests extends AST2BaseTest { public void testBasicFunction() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IScope globalScope = tu.getScope(); IASTDeclaration[] declarations = tu.getDeclarations(); @@ -331,7 +329,7 @@ public class AST2Tests extends AST2BaseTest { public void testSimpleStruct() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu .getDeclarations()[0]; IASTCompositeTypeSpecifier type = (IASTCompositeTypeSpecifier) decl @@ -460,7 +458,7 @@ public class AST2Tests extends AST2BaseTest { validateSimpleUnaryExpressionC( "sizeof x", IASTUnaryExpression.op_sizeof); //$NON-NLS-1$ validateSimpleTypeIdExpressionC( - "sizeof( int )", IASTTypeIdExpression.op_sizeof); //$NON-NLS-1$ + "sizeof(int)", IASTTypeIdExpression.op_sizeof); //$NON-NLS-1$ validateSimpleUnaryTypeIdExpression( "(int)x", IASTCastExpression.op_cast); //$NON-NLS-1$ validateSimplePostfixInitializerExpressionC("(int) { 5 }"); //$NON-NLS-1$ @@ -520,7 +518,7 @@ public class AST2Tests extends AST2BaseTest { public void testMultipleDeclarators() throws Exception { IASTTranslationUnit tu = parse("int r, s;", ParserLanguage.C); //$NON-NLS-1$ assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu .getDeclarations()[0]; IASTDeclarator[] declarators = decl.getDeclarators(); @@ -552,7 +550,7 @@ public class AST2Tests extends AST2BaseTest { public void testStructureTagScoping_1() throws Exception { StringBuffer buffer = new StringBuffer(); buffer.append("struct A; \n"); //$NON-NLS-1$ - buffer.append("void f(){ \n"); //$NON-NLS-1$ + buffer.append("void f() { \n"); //$NON-NLS-1$ buffer.append(" struct A; \n"); //$NON-NLS-1$ buffer.append(" struct A * a; \n"); //$NON-NLS-1$ buffer.append("} \n"); //$NON-NLS-1$ @@ -560,7 +558,7 @@ public class AST2Tests extends AST2BaseTest { IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { // struct A; IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu .getDeclarations()[0]; @@ -641,14 +639,14 @@ public class AST2Tests extends AST2BaseTest { public void testStructureTagScoping_2() throws Exception { StringBuffer buffer = new StringBuffer(); buffer.append("struct A; \n"); //$NON-NLS-1$ - buffer.append("void f(){ \n"); //$NON-NLS-1$ + buffer.append("void f() { \n"); //$NON-NLS-1$ buffer.append(" struct A * a; \n"); //$NON-NLS-1$ buffer.append("} \r\n"); //$NON-NLS-1$ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { // struct A; IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu .getDeclarations()[0]; @@ -720,7 +718,7 @@ public class AST2Tests extends AST2BaseTest { IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { // struct A; IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu .getDeclarations()[0]; @@ -828,14 +826,14 @@ public class AST2Tests extends AST2BaseTest { } // struct x {}; - // void f( int x ) { + // void f(int x) { // struct x i; // } public void testStructureNamespace() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration declaration1 = (IASTSimpleDeclaration) tu .getDeclarations()[0]; IASTCompositeTypeSpecifier typeSpec = (IASTCompositeTypeSpecifier) declaration1 @@ -923,22 +921,22 @@ public class AST2Tests extends AST2BaseTest { } } - // void f( int a ); - // void f( int b ){ + // void f(int a); + // void f(int b) { // b; // } public void testFunctionParameters() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { // void f( IASTSimpleDeclaration f_decl = (IASTSimpleDeclaration) tu .getDeclarations()[0]; IASTStandardFunctionDeclarator dtor = (IASTStandardFunctionDeclarator) f_decl .getDeclarators()[0]; IASTName f_name1 = dtor.getName(); - // int a ); + // int a); IASTParameterDeclaration param1 = dtor.getParameters()[0]; IASTDeclarator paramDtor = param1.getDeclarator(); IASTName name_param1 = paramDtor.getName(); @@ -949,7 +947,7 @@ public class AST2Tests extends AST2BaseTest { assertTrue(f_defn.getDeclarator() instanceof IASTStandardFunctionDeclarator); dtor = (IASTStandardFunctionDeclarator) f_defn.getDeclarator(); IASTName f_name2 = dtor.getName(); - // int b ); + // int b); IASTParameterDeclaration param2 = dtor.getParameters()[0]; paramDtor = param2.getDeclarator(); IASTName name_param2 = paramDtor.getName(); @@ -1013,11 +1011,11 @@ public class AST2Tests extends AST2BaseTest { } } - // void f( int a, int b ) { } + // void f(int a, int b) { } public void testSimpleFunction() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTFunctionDefinition fDef = (IASTFunctionDefinition) tu .getDeclarations()[0]; assertTrue(fDef.getDeclarator() instanceof IASTStandardFunctionDeclarator); @@ -1065,12 +1063,12 @@ public class AST2Tests extends AST2BaseTest { // void g() { // f(); // } - // void f(){ } + // void f() { } public void testSimpleFunctionCall() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { // void f(); IASTSimpleDeclaration fdecl = (IASTSimpleDeclaration) tu .getDeclarations()[0]; @@ -1135,14 +1133,14 @@ public class AST2Tests extends AST2BaseTest { } // void f() { - // for( int i = 0; i < 5; i++ ) { + // for (int i = 0; i < 5; i++) { // i; // } // } public void testForLoop() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { // void f() { IASTFunctionDefinition fdef = (IASTFunctionDefinition) tu .getDeclarations()[0]; @@ -1163,7 +1161,7 @@ public class AST2Tests extends AST2BaseTest { IASTName name_i2 = id_i.getName(); IASTLiteralExpression lit_5 = (IASTLiteralExpression) exp.getOperand2(); assertEquals(IASTLiteralExpression.lk_integer_constant, lit_5.getKind()); - // i++ ) { + // i++) { IASTUnaryExpression un = (IASTUnaryExpression) for_stmt .getIterationExpression(); IASTIdExpression id_i2 = (IASTIdExpression) un.getOperand(); @@ -1214,13 +1212,13 @@ public class AST2Tests extends AST2BaseTest { } // struct A { int x; }; - // void f(){ + // void f() { // ((struct A *) 1)->x; // } public void testExpressionFieldReference() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) tu .getDeclarations()[0]; IASTCompositeTypeSpecifier compType = (IASTCompositeTypeSpecifier) simpleDecl @@ -1276,8 +1274,8 @@ public class AST2Tests extends AST2BaseTest { } // void f() { - // while( 1 ) { - // if( 1 ) + // while (1) { + // if (1) // goto end; // } // end: ; @@ -1285,7 +1283,7 @@ public class AST2Tests extends AST2BaseTest { public void testLabels() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { CNameCollector collector = new CNameCollector(); tu.accept(collector); @@ -1316,11 +1314,11 @@ public class AST2Tests extends AST2BaseTest { } // typedef struct { } X; - // int f( X x ); + // int f(X x); public void testAnonStruct() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { // test tu.getDeclarationsInAST(IBinding) IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu .getDeclarations()[0]; @@ -1374,13 +1372,13 @@ public class AST2Tests extends AST2BaseTest { // void f() { // col = blue; // cp = &col; - // if( *cp != red ) + // if (*cp != red) // return; // } public void testEnumerations() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu .getDeclarations()[0]; assertEquals(decl1.getDeclarators().length, 0); @@ -1528,7 +1526,7 @@ public class AST2Tests extends AST2BaseTest { public void testPointerToFunction() throws Exception { IASTTranslationUnit tu = parse("int (*pfi)();", ParserLanguage.C); //$NON-NLS-1$ assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { assertEquals(tu.getDeclarations().length, 1); IASTSimpleDeclaration d = (IASTSimpleDeclaration) tu.getDeclarations()[0]; assertEquals(d.getDeclarators().length, 1); @@ -1559,7 +1557,7 @@ public class AST2Tests extends AST2BaseTest { public void testBasicTypes() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu .getDeclarations()[0]; IVariable a = (IVariable) decl.getDeclarators()[0].getName() @@ -1662,7 +1660,7 @@ public class AST2Tests extends AST2BaseTest { public void testCompositeTypes() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu .getDeclarations()[0]; IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl @@ -1749,7 +1747,7 @@ public class AST2Tests extends AST2BaseTest { public void testArrayTypes() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0]; IASTName name_a = decl.getDeclarators()[0].getName(); IVariable a = (IVariable) decl.getDeclarators()[0].getName().resolveBinding(); @@ -1824,13 +1822,13 @@ public class AST2Tests extends AST2BaseTest { } // struct A; - // int * f( int i, char c ); - // void ( *g ) ( struct A * ); - // void (* (*h)(struct A**) ) ( int d ); + // int * f(int i, char c); + // void (*g) (struct A *); + // void (* (*h)(struct A**)) (int d); public void testFunctionTypes() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu .getDeclarations()[0]; IASTElaboratedTypeSpecifier elabSpec = (IASTElaboratedTypeSpecifier) decl @@ -1976,7 +1974,7 @@ public class AST2Tests extends AST2BaseTest { public void testDesignatedInitializers() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { assertNotNull(tu); IASTDeclaration[] declarations = tu.getDeclarations(); IASTName name_Coord = ((IASTSimpleDeclaration) declarations[0]) @@ -2036,8 +2034,7 @@ public class AST2Tests extends AST2BaseTest { for (int j = 0; j < 2; ++j) { ICASTDesignatedInitializer designatedInitializer = (ICASTDesignatedInitializer) initializers1[j]; assertEquals(designatedInitializer.getDesignators().length, 1); - ICASTFieldDesignator fieldDesignator = (ICASTFieldDesignator) designatedInitializer - .getDesignators()[0]; + ICASTFieldDesignator fieldDesignator = (ICASTFieldDesignator) designatedInitializer.getDesignators()[0]; assertNotNull(fieldDesignator.getName().toString()); } @@ -2092,7 +2089,7 @@ public class AST2Tests extends AST2BaseTest { public void testMoregetDeclarationsInAST1() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu .getDeclarations()[0]; IASTFunctionDefinition f_def = (IASTFunctionDefinition) tu @@ -2135,7 +2132,7 @@ public class AST2Tests extends AST2BaseTest { public void testMoregetDeclarationsInAST2() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu .getDeclarations()[0]; @@ -2177,11 +2174,9 @@ public class AST2Tests extends AST2BaseTest { public void testMoregetDeclarationsInAST3() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { - IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - IASTSimpleDeclaration x_decl = (IASTSimpleDeclaration) tu - .getDeclarations()[3]; + for (int i = 0; i < NUM_TESTS; i++) { + 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] @@ -2213,9 +2208,9 @@ public class AST2Tests extends AST2BaseTest { public void testFnReturningPtrToFn() throws Exception { IASTTranslationUnit tu = parse( - "void ( * f( int ) )(){}", ParserLanguage.C); //$NON-NLS-1$ + "void (* f(int))() {}", ParserLanguage.C); //$NON-NLS-1$ assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[0]; final IASTName fname = def.getDeclarator().getName(); IFunction f = (IFunction) fname.resolveBinding(); @@ -2243,11 +2238,9 @@ public class AST2Tests extends AST2BaseTest { IASTTranslationUnit tu = parse( "void f(int parm[const 3]);", ParserLanguage.C); //$NON-NLS-1$ assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { - IASTSimpleDeclaration def = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - IFunction f = (IFunction) def.getDeclarators()[0].getName() - .resolveBinding(); + for (int i = 0; i < NUM_TESTS; i++) { + IASTSimpleDeclaration def = (IASTSimpleDeclaration) tu.getDeclarations()[0]; + IFunction f = (IFunction) def.getDeclarators()[0].getName().resolveBinding(); IFunctionType ft = f.getType(); assertTrue(ft.getParameterTypes()[0] instanceof IPointerType); @@ -2264,7 +2257,21 @@ public class AST2Tests extends AST2BaseTest { tu = validateCopy(tu); } } - + + // void func(int** p); + // + // void test(int a[]) { + // func(&a); + // } + public void _testArrayPointer_261417() throws Exception { + final boolean[] isCpps= {false, true}; + String code= getAboveComment(); + for (boolean isCpp : isCpps) { + BindingAssertionHelper ba= new BindingAssertionHelper(code, isCpp); + ba.assertNonProblem("func(&a)", 4, ICPPFunction.class); + } + } + // int f() {} // int *f2() {} // int (* f3())() {} @@ -2272,7 +2279,7 @@ public class AST2Tests extends AST2BaseTest { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTFunctionDefinition def1 = (IASTFunctionDefinition) tu .getDeclarations()[0]; IFunction f = (IFunction) def1.getDeclarator().getName() @@ -2323,7 +2330,7 @@ public class AST2Tests extends AST2BaseTest { IASTTranslationUnit tu = parse( "int f(int g(void)) { return g();}", ParserLanguage.C); //$NON-NLS-1$ assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTFunctionDefinition def = (IASTFunctionDefinition) tu .getDeclarations()[0]; IFunction f = (IFunction) def.getDeclarator().getName() @@ -2362,7 +2369,7 @@ public class AST2Tests extends AST2BaseTest { "int (*v[])(int *x, int *y);", ParserLanguage.C); //$NON-NLS-1$ assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu .getDeclarations()[0]; IVariable v = (IVariable) ((IASTStandardFunctionDeclarator) decl @@ -2410,7 +2417,7 @@ public class AST2Tests extends AST2BaseTest { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu .getDeclarations()[0]; ITypedef dword = (ITypedef) decl1.getDeclarators()[0].getName() @@ -2470,7 +2477,7 @@ public class AST2Tests extends AST2BaseTest { public void testTypedefExample4b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu .getDeclarations()[0]; ITypedef dword = (ITypedef) decl1.getDeclarators()[0].getName() @@ -2564,7 +2571,7 @@ public class AST2Tests extends AST2BaseTest { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu .getDeclarations()[0]; ITypedef fv = (ITypedef) decl.getDeclarators()[0].getName() @@ -2665,7 +2672,7 @@ public class AST2Tests extends AST2BaseTest { } - // int y ( int [ const *] ); + // int y (int [ const *]); public void testBug80978() throws Exception { ICASTArrayModifier mod = (ICASTArrayModifier) ((IASTArrayDeclarator) ((IASTStandardFunctionDeclarator) ((IASTSimpleDeclaration) parse( getAboveComment(), ParserLanguage.C).getDeclarations()[0]) @@ -2680,7 +2687,7 @@ public class AST2Tests extends AST2BaseTest { //AJN: bug 77383 don't do external variables // // void f() { - // // if( a == 0 ) + // // if (a == 0) // // a = a + 3; // // } // public void testExternalVariable() throws Exception { @@ -2696,17 +2703,17 @@ public class AST2Tests extends AST2BaseTest { // void f() { // int a = 1; - // if( a == 0 ) - // g( a ); - // if( a < 0 ) - // g( a >> 1 ); - // if( a > 0 ) - // g( *(&a + 2) ); + // if (a == 0) + // g(a); + // if (a < 0) + // g(a >> 1); + // if (a > 0) + // g(*(&a + 2)); // } public void testExternalDefs() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { CNameCollector col = new CNameCollector(); tu.accept(col); @@ -2731,7 +2738,7 @@ public class AST2Tests extends AST2BaseTest { public void testFieldDesignators() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { CNameCollector col = new CNameCollector(); tu.accept(col); @@ -2756,7 +2763,7 @@ public class AST2Tests extends AST2BaseTest { public void testArrayDesignator() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { CNameCollector col = new CNameCollector(); tu.accept(col); @@ -2772,17 +2779,17 @@ public class AST2Tests extends AST2BaseTest { } // void f() { - // if( a == 0 ) - // g( a ); - // else if( a < 0 ) - // g( a >> 1 ); - // else if( a > 0 ) - // g( *(&a + 2) ); + // if (a == 0) + // g(a); + // else if (a < 0) + // g(a >> 1); + // else if (a > 0) + // g(*(&a + 2)); // } public void testBug83737() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { IASTIfStatement if_statement = (IASTIfStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu .getDeclarations()[0]).getBody()).getStatements()[0]; assertEquals(((IASTBinaryExpression) if_statement @@ -2804,15 +2811,15 @@ public class AST2Tests extends AST2BaseTest { } // void f() { - // while(1){ - // if( 1 ) goto end; + // while (1) { + // if (1) goto end; // } // end: ; // } public void testBug84090_LabelReferences() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { CNameCollector col = new CNameCollector(); tu.accept(col); @@ -2832,7 +2839,7 @@ public class AST2Tests extends AST2BaseTest { public void testBug84092_EnumReferences() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { CNameCollector collector = new CNameCollector(); tu.accept(collector); @@ -2851,7 +2858,7 @@ public class AST2Tests extends AST2BaseTest { IASTTranslationUnit tu = parse( "struct s { int a; } ss = { .a = 1 }; \n", ParserLanguage.C); //$NON-NLS-1$ assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { CNameCollector collector = new CNameCollector(); tu.accept(collector); @@ -2880,7 +2887,7 @@ public class AST2Tests extends AST2BaseTest { public void testEnumerationForwards() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { CNameCollector col = new CNameCollector(); tu.accept(col); @@ -2897,7 +2904,7 @@ public class AST2Tests extends AST2BaseTest { } // void f() { - // int ( *p ) [2]; + // int (*p) [2]; // (&p)[0] = 1; // } public void testBug84185() throws Exception { @@ -2916,7 +2923,7 @@ public class AST2Tests extends AST2BaseTest { } // void f() { - // int ( *p ) [2]; + // int (*p) [2]; // (&p)[0] = 1; // } public void testBug84185_2() throws Exception { @@ -2939,14 +2946,14 @@ public class AST2Tests extends AST2BaseTest { // struct s *p = 0, *q; // int j = 0; // q = p; - // p = &((struct s){ j++ }); + // p = &((struct s) { j++ }); // } public void testBug84176() throws Exception { parse(getAboveComment(), ParserLanguage.C, false, true); } // struct s { double i; } f(void); - // struct s f(void){} + // struct s f(void) {} public void testBug84266() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); CNameCollector col = new CNameCollector(); @@ -2977,7 +2984,7 @@ public class AST2Tests extends AST2BaseTest { ICompositeType s = (ICompositeType) col.getName(0).resolveBinding(); assertNotNull(s); - tu = parse("struct s f(void){}", ParserLanguage.C); //$NON-NLS-1$ + tu = parse("struct s f(void) {}", ParserLanguage.C); //$NON-NLS-1$ col = new CNameCollector(); tu.accept(col); @@ -3015,7 +3022,7 @@ public class AST2Tests extends AST2BaseTest { } // typedef struct { int a; } S; - // void g( S* (*funcp) (void) ) { + // void g(S* (*funcp) (void)) { // (*funcp)()->a; // funcp()->a; // } @@ -3041,8 +3048,8 @@ public class AST2Tests extends AST2BaseTest { assertSame(((IPointerType) ft.getReturnType()).getType(), S); } - // void f( int m, int c[m][m] ); - // void f( int m, int c[m][m] ){ + // void f(int m, int c[m][m]); + // void f(int m, int c[m][m]) { // int x; // { int x = x; } // } @@ -3101,7 +3108,7 @@ public class AST2Tests extends AST2BaseTest { public void testBug86766() throws Exception { IASTTranslationUnit tu = parse( - "char foo; void foo(){}", ParserLanguage.C); //$NON-NLS-1$ + "char foo; void foo() {}", ParserLanguage.C); //$NON-NLS-1$ CNameCollector col = new CNameCollector(); tu.accept(col); @@ -3168,7 +3175,7 @@ public class AST2Tests extends AST2BaseTest { // struct S {}; // int S; - // void f( ) { + // void f() { // int S; // { // S : ; @@ -3210,12 +3217,11 @@ public class AST2Tests extends AST2BaseTest { tu.accept(col); for (int i = 0; i < col.size(); ++i) assertFalse(col.getName(i).resolveBinding() instanceof IProblemBinding); - } public void testBug85786() throws Exception { IASTTranslationUnit tu = parse( - "void f( int ); void foo () { void * p = &f; ( (void (*) (int)) p ) ( 1 ); }", ParserLanguage.C); //$NON-NLS-1$ + "void f(int); void foo () { void * p = &f; ((void (*) (int)) p) (1); }", ParserLanguage.C); //$NON-NLS-1$ CNameCollector nameResolver = new CNameCollector(); tu.accept(nameResolver); assertNoProblemBindings(nameResolver); @@ -3227,7 +3233,7 @@ public class AST2Tests extends AST2BaseTest { // i= (i)&0x00ff; // } public void testBug95720() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.C ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); CNameCollector nameResolver = new CNameCollector(); tu.accept(nameResolver); assertNoProblemBindings(nameResolver); @@ -3287,7 +3293,7 @@ public class AST2Tests extends AST2BaseTest { // float _Complex x; // double _Complex y; public void testBug95757() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.C, true, true ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true, true); IASTDeclaration[] decls = tu.getDeclarations(); assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).isComplex()); @@ -3305,35 +3311,35 @@ public class AST2Tests extends AST2BaseTest { tu.accept(col); IFunction foo = (IFunction) col.getName(0).resolveBinding(); - assertSame( foo, col.getName(2).resolveBinding() ); + assertSame(foo, col.getName(2).resolveBinding()); IVariable zoot = (IVariable) col.getName(4).resolveBinding(); IType t = zoot.getType(); - assertTrue( t instanceof IBasicType ); - assertEquals( ((IBasicType)t).getType(), IBasicType.t_int ); + assertTrue(t instanceof IBasicType); + assertEquals(((IBasicType)t).getType(), IBasicType.t_int); } public void testBug95866() throws Exception { - IASTTranslationUnit tu = parse( "int test[10] = { [0 ... 9] = 2 };", ParserLanguage.C, true, true ); //$NON-NLS-1$ + IASTTranslationUnit tu = parse("int test[10] = { [0 ... 9] = 2 };", ParserLanguage.C, true, true); //$NON-NLS-1$ CNameCollector col = new CNameCollector(); tu.accept(col); assertNoProblemBindings(col); } public void testBug98502() throws Exception { - IASTTranslationUnit tu = parse("typedef enum { ONE } e;", ParserLanguage.C, true, true ); //$NON-NLS-1$ + IASTTranslationUnit tu = parse("typedef enum { ONE } e;", ParserLanguage.C, true, true); //$NON-NLS-1$ CNameCollector col = new CNameCollector(); tu.accept(col); IEnumeration etion = (IEnumeration) col.getName(0).resolveBinding(); ITypedef e = (ITypedef) col.getName(2).resolveBinding(); - assertSame( e.getType(), etion ); + assertSame(e.getType(), etion); } // typedef struct _loop_data { // enum { PIPERR } pipe_err; // } loop_data; - // void f(){ + // void f() { // PIPERR; // } public void testBug98365() throws Exception { @@ -3342,7 +3348,7 @@ public class AST2Tests extends AST2BaseTest { tu.accept(col); IEnumerator etor = (IEnumerator) col.getName(2).resolveBinding(); - assertSame( etor, col.getName(6).resolveBinding() ); + assertSame(etor, col.getName(6).resolveBinding()); } public void testBug99262() throws Exception { @@ -3372,23 +3378,23 @@ public class AST2Tests extends AST2BaseTest { IVariable a2 = (IVariable) col.getName(2).resolveBinding(); IVariable a3 = (IVariable) col.getName(3).resolveBinding(); - assertSame( a1, a2 ); - assertNotSame( a2, a3 ); + assertSame(a1, a2); + assertNotSame(a2, a3); } public void testBug100408() throws Exception { - IASTTranslationUnit tu = parse( "int foo() { int x=1; (x)*3; }", ParserLanguage.C ); //$NON-NLS-1$ + IASTTranslationUnit tu = parse("int foo() { int x=1; (x)*3; }", ParserLanguage.C); //$NON-NLS-1$ CNameCollector col = new CNameCollector(); - tu.accept( col ); - assertNoProblemBindings( col ); + tu.accept(col); + assertNoProblemBindings(col); } // struct nfa; // void f() { // struct nfa * n; - // freenfa( n ); + // freenfa(n); // } - // static void freenfa( nfa ) + // static void freenfa(nfa) // struct nfa * nfa; // { // } @@ -3399,9 +3405,9 @@ public class AST2Tests extends AST2BaseTest { IFunction free = (IFunction) col.getName(4).resolveBinding(); IParameter [] ps = free.getParameters(); - assertEquals( ps.length, 1 ); + assertEquals(ps.length, 1); - assertSame( free, col.getName(6).resolveBinding() ); + assertSame(free, col.getName(6).resolveBinding()); } // void testCasting() { @@ -3413,11 +3419,11 @@ public class AST2Tests extends AST2BaseTest { // Employee e = (Employee)MY_DETAILS; // } public void testBug79650() throws Exception { - parseAndCheckBindings( getAboveComment() ); + parseAndCheckBindings(getAboveComment()); } public void testBug80171() throws Exception { - parseAndCheckBindings( "static var;"); //$NON-NLS-1$ + parseAndCheckBindings("static var;"); //$NON-NLS-1$ } // enum E_OPTIONCODE { @@ -3428,12 +3434,12 @@ public class AST2Tests extends AST2BaseTest { // { // int myColor = 5; // int temp = eOption - myColor; /* Syntax error */ - // if(eOption-myColor) /* Invalid arithmetic conversion */ + // if (eOption-myColor) /* Invalid arithmetic conversion */ // { // } // } public void testBug79067() throws Exception { - parseAndCheckBindings( getAboveComment() ); + parseAndCheckBindings(getAboveComment()); } // enum COLOR { @@ -3444,29 +3450,29 @@ public class AST2Tests extends AST2BaseTest { // return ret; // } public void testBug84759() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings( getAboveComment() ); + IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment()); IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[1]; - assertEquals( fd.getDeclSpecifier().getRawSignature(), "enum COLOR"); //$NON-NLS-1$ + assertEquals(fd.getDeclSpecifier().getRawSignature(), "enum COLOR"); //$NON-NLS-1$ } // int f() { - // int x = 4; while( x < 10 ) blah: ++x; + // int x = 4; while (x < 10) blah: ++x; // } public void test1043290() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment() ); + IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment()); IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[0]; IASTStatement [] statements = ((IASTCompoundStatement)fd.getBody()).getStatements(); IASTWhileStatement whileStmt = (IASTWhileStatement) statements[1]; IASTLabelStatement labelStmt = (IASTLabelStatement) whileStmt.getBody(); - assertTrue( labelStmt.getNestedStatement() instanceof IASTExpressionStatement ); + assertTrue(labelStmt.getNestedStatement() instanceof IASTExpressionStatement); IASTExpressionStatement es = (IASTExpressionStatement) labelStmt.getNestedStatement(); - assertTrue( es.getExpression() instanceof IASTUnaryExpression ); + assertTrue(es.getExpression() instanceof IASTUnaryExpression); } // void f() { // int x; - // for( int x; ; ) + // for (int x; ;) // blah: x; // } public void testBug104390_2() throws Exception { @@ -3476,82 +3482,82 @@ public class AST2Tests extends AST2BaseTest { IVariable x = (IVariable) col.getName(1).resolveBinding(); IVariable x2 = (IVariable) col.getName(2).resolveBinding(); - assertNotSame( x, x2 ); - assertSame( x2, col.getName(4).resolveBinding() ); - assertTrue( col.getName(3).resolveBinding() instanceof ILabel ); + assertNotSame(x, x2); + assertSame(x2, col.getName(4).resolveBinding()); + assertTrue(col.getName(3).resolveBinding() instanceof ILabel); } // int f() { // int i; - // do { ++i; } while( i < 10 ); + // do { ++i; } while (i < 10); // return 0; // } public void testBug104800() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings( getAboveComment() ); + IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment()); IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0]; IASTCompoundStatement body = (IASTCompoundStatement) f.getBody(); - assertEquals( body.getStatements().length, 3 ); + assertEquals(body.getStatements().length, 3); } public void testBug107150() throws Exception { StringBuffer buffer = new StringBuffer(); buffer.append("#define FUNC_PROTOTYPE_PARAMS(list) list\r\n"); //$NON-NLS-1$ - buffer.append("int func1 FUNC_PROTOTYPE_PARAMS((int arg1)){\r\n"); //$NON-NLS-1$ + buffer.append("int func1 FUNC_PROTOTYPE_PARAMS((int arg1)) {\r\n"); //$NON-NLS-1$ buffer.append("return 0;\r\n"); //$NON-NLS-1$ buffer.append("}\r\n"); //$NON-NLS-1$ buffer.append("int func2 FUNC_PROTOTYPE_PARAMS\r\n"); //$NON-NLS-1$ - buffer.append("((int arg1)){\r\n"); //$NON-NLS-1$ + 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(), ParserLanguage.C); - assertFalse( tu.getDeclarations()[1] instanceof IASTProblemDeclaration ); + assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration); tu = parse(buffer.toString(), ParserLanguage.CPP); - assertFalse( tu.getDeclarations()[1] instanceof IASTProblemDeclaration ); + assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration); buffer = new StringBuffer(); buffer.append("#define FUNC_PROTOTYPE_PARAMS(list) list\n"); //$NON-NLS-1$ - buffer.append("int func1 FUNC_PROTOTYPE_PARAMS((int arg1)){\n"); //$NON-NLS-1$ + buffer.append("int func1 FUNC_PROTOTYPE_PARAMS((int arg1)) {\n"); //$NON-NLS-1$ buffer.append("return 0;\n"); //$NON-NLS-1$ buffer.append("}\n"); //$NON-NLS-1$ buffer.append("int func2 FUNC_PROTOTYPE_PARAMS\n"); //$NON-NLS-1$ - buffer.append("((int arg1)){\n"); //$NON-NLS-1$ + 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(), ParserLanguage.C); - assertFalse( tu.getDeclarations()[1] instanceof IASTProblemDeclaration ); + assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration); tu= parse(buffer.toString(), ParserLanguage.CPP); - assertFalse( tu.getDeclarations()[1] instanceof IASTProblemDeclaration ); + assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration); } public void testBug107150b() throws Exception { StringBuffer buffer = new StringBuffer(); buffer.append("#define FUNC_PROTOTYPE_PARAMS(list) list\r\n"); //$NON-NLS-1$ - buffer.append("int func1 FUNC_PROTOTYPE_PARAMS((int arg1)){\r\n"); //$NON-NLS-1$ + buffer.append("int func1 FUNC_PROTOTYPE_PARAMS((int arg1)) {\r\n"); //$NON-NLS-1$ buffer.append("return 0;\r\n"); //$NON-NLS-1$ buffer.append("}\r\n"); //$NON-NLS-1$ buffer.append("int func2 FUNC_PROTOTYPE_PARAMS\r\n \r\n \t \r\n \r\n "); //$NON-NLS-1$ - buffer.append("((int arg1)){\r\n"); //$NON-NLS-1$ + 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(), ParserLanguage.C); - assertFalse( tu.getDeclarations()[1] instanceof IASTProblemDeclaration ); + assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration); tu = parse(buffer.toString(), ParserLanguage.CPP); - assertFalse( tu.getDeclarations()[1] instanceof IASTProblemDeclaration ); + assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration); buffer = new StringBuffer(); buffer.append("#define FUNC_PROTOTYPE_PARAMS(list) list\n"); //$NON-NLS-1$ - buffer.append("int func1 FUNC_PROTOTYPE_PARAMS((int arg1)){\n"); //$NON-NLS-1$ + buffer.append("int func1 FUNC_PROTOTYPE_PARAMS((int arg1)) {\n"); //$NON-NLS-1$ buffer.append("return 0;\n"); //$NON-NLS-1$ buffer.append("}\n"); //$NON-NLS-1$ buffer.append("int func2 FUNC_PROTOTYPE_PARAMS\n"); //$NON-NLS-1$ - buffer.append("((int arg1)){\n"); //$NON-NLS-1$ + 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(), ParserLanguage.C); - assertFalse( tu.getDeclarations()[1] instanceof IASTProblemDeclaration ); + assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration); tu = parse(buffer.toString(), ParserLanguage.CPP); - assertFalse( tu.getDeclarations()[1] instanceof IASTProblemDeclaration ); + assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration); } // NWindow NewWindowDuplicate(NWindow theWindow, bool insert)\n"); @@ -3646,7 +3652,7 @@ public class AST2Tests extends AST2BaseTest { " return func(LIT); // fails to parse\r\n" + "}\r\n"; - IASTTranslationUnit tu = parse( simple, ParserLanguage.CPP, true, true ); + IASTTranslationUnit tu = parse(simple, ParserLanguage.CPP, true, true); // actual reduced test case, plus extra cases String text = @@ -3659,7 +3665,7 @@ public class AST2Tests extends AST2BaseTest { "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" + + "#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" + @@ -3668,7 +3674,7 @@ public class AST2Tests extends AST2BaseTest { ; // essential test: this code should be parseable - tu = parse( text, ParserLanguage.CPP, true, true ); + tu = parse(text, ParserLanguage.CPP, true, true); // verify macros IASTPreprocessorMacroDefinition[] macroDefinitions = tu.getMacroDefinitions(); @@ -3679,7 +3685,7 @@ public class AST2Tests extends AST2BaseTest { String expectExpansion= "1 + 2"; assertEquals(expectExpansion, macroDefinitions[2].getExpansion()); assertEquals("(KDebugNum(x))", macroDefinitions[3].getExpansion()); - assertEquals("{if((DEBUGNUM(a)))p;}", macroDefinitions[4].getExpansion()); + assertEquals("{if ((DEBUGNUM(a)))p;}", macroDefinitions[4].getExpansion()); // TODO: exhaustive macro testing } @@ -3689,8 +3695,8 @@ public class AST2Tests extends AST2BaseTest { // decl('a'); // } public void testBug181305_1() throws Exception { - for(ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse( getAboveComment(), lang, true, true ); + for (ParserLanguage lang : ParserLanguage.values()) { + IASTTranslationUnit tu = parse(getAboveComment(), lang, true, true); // check class IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[1]; @@ -3710,8 +3716,8 @@ public class AST2Tests extends AST2BaseTest { // decl('a'); // } public void testBug181305_2() throws Exception { - for(ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse( getAboveComment(), lang, true, true ); + for (ParserLanguage lang : ParserLanguage.values()) { + IASTTranslationUnit tu = parse(getAboveComment(), lang, true, true); // check class IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[1]; @@ -3732,7 +3738,7 @@ public class AST2Tests extends AST2BaseTest { + "int g(int n, int m) {return n;}\n" + "void foo() { f=g; }"; - for(ParserLanguage lang : ParserLanguage.values()) + for (ParserLanguage lang : ParserLanguage.values()) parseAndCheckBindings(code, lang); } @@ -3740,8 +3746,8 @@ public class AST2Tests extends AST2BaseTest { // char d= *"b"; // } public void testBug181942() throws Exception { - for(ParserLanguage lang : ParserLanguage.values()) - parse( getAboveComment(), lang, true, true ); + for (ParserLanguage lang : ParserLanguage.values()) + parse(getAboveComment(), lang, true, true); } public void testMacroCommentsBug_177154_2() throws Exception { @@ -3766,18 +3772,18 @@ public class AST2Tests extends AST2BaseTest { // this should work String textNoComment = noCommentMacro + textTail; - IASTTranslationUnit tu = parse( textNoComment, ParserLanguage.CPP, true, true ); + IASTTranslationUnit tu = parse(textNoComment, ParserLanguage.CPP, true, true); // this fails String textComment = commentMacro + textTail; - tu = parse( textComment, ParserLanguage.CPP, true, true ); + tu = parse(textComment, ParserLanguage.CPP, true, true); } // int __builtin_sin; public void testBug182464() throws Exception { - for(ParserLanguage lang : ParserLanguage.values()) - parseAndCheckBindings( getAboveComment(), lang, true); + for (ParserLanguage lang : ParserLanguage.values()) + parseAndCheckBindings(getAboveComment(), lang, true); } public void testBug186018() throws Exception { @@ -3820,7 +3826,7 @@ public class AST2Tests extends AST2BaseTest { public void test186736() throws Exception { IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { CNameCollector col = new CNameCollector(); tu.accept(col); IBinding methodb= col.getName(27).resolveBinding(); @@ -3872,7 +3878,7 @@ public class AST2Tests extends AST2BaseTest { public void test186736_variant1() throws Exception { IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { CNameCollector col = new CNameCollector(); tu.accept(col); IBinding methodA= col.getName(30).resolveBinding(); @@ -3927,7 +3933,7 @@ public class AST2Tests extends AST2BaseTest { // line \ // string"; public void testBug188707_backslashNewline() throws Exception { - parseAndCheckBindings( getAboveComment() ); + parseAndCheckBindings(getAboveComment()); } // typedef A B; @@ -3938,8 +3944,8 @@ public class AST2Tests extends AST2BaseTest { // typedef I *************I; // typedef int (*J)(J); public void testBug192165() throws Exception { - for(ParserLanguage lang : ParserLanguage.values()) { - IASTTranslationUnit tu = parse( getAboveComment(), lang, true, false ); + for (ParserLanguage lang : ParserLanguage.values()) { + IASTTranslationUnit tu = parse(getAboveComment(), lang, true, false); CNameCollector col = new CNameCollector(); tu.accept(col); assertInstance(col.getName(0).resolveBinding(), IProblemBinding.class); @@ -3975,8 +3981,8 @@ public class AST2Tests extends AST2BaseTest { // INVALID(1, 2) // public void test192639() throws Exception { - parse( getAboveComment(), ParserLanguage.CPP, false, false ); - parse( getAboveComment(), ParserLanguage.C, false, false ); + parse(getAboveComment(), ParserLanguage.CPP, false, false); + parse(getAboveComment(), ParserLanguage.C, false, false); } public void test195943() throws Exception { @@ -3989,18 +3995,18 @@ public class AST2Tests extends AST2BaseTest { buffer.append("int a= M" + (depth-1) + ";\n"); long time= System.currentTimeMillis(); parse(buffer.toString(), ParserLanguage.CPP); - parse( buffer.toString(), ParserLanguage.C); + parse(buffer.toString(), ParserLanguage.C); assertTrue(System.currentTimeMillis()-time < 2000); } // int array[12]= {}; public void testBug196468_emptyArrayInitializer() throws Exception { final String content = getAboveComment(); - parse( content, ParserLanguage.CPP, false); - parse( content, ParserLanguage.CPP, true); - parse( content, ParserLanguage.C, true); + parse(content, ParserLanguage.CPP, false); + parse(content, ParserLanguage.CPP, true); + parse(content, ParserLanguage.C, true); try { - parse( content, ParserLanguage.C, false); + parse(content, ParserLanguage.C, false); fail("C89 does not allow empty braces in array initializer"); } catch (ParserException e) { @@ -4008,7 +4014,7 @@ public class AST2Tests extends AST2BaseTest { } // #define foo(f,...) - // void bar(void){} + // void bar(void) {} // int main(int argc, char **argv) { // foo("a", bar); // ok // foo("a", bar, bar); // ok @@ -4019,16 +4025,16 @@ public class AST2Tests extends AST2BaseTest { // } public void testBug197633_parenthesisInVarargMacros() throws Exception { final String content = getAboveComment(); - parse( content, ParserLanguage.CPP); - parse( content, ParserLanguage.C); + parse(content, ParserLanguage.CPP); + parse(content, ParserLanguage.C); } - // void ( __attribute__((__stdcall__))* foo1) (int); - // void ( * __attribute__((__stdcall__)) foo2) (int); - // void ( * __attribute__((__stdcall__))* foo3) (int); + // void (__attribute__((__stdcall__))* foo1) (int); + // void (* __attribute__((__stdcall__)) foo2) (int); + // void (* __attribute__((__stdcall__))* foo3) (int); public void testBug191450_attributesInBetweenPointers() throws Exception { - parse( getAboveComment(), ParserLanguage.CPP, true, true ); - parse( getAboveComment(), ParserLanguage.C, true, true ); + parse(getAboveComment(), ParserLanguage.CPP, true, true); + parse(getAboveComment(), ParserLanguage.C, true, true); } // class NameClash {}; @@ -4036,9 +4042,9 @@ public class AST2Tests extends AST2BaseTest { // namespace NameClash2 {}; // class NameClash2 {}; public void testBug202271_nameClash() throws Exception { - IASTTranslationUnit tu= parseAndCheckBindings( getAboveComment(), ParserLanguage.CPP, true ); + IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { CNameCollector col = new CNameCollector(); tu.accept(col); assertInstance(col.getName(0).resolveBinding(), ICPPClassType.class); @@ -4056,7 +4062,7 @@ public class AST2Tests extends AST2BaseTest { // int b= WRAP(MACRO); public void testBug94673_refsForMacrosAsArguments() throws Exception { String content= getAboveComment(); - IASTTranslationUnit tu= parseAndCheckBindings( content, ParserLanguage.CPP, true ); + IASTTranslationUnit tu= parseAndCheckBindings(content, ParserLanguage.CPP, true); IASTPreprocessorMacroDefinition[] defs= tu.getMacroDefinitions(); assertEquals(2, defs.length); IASTPreprocessorMacroDefinition md= defs[1]; @@ -4115,10 +4121,10 @@ public class AST2Tests extends AST2BaseTest { StringBuffer[] buffer = getContents(2); final String content1 = buffer[0].toString(); final String content2 = buffer[1].toString(); - parse( content1, ParserLanguage.CPP); - parse( content1, ParserLanguage.C); - parse( content2, ParserLanguage.CPP); - parse( content2, ParserLanguage.C); + parse(content1, ParserLanguage.CPP); + parse(content1, ParserLanguage.C); + parse(content2, ParserLanguage.CPP); + parse(content2, ParserLanguage.C); } @@ -4226,7 +4232,7 @@ public class AST2Tests extends AST2BaseTest { public void testBug210019_designatedInitializers() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.C); assertTrue(tu.isFrozen()); - for(int i = 0; i < NUM_TESTS; i++) { + for (int i = 0; i < NUM_TESTS; i++) { CNameCollector col = new CNameCollector(); tu.accept(col); @@ -4277,10 +4283,10 @@ public class AST2Tests extends AST2BaseTest { // f3(&i); // ok // } public void testBug213029_cvConversion() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP, false ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, false); CNameCollector col = new CNameCollector(); tu.accept(col); - for(Object o : col.nameList) { + for (Object o : col.nameList) { IASTName n = (IASTName)o; if (n.isReference() && "f1".equals(n.toString())) assertTrue(n.resolveBinding() instanceof IProblemBinding); @@ -4289,7 +4295,7 @@ public class AST2Tests extends AST2BaseTest { } } - // void isTrue( int field, int bit ){ + // void isTrue(int field, int bit) { // return ((field) & (bit)); // } // void test() { @@ -4304,7 +4310,7 @@ public class AST2Tests extends AST2BaseTest { ba.assertNonProblem("bit))", 3); ba.assertNonProblem("foux)", 4); cpp= !cpp; - } while(cpp); + } while (cpp); } // void f1(int& r) {} @@ -4870,7 +4876,7 @@ public class AST2Tests extends AST2BaseTest { // } public void testBug228422_noKnrParam() throws Exception { StringBuffer buffer = getContents(1)[0]; - parse(buffer.toString(), ParserLanguage.C, false ); + parse(buffer.toString(), ParserLanguage.C, false); } // struct { @@ -4939,10 +4945,10 @@ public class AST2Tests extends AST2BaseTest { // function1(); // ref // } public void testOutOfOrderResolution_Bug232300() throws Exception { - final boolean[] isCpp= {false, true}; + final boolean[] isCpps= {false, true}; String code= getAboveComment(); - for (boolean element : isCpp) { - BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), element); + for (boolean isCpp : isCpps) { + BindingAssertionHelper ba= new BindingAssertionHelper(code, isCpp); IBinding b1= ba.assertNonProblem("function1(); // decl", 9); IBinding b2= ba.assertNonProblem("function1() {", 9); IBinding b3= ba.assertNonProblem("function1(); // ref", 9); @@ -4957,7 +4963,7 @@ public class AST2Tests extends AST2BaseTest { final boolean[] isCpps= {false, true}; String code= getAboveComment(); for (boolean isCpp : isCpps) { - BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), isCpp); + BindingAssertionHelper ba= new BindingAssertionHelper(code, isCpp); IBinding b1= ba.assertNonProblem("ptrdiff_t", 9); assertInstance(b1, ITypedef.class); ITypedef td= (ITypedef) b1; @@ -4974,7 +4980,7 @@ public class AST2Tests extends AST2BaseTest { final boolean[] isCpps= {false, true}; String code= getAboveComment(); for (boolean isCpp : isCpps) { - BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), isCpp); + BindingAssertionHelper ba= new BindingAssertionHelper(code, isCpp); ba.assertNonProblem("a; // ref", 1); // now scope is fully resolved ICompositeType ct= ba.assertNonProblem("S;", 1, ICompositeType.class); @@ -5002,7 +5008,7 @@ public class AST2Tests extends AST2BaseTest { final boolean[] isCpps= {false, true}; String code= getAboveComment(); for (boolean isCpp : isCpps) { - BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), isCpp); + BindingAssertionHelper ba= new BindingAssertionHelper(code, isCpp); ITypedef td= ba.assertNonProblem("VOID;", 4, ITypedef.class); IBinding ref= ba.assertNonProblem("VOID)", 4); assertSame(td, ref); @@ -5094,10 +5100,10 @@ public class AST2Tests extends AST2BaseTest { } } - // void f1(){} - // void (f2)(){} - // void (f3()){} - // void ((f4)()){} + // void f1() {} + // void (f2)() {} + // void (f3()) {} + // void ((f4)()) {} // void f1(); // void (f2)(); // void (f3()); @@ -5640,16 +5646,17 @@ public class AST2Tests extends AST2BaseTest { try { syntax= x.getTrailingSyntax(); fail(); - } catch (ExpansionOverlapsBoundaryException e) {} + } catch (ExpansionOverlapsBoundaryException e) { + } tu= parseAndCheckBindings(code + "IF_COND {}}"); f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression(); try { syntax= x.getTrailingSyntax(); fail(); - } catch (ExpansionOverlapsBoundaryException e) {} + } catch (ExpansionOverlapsBoundaryException e) { + } } - // #define IF if // #define IF_P if ( @@ -5699,7 +5706,8 @@ public class AST2Tests extends AST2BaseTest { try { syntax= x.getSyntax(); fail(); - } catch (ExpansionOverlapsBoundaryException e) {} + } catch (ExpansionOverlapsBoundaryException e) { + } } private void checkToken(IToken token, String image, int offset) { @@ -5745,7 +5753,7 @@ public class AST2Tests extends AST2BaseTest { assertEquals(i, numericalValue.intValue()); } - // void myfunc(char *arg){} + // void myfunc(char *arg) {} // void (*funcVar2)(char *) = myfunc; // void caller() { // myfunc(""); @@ -5861,9 +5869,9 @@ public class AST2Tests extends AST2BaseTest { // float a; // int b; // } cs; - // void x(void){ + // void x(void) { // cs foo; - // foo = ((cs){1.2,1}); + // foo = ((cs) {1.2,1}); // } public void testCompoundLiterals_Bug258496() throws Exception { final String code= getAboveComment();