]> granicus.if.org Git - clang/commitdiff
When printing an overload candidate that is a function template specialization,
authorDouglas Gregor <dgregor@apple.com>
Tue, 15 Sep 2009 20:11:42 +0000 (20:11 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 15 Sep 2009 20:11:42 +0000 (20:11 +0000)
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);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81907 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaOverload.cpp
test/SemaTemplate/ambiguous-ovl-print.cpp [new file with mode: 0644]

index 6a8ad5c6177e00354def33106d8f7f8edfa3e380..bd59436dcf43179fb98efeddc590a74f8a5c451c 100644 (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">;
index cda7c829689746a4011e7ed94152a8d740a2c497..33766f9a79653d31fbdc088d3a14705b6a98a2ee 100644 (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!
diff --git a/test/SemaTemplate/ambiguous-ovl-print.cpp b/test/SemaTemplate/ambiguous-ovl-print.cpp
new file mode 100644 (file)
index 0000000..ccdeb9b
--- /dev/null
@@ -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}}
+}