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

fix bug 84469 - visiting names in pointers to members

This commit is contained in:
Andrew Niefer 2005-02-11 21:41:24 +00:00
parent d77e74d43e
commit 3166aa1864
2 changed files with 26 additions and 1 deletions

View file

@ -1425,5 +1425,19 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances( col, mutate, 2 );
assertInstances( col, B, 2 );
}
public void testBug84469() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("struct S { int i; }; \n"); //$NON-NLS-1$
buffer.append("void f() { ; \n"); //$NON-NLS-1$
buffer.append(" int S::* pm = &S::i; \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( 9, col.size() );
}
}

View file

@ -967,7 +967,9 @@ public class CPPVisitor {
if( name instanceof ICPPASTQualifiedName ){
IASTName [] names = ((ICPPASTQualifiedName)name).getNames();
for( int i = 0; i < names.length; i++ ){
if( !visitName( names[i], action ) ) return false;
if( i == names.length - 1 ){
if( names[i].toCharArray().length > 0 && !visitName( names[i], action ) ) return false;
} else if( !visitName( names[i], action ) ) return false;
}
}
return true;
@ -1031,6 +1033,15 @@ public class CPPVisitor {
}
}
IASTPointerOperator [] ptrs = declarator.getPointerOperators();
if( ptrs.length > 0 ){
for( int i = 0; i < ptrs.length; i++ ){
if( ptrs[i] instanceof ICPPASTPointerToMember ){
if( !visitName( ((ICPPASTPointerToMember) ptrs[i]).getName(), action ) ) return false;
}
}
}
if( declarator.getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR &&
declarator.getNestedDeclarator() == null )
{