diff options
author | Anders Carlsson <andersca@mac.com> | 2009-07-10 21:35:09 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-07-10 21:35:09 +0000 |
commit | 4e579922ada4e19618710878c32543322f86c9c8 (patch) | |
tree | a9253bda383163578e42f7a3cd9bb3fc0d914c7a | |
parent | 8d344ae81aeae1f2e4f21eddd1021acdca85abd7 (diff) |
Fix type of 'this' and add a decltype test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75291 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/DeclCXX.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/decltype-this.cpp | 15 | ||||
-rw-r--r-- | test/SemaTemplate/instantiate-function-1.cpp | 2 |
3 files changed, 17 insertions, 2 deletions
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index b7051f8d2c..45825e1032 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -360,7 +360,7 @@ QualType CXXMethodDecl::getThisType(ASTContext &C) const { else ClassTy = C.getTagDeclType(const_cast<CXXRecordDecl*>(getParent())); ClassTy = ClassTy.getWithAdditionalQualifiers(getTypeQualifiers()); - return C.getPointerType(ClassTy).withConst(); + return C.getPointerType(ClassTy); } CXXBaseOrMemberInitializer:: diff --git a/test/SemaCXX/decltype-this.cpp b/test/SemaCXX/decltype-this.cpp new file mode 100644 index 0000000000..fc001063c5 --- /dev/null +++ b/test/SemaCXX/decltype-this.cpp @@ -0,0 +1,15 @@ +// RUN: clang-cc -fsyntax-only -verify -std=c++0x %t +template<typename T, typename U> struct is_same { + static const bool value = false; +}; + +template<typename T> struct is_same<T, T> { + static const bool value = true; +}; + +struct S { + void f() { static_assert(is_same<decltype(this), S*>::value, ""); } + void g() const { static_assert(is_same<decltype(this), const S*>::value, ""); } + void h() volatile { static_assert(is_same<decltype(this), volatile S*>::value, ""); } + void i() const volatile { static_assert(is_same<decltype(this), const volatile S*>::value, ""); } +}; diff --git a/test/SemaTemplate/instantiate-function-1.cpp b/test/SemaTemplate/instantiate-function-1.cpp index 023cc5437f..2749ec2440 100644 --- a/test/SemaTemplate/instantiate-function-1.cpp +++ b/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 'Member0<T> *const' is not a structure or union}} + this.f; // expected-error{{member reference base type 'Member0<T> *' is not a structure or union}} } }; |