]> granicus.if.org Git - clang/commitdiff
Make sure to strip off top-level cv-qualifiers as part of a
authorDouglas Gregor <dgregor@apple.com>
Tue, 25 May 2010 15:31:05 +0000 (15:31 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 25 May 2010 15:31:05 +0000 (15:31 +0000)
derived-to-base conversion on a pointer. Fixes PR7224.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104607 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp
test/SemaCXX/overload-call.cpp

index 6c64905561bfc4c32d818a2b9f101161b56cb62e..2754d443b25a54504a189c8a74c23189dc55a456 100644 (file)
@@ -1233,7 +1233,7 @@ BuildSimilarlyQualifiedPointerType(const PointerType *FromPtr,
   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.
index 9618ea22495f65b3501501a3741c5b8da8c9b06e..29133c7c7ff100c6d13ae6dc3b9d69bc8dd997d4 100644 (file)
@@ -444,3 +444,19 @@ namespace PR7095 {
   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);
+  }
+}