mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
fix bug 86649
This commit is contained in:
parent
ac9494b61c
commit
7591bd643e
2 changed files with 58 additions and 0 deletions
|
@ -2615,5 +2615,41 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertInstances( col, g1, 1 );
|
assertInstances( col, g1, 1 );
|
||||||
assertInstances( col, g2, 2 );
|
assertInstances( col, g2, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBug86649() throws Exception {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("class V { int f(); int x; }; \n"); //$NON-NLS-1$
|
||||||
|
buffer.append("class W { int g(); int y; }; \n"); //$NON-NLS-1$
|
||||||
|
buffer.append("class B : public virtual V, public W { \n"); //$NON-NLS-1$
|
||||||
|
buffer.append(" int f(); int x; \n"); //$NON-NLS-1$
|
||||||
|
buffer.append(" int g(); int y; \n"); //$NON-NLS-1$
|
||||||
|
buffer.append("}; \n"); //$NON-NLS-1$
|
||||||
|
buffer.append("class C : public virtual V, public W {}; \n"); //$NON-NLS-1$
|
||||||
|
buffer.append("class D : public B, public C { \n"); //$NON-NLS-1$
|
||||||
|
buffer.append(" void foo(); \n"); //$NON-NLS-1$
|
||||||
|
buffer.append("}; \n"); //$NON-NLS-1$
|
||||||
|
buffer.append("void D::foo(){ \n"); //$NON-NLS-1$
|
||||||
|
buffer.append(" x++; \n"); //$NON-NLS-1$
|
||||||
|
buffer.append(" f(); \n"); //$NON-NLS-1$
|
||||||
|
buffer.append(" y++; \n"); //$NON-NLS-1$
|
||||||
|
buffer.append(" g(); \n"); //$NON-NLS-1$
|
||||||
|
buffer.append("} \n"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
|
||||||
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
|
tu.getVisitor().visitTranslationUnit(col);
|
||||||
|
|
||||||
|
ICPPField x = (ICPPField) col.getName(23).resolveBinding();
|
||||||
|
ICPPMethod f = (ICPPMethod) col.getName(24).resolveBinding();
|
||||||
|
|
||||||
|
IProblemBinding y = (IProblemBinding) col.getName(25).resolveBinding();
|
||||||
|
IProblemBinding g = (IProblemBinding) col.getName(26).resolveBinding();
|
||||||
|
|
||||||
|
assertEquals( y.getID(), IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP );
|
||||||
|
assertEquals( g.getID(), IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP );
|
||||||
|
|
||||||
|
assertInstances( col, x, 2 );
|
||||||
|
assertInstances( col, f, 2 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -746,6 +746,8 @@ public class CPPSemantics {
|
||||||
|
|
||||||
if( inherited == null || inherited.length == 0 ){
|
if( inherited == null || inherited.length == 0 ){
|
||||||
inherited = lookupInParents( data, parent );
|
inherited = lookupInParents( data, parent );
|
||||||
|
} else {
|
||||||
|
visitVirtualBaseClasses( data, cls );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
data.problem = new ProblemBinding( IProblemBinding.SEMANTIC_CIRCULAR_INHERITANCE, bases[i].getName().toCharArray() );
|
data.problem = new ProblemBinding( IProblemBinding.SEMANTIC_CIRCULAR_INHERITANCE, bases[i].getName().toCharArray() );
|
||||||
|
@ -775,6 +777,26 @@ public class CPPSemantics {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void visitVirtualBaseClasses( LookupData data, ICPPClassType cls ){
|
||||||
|
ICPPBase [] bases = null;
|
||||||
|
try {
|
||||||
|
bases = cls.getBases();
|
||||||
|
} catch ( DOMException e ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for( int i = 0; i < bases.length; i++ ){
|
||||||
|
try {
|
||||||
|
if( bases[i].isVirtual() ){
|
||||||
|
if( data.visited == ObjectSet.EMPTY_SET )
|
||||||
|
data.visited = new ObjectSet(2);
|
||||||
|
data.visited.put( bases[i].getBaseClass().getCompositeScope() );
|
||||||
|
} else {
|
||||||
|
visitVirtualBaseClasses( data, bases[i].getBaseClass() );
|
||||||
|
}
|
||||||
|
} catch ( DOMException e1 ) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private static boolean checkAmbiguity( IASTName n, IASTName []names ) throws DOMException{
|
private static boolean checkAmbiguity( IASTName n, IASTName []names ) throws DOMException{
|
||||||
names = (IASTName[]) ArrayUtil.trim( IASTName.class, names );
|
names = (IASTName[]) ArrayUtil.trim( IASTName.class, names );
|
||||||
if( names.length == 0 )
|
if( names.length == 0 )
|
||||||
|
|
Loading…
Add table
Reference in a new issue