I figured it might be a good idea to warn about variadic main decl (well, not in freestanding environment where it's implementation-defined).
Regtested/bootstrapped on x86_64-linux, ok for 5.0? 2014-02-12 Marek Polacek <pola...@redhat.com> PR c/60156 c-family/ * c-common.c (check_main_parameter_types): Warn about variadic main. testsuite/ * c-c++-common/pr60156.c: New test. diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c index 5cf285b..bdf2852 100644 --- gcc/c-family/c-common.c +++ 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 gcc/testsuite/c-c++-common/pr60156.c gcc/testsuite/c-c++-common/pr60156.c index e69de29..1e8204c 100644 --- gcc/testsuite/c-c++-common/pr60156.c +++ 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; +} Marek