mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 06:45:43 +02:00
fix bug 84469 - visiting names in pointers to members
This commit is contained in:
parent
d77e74d43e
commit
3166aa1864
2 changed files with 26 additions and 1 deletions
|
@ -1425,5 +1425,19 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertInstances( col, mutate, 2 );
|
assertInstances( col, mutate, 2 );
|
||||||
assertInstances( col, B, 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() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -967,7 +967,9 @@ public class CPPVisitor {
|
||||||
if( name instanceof ICPPASTQualifiedName ){
|
if( name instanceof ICPPASTQualifiedName ){
|
||||||
IASTName [] names = ((ICPPASTQualifiedName)name).getNames();
|
IASTName [] names = ((ICPPASTQualifiedName)name).getNames();
|
||||||
for( int i = 0; i < names.length; i++ ){
|
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;
|
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 &&
|
if( declarator.getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR &&
|
||||||
declarator.getNestedDeclarator() == null )
|
declarator.getNestedDeclarator() == null )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue