mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-16 20:55:44 +02:00
Test case for bug 261417.
This commit is contained in:
parent
07fe9a9e75
commit
b41dac654c
1 changed files with 235 additions and 227 deletions
|
@ -127,8 +127,6 @@ public class AST2Tests extends AST2BaseTest {
|
|||
super(name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected IASTTranslationUnit parseAndCheckBindings(String code) throws Exception {
|
||||
return parseAndCheckBindings(code, ParserLanguage.C);
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -2178,10 +2175,8 @@ public class AST2Tests extends AST2BaseTest {
|
|||
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];
|
||||
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]
|
||||
|
@ -2244,10 +2239,8 @@ public class AST2Tests extends AST2BaseTest {
|
|||
"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();
|
||||
IASTSimpleDeclaration def = (IASTSimpleDeclaration) tu.getDeclarations()[0];
|
||||
IFunction f = (IFunction) def.getDeclarators()[0].getName().resolveBinding();
|
||||
|
||||
IFunctionType ft = f.getType();
|
||||
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 *f2() {}
|
||||
// int (* f3())() {}
|
||||
|
@ -3210,7 +3217,6 @@ 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 {
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue