From: Douglas Gregor Date: Tue, 25 May 2010 15:31:05 +0000 (+0000) Subject: Make sure to strip off top-level cv-qualifiers as part of a X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=af7bea5fb496921c386459dc695485490bb06963;p=clang Make sure to strip off top-level cv-qualifiers as part of a 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 --- diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 6c64905561..2754d443b2 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -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. diff --git a/test/SemaCXX/overload-call.cpp b/test/SemaCXX/overload-call.cpp index 9618ea2249..29133c7c7f 100644 --- a/test/SemaCXX/overload-call.cpp +++ b/test/SemaCXX/overload-call.cpp @@ -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); + } +}