1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-05 16:56:04 +02:00

Bug 446711 - Name resolution problem with dependent enumeration

Fixed ownership of enumeration specializations.
This commit is contained in:
Sergey Prigogin 2014-10-20 12:29:59 -07:00
parent 88a494349a
commit 0c4ddcf922

View file

@ -962,7 +962,7 @@ public class CPPTemplates {
IType type= instantiateType(aliasTemplate.getType(), tpMap, -1, getSpecializationContext(owner), point); IType type= instantiateType(aliasTemplate.getType(), tpMap, -1, getSpecializationContext(owner), point);
spec = new CPPAliasTemplateInstance(decl.getNameCharArray(), aliasTemplate, type); spec = new CPPAliasTemplateInstance(decl.getNameCharArray(), aliasTemplate, type);
} else if (decl instanceof ICPPEnumeration) { } else if (decl instanceof ICPPEnumeration) {
spec = instantiateEnumeration((ICPPEnumeration) decl, getSpecializationContext(owner), tpMap, point); spec = instantiateEnumeration((ICPPEnumeration) decl, owner, tpMap, point);
} else if (decl instanceof IEnumerator) { } else if (decl instanceof IEnumerator) {
IEnumerator enumerator = (IEnumerator) decl; IEnumerator enumerator = (IEnumerator) decl;
ICPPEnumeration enumeration = (ICPPEnumeration) enumerator.getOwner(); ICPPEnumeration enumeration = (ICPPEnumeration) enumerator.getOwner();
@ -997,11 +997,12 @@ public class CPPTemplates {
return spec; return spec;
} }
private static IBinding instantiateEnumeration(ICPPEnumeration enumeration, ICPPClassSpecialization within, private static IBinding instantiateEnumeration(ICPPEnumeration enumeration, ICPPClassSpecialization owner,
final ICPPTemplateParameterMap tpMap, IASTNode point) { final ICPPTemplateParameterMap tpMap, IASTNode point) {
ICPPClassSpecialization within = getSpecializationContext(owner);
IType fixedType = instantiateType(enumeration.getFixedType(), tpMap, -1, within, point); IType fixedType = instantiateType(enumeration.getFixedType(), tpMap, -1, within, point);
CPPEnumerationSpecialization specializedEnumeration = CPPEnumerationSpecialization specializedEnumeration =
new CPPEnumerationSpecialization(enumeration, within, tpMap, fixedType); new CPPEnumerationSpecialization(enumeration, owner, tpMap, fixedType);
IEnumerator[] enumerators = enumeration.getEnumerators(); IEnumerator[] enumerators = enumeration.getEnumerators();
IEnumerator[] specializedEnumerators = new IEnumerator[enumerators.length]; IEnumerator[] specializedEnumerators = new IEnumerator[enumerators.length];
specializedEnumeration.setEnumerators(specializedEnumerators); specializedEnumeration.setEnumerators(specializedEnumerators);
@ -1015,10 +1016,9 @@ public class CPPTemplates {
internalType = ((ICPPInternalEnumerator) enumerator).getInternalType(); internalType = ((ICPPInternalEnumerator) enumerator).getInternalType();
if (internalType != null) { if (internalType != null) {
internalType = instantiateType(internalType, tpMap, -1, within, point); internalType = instantiateType(internalType, tpMap, -1, within, point);
} else { } else if (previousInternalType instanceof IBasicType) {
if (previousInternalType instanceof IBasicType) { internalType = ASTEnumerator.getTypeOfIncrementedValue((IBasicType) previousInternalType, specializedValue);
internalType = ASTEnumerator.getTypeOfIncrementedValue((IBasicType) previousInternalType, specializedValue); }
} }
if (internalType != null) { if (internalType != null) {
previousInternalType = internalType; previousInternalType = internalType;
} }