diff options
author | Marek Polacek <polacek@redhat.com> | 2014-04-25 08:22:47 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2014-04-25 08:22:47 +0000 |
commit | 38e514c017e1ce7dfe9af7e81d104deb1a9f5a1a (patch) | |
tree | 967dd3337f7d3cada265120a5b421177e26f1f5d | |
parent | e4012a04cddf147ef36a4b8d06f4f2c20571b3da (diff) | |
download | gcc-38e514c017e1ce7dfe9af7e81d104deb1a9f5a1a.zip gcc-38e514c017e1ce7dfe9af7e81d104deb1a9f5a1a.tar.gz gcc-38e514c017e1ce7dfe9af7e81d104deb1a9f5a1a.tar.bz2 |
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
-rw-r--r-- | gcc/c-family/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/pr60156.c | 9 |
4 files changed, 23 insertions, 0 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 34a5864..9d5ecc4 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2014-04-25 Marek Polacek <polacek@redhat.com> + + PR c/60156 + * c-common.c (check_main_parameter_types): Warn about variadic main. + 2014-04-24 Mike Stump <mikestump@comcast.net> * c.opt (Wshadow-ivar): Default to on. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index a08c873..97d16c1 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 d11d70b..d7a3677 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-04-25 Marek Polacek <polacek@redhat.com> + + PR c/60156 + * c-c++-common/pr60156.c: New test. + 2014-04-25 Richard Biener <rguenther@suse.de> 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 0000000..1e8204c --- /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; +} |