[cfe-commits] [Request for approval] Redundant NNS and missing template keyword)
Douglas Gregor
dgregor at apple.com
Tue Aug 10 06:39:56 PDT 2010
Sent from my iPhone
On Aug 10, 2010, at 1:16 AM, Abramo Bagnara <abramo.bagnara at gmail.com> wrote:
>
> Douglas Gregor wrote:
>> On Jul 27, 2010, at 12:01 PM, Abramo Bagnara wrote:
>>
>>> Please find attached a couple of patches that are meant to fix the
>>> problems shown by the following examples.
>
> [...]
>
>>> The first problem is due to the fact that the NNS is encoded *both* in
>>> the ElaboratedType and in the underlying (dependent)
>>> TemplateSpecializationType: this should be corrected in redundant-nns.patch
>>
>> In this patch, we have:
>>
>> Index: lib/Sema/SemaTemplate.cpp
>> ===================================================================
>> --- lib/Sema/SemaTemplate.cpp (revision 109367)
>> +++ lib/Sema/SemaTemplate.cpp (working copy)
>> @@ -5258,8 +5260,6 @@
>>
>> TypeSourceInfo *InnerTSI = 0;
>> QualType T = GetTypeFromParser(Ty, &InnerTSI);
>> - NestedNameSpecifier *NNS
>> - = static_cast<NestedNameSpecifier *>(SS.getScopeRep());
>>
>> assert(isa<TemplateSpecializationType>(T) &&
>> "Expected a template specialization type");
>> @@ -5276,7 +5276,7 @@
>> else
>> Builder.push<TemplateSpecializationTypeLoc>(T).initialize(TemplateLoc);
>>
>> - T = Context.getElaboratedType(ETK_Typename, NNS, T);
>> + T = Context.getElaboratedType(ETK_Typename, /*NNS=*/0, T);
>> ElaboratedTypeLoc TL = Builder.push<ElaboratedTypeLoc>(T);
>> TL.setKeywordLoc(TypenameLoc);
>> TL.setQualifierRange(SS.getRange());
>>
>> I think we only want to drop NNS when T is a TemplateSpecializationTypeLoc. Otherwise, we'll end up eliminating some syntactic sugar in the non-template-specialization case.
>
> Here T is known to definitely be a TemplateSpecializationType.
> see the assert a few lines above:
>
> assert(isa<TemplateSpecializationType>(T) &&
> "Expected a template specialization type");
You're right, sorry.
> Anyway, we managed to improve this patch: we found another occurrence of
> the same problem in SemaType.cpp.
>
> OK to commit?
Yes.
- Doug
> Cheers,
> Abramo.
> <redundant-nns-2.patch>
More information about the cfe-commits
mailing list