diff options
| author | John McCall <rjmccall@apple.com> | 2010-02-02 02:42:52 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2010-02-02 02:42:52 +0000 |
| commit | fb7ad0f57a0cbecb76085017e3a4581f29b75e4f (patch) | |
| tree | da6b55251c2dec51014f6ce3c0b03917b3e6a157 | |
| parent | 372688757b6726c7e3848f6b4be9f94c3252a822 (diff) | |
| download | bcm5719-llvm-fb7ad0f57a0cbecb76085017e3a4581f29b75e4f.tar.gz bcm5719-llvm-fb7ad0f57a0cbecb76085017e3a4581f29b75e4f.zip | |
Improve the diagnostic used when an incompatible overload set is passed
as an argument during overload resolution.
llvm-svn: 95057
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 7 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 18 | ||||
| -rw-r--r-- | clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp | 2 |
3 files changed, 26 insertions, 1 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 78b791c971c..b5d378d0e35 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -957,6 +957,13 @@ def note_ovl_candidate_bad_conv_incomplete : Note<"candidate " "constructor (the implicit copy constructor)|" "function (the implicit copy assignment operator)}0%1 " "not viable: cannot convert argument of incomplete type %2 to %3">; +def note_ovl_candidate_bad_overload : Note<"candidate " + "%select{function|function|constructor|" + "function |function |constructor |" + "constructor (the implicit default constructor)|" + "constructor (the implicit copy constructor)|" + "function (the implicit copy assignment operator)}0%1" + " not viable: no overload of %3 matching %2 for %ordinal4 argument">; def note_ovl_candidate_bad_conv : Note<"candidate " "%select{function|function|constructor|" "function |function |constructor |" diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 1eb5b38889e..83cbce72261 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -4450,6 +4450,24 @@ void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand, unsigned I) { QualType FromTy = Conv.Bad.getFromType(); QualType ToTy = Conv.Bad.getToType(); + if (FromTy == S.Context.OverloadTy) { + assert(FromExpr); + Expr *E = FromExpr->IgnoreParens(); + if (isa<UnaryOperator>(E)) + E = cast<UnaryOperator>(E)->getSubExpr()->IgnoreParens(); + DeclarationName Name; + if (isa<UnresolvedLookupExpr>(E)) + Name = cast<UnresolvedLookupExpr>(E)->getName(); + else + Name = cast<UnresolvedMemberExpr>(E)->getMemberName(); + + S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_overload) + << (unsigned) FnKind << FnDesc + << (FromExpr ? FromExpr->getSourceRange() : SourceRange()) + << ToTy << Name << I+1; + return; + } + // Do some hand-waving analysis to see if the non-viability is due // to a qualifier mismatch. CanQualType CFromTy = S.Context.getCanonicalType(FromTy); diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp index c1fc696baf5..8f919f53159 100644 --- a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp +++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp @@ -3,7 +3,7 @@ namespace test0 { // FIXME: this second note is horrible. template<class T> void apply(T x, void (*f)(T)) { f(x); } // expected-note 2 {{failed template argument deduction}}\ - // expected-note {{no known conversion from '<overloaded function type>' to 'void (*)(int)'}} + // expected-note {{no overload of 'temp2' matching 'void (*)(int)'}} template<class A> void temp(A); void test0() { |

