diff options
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/AST/DeclCXX.cpp | 7 | ||||
| -rw-r--r-- | clang/test/SemaTemplate/instantiate-function-1.cpp | 8 | 
2 files changed, 13 insertions, 2 deletions
| diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index 94daf484458..8430da2be6b 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -260,7 +260,12 @@ QualType CXXMethodDecl::getThisType(ASTContext &C) const {    // the type of this is const volatile X*.    assert(isInstance() && "No 'this' for static methods!"); -  QualType ClassTy = C.getTagDeclType(const_cast<CXXRecordDecl*>(getParent())); + +  QualType ClassTy; +  if (ClassTemplateDecl *TD = getParent()->getDescribedClassTemplate()) +    ClassTy = TD->getInjectedClassNameType(C); +  else +    ClassTy = C.getTagDeclType(const_cast<CXXRecordDecl*>(getParent()));    ClassTy = ClassTy.getWithAdditionalQualifiers(getTypeQualifiers());    return C.getPointerType(ClassTy).withConst();  } diff --git a/clang/test/SemaTemplate/instantiate-function-1.cpp b/clang/test/SemaTemplate/instantiate-function-1.cpp index 5b3a6d99840..023cc5437f6 100644 --- a/clang/test/SemaTemplate/instantiate-function-1.cpp +++ b/clang/test/SemaTemplate/instantiate-function-1.cpp @@ -140,7 +140,7 @@ template<typename T> struct Member0 {      tp->f;      this->f; -    this.f; // expected-error{{member reference base type 'struct Member0 *const' is not a structure or union}} +    this.f; // expected-error{{member reference base type 'Member0<T> *const' is not a structure or union}}    }  }; @@ -209,3 +209,9 @@ struct Abstract {  template struct TryCatch0<int>; // okay  template struct TryCatch0<Incomplete*>; // expected-note{{instantiation}}  template struct TryCatch0<Abstract>; // expected-note{{instantiation}} + +// PR4383 +template<typename T> struct X; +template<typename T> struct Y : public X<T> { +  Y& x() { return *this; } +}; | 

