diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java index b2ce8163667..ae56175d0d9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java @@ -56,7 +56,7 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP ICPPBase [] bindings = cls.getBases(); for (int i = 0; i < bindings.length; i++) { IBinding base = bindings[i].getBaseClass(); - if (base instanceof IType) { + if (bindings[i] instanceof CPPBaseClause && base instanceof IType) { IType specBase = CPPTemplates.instantiateType((IType) base, argumentMap); ((CPPBaseClause)bindings[i]).setBaseClass((ICPPClassType)specBase); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java index dfff1da21b8..71b6b23c280 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java @@ -78,7 +78,7 @@ public class CPPClassSpecialization extends CPPSpecialization implements ICPPBase[] bindings = ((ICPPClassType)getSpecializedBinding()).getBases(); for (int i = 0; i < bindings.length; i++) { IBinding base = bindings[i].getBaseClass(); - if (base instanceof IType) { + if (bindings[i] instanceof CPPBaseClause && base instanceof IType) { IType specBase = CPPTemplates.instantiateType((IType) base, argumentMap); ((CPPBaseClause)bindings[i]).setBaseClass((ICPPClassType)specBase); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java index 66f18a6cd0d..31970632b3e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java @@ -382,8 +382,9 @@ public class CPPTemplates { } } - if( spec != null ){ - ((ICPPInternalBinding)spec).addDefinition( id ); + if (spec != null) { + if( spec instanceof ICPPInternalBinding ) + ((ICPPInternalBinding)spec).addDefinition( id ); return spec; } @@ -435,11 +436,11 @@ public class CPPTemplates { ICPPSpecialization spec = null; if( parent.getParent() instanceof ICPPASTExplicitTemplateInstantiation ){ - spec = ((ICPPInternalTemplate)function).getInstance( (IType[])map_types[1] ); + spec = ((ICPPInternalTemplateInstantiator)function).getInstance( (IType[])map_types[1] ); if( spec == null ) spec = (ICPPSpecialization) CPPTemplates.createInstance( scope, function, (ObjectMap)map_types[0], (IType[])map_types[1] ); } else { - spec = ((ICPPInternalTemplate)function).getInstance( (IType[])map_types[1] ); + spec = ((ICPPInternalTemplateInstantiator)function).getInstance( (IType[])map_types[1] ); if( spec == null ) { if( function instanceof ICPPConstructor ) spec = new CPPConstructorSpecialization( function, scope, (ObjectMap) map_types[0] ); @@ -449,12 +450,15 @@ public class CPPTemplates { spec = new CPPFunctionSpecialization( function, scope, (ObjectMap) map_types[0] ); } - if( parent instanceof IASTSimpleDeclaration ) - ((ICPPInternalBinding)spec).addDeclaration( name ); - else if( parent instanceof IASTFunctionDefinition ) - ((ICPPInternalBinding)spec).addDefinition( name ); + if (spec instanceof ICPPInternalBinding) { + if( parent instanceof IASTSimpleDeclaration ) + ((ICPPInternalBinding)spec).addDeclaration( name ); + else if( parent instanceof IASTFunctionDefinition ) + ((ICPPInternalBinding)spec).addDefinition( name ); + } } - ((ICPPInternalTemplate)function).addSpecialization( (IType[]) map_types[1], spec ); + if (function instanceof ICPPInternalTemplate) + ((ICPPInternalTemplate)function).addSpecialization( (IType[]) map_types[1], spec ); return spec; } //TODO problem? @@ -1275,14 +1279,14 @@ public class CPPTemplates { //Using the transformed parameter list, perform argument deduction against the other //function template IType [] args = createArgsForFunctionTemplateOrdering( f1 ); - ICPPFunction function = (ICPPFunction) ((ICPPInternalTemplate)f1).instantiate( args ); + ICPPFunction function = (ICPPFunction) ((ICPPInternalTemplateInstantiator)f1).instantiate( args ); ObjectMap m1 = null; if( function != null ) m1 = deduceTemplateArguments( f2, function.getType().getParameterTypes() ); args = createArgsForFunctionTemplateOrdering( f2 ); - function = (ICPPFunction) ((ICPPInternalTemplate)f2).instantiate( args ); + function = (ICPPFunction) ((ICPPInternalTemplateInstantiator)f2).instantiate( args ); ObjectMap m2 = null; if( function != null ) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java index 8cfdb65eb20..1c41c4ab752 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java @@ -573,6 +573,19 @@ public class CPPVisitor { } } + if (binding instanceof IIndexBinding) { + ICPPASTTemplateDeclaration templateDecl = CPPTemplates.getTemplateDeclaration(name); + if (templateDecl != null) { + ICPPASTTemplateParameter[] params = templateDecl.getTemplateParameters(); + for (int i = 0; i < params.length; i++) { + IASTName paramName = CPPTemplates.getTemplateParameterName(params[i]); + paramName.setBinding(null); + //unsetting the index bindings so that they + //can be re-resolved with normal bindings + } + } + } + if( scope instanceof ICPPClassScope ){ if( isConstructor( scope, declarator) ) binding = template ? (ICPPConstructor) new CPPConstructorTemplate( name ) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java index 2ea7436436e..2ddb7d2eea9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java @@ -573,6 +573,8 @@ class PDOMCPPLinkage extends PDOMLinkage { return new PDOMCPPNamespaceAlias(pdom, record); case CPPBASICTYPE: return new PDOMCPPBasicType(pdom, record); + case CPPPARAMETER: + return new PDOMCPPParameter(pdom, record); case CPPENUMERATION: return new PDOMCPPEnumeration(pdom, record); case CPPENUMERATOR: