[cfe-commits] r111428 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/conversion-function.cpp
Douglas Gregor
dgregor at apple.com
Wed Aug 18 14:25:30 PDT 2010
Author: dgregor
Date: Wed Aug 18 16:25:30 2010
New Revision: 111428
URL: http://llvm.org/viewvc/llvm-project?rev=111428&view=rev
Log:
There is no pointer conversion between to similar types (i.e., same
type ignoring cv-qualifiers). These are qualification
conversions. Fixes PR7934.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/conversion-function.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=111428&r1=111427&r2=111428&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Aug 18 16:25:30 2010
@@ -1406,6 +1406,11 @@
QualType FromPointeeType = FromTypePtr->getPointeeType();
+ // If the unqualified pointee types are the same, this can't be a
+ // pointer conversion, so don't do all of the work below.
+ if (Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType))
+ return false;
+
// An rvalue of type "pointer to cv T," where T is an object type,
// can be converted to an rvalue of type "pointer to cv void" (C++
// 4.10p2).
Modified: cfe/trunk/test/SemaCXX/conversion-function.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/conversion-function.cpp?rev=111428&r1=111427&r2=111428&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/conversion-function.cpp (original)
+++ cfe/trunk/test/SemaCXX/conversion-function.cpp Wed Aug 18 16:25:30 2010
@@ -248,3 +248,25 @@
Y f2(foo());
}
+
+namespace PR7934 {
+ typedef unsigned char uint8;
+
+ struct MutablePtr {
+ MutablePtr() : ptr(0) {}
+ void *ptr;
+
+ operator void*() { return ptr; }
+
+ private:
+ operator uint8*() { return reinterpret_cast<uint8*>(ptr); }
+ operator const char*() const { return reinterpret_cast<const char*>(ptr); }
+ };
+
+ void fake_memcpy(const void *);
+
+ void use() {
+ MutablePtr ptr;
+ fake_memcpy(ptr);
+ }
+}
More information about the cfe-commits
mailing list