]> granicus.if.org Git - clang/commitdiff
When emitting a "too many arguments to function call..." error, also include a note...
authorTed Kremenek <kremenek@apple.com>
Mon, 4 Apr 2011 17:22:27 +0000 (17:22 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 4 Apr 2011 17:22:27 +0000 (17:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128833 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaExpr.cpp
test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp
test/Sema/exprs.c
test/Sema/function-redecl.c

index 6e0bec2f1fe4f24d16ee34d4ed413e8b99bf2e58..4a3391c59eb9d62cd169a96183e73c3f890c1e74 100644 (file)
@@ -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">;
index 9ebc7de84d333344697c89d605879616292811f4..55155efa696290772d3df7cbad93bb746786e42f 100644 (file)
@@ -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;
index 0c905fbf325d704be23d0bda1dd60b7eb8a4e1a7..cee7c0242033372197b2251f77db35c6839dd41b 100644 (file)
@@ -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);
index 86cd52ec636244159103837eb1142d2ce721d7dc..d7cbbad4aa16646ed8ab21680c771139972f7f28 100644 (file)
@@ -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}}
index 27ec163ea9cb8154d09ce74dcb4975bd1629edd3..7076bdf3bd1fff1545e70bddaf6bdb6ecea202c1 100644 (file)
@@ -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}}