Make sure to strip off top-level cv-qualifiers as part of a
derived-to-base conversion on a pointer. Fixes PR7224.

llvm-svn: 104607
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 6c64905..2754d44 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1233,7 +1233,7 @@
   if (CanonToPointee.getLocalQualifiers() == Quals) {
     // ToType is exactly what we need. Return it.
     if (!ToType.isNull())
-      return ToType;
+      return ToType.getUnqualifiedType();
 
     // Build a pointer to ToPointee. It has the right qualifiers
     // already.
diff --git a/clang/test/SemaCXX/overload-call.cpp b/clang/test/SemaCXX/overload-call.cpp
index 9618ea2..29133c7 100644
--- a/clang/test/SemaCXX/overload-call.cpp
+++ b/clang/test/SemaCXX/overload-call.cpp
@@ -444,3 +444,19 @@
   void f(const X *);
   void g(Y y) { f(y); }
 }
+
+namespace PR7224 {
+  class A {};
+  class B : public A {};
+
+  int &foo(A *const d);
+  float &foo(const A *const d);
+
+  void bar()
+  {
+    B *const d = 0;
+    B const *const d2 = 0;
+    int &ir = foo(d);
+    float &fr = foo(d2);
+  }
+}