mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Bug 316931: IASTTranslationUnit.getDeclarations() for parameters.
This commit is contained in:
parent
4088b51a27
commit
6468bb856d
2 changed files with 25 additions and 3 deletions
|
@ -5871,8 +5871,8 @@ public class AST2Tests extends AST2BaseTest {
|
|||
long mem= memoryUsed();
|
||||
IASTTranslationUnit tu= parse(code, lang, false, true, true);
|
||||
long diff= memoryUsed()-mem;
|
||||
// allow a copy of the buffer + not even 1 byte per initializer
|
||||
final int expected = code.length()*2 + AMOUNT-1;
|
||||
// allow a copy of the buffer + less than 2 bytes per initializer
|
||||
final int expected = code.length()*2 + AMOUNT + AMOUNT/2;
|
||||
assertTrue(String.valueOf(diff) + " expected < " + expected, diff < expected);
|
||||
assertTrue(tu.isFrozen());
|
||||
}
|
||||
|
@ -7252,4 +7252,23 @@ public class AST2Tests extends AST2BaseTest {
|
|||
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();
|
||||
parseAndCheckBindings(code);
|
||||
for (int k=0; k<2; k++) {
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(code, k>0);
|
||||
IParameter i= bh.assertNonProblem("i)", 1);
|
||||
IParameter j= bh.assertNonProblem("j)", 1);
|
||||
assertSame(i, j);
|
||||
|
||||
IASTTranslationUnit tu= bh.getTranslationUnit();
|
||||
IASTName[] decls = tu.getDeclarationsInAST(i);
|
||||
assertEquals(2, decls.length);
|
||||
decls = tu.getDeclarationsInAST(j);
|
||||
assertEquals(2, decls.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1342,7 +1342,10 @@ public class CPPVisitor extends ASTQueries {
|
|||
kind = KIND_TYPE;
|
||||
} else if (binding instanceof ICPPNamespace) {
|
||||
kind = KIND_NAMESPACE;
|
||||
} else {
|
||||
} else if (binding instanceof IParameter) {
|
||||
requiredName= null;
|
||||
kind = KIND_OBJ_FN;
|
||||
} else {
|
||||
kind = KIND_OBJ_FN;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue