diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 7f660e1a27..83f232e876 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -3696,11 +3696,11 @@ 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">; +def note_callee_decl : Note< + "%0 declared here">; def warn_call_wrong_number_of_arguments : Warning< "too %select{few|many}0 arguments in call to %1">; def err_atomic_builtin_must_be_pointer : Error< diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 9019e95747..bfaf546036 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -3231,10 +3231,18 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, // If too few arguments are available (and we don't have default // arguments for the remaining parameters), don't make the call. if (NumArgs < NumArgsInProto) { - if (!FDecl || NumArgs < FDecl->getMinRequiredArguments()) - return Diag(RParenLoc, diag::err_typecheck_call_too_few_args) + if (!FDecl || NumArgs < FDecl->getMinRequiredArguments()) { + Diag(RParenLoc, diag::err_typecheck_call_too_few_args) << Fn->getType()->isBlockPointerType() << NumArgsInProto << NumArgs << Fn->getSourceRange(); + + // Emit the location of the prototype. + if (FDecl && !FDecl->getBuiltinID()) + Diag(FDecl->getLocStart(), diag::note_callee_decl) + << FDecl; + + return true; + } Call->setNumArgs(Context, NumArgsInProto); } @@ -3251,9 +3259,8 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, // Emit the location of the prototype. if (FDecl && !FDecl->getBuiltinID()) - Diag(FDecl->getLocStart(), - diag::note_typecheck_call_too_many_args) - << FDecl; + Diag(FDecl->getLocStart(), diag::note_callee_decl) + << FDecl; // This deletes the extra arguments. Call->setNumArgs(Context, NumArgsInProto); diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp index 9d26561ca8..385e45dadf 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp @@ -5,7 +5,7 @@ struct A { }; struct B : public A { - void f(int a); + void f(int a); // expected-note{{'f' declared here}} }; void m() { diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp index b2129b259b..f3dec52f63 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp @@ -41,7 +41,7 @@ namespace N1 { void m() { - void f(int, int); + void f(int, int); // expected-note{{'f' declared here}} f(4); // expected-error{{too few arguments to function call}} void f(int, int = 5); // expected-note{{previous definition}} f(4); // okay diff --git a/test/PCH/functions.c b/test/PCH/functions.c index 23becb60e8..35e3921058 100644 --- a/test/PCH/functions.c +++ b/test/PCH/functions.c @@ -4,7 +4,7 @@ // Test with pch. // RUN: %clang_cc1 -emit-pch -o %t %S/functions.h // RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s - +// expected-note{{'f1' declared here}} int f0(int x0, int y0, ...) { return x0 + y0; } // expected-note{{passing argument to parameter here}} float *test_f1(int val, double x, double y) { diff --git a/test/Sema/exprs.c b/test/Sema/exprs.c index 9ce1481f16..460f72cb17 100644 --- a/test/Sema/exprs.c +++ b/test/Sema/exprs.c @@ -163,7 +163,7 @@ void test17(int x) { } // PR6501 -void test18_a(int a); // expected-note {{'test18_a' declared here}} +void test18_a(int a); // expected-note 2 {{'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}}