]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/60156 (GCC doesn't warn about variadic main)
authorMarek Polacek <polacek@redhat.com>
Fri, 25 Apr 2014 08:22:47 +0000 (08:22 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 25 Apr 2014 08:22:47 +0000 (08:22 +0000)
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
gcc/c-family/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr60156.c [new file with mode: 0644]

index 34a58647ad7d65304abb227b965e393ce0cde05f..9d5ecc49be83fce46fd65c6fb9d1cd2cf042a317 100644 (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.
index a08c873c536d9035ae27aded43492b33224b130c..97d16c16dd7648297a8df9d7661f967e556104cf 100644 (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
index d11d70b3f16f56f7a6e9b21c217b02fda3cbeee8..d7a3677588972163b44fe54e5a163c38c188fc7e 100644 (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
diff --git a/gcc/testsuite/c-c++-common/pr60156.c b/gcc/testsuite/c-c++-common/pr60156.c
new file mode 100644 (file)
index 0000000..1e8204c
--- /dev/null
@@ -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;
+}