1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 12:03:16 +02:00

Specialization of owners of deferred instances, bug 259872.

This commit is contained in:
Markus Schorn 2009-01-14 09:09:42 +00:00
parent 27e180373f
commit 4218500207
3 changed files with 27 additions and 27 deletions

View file

@ -3570,7 +3570,7 @@ public class AST2TemplateTests extends AST2BaseTest {
// new A<B, int>(&B::m);
// }
// };
public void _testNestedTemplates_259872() throws Exception {
public void testNestedTemplates_259872() throws Exception {
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
bh.assertNonProblem("A<B, int>", 9, ICPPConstructor.class);
}

View file

@ -16,6 +16,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTComment;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.core.dom.ast.IASTName;
@ -35,6 +36,7 @@ import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.core.index.IIndexFileSet;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver;
import org.eclipse.cdt.internal.core.parser.scanner.ISkippedIndexedFilesListener;
import org.eclipse.cdt.internal.core.parser.scanner.IncludeFileContent;
@ -355,12 +357,22 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
public void cleanupAfterAmbiguityResolution() {
// clear bindings (see bug 232811)
accept(new ASTVisitor(){
{shouldVisitNames= true;}
{
shouldVisitNames= true;
shouldVisitDeclSpecifiers= true;
}
@Override
public int visit(IASTName name) {
name.setBinding(null);
return PROCESS_CONTINUE;
}
@Override
public int visit(IASTDeclSpecifier declSpec) {
if (declSpec instanceof CPPASTCompositeTypeSpecifier)
((CPPASTCompositeTypeSpecifier) declSpec).setScope(null);
return PROCESS_CONTINUE;
}
});
}

View file

@ -793,15 +793,14 @@ public class CPPTemplates {
if (within != null && type instanceof IBinding &&
(type instanceof ITypedef || type instanceof ICPPClassType)) {
ICPPClassType originalClass= within.getSpecializedBinding();
if (originalClass.isSameType(type))
return within;
IBinding typeAsBinding= (IBinding) type;
IBinding typeOwner= typeAsBinding.getOwner();
ICPPClassType originalClass= within.getSpecializedBinding();
if (typeOwner instanceof IType) {
final IType parentType = (IType) typeOwner;
if (parentType.isSameType(originalClass)) {
return (IType) within.specializeMember(typeAsBinding);
}
IType newOwner= instantiateType(parentType, tpMap, within);
IType newOwner= instantiateType((IType) typeOwner, tpMap, within);
if (newOwner != typeOwner && newOwner instanceof ICPPClassSpecialization) {
return (IType) ((ICPPClassSpecialization) newOwner).specializeMember(typeAsBinding);
}
@ -2012,16 +2011,11 @@ public class CPPTemplates {
}
final IBinding owner= unknown.getOwner();
if (!(owner instanceof ICPPTemplateTypeParameter || owner instanceof ICPPUnknownClassType))
return unknown;
IBinding result = unknown;
IType t = null;
if (owner instanceof ICPPTemplateTypeParameter) {
t = CPPTemplates.instantiateType((ICPPTemplateTypeParameter) owner, tpMap, null);
} else if (owner instanceof ICPPUnknownClassType) {
IBinding binding= resolveUnknown((ICPPUnknownBinding) owner, tpMap, within);
if (binding instanceof IType) {
t = (IType) binding;
}
}
IType t = CPPTemplates.instantiateType((IType) owner, tpMap, within);
if (t != null) {
t = SemanticUtil.getUltimateType(t, false);
if (t instanceof ICPPUnknownBinding) {
@ -2073,17 +2067,11 @@ public class CPPTemplates {
boolean changed= arguments != newArgs;
ICPPClassTemplate classTemplate = dci.getClassTemplate();
if (classTemplate instanceof ICPPTemplateParameter) {
// template template parameter
ICPPTemplateArgument arg= tpMap.getArgument((ICPPTemplateParameter) classTemplate);
if (arg != null) {
IType t= arg.getTypeValue();
if (t instanceof ICPPClassTemplate) {
classTemplate= (ICPPClassTemplate) t;
IType specializedClassTemplate= instantiateType(classTemplate, tpMap, within);
if (specializedClassTemplate != classTemplate && specializedClassTemplate instanceof ICPPClassTemplate) {
classTemplate= (ICPPClassTemplate) specializedClassTemplate;
changed= true;
}
}
}
if (changed) {
IBinding inst= instantiate(classTemplate, newArgs);