]> granicus.if.org Git - clang/commitdiff
Don't report ambiguities in the user-defined conversion if we weren't supposed
authorJohn McCall <rjmccall@apple.com>
Wed, 13 Jan 2010 22:30:33 +0000 (22:30 +0000)
committerJohn McCall <rjmccall@apple.com>
Wed, 13 Jan 2010 22:30:33 +0000 (22:30 +0000)
to be considering user-defined conversions in the first place.

Doug, please review;  I'm not sure what we should be doing if we see a real
ambiguity in selecting a copy constructor when otherwise suppressing
user-defined conversions.

Fixes PR6014.

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

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

index ffcf8d4609ac85cc04f7ddaea532364866d62f53..5abca9989681541c81e628b7452e7f9ae155ac7e 100644 (file)
@@ -493,7 +493,7 @@ Sema::TryImplicitConversion(Expr* From, QualType ToType,
       ICS.setBad();
       ICS.Bad.init(BadConversionSequence::suppressed_user, From, ToType);
     }
-  } else if (UserDefResult == OR_Ambiguous) {
+  } else if (UserDefResult == OR_Ambiguous && !SuppressUserConversions) {
     ICS.setAmbiguous();
     ICS.Ambiguous.setFromType(From->getType());
     ICS.Ambiguous.setToType(ToType);
index 0a2508d4b8067e95360d0578c6fb3b84b886d8f5..acd1e50afe44e6e56220ff51216bffe505d5a60b 100644 (file)
@@ -317,3 +317,19 @@ namespace test1 {
   }
 }
 
+// PR 6014
+namespace test2 {
+  struct QFixed {
+    QFixed(int i);
+    QFixed(long i);
+  };
+
+  bool operator==(const QFixed &f, int i);
+
+  class qrgb666 {
+    inline operator unsigned int () const;
+
+    inline bool operator==(const qrgb666 &v) const;
+    inline bool operator!=(const qrgb666 &v) const { return !(*this == v); }
+  };
+}