OSDN Git Service

2006-12-23 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
authormanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 23 Dec 2006 17:45:33 +0000 (17:45 +0000)
committermanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 23 Dec 2006 17:45:33 +0000 (17:45 +0000)
PR middle-end/7651
* c.opt (Wmissing-parameter-type): New.
* doc/invoke.texi (Wmissing-parameter-type): Document it.
(Wextra): Enabled by -Wextra.
* c-opts.c (c_common_post_options): Enabled by -Wextra.
* c-decl.c (store_parm_decls_oldstyle): Replace Wextra with
Wmissing-parameter-type.

testsuite/

* gcc.dg/Wmissing-parameter-type.c: New.
* gcc.dg/Wmissing-parameter-type-Wextra.c: New.
* gcc.dg/Wmissing-parameter-type-no.c: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120173 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-decl.c
gcc/c-opts.c
gcc/c.opt
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wmissing-parameter-type-Wextra.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wmissing-parameter-type-no.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wmissing-parameter-type.c [new file with mode: 0644]

index 91255aa..09056a4 100644 (file)
@@ -1,3 +1,13 @@
+2006-12-23  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+
+       PR middle-end/7651
+       * c.opt (Wmissing-parameter-type): New.
+       * doc/invoke.texi (Wmissing-parameter-type): Document it.
+       (Wextra): Enabled by -Wextra.
+       * c-opts.c (c_common_post_options): Enabled by -Wextra.
+       * c-decl.c (store_parm_decls_oldstyle): Replace Wextra with
+       Wmissing-parameter-type.
+       
 2006-12-23  Eric Botcazou  <ebotcazou@adacore.com>
 
        * dwarf2out.c (dbx_reg_number): Do leaf register remapping
index c95f495..a9506e1 100644 (file)
@@ -6414,8 +6414,8 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
 
          if (flag_isoc99)
            pedwarn ("type of %q+D defaults to %<int%>", decl);
-         else if (extra_warnings)
-           warning (OPT_Wextra, "type of %q+D defaults to %<int%>", decl);
+         else 
+           warning (OPT_Wmissing_parameter_type, "type of %q+D defaults to %<int%>", decl);
        }
 
       TREE_PURPOSE (parm) = decl;
index 12caf1b..5390a05 100644 (file)
@@ -1026,7 +1026,7 @@ c_common_post_options (const char **pfilename)
     flag_exceptions = 1;
 
   /* -Wextra implies -Wclobbered, -Wempty-body, -Wsign-compare, 
-     -Wmissing-field-initializers and -Woverride-init, 
+     -Wmissing-field-initializers, -Wmissing-parameter-type and -Woverride-init, 
      but not if explicitly overridden.  */
   if (warn_clobbered == -1)
     warn_clobbered = extra_warnings;
@@ -1036,6 +1036,8 @@ c_common_post_options (const char **pfilename)
     warn_sign_compare = extra_warnings;
   if (warn_missing_field_initializers == -1)
     warn_missing_field_initializers = extra_warnings;
+  if (warn_missing_parameter_type == -1)
+    warn_missing_parameter_type = extra_warnings;
   if (warn_override_init == -1)
     warn_override_init = extra_warnings;
 
index 74aef8e..e4d45e4 100644 (file)
--- a/gcc/c.opt
+++ b/gcc/c.opt
@@ -283,6 +283,10 @@ Wmissing-include-dirs
 C ObjC C++ ObjC++
 Warn about user-specified include directories that do not exist
 
+Wmissing-parameter-type
+C ObjC Var(warn_missing_parameter_type) Init(-1)
+Warn about function parameters declared without a type specifier in K&R-style functions
+
 Wmissing-prototypes
 C ObjC Var(warn_missing_prototypes)
 Warn about global functions without prototypes
index 63f22f2..4fc0966 100644 (file)
@@ -256,7 +256,8 @@ Objective-C and Objective-C++ Dialects}.
 
 @item C-only Warning Options
 @gccoptlist{-Wbad-function-cast  -Wmissing-declarations @gol
--Wmissing-prototypes  -Wnested-externs  -Wold-style-definition @gol
+-Wmissing-parameter-type  -Wmissing-prototypes @gol
+-Wnested-externs  -Wold-style-definition @gol
 -Wstrict-prototypes  -Wtraditional  -Wtraditional-conversion @gol
 -Wdeclaration-after-statement -Wpointer-sign}
 
@@ -2908,13 +2909,10 @@ designated initializers (@pxref{Designated Inits, , Designated
 Initializers}).  This warning can be independently controlled by
 @option{-Woverride-init}.
 
-@item
+@item @r{(C only)}
 A function parameter is declared without a type specifier in K&R-style
-functions:
-
-@smallexample
-void foo(bar) @{ @}
-@end smallexample
+functions.  This warning can be independently controlled by
+@option{-Wmissing-parameter-type}.
 
 @item
 An empty body occurs in an @samp{if} or @samp{else} statement. This
@@ -3221,6 +3219,17 @@ types.)
 Warn if an old-style function definition is used.  A warning is given
 even if there is a previous prototype.
 
+@item -Wmissing-parameter-type @r{(C only)}
+@opindex Wmissing-parameter-type
+A function parameter is declared without a type specifier in K&R-style
+functions:
+
+@smallexample
+void foo(bar) @{ @}
+@end smallexample
+
+This warning is also enabled by @option{-Wextra}.
+
 @item -Wmissing-prototypes @r{(C only)}
 @opindex Wmissing-prototypes
 Warn if a global function is defined without a previous prototype
index c452eb4..614ece9 100644 (file)
@@ -1,3 +1,10 @@
+2006-12-23  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+
+       PR middle-end/7651
+       * gcc.dg/Wmissing-parameter-type.c: New.
+       * gcc.dg/Wmissing-parameter-type-Wextra.c: New.
+       * gcc.dg/Wmissing-parameter-type-no.c: New.
+       
 2006-12-22  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/25818
diff --git a/gcc/testsuite/gcc.dg/Wmissing-parameter-type-Wextra.c b/gcc/testsuite/gcc.dg/Wmissing-parameter-type-Wextra.c
new file mode 100644 (file)
index 0000000..37e1a57
--- /dev/null
@@ -0,0 +1,7 @@
+/* Test -Wmissing-parameter-type is enabled by -Wextra */
+/* { dg-do compile } */
+/* { dg-options "-Wextra" } */
+
+int foo(bar) { return bar;} /* { dg-warning "type of 'bar' defaults to 'int'" } */
+
+
diff --git a/gcc/testsuite/gcc.dg/Wmissing-parameter-type-no.c b/gcc/testsuite/gcc.dg/Wmissing-parameter-type-no.c
new file mode 100644 (file)
index 0000000..1031e57
--- /dev/null
@@ -0,0 +1,7 @@
+/* Test that we can disable -Wmissing-parameter-type */
+/* { dg-do compile } */
+/* { dg-options "-Wall -Wextra -Wno-missing-parameter-type" } */
+
+int foo(bar) { return bar;} /* { dg-bogus "type of 'bar' defaults to 'int'" } */
+
+
diff --git a/gcc/testsuite/gcc.dg/Wmissing-parameter-type.c b/gcc/testsuite/gcc.dg/Wmissing-parameter-type.c
new file mode 100644 (file)
index 0000000..8ec94e2
--- /dev/null
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-Wmissing-parameter-type" } */
+
+int foo(bar) { return bar; } /* { dg-warning "type of 'bar' defaults to 'int'" } */
+
+