mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Call Hierarchy for reference in initializer of variable with function-type, related to bug 252488.
This commit is contained in:
parent
2e199def93
commit
70431722fe
2 changed files with 17 additions and 0 deletions
|
@ -5475,4 +5475,19 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertNotNull(numericalValue);
|
assertNotNull(numericalValue);
|
||||||
assertEquals(i, numericalValue.intValue());
|
assertEquals(i, numericalValue.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// void myfunc(char *arg){}
|
||||||
|
// void (*funcVar2)(char *) = myfunc;
|
||||||
|
// void caller() {
|
||||||
|
// myfunc("");
|
||||||
|
// }
|
||||||
|
public void testReferencesInInitializer_Bug251514() 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();
|
||||||
|
assertEquals(2, tu.getReferences(name.resolveBinding()).length);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
||||||
|
|
||||||
abstract public class IndexerASTVisitor extends ASTVisitor {
|
abstract public class IndexerASTVisitor extends ASTVisitor {
|
||||||
private static class Definition {
|
private static class Definition {
|
||||||
|
@ -172,6 +173,7 @@ abstract public class IndexerASTVisitor extends ASTVisitor {
|
||||||
if (!(fDefinitionNode instanceof IASTFunctionDefinition)) {
|
if (!(fDefinitionNode instanceof IASTFunctionDefinition)) {
|
||||||
IASTNode cand= initializer.getParent();
|
IASTNode cand= initializer.getParent();
|
||||||
if (cand instanceof IASTDeclarator) {
|
if (cand instanceof IASTDeclarator) {
|
||||||
|
cand= CVisitor.findInnermostDeclarator((IASTDeclarator) cand);
|
||||||
push(((IASTDeclarator) cand).getName(), initializer);
|
push(((IASTDeclarator) cand).getName(), initializer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue