[cfe-commits] r81907 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaOverload.cpp test/SemaTemplate/ambiguous-ovl-print.cpp

Douglas Gregor dgregor at apple.com
Tue Sep 15 13:11:42 PDT 2009


Author: dgregor
Date: Tue Sep 15 15:11:42 2009
New Revision: 81907

URL: http://llvm.org/viewvc/llvm-project?rev=81907&view=rev
Log:
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);



Added:
    cfe/trunk/test/SemaTemplate/ambiguous-ovl-print.cpp
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=81907&r1=81906&r2=81907&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Sep 15 15:11:42 2009
@@ -761,6 +761,8 @@
 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">;

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=81907&r1=81906&r2=81907&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Sep 15 15:11:42 2009
@@ -3831,6 +3831,13 @@
           // 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!

Added: cfe/trunk/test/SemaTemplate/ambiguous-ovl-print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/ambiguous-ovl-print.cpp?rev=81907&view=auto

==============================================================================
--- cfe/trunk/test/SemaTemplate/ambiguous-ovl-print.cpp (added)
+++ cfe/trunk/test/SemaTemplate/ambiguous-ovl-print.cpp Tue Sep 15 15:11:42 2009
@@ -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}}
+}





More information about the cfe-commits mailing list