From: Douglas Gregor Date: Fri, 4 Mar 2011 18:53:13 +0000 (+0000) Subject: When constructing source-location information for a X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=087eb5a2d3c7988eb7c440cd86cc7479e57d5dc0;p=clang When constructing source-location information for a DependentTemplateSpecializationType during tree transformation, retain the NestedNameSpecifierLoc as it was used to translate the template name, rather than reconstructing it from the template name. Fixes PR9401. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127015 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 76792a0c76..9eb7d63505 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -498,7 +498,8 @@ public: QualType TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB, DependentTemplateSpecializationTypeLoc TL, - TemplateName Template); + TemplateName Template, + CXXScopeSpec &SS); QualType TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB, @@ -3103,7 +3104,8 @@ TreeTransform::TransformTypeInObjectScope(TypeLoc TL, Result = getDerived().TransformDependentTemplateSpecializationType(TLB, SpecTL, - Template); + Template, + SS); } else { // Nothing special needs to be done for these. Result = getDerived().TransformType(TLB, TL); @@ -3159,7 +3161,8 @@ TreeTransform::TransformTypeInObjectScope(TypeSourceInfo *TSInfo, Result = getDerived().TransformDependentTemplateSpecializationType(TLB, SpecTL, - Template); + Template, + SS); } else { // Nothing special needs to be done for these. Result = getDerived().TransformType(TLB, TL); @@ -4245,7 +4248,8 @@ template QualType TreeTransform::TransformDependentTemplateSpecializationType( TypeLocBuilder &TLB, DependentTemplateSpecializationTypeLoc TL, - TemplateName Template) { + TemplateName Template, + CXXScopeSpec &SS) { TemplateArgumentListInfo NewTemplateArgs; NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc()); NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc()); @@ -4270,8 +4274,6 @@ QualType TreeTransform::TransformDependentTemplateSpecializationType( = TLB.push(Result); NewTL.setKeywordLoc(TL.getKeywordLoc()); - CXXScopeSpec SS; - SS.Adopt(TL.getQualifierLoc()); NewTL.setQualifierLoc(SS.getWithLocInContext(SemaRef.Context)); NewTL.setNameLoc(TL.getNameLoc()); NewTL.setLAngleLoc(TL.getLAngleLoc()); diff --git a/test/SemaTemplate/dependent-template-recover.cpp b/test/SemaTemplate/dependent-template-recover.cpp index e91ffb5253..3c01f6586b 100644 --- a/test/SemaTemplate/dependent-template-recover.cpp +++ b/test/SemaTemplate/dependent-template-recover.cpp @@ -16,3 +16,45 @@ struct X { (*t).f2<0>(); // expected-error{{expected expression}} } }; + +namespace PR9401 { + // From GCC PR c++/45558 + template + struct C + { + template + struct B + { + template + struct E + { + explicit E(const W &x) : w(x) {} + const W &w; + }; + }; + }; + + struct F; + template + struct D + { + D() {} + }; + + const D g; + template + struct A + { + template + struct B : C::template B + { + typedef typename C::template B V; + static const D > > a; + }; + }; + + template + template + const D::template B::template E > > + A::B::a = typename C::template B::template E >(g); +}