]> granicus.if.org Git - clang/commitdiff
Patch to clean up and improve visual display of
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 16 Oct 2009 23:25:02 +0000 (23:25 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 16 Oct 2009 23:25:02 +0000 (23:25 +0000)
builtin function ambiguity.

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

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaOverload.cpp
test/SemaCXX/ambiguous-builtin-unary-operator.cpp
test/SemaCXX/builtin-ptrtomember-ambig.cpp

index a38b8bc7d6d095d28753e180537c9a8f3021c723..d1b0445989fbc531e5133f752e45ee96bb61d688 100644 (file)
@@ -785,9 +785,9 @@ def err_ovl_template_candidate : Note<
 def err_ovl_candidate_deleted : Note<
   "candidate function has been explicitly %select{made unavailable|deleted}0">;
 def err_ovl_builtin_binary_candidate : Note<
-    "built-in candidate operator %0 (%1, %2)">;
+    "built-in candidate %0">;
 def err_ovl_builtin_unary_candidate : Note<
-    "built-in candidate operator %0 (%1)">;
+    "built-in candidate %0">;
 def err_ovl_no_viable_function_in_init : Error<
   "no matching constructor for initialization of %0">;
 def err_ovl_ambiguous_init : Error<"call to constructor of %0 is ambiguous">;
index a227dfba93aa9dc68cbba879cb554c820178a99a..ecadcd904e28aac28baba9f41adc7ea5aa1655fe 100644 (file)
@@ -4148,13 +4148,20 @@ Sema::PrintOverloadCandidates(OverloadCandidateSet& CandidateSet,
       } else if (OnlyViable) {
         assert(Cand->Conversions.size() <= 2 && 
                "builtin-binary-operator-not-binary");
-        if (Cand->Conversions.size() == 1)
-          Diag(OpLoc, diag::err_ovl_builtin_unary_candidate)
-                << Opc << Cand->BuiltinTypes.ParamTypes[0];
-        else
-          Diag(OpLoc, diag::err_ovl_builtin_binary_candidate)
-                << Opc << Cand->BuiltinTypes.ParamTypes[0]
-                << Cand->BuiltinTypes.ParamTypes[1];
+        std::string TypeStr("operator");
+        TypeStr += Opc;
+        TypeStr += "(";
+        TypeStr += Cand->BuiltinTypes.ParamTypes[0].getAsString();
+        if (Cand->Conversions.size() == 1) {
+          TypeStr += ")";
+          Diag(OpLoc, diag::err_ovl_builtin_unary_candidate) << TypeStr;
+        }
+        else {
+          TypeStr += ", ";
+          TypeStr += Cand->BuiltinTypes.ParamTypes[1].getAsString();
+          TypeStr += ")";
+          Diag(OpLoc, diag::err_ovl_builtin_binary_candidate) << TypeStr;
+        }
       }
       else if (!Cand->Viable && !Reported) {
         // Non-viability might be due to ambiguous user-defined conversions,
index 0c9433ff6ac43514f046f11943b46ee23d3cce49..5affd19a2fdf063b64a0dddb1d65a10984950b72 100644 (file)
@@ -14,10 +14,10 @@ struct C : B, A { };
 
 void test(C c) {
   ++c; // expected-error {{use of overloaded operator '++' is ambiguous}}\
-       // expected-note {{built-in candidate operator ++ ('int &')}} \
-       // expected-note {{built-in candidate operator ++ ('long &')}} \
-       // expected-note {{built-in candidate operator ++ ('long *&')}} \
-       // expected-note {{built-in candidate operator ++ ('int *&')}}
+       // expected-note {{built-in candidate operator++(int &)}} \
+       // expected-note {{built-in candidate operator++(long &)}} \
+       // expected-note {{built-in candidate operator++(long *&)}} \
+       // expected-note {{built-in candidate operator++(int *&)}}
 }
 
 struct A1 { operator volatile int&(); };
@@ -28,7 +28,7 @@ struct C1 : B1, A1 { };
 
 void test(C1 c) {
   ++c; // expected-error {{use of overloaded operator '++' is ambiguous}} \
-       // expected-note {{built-in candidate operator ++ ('int volatile &')}} \
-       // expected-note {{built-in candidate operator ++ ('long volatile &')}}
+       // expected-note {{built-in candidate operator++(int volatile &)}} \
+       // expected-note {{built-in candidate operator++(long volatile &)}}
 }
 
index 34652474f3b32f4353474031bd0fd7e9065ee4b0..1b52651910d951358354c6b1eee680365db773f2 100644 (file)
@@ -19,9 +19,9 @@ struct C : B {
 void foo(C c, int A::* pmf) {
                                        // FIXME. Why so many built-in candidates?
        int i = c->*pmf;        // expected-error {{use of overloaded operator '->*' is ambiguous}} \
-                               // expected-note {{built-in candidate operator ->* ('struct A const *', 'int const struct A::*')}} \
-                               // expected-note {{built-in candidate operator ->* ('struct A const *', 'int struct A::*')}} \
-                               // expected-note {{built-in candidate operator ->* ('struct A *', 'int const struct A::*')}} \
-                               // expected-note {{built-in candidate operator ->* ('struct A *', 'int struct A::*')}}
+                               // expected-note {{built-in candidate operator->*(struct A const *, int const struct A::*)}} \
+                               // expected-note {{built-in candidate operator->*(struct A const *, int struct A::*)}} \
+                               // expected-note {{built-in candidate operator->*(struct A *, int const struct A::*)}} \
+                               // expected-note {{built-in candidate operator->*(struct A *, int struct A::*)}}
 }