From 38e514c017e1ce7dfe9af7e81d104deb1a9f5a1a Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Fri, 25 Apr 2014 08:22:47 +0000 Subject: [PATCH] re PR c/60156 (GCC doesn't warn about variadic main) PR c/60156 * c-common.c (check_main_parameter_types): Warn about variadic main. * c-c++-common/pr60156.c: New test. From-SVN: r209787 --- gcc/c-family/ChangeLog | 5 +++++ gcc/c-family/c-common.c | 4 ++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/c-c++-common/pr60156.c | 9 +++++++++ 4 files changed, 23 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/pr60156.c diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 34a58647ad7..9d5ecc49be8 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2014-04-25 Marek Polacek + + PR c/60156 + * c-common.c (check_main_parameter_types): Warn about variadic main. + 2014-04-24 Mike Stump * c.opt (Wshadow-ivar): Default to on. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index a08c873c536..97d16c16dd7 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -2228,6 +2228,10 @@ check_main_parameter_types (tree decl) if (argct > 0 && (argct < 2 || argct > 3)) pedwarn (input_location, OPT_Wmain, "%q+D takes only zero or two arguments", decl); + + if (stdarg_p (TREE_TYPE (decl))) + pedwarn (input_location, OPT_Wmain, + "%q+D declared as variadic function", decl); } /* vector_targets_convertible_p is used for vector pointer types. The diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d11d70b3f16..d7a36775889 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-04-25 Marek Polacek + + PR c/60156 + * c-c++-common/pr60156.c: New test. + 2014-04-25 Richard Biener PR ipa/60912 diff --git a/gcc/testsuite/c-c++-common/pr60156.c b/gcc/testsuite/c-c++-common/pr60156.c new file mode 100644 index 00000000000..1e8204c99c7 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr60156.c @@ -0,0 +1,9 @@ +/* PR c/60156 */ +/* { dg-do compile } */ +/* { dg-options "-Wpedantic" } */ + +int +main (int argc, char *argv[], ...) /* { dg-warning "declared as variadic function" } */ +{ + return 0; +} -- 2.30.2