From c3d2ebb60f6048cf99a5c30ce77b9ec9118b635b Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 7 Jun 2013 02:33:37 +0000 Subject: PR16243: Use CXXThisOverride during template instantiation, and fix up the places which weren't setting it up properly. This allows us to get the right cv-qualifiers for 'this' when it appears outside a method body in a class template. llvm-svn: 183483 --- clang/lib/Sema/SemaTemplateInstantiate.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'clang/lib/Sema/SemaTemplateInstantiate.cpp') diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 60f447711e2..5e3ced47f44 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -2080,6 +2080,14 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation, E = LateAttrs.end(); I != E; ++I) { assert(CurrentInstantiationScope == Instantiator.getStartingScope()); CurrentInstantiationScope = I->Scope; + + // Allow 'this' within late-parsed attributes. + NamedDecl *ND = dyn_cast(I->NewDecl); + CXXRecordDecl *ThisContext = + dyn_cast_or_null(ND->getDeclContext()); + CXXThisScopeRAII ThisScope(*this, ThisContext, /*TypeQuals*/0, + ND && ND->isCXXInstanceMember()); + Attr *NewAttr = instantiateTemplateAttribute(I->TmplAttr, Context, *this, TemplateArgs); I->NewDecl->addAttr(NewAttr); -- cgit v1.2.3