[cfe-commits] r128833 - in /cfe/trunk: 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
Ted Kremenek
kremenek at apple.com
Mon Apr 4 10:22:27 PDT 2011
Author: kremenek
Date: Mon Apr 4 12:22:27 2011
New Revision: 128833
URL: http://llvm.org/viewvc/llvm-project?rev=128833&view=rev
Log:
When emitting a "too many arguments to function call..." error, also include a note with a location for the function prototype.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp
cfe/trunk/test/Sema/exprs.c
cfe/trunk/test/Sema/function-redecl.c
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=128833&r1=128832&r2=128833&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Apr 4 12:22:27 2011
@@ -3180,6 +3180,8 @@
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">;
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=128833&r1=128832&r2=128833&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Apr 4 12:22:27 2011
@@ -4385,6 +4385,13 @@
<< 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;
Modified: cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp?rev=128833&r1=128832&r2=128833&view=diff
==============================================================================
--- cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp (original)
+++ cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp Mon Apr 4 12:22:27 2011
@@ -17,7 +17,7 @@
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);
Modified: cfe/trunk/test/Sema/exprs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/exprs.c?rev=128833&r1=128832&r2=128833&view=diff
==============================================================================
--- cfe/trunk/test/Sema/exprs.c (original)
+++ cfe/trunk/test/Sema/exprs.c Mon Apr 4 12:22:27 2011
@@ -163,7 +163,7 @@
}
// 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}}
Modified: cfe/trunk/test/Sema/function-redecl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/function-redecl.c?rev=128833&r1=128832&r2=128833&view=diff
==============================================================================
--- cfe/trunk/test/Sema/function-redecl.c (original)
+++ cfe/trunk/test/Sema/function-redecl.c Mon Apr 4 12:22:27 2011
@@ -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}}
More information about the cfe-commits
mailing list