1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Patch for Bryan - Bug 179173 Fixing a few exceptions.

This commit is contained in:
Doug Schaefer 2007-03-27 20:57:07 +00:00
parent 57c6cf3ad2
commit e855aa7a21
5 changed files with 32 additions and 13 deletions

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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 )

View file

@ -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 )

View file

@ -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: