From: John McCall Date: Wed, 13 Jan 2010 22:30:33 +0000 (+0000) Subject: Don't report ambiguities in the user-defined conversion if we weren't supposed X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cefd3ada97faf5a759dac4705900053d3aa071e9;p=clang Don't report ambiguities in the user-defined conversion if we weren't supposed 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 --- diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index ffcf8d4609..5abca99896 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -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); diff --git a/test/SemaCXX/overload-call.cpp b/test/SemaCXX/overload-call.cpp index 0a2508d4b8..acd1e50afe 100644 --- a/test/SemaCXX/overload-call.cpp +++ b/test/SemaCXX/overload-call.cpp @@ -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); } + }; +}