aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-05-25 15:31:05 +0000
committerDouglas Gregor <dgregor@apple.com>2010-05-25 15:31:05 +0000
commitaf7bea5fb496921c386459dc695485490bb06963 (patch)
tree34ebd901265cb6cfcdafa6faef02f8405e0b681c
parentb453c530647acda78e6dc56d086e99566e59e5b1 (diff)
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
-rw-r--r--lib/Sema/SemaOverload.cpp2
-rw-r--r--test/SemaCXX/overload-call.cpp16
2 files changed, 17 insertions, 1 deletions
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);
+ }
+}