1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-17 05:05:43 +02:00

Test case for bug 261417.

This commit is contained in:
Sergey Prigogin 2009-01-18 04:19:26 +00:00
parent 07fe9a9e75
commit b41dac654c

View file

@ -127,8 +127,6 @@ public class AST2Tests extends AST2BaseTest {
super(name); super(name);
} }
protected IASTTranslationUnit parseAndCheckBindings(String code) throws Exception { protected IASTTranslationUnit parseAndCheckBindings(String code) throws Exception {
return parseAndCheckBindings(code, ParserLanguage.C); return parseAndCheckBindings(code, ParserLanguage.C);
} }
@ -2036,8 +2034,7 @@ public class AST2Tests extends AST2BaseTest {
for (int j = 0; j < 2; ++j) { for (int j = 0; j < 2; ++j) {
ICASTDesignatedInitializer designatedInitializer = (ICASTDesignatedInitializer) initializers1[j]; ICASTDesignatedInitializer designatedInitializer = (ICASTDesignatedInitializer) initializers1[j];
assertEquals(designatedInitializer.getDesignators().length, 1); assertEquals(designatedInitializer.getDesignators().length, 1);
ICASTFieldDesignator fieldDesignator = (ICASTFieldDesignator) designatedInitializer ICASTFieldDesignator fieldDesignator = (ICASTFieldDesignator) designatedInitializer.getDesignators()[0];
.getDesignators()[0];
assertNotNull(fieldDesignator.getName().toString()); assertNotNull(fieldDesignator.getName().toString());
} }
@ -2178,10 +2175,8 @@ public class AST2Tests extends AST2BaseTest {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
assertTrue(tu.isFrozen()); assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) { for (int i = 0; i < NUM_TESTS; i++) {
IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
.getDeclarations()[0]; IASTSimpleDeclaration x_decl = (IASTSimpleDeclaration) tu.getDeclarations()[3];
IASTSimpleDeclaration x_decl = (IASTSimpleDeclaration) tu
.getDeclarations()[3];
IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl
.getDeclSpecifier()).getMembers()[0]).getDeclarators()[0] .getDeclSpecifier()).getMembers()[0]).getDeclarators()[0]
@ -2244,10 +2239,8 @@ public class AST2Tests extends AST2BaseTest {
"void f(int parm[const 3]);", ParserLanguage.C); //$NON-NLS-1$ "void f(int parm[const 3]);", ParserLanguage.C); //$NON-NLS-1$
assertTrue(tu.isFrozen()); assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) { for (int i = 0; i < NUM_TESTS; i++) {
IASTSimpleDeclaration def = (IASTSimpleDeclaration) tu IASTSimpleDeclaration def = (IASTSimpleDeclaration) tu.getDeclarations()[0];
.getDeclarations()[0]; IFunction f = (IFunction) def.getDeclarators()[0].getName().resolveBinding();
IFunction f = (IFunction) def.getDeclarators()[0].getName()
.resolveBinding();
IFunctionType ft = f.getType(); IFunctionType ft = f.getType();
assertTrue(ft.getParameterTypes()[0] instanceof IPointerType); assertTrue(ft.getParameterTypes()[0] instanceof IPointerType);
@ -2265,6 +2258,20 @@ public class AST2Tests extends AST2BaseTest {
} }
} }
// 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 f() {}
// int *f2() {} // int *f2() {}
// int (* f3())() {} // int (* f3())() {}
@ -3210,7 +3217,6 @@ public class AST2Tests extends AST2BaseTest {
tu.accept(col); tu.accept(col);
for (int i = 0; i < col.size(); ++i) for (int i = 0; i < col.size(); ++i)
assertFalse(col.getName(i).resolveBinding() instanceof IProblemBinding); assertFalse(col.getName(i).resolveBinding() instanceof IProblemBinding);
} }
public void testBug85786() throws Exception { public void testBug85786() throws Exception {
@ -4939,10 +4945,10 @@ public class AST2Tests extends AST2BaseTest {
// function1(); // ref // function1(); // ref
// } // }
public void testOutOfOrderResolution_Bug232300() throws Exception { public void testOutOfOrderResolution_Bug232300() throws Exception {
final boolean[] isCpp= {false, true}; final boolean[] isCpps= {false, true};
String code= getAboveComment(); String code= getAboveComment();
for (boolean element : isCpp) { for (boolean isCpp : isCpps) {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), element); BindingAssertionHelper ba= new BindingAssertionHelper(code, isCpp);
IBinding b1= ba.assertNonProblem("function1(); // decl", 9); IBinding b1= ba.assertNonProblem("function1(); // decl", 9);
IBinding b2= ba.assertNonProblem("function1() {", 9); IBinding b2= ba.assertNonProblem("function1() {", 9);
IBinding b3= ba.assertNonProblem("function1(); // ref", 9); IBinding b3= ba.assertNonProblem("function1(); // ref", 9);
@ -4957,7 +4963,7 @@ public class AST2Tests extends AST2BaseTest {
final boolean[] isCpps= {false, true}; final boolean[] isCpps= {false, true};
String code= getAboveComment(); String code= getAboveComment();
for (boolean isCpp : isCpps) { for (boolean isCpp : isCpps) {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), isCpp); BindingAssertionHelper ba= new BindingAssertionHelper(code, isCpp);
IBinding b1= ba.assertNonProblem("ptrdiff_t", 9); IBinding b1= ba.assertNonProblem("ptrdiff_t", 9);
assertInstance(b1, ITypedef.class); assertInstance(b1, ITypedef.class);
ITypedef td= (ITypedef) b1; ITypedef td= (ITypedef) b1;
@ -4974,7 +4980,7 @@ public class AST2Tests extends AST2BaseTest {
final boolean[] isCpps= {false, true}; final boolean[] isCpps= {false, true};
String code= getAboveComment(); String code= getAboveComment();
for (boolean isCpp : isCpps) { for (boolean isCpp : isCpps) {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), isCpp); BindingAssertionHelper ba= new BindingAssertionHelper(code, isCpp);
ba.assertNonProblem("a; // ref", 1); ba.assertNonProblem("a; // ref", 1);
// now scope is fully resolved // now scope is fully resolved
ICompositeType ct= ba.assertNonProblem("S;", 1, ICompositeType.class); ICompositeType ct= ba.assertNonProblem("S;", 1, ICompositeType.class);
@ -5002,7 +5008,7 @@ public class AST2Tests extends AST2BaseTest {
final boolean[] isCpps= {false, true}; final boolean[] isCpps= {false, true};
String code= getAboveComment(); String code= getAboveComment();
for (boolean isCpp : isCpps) { for (boolean isCpp : isCpps) {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), isCpp); BindingAssertionHelper ba= new BindingAssertionHelper(code, isCpp);
ITypedef td= ba.assertNonProblem("VOID;", 4, ITypedef.class); ITypedef td= ba.assertNonProblem("VOID;", 4, ITypedef.class);
IBinding ref= ba.assertNonProblem("VOID)", 4); IBinding ref= ba.assertNonProblem("VOID)", 4);
assertSame(td, ref); assertSame(td, ref);
@ -5640,16 +5646,17 @@ public class AST2Tests extends AST2BaseTest {
try { try {
syntax= x.getTrailingSyntax(); syntax= x.getTrailingSyntax();
fail(); fail();
} catch (ExpansionOverlapsBoundaryException e) {} } catch (ExpansionOverlapsBoundaryException e) {
}
tu= parseAndCheckBindings(code + "IF_COND {}}"); tu= parseAndCheckBindings(code + "IF_COND {}}");
f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression(); f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
try { try {
syntax= x.getTrailingSyntax(); syntax= x.getTrailingSyntax();
fail(); fail();
} catch (ExpansionOverlapsBoundaryException e) {} } catch (ExpansionOverlapsBoundaryException e) {
}
} }
// #define IF if // #define IF if
// #define IF_P if ( // #define IF_P if (
@ -5699,7 +5706,8 @@ public class AST2Tests extends AST2BaseTest {
try { try {
syntax= x.getSyntax(); syntax= x.getSyntax();
fail(); fail();
} catch (ExpansionOverlapsBoundaryException e) {} } catch (ExpansionOverlapsBoundaryException e) {
}
} }
private void checkToken(IToken token, String image, int offset) { private void checkToken(IToken token, String image, int offset) {