1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-03 22:35:43 +02:00

fix bug 105769

This commit is contained in:
Andrew Niefer 2005-11-25 02:02:01 +00:00
parent bdd3de47b7
commit 4fa15e42ed
3 changed files with 23 additions and 1 deletions

View file

@ -1924,4 +1924,22 @@ public class AST2TemplateTests extends AST2BaseTest {
assertTrue( A instanceof ICPPTemplateInstance );
assertSame( ((ICPPTemplateInstance)A).getTemplateDefinition(), Aspec);
}
public void testBug105769() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("template< class T > class A : public T {}; \n"); //$NON-NLS-1$
buffer.append("class C { public: int c; }; \n"); //$NON-NLS-1$
buffer.append("class B : public A<C> { }; \n"); //$NON-NLS-1$
buffer.append("void main(){ \n"); //$NON-NLS-1$
buffer.append(" B k; \n"); //$NON-NLS-1$
buffer.append(" k.c; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, true, true );
CPPNameCollector col = new CPPNameCollector();
tu.accept( col );
ICPPVariable c = (ICPPVariable) col.getName(13).resolveBinding();
assertSame( c, col.getName(4).resolveBinding() );
}
}

View file

@ -26,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.parser.util.ObjectMap;
/**
@ -173,6 +174,8 @@ public class CPPDeferredClassInstance extends CPPInstance implements ICPPClassTy
return (typeClass == classTemplate );
} else if( type instanceof ICPPClassTemplate && classTemplate == type ){
return true;
} else if( type instanceof ICPPTemplateInstance && ((ICPPTemplateInstance)type).getTemplateDefinition() == classTemplate ){
return true;
}
return false;
}

View file

@ -74,6 +74,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectMap;
@ -228,7 +229,7 @@ public class CPPTemplates {
//a reference: class or function template?
IBinding template = null;
if( parent instanceof ICPPASTNamedTypeSpecifier || segment == 0 ){
if( parent instanceof ICPPASTNamedTypeSpecifier || parent instanceof ICPPASTBaseSpecifier || segment == 0 ){
//class template
IASTName templateName = id.getTemplateName();
template = templateName.resolveBinding();