When emitting a "too many arguments to function call..." error, also include a note with a location for the function prototype.
llvm-svn: 128833
This commit is contained in:
parent
bda3632bcd
commit
99a337eed0
|
@ -3180,6 +3180,8 @@ def err_typecheck_call_too_few_args_at_least : Error<
|
|||
def err_typecheck_call_too_many_args : Error<
|
||||
"too many arguments to %select{function|block|method}0 call, "
|
||||
"expected %1, have %2">;
|
||||
def note_typecheck_call_too_many_args : Note<
|
||||
"%0 declared here">;
|
||||
def err_typecheck_call_too_many_args_at_most : Error<
|
||||
"too many arguments to %select{function|block|method}0 call, "
|
||||
"expected at most %1, have %2">;
|
||||
|
|
|
@ -4385,6 +4385,13 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
|
|||
<< NumArgsInProto << NumArgs << Fn->getSourceRange()
|
||||
<< SourceRange(Args[NumArgsInProto]->getLocStart(),
|
||||
Args[NumArgs-1]->getLocEnd());
|
||||
|
||||
// Emit the location of the prototype.
|
||||
if (FDecl && !FDecl->getBuiltinID())
|
||||
Diag(FDecl->getLocStart(),
|
||||
diag::note_typecheck_call_too_many_args)
|
||||
<< FDecl;
|
||||
|
||||
// This deletes the extra arguments.
|
||||
Call->setNumArgs(Context, NumArgsInProto);
|
||||
return true;
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace M {
|
|||
struct Y : N::X { };
|
||||
}
|
||||
|
||||
void f();
|
||||
void f(); // expected-note 2 {{'f' declared here}}
|
||||
|
||||
void test_operator_adl(N::X x, M::Y y) {
|
||||
(void)(x + x);
|
||||
|
|
|
@ -163,7 +163,7 @@ void test17(int x) {
|
|||
}
|
||||
|
||||
// PR6501
|
||||
void test18_a(int a);
|
||||
void test18_a(int a); // expected-note {{'test18_a' declared here}}
|
||||
void test18(int b) {
|
||||
test18_a(b, b); // expected-error {{too many arguments to function call, expected 1, have 2}}
|
||||
test18_a(); // expected-error {{too few arguments to function call, expected 1, have 0}}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// PR3588
|
||||
void g0(int, int);
|
||||
void g0(); // expected-note{{previous declaration is here}}
|
||||
void g0(); // expected-note{{previous declaration is here}} expected-note{{'g0' declared here}}
|
||||
|
||||
void f0() {
|
||||
g0(1, 2, 3); // expected-error{{too many arguments to function call}}
|
||||
|
|
Loading…
Reference in New Issue