From 19dc6d015261862f1335587ab362f79a89dfc0c9 Mon Sep 17 00:00:00 2001 From: Nicola Pero Date: Thu, 23 Sep 2010 22:21:39 +0000 Subject: [PATCH] In gcc/: * c-typeck.c (convert_arguments): Use warning 'too many arguments to method [methodname]' for an Objective-C method instead of the less satisfactory 'too many arguments to function' (with no method name). In gcc/cp/: * typeck.c (warn_args_num): Use warning 'too many arguments to method [methodname]' for an Objective-C method instead of the less satisfactory 'too many arguments to function' (with no method name). In gcc/testsuite/: * obj-c++.dg/too-many-args.mm: New file. Merge from 'apple/trunk' branch on FSF servers. 2006-03-27 Fariborz Jahanian Radar 4491608 * objc.dg/too-many-args.m: New From-SVN: r164573 --- gcc/ChangeLog | 7 +++++++ gcc/c-typeck.c | 9 +++++++-- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/typeck.c | 13 +++++++++++-- gcc/testsuite/ChangeLog | 13 +++++++++++++ gcc/testsuite/obj-c++.dg/too-many-args.mm | 10 ++++++++++ gcc/testsuite/objc.dg/too-many-args.m | 10 ++++++++++ 7 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/obj-c++.dg/too-many-args.mm create mode 100644 gcc/testsuite/objc.dg/too-many-args.m diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 01019ce11048..d23732f7ea60 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2010-09-24 Nicola Pero + + * c-typeck.c (convert_arguments): Use warning 'too many arguments + to method [methodname]' for an Objective-C method instead of the + less satisfactory 'too many arguments to function' (with no method + name). + 2010-09-23 Eric Botcazou * tree-flow.h (execute_update_addresses_taken): Remove parameter. diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 7ac866abfeb2..065e9b802c76 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -2897,8 +2897,13 @@ convert_arguments (tree typelist, VEC(tree,gc) *values, if (type == void_type_node) { - error_at (input_location, - "too many arguments to function %qE", function); + if (selector) + error_at (input_location, + "too many arguments to method %qE", selector); + else + error_at (input_location, + "too many arguments to function %qE", function); + if (fundecl && !DECL_BUILT_IN (fundecl)) inform (DECL_SOURCE_LOCATION (fundecl), "declared here"); return parmnum; diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3994a3a45848..95613b05047b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2010-09-24 Nicola Pero + + * typeck.c (warn_args_num): Use warning 'too many arguments to + method [methodname]' for an Objective-C method instead of the less + satisfactory 'too many arguments to function' (with no method + name). + 2010-09-21 Jason Merrill * mangle.c (write_expression) [SCOPE_REF]: Only do -fabi-version=1 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 0ac95d05b697..019c51eed856 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3428,8 +3428,17 @@ warn_args_num (location_t loc, tree fndecl, bool too_many_p) "declared here"); } else - error_at (loc, too_many_p ? G_("too many arguments to function") - : G_("too few arguments to function")); + { + if (c_dialect_objc () && objc_message_selector ()) + error_at (loc, + too_many_p + ? G_("too many arguments to method %q#D") + : G_("too few arguments to method %q#D"), + objc_message_selector ()); + else + error_at (loc, too_many_p ? G_("too many arguments to function") + : G_("too few arguments to function")); + } } /* Convert the actual parameter expressions in the list VALUES to the diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3773f07bc287..649c269979f0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,16 @@ +2010-09-24 Nicola Pero + + * obj-c++.dg/too-many-args.mm: New file. + +2010-09-24 Nicola Pero + + Merge from 'apple/trunk' branch on FSF servers. + + 2006-03-27 Fariborz Jahanian + + Radar 4491608 + * objc.dg/too-many-args.m: New + 2010-09-23 Thomas Koenig PR fortran/45744 diff --git a/gcc/testsuite/obj-c++.dg/too-many-args.mm b/gcc/testsuite/obj-c++.dg/too-many-args.mm new file mode 100644 index 000000000000..6fee1b31bd53 --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/too-many-args.mm @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +@interface SomeClass ++ method:(int)foo; +@end + +int main(void) { + [SomeClass method:3, 4]; /* { dg-error "too many arguments to method \\'method:\\'" } */ + return 0; +} diff --git a/gcc/testsuite/objc.dg/too-many-args.m b/gcc/testsuite/objc.dg/too-many-args.m new file mode 100644 index 000000000000..6fee1b31bd53 --- /dev/null +++ b/gcc/testsuite/objc.dg/too-many-args.m @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +@interface SomeClass ++ method:(int)foo; +@end + +int main(void) { + [SomeClass method:3, 4]; /* { dg-error "too many arguments to method \\'method:\\'" } */ + return 0; +}