mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 17:55:39 +02:00
fix bug 84692
This commit is contained in:
parent
e20bdb8813
commit
d2350bf588
2 changed files with 51 additions and 17 deletions
|
@ -1158,5 +1158,42 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertEquals( name.getNames()[1].toString(), "DEF" ); //$NON-NLS-1$
|
||||
assertEquals( name.getNames()[2].toString(), "ghi" ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void _test84679() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("namespace Y { void f(float); } // NPE on resolve binding \n"); //$NON-NLS-1$
|
||||
buffer.append("namespace A { using namespace Y; f(int); } // NPE on resolve binding \n" ); //$NON-NLS-1$
|
||||
buffer.append("namespace B { void f(char); } // NPE on resolve binding \n "); //$NON-NLS-1$
|
||||
buffer.append("namespace AB { using namespace A; using namespace B; } \n" ); //$NON-NLS-1$
|
||||
buffer.append("void h(){ \n"); //$NON-NLS-1$
|
||||
buffer.append(" AB::f(1); \n"); //$NON-NLS-1$
|
||||
buffer.append(" AB::f(’c’); \n"); //$NON-NLS-1$
|
||||
buffer.append("} \n"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testBug84692() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("struct Node { \n"); //$NON-NLS-1$
|
||||
buffer.append(" struct Node* Next; \n"); //$NON-NLS-1$
|
||||
buffer.append(" struct Data* Data; \n"); //$NON-NLS-1$
|
||||
buffer.append("}; \n"); //$NON-NLS-1$
|
||||
buffer.append("struct Data { \n"); //$NON-NLS-1$
|
||||
buffer.append(" struct Node * node; \n"); //$NON-NLS-1$
|
||||
buffer.append(" friend struct Glob; \n"); //$NON-NLS-1$
|
||||
buffer.append("}; \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
CPPVisitor.visitTranslationUnit(tu, col);
|
||||
|
||||
assertEquals(col.size(), 9);
|
||||
|
||||
ICPPClassType Node = (ICPPClassType) col.getName(1).resolveBinding();
|
||||
ICPPClassType Data = (ICPPClassType) col.getName(3).resolveBinding();
|
||||
|
||||
assertInstances( col, Node, 3 );
|
||||
assertInstances( col, Data, 2 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -709,31 +709,28 @@ public class CPPSemantics {
|
|||
nodes = dtor.getParameters();
|
||||
}
|
||||
|
||||
if( scope instanceof ICPPClassScope ){
|
||||
blockItem = null;
|
||||
}
|
||||
|
||||
int idx = -1;
|
||||
boolean classScope = ( scope instanceof ICPPClassScope );
|
||||
IASTNode item = ( nodes != null ? (nodes.length > 0 ? nodes[++idx] : null ) : parent );
|
||||
|
||||
while( item != null ) {
|
||||
if( item == null || ( blockItem != null && ((ASTNode)item).getOffset() > ((ASTNode) blockItem).getOffset() ))
|
||||
if( !classScope && blockItem != null && ((ASTNode)item).getOffset() > ((ASTNode) blockItem).getOffset() )
|
||||
break;
|
||||
if( item == blockItem && !data.includeBlockItem( item ) )
|
||||
break;
|
||||
|
||||
if( item instanceof ICPPASTUsingDirective && !data.ignoreUsingDirectives ) {
|
||||
if( usingDirectives != null )
|
||||
usingDirectives.add( item );
|
||||
} else {
|
||||
possible = collectResult( data, scope, item, (item == parent) );
|
||||
if( possible != null ){
|
||||
if( found == null )
|
||||
found = new ArrayList(2);
|
||||
found.add( possible );
|
||||
if( item != blockItem || data.includeBlockItem( item ) ){
|
||||
if( item instanceof ICPPASTUsingDirective && !data.ignoreUsingDirectives ) {
|
||||
if( usingDirectives != null )
|
||||
usingDirectives.add( item );
|
||||
} else {
|
||||
possible = collectResult( data, scope, item, (item == parent) );
|
||||
if( possible != null ){
|
||||
if( found == null )
|
||||
found = new ArrayList(2);
|
||||
found.add( possible );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( item == blockItem )
|
||||
if( item == blockItem && !classScope )
|
||||
break;
|
||||
if( idx > -1 && ++idx < nodes.length ){
|
||||
item = nodes[idx];
|
||||
|
|
Loading…
Add table
Reference in a new issue