summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.td4
-rw-r--r--clang/lib/Sema/SemaExpr.cpp17
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp2
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp2
-rw-r--r--clang/test/PCH/functions.c2
-rw-r--r--clang/test/Sema/exprs.c2
6 files changed, 18 insertions, 11 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 7f660e1a279..83f232e8765 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/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/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 9019e95747d..bfaf5460361 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/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/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp
index 9d26561ca8d..385e45dadfa 100644
--- a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp
+++ b/clang/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/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
index b2129b259bb..f3dec52f63b 100644
--- a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
+++ b/clang/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/clang/test/PCH/functions.c b/clang/test/PCH/functions.c
index 23becb60e8e..35e39210585 100644
--- a/clang/test/PCH/functions.c
+++ b/clang/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/clang/test/Sema/exprs.c b/clang/test/Sema/exprs.c
index 9ce1481f16c..460f72cb174 100644
--- a/clang/test/Sema/exprs.c
+++ b/clang/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}}
OpenPOWER on IntegriCloud