Author: rjmccall
Date: Wed Jan 13 18:56:20 2010
New Revision: 93395
URL: http://llvm.org/viewvc/llvm-project?rev=93395&view=rev
Log:
Improve the diagnostic for bad conversions in overload resolution to talk
about 'object argument' vs. 'nth argument'.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/overload-call.cpp
cfe/trunk/test/SemaCXX/overload-member-call.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=93395&r1=93394&r2=93395&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jan 13 18:56:20
2010
@@ -923,7 +923,8 @@
"constructor (the implicit default constructor)|"
"constructor (the implicit copy constructor)|"
"function (the implicit copy assignment operator)}0%1"
- " not viable: no known conversion from %2 to %3 for argument %4">;
+ " not viable: no known conversion from %2 to %3 for "
+ "%select{%ordinal5 argument|object argument}4">;
def note_ambiguous_type_conversion: Note<
"because of ambiguity in conversion of %0 to %1">;
def note_ovl_builtin_binary_candidate : Note<
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=93395&r1=93394&r2=93395&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Jan 13 18:56:20 2010
@@ -4388,7 +4388,7 @@
S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_conv)
<< (unsigned) FnKind << FnDesc
<< (FromExpr ? FromExpr->getSourceRange() : SourceRange())
- << FromTy << ToTy << I+1;
+ << FromTy << ToTy << (unsigned) isObjectArgument << I+1;
}
void DiagnoseArityMismatch(Sema &S, OverloadCandidate *Cand,
Modified: cfe/trunk/test/SemaCXX/overload-call.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overload-call.cpp?rev=93395&r1=93394&r2=93395&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/overload-call.cpp (original)
+++ cfe/trunk/test/SemaCXX/overload-call.cpp Wed Jan 13 18:56:20 2010
@@ -304,8 +304,8 @@
// Tests the exact text used to note the candidates
namespace test1 {
- template <class T> void foo(T t, unsigned N); // expected-note {{candidate
function [with T = int] not viable: no known conversion from 'char const [6]'
to 'unsigned int' for argument 2}}
- void foo(int n, char N); // expected-note {{candidate function not viable:
no known conversion from 'char const [6]' to 'char' for argument 2}}
+ template <class T> void foo(T t, unsigned N); // expected-note {{candidate
function [with T = int] not viable: no known conversion from 'char const [6]'
to 'unsigned int' for 2nd argument}}
+ void foo(int n, char N); // expected-note {{candidate function not viable:
no known conversion from 'char const [6]' to 'char' for 2nd argument}}
void foo(int n); // expected-note {{candidate function not viable: requires
1 argument, but 2 were provided}}
void foo(unsigned n = 10); // expected-note {{candidate function not viable:
requires at most 1 argument, but 2 were provided}}
void foo(int n, const char *s, int t); // expected-note {{candidate function
not viable: requires 3 arguments, but 2 were provided}}
Modified: cfe/trunk/test/SemaCXX/overload-member-call.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overload-member-call.cpp?rev=93395&r1=93394&r2=93395&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/overload-member-call.cpp (original)
+++ cfe/trunk/test/SemaCXX/overload-member-call.cpp Wed Jan 13 18:56:20 2010
@@ -70,18 +70,24 @@
// Tests the exact text used to note the candidates
namespace test1 {
class A {
- template <class T> void foo(T t, unsigned N); // expected-note {{candidate
function [with T = int] not viable: no known conversion from 'char const [6]'
to 'unsigned int' for argument 2}}
- void foo(int n, char N); // expected-note {{candidate function not viable:
no known conversion from 'char const [6]' to 'char' for argument 2}}
+ template <class T> void foo(T t, unsigned N); // expected-note {{candidate
function [with T = int] not viable: no known conversion from 'char const [6]'
to 'unsigned int' for 2nd argument}}
+ void foo(int n, char N); // expected-note {{candidate function not viable:
no known conversion from 'char const [6]' to 'char' for 2nd argument}}
void foo(int n); // expected-note {{candidate function not viable:
requires 1 argument, but 2 were provided}}
void foo(unsigned n = 10); // expected-note {{candidate function not
viable: requires at most 1 argument, but 2 were provided}}
void foo(int n, const char *s, int t); // expected-note {{candidate
function not viable: requires 3 arguments, but 2 were provided}}
void foo(int n, const char *s, int t, ...); // expected-note {{candidate
function not viable: requires at least 3 arguments, but 2 were provided}}
void foo(int n, const char *s, int t, int u = 0); // expected-note
{{candidate function not viable: requires at least 3 arguments, but 2 were
provided}}
+
+ void bar(double d); //expected-note {{candidate function not viable: no
known conversion from 'class test1::A const' to 'class test1::A' for object
argument}}
+ void bar(int i); //expected-note {{candidate function not viable: no known
conversion from 'class test1::A const' to 'class test1::A' for object argument}}
};
void test() {
A a;
a.foo(4, "hello"); //expected-error {{no matching member function for call
to 'foo'}}
+
+ const A b;
+ b.bar(0); //expected-error {{no matching member function for call to
'bar'}}
}
}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits