diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 6a8ad5c6177e..bd59436dcf43 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -761,6 +761,8 @@ def err_ovl_ambiguous_member_call : Error< def err_ovl_deleted_member_call : Error< "call to %select{unavailable|deleted}0 member function %1">; def err_ovl_candidate : Note<"candidate function">; +def err_ovl_template_candidate : Note< + "candidate function template specialization %0">; def err_ovl_candidate_deleted : Note< "candidate function has been explicitly %select{made unavailable|deleted}0">; def err_ovl_builtin_candidate : Note<"built-in candidate function %0">; diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index cda7c8296897..33766f9a7965 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -3831,6 +3831,13 @@ Sema::PrintOverloadCandidates(OverloadCandidateSet& CandidateSet, // Deleted or "unavailable" function. Diag(Cand->Function->getLocation(), diag::err_ovl_candidate_deleted) << Cand->Function->isDeleted(); + } else if (FunctionTemplateDecl *FunTmpl + = Cand->Function->getPrimaryTemplate()) { + // Function template specialization + // FIXME: Give a better reason! + Diag(Cand->Function->getLocation(), diag::err_ovl_template_candidate) + << getTemplateArgumentBindingsText(FunTmpl->getTemplateParameters(), + *Cand->Function->getTemplateSpecializationArgs()); } else { // Normal function // FIXME: Give a better reason! diff --git a/clang/test/SemaTemplate/ambiguous-ovl-print.cpp b/clang/test/SemaTemplate/ambiguous-ovl-print.cpp new file mode 100644 index 000000000000..ccdeb9bebc57 --- /dev/null +++ b/clang/test/SemaTemplate/ambiguous-ovl-print.cpp @@ -0,0 +1,9 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +void f(void*, int); // expected-note{{candidate function}} +template + void f(T*, long); // expected-note{{candidate function template}} + +void test_f(int *ip, int i) { + f(ip, i); // expected-error{{ambiguous}} +}