When printing an overload candidate that is a function template specialization,

point at the template and print out its template arguments, e.g.,

ambiguous-ovl-print.cpp:5:8: note: candidate function template specialization
      [with T = int]
  void f(T*, long);

llvm-svn: 81907
This commit is contained in:
Douglas Gregor 2009-09-15 20:11:42 +00:00
parent 42d25debb4
commit 4fb9cde8ef
3 changed files with 18 additions and 0 deletions

View File

@ -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">;

View File

@ -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!

View File

@ -0,0 +1,9 @@
// RUN: clang-cc -fsyntax-only -verify %s
void f(void*, int); // expected-note{{candidate function}}
template<typename T>
void f(T*, long); // expected-note{{candidate function template}}
void test_f(int *ip, int i) {
f(ip, i); // expected-error{{ambiguous}}
}