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
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index b7051f8..45825e1 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -360,7 +360,7 @@
   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 0000000..fc00106
--- /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 023cc54..2749ec2 100644
--- a/test/SemaTemplate/instantiate-function-1.cpp
+++ b/test/SemaTemplate/instantiate-function-1.cpp
@@ -140,7 +140,7 @@
     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}}
   }
 };