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
This commit is contained in:
Marek Polacek 2014-04-25 08:22:47 +00:00 committed by Marek Polacek
parent e4012a04cd
commit 38e514c017
4 changed files with 23 additions and 0 deletions

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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;
}