]> granicus.if.org Git - clang/commitdiff
Fix type of 'this' and add a decltype test.
authorAnders Carlsson <andersca@mac.com>
Fri, 10 Jul 2009 21:35:09 +0000 (21:35 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 10 Jul 2009 21:35:09 +0000 (21:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75291 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclCXX.cpp
test/SemaCXX/decltype-this.cpp [new file with mode: 0644]
test/SemaTemplate/instantiate-function-1.cpp

index b7051f8d2c53f5119ae5da1b330505570392f810..45825e103240aa3d44dc5915337d6b31daf5a95d 100644 (file)
@@ -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 (file)
index 0000000..fc00106
--- /dev/null
@@ -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, ""); }
+};
index 023cc5437f69e28c86263e05d4de6bf66d110219..2749ec24401bf5038fa5af21bdfddebb68797d85 100644 (file)
@@ -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}}
   }
 };