1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Follow up for bug 264666.

This commit is contained in:
Markus Schorn 2009-02-25 10:09:16 +00:00
parent 6694822fcb
commit 950242a0f3
4 changed files with 36 additions and 1 deletions

View file

@ -5827,6 +5827,19 @@ public class AST2Tests extends AST2BaseTest {
return runtime.totalMemory()-runtime.freeMemory();
}
// int n= 0;
// int a[]= {0x00, sizeof(n)};
public void testNonTrivialInitializer_Bug253690() throws Exception {
final String code= getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
IASTTranslationUnit tu= parse(code, lang, false, true, true);
IASTSimpleDeclaration d= getDeclaration(tu, 0);
IBinding b= d.getDeclarators()[0].getName().resolveBinding();
IASTName[] refs = tu.getReferences(b);
assertEquals(1, refs.length);
}
}
// void test() {
// const void* p = 1+2;
// }

View file

@ -127,7 +127,9 @@ public abstract class ASTVisitor {
public boolean includeInactiveNodes= false;
/**
* For internal use, only.
* Normally neither ambiguous nodes nor their children are visited. By setting
* this flag to <code>true</code> ambiguous nodes are visited, their children
* are not.
* @noreference This field is not intended to be referenced by clients.
*/
public boolean shouldVisitAmbiguousNodes = false;

View file

@ -45,6 +45,15 @@ public class ASTQueries {
fFound= true;
return PROCESS_ABORT;
}
@Override
public int visit(ASTAmbiguousNode node) {
IASTNode[] alternatives= node.getNodes();
for (IASTNode alt : alternatives) {
if (!alt.accept(this))
return PROCESS_ABORT;
}
return PROCESS_CONTINUE;
}
}
private static NameSearch NAME_SEARCH= new NameSearch();

View file

@ -121,6 +121,17 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
((ASTNode) node).setInactive();
return PROCESS_CONTINUE;
}
@Override
public int visit(ASTAmbiguousNode node) {
node.setInactive();
IASTNode[] alternatives= node.getNodes();
for (IASTNode alt : alternatives) {
if (!alt.accept(this))
return PROCESS_ABORT;
}
return PROCESS_CONTINUE;
}
};
protected static final int DEFAULT_DESIGNATOR_LIST_SIZE = 4;