]> granicus.if.org Git - clang/commitdiff
There is no pointer conversion between to similar types (i.e., same
authorDouglas Gregor <dgregor@apple.com>
Wed, 18 Aug 2010 21:25:30 +0000 (21:25 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 18 Aug 2010 21:25:30 +0000 (21:25 +0000)
type ignoring cv-qualifiers). These are qualification
conversions. Fixes PR7934.

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

lib/Sema/SemaOverload.cpp
test/SemaCXX/conversion-function.cpp

index 8a0732702b94965620a1acdef9955adfc3d27b73..694975546cd50cf5bb1eb51eef37a20a9c00ab04 100644 (file)
@@ -1406,6 +1406,11 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
 
   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).
index 73b78f414a59242b88c285cf30df3084baf74b32..951cdb3f51ac93050980023ccc9990a7ba8c3181 100644 (file)
@@ -248,3 +248,25 @@ namespace PR7055 {
   
   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);
+  }
+}