diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-09-22 19:53:15 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-09-22 19:53:15 +0000 |
commit | 455acd9452f5b2a69d7ab8e53f733e46b500473a (patch) | |
tree | 426c4e40ec0b2f828b1a82828def0a2e0f77b551 /lib | |
parent | fb5704295c6137685a7b90b92cd6b958028740c8 (diff) |
Issue good ambiguity diagnostic when convesion fails.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82565 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 063b387fba..f7a5cb9b1b 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -1983,10 +1983,19 @@ bool Sema::PerformCopyInitialization(Expr *&From, QualType ToType, if (!PerformImplicitConversion(From, ToType, Flavor, /*AllowExplicit=*/false, Elidable)) return false; - - return Diag(From->getSourceRange().getBegin(), - diag::err_typecheck_convert_incompatible) - << ToType << From->getType() << Flavor << From->getSourceRange(); + ImplicitConversionSequence ICS; + OverloadCandidateSet CandidateSet; + if (IsUserDefinedConversion(From, ToType, ICS.UserDefined, + CandidateSet, + true, false, false) != OR_Ambiguous) + return Diag(From->getSourceRange().getBegin(), + diag::err_typecheck_convert_incompatible) + << ToType << From->getType() << Flavor << From->getSourceRange(); + Diag(From->getSourceRange().getBegin(), + diag::err_typecheck_ambiguous_condition) + << From->getType() << ToType << From->getSourceRange(); + PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/false); + return true; } /// TryObjectArgumentInitialization - Try to initialize the object @@ -2104,13 +2113,13 @@ bool Sema::PerformContextuallyConvertToBool(Expr *&From) { OverloadCandidateSet CandidateSet; if (IsUserDefinedConversion(From, Context.BoolTy, ICS.UserDefined, CandidateSet, - true, true, false) != OR_Ambiguous) + true, false, false) != OR_Ambiguous) return Diag(From->getSourceRange().getBegin(), diag::err_typecheck_bool_condition) << From->getType() << From->getSourceRange(); Diag(From->getSourceRange().getBegin(), - diag::err_typecheck_ambiguous_bool_condition) - << From->getType() << From->getSourceRange(); + diag::err_typecheck_ambiguous_condition) + << From->getType() << Context.BoolTy << From->getSourceRange(); PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/false); return true; } |