]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
invoke.texi (Warning Options): Describe -Wold-style-definition.
authorAndreas Jaeger <aj@suse.de>
Mon, 15 Sep 2003 09:31:17 +0000 (11:31 +0200)
committerAndreas Jaeger <aj@gcc.gnu.org>
Mon, 15 Sep 2003 09:31:17 +0000 (11:31 +0200)
2003-09-15  Andreas Jaeger  <aj@suse.de>
            Kaveh R. Ghazi <ghazi@caip.rutgers.edu>

* doc/invoke.texi (Warning Options): Describe -Wold-style-definition.
* c-opts.c (c_common_handle_option): Handle OPT_Wold_style_definition.
* c-parse.in: Warn about old-style parameter definition.
* c-common.c: Define warn_old_style_defintion.
* c-common.h: Declare it.
* c.opt: Add Wold-style-defintion.

testsuite:
2003-09-15  Andreas Jaeger  <aj@suse.de>

* gcc.dg/Wold-style-definition-1.c: New test.

From-SVN: r71400

gcc/c-common.c
gcc/c-common.h
gcc/c-opts.c
gcc/c-parse.in
gcc/c.opt
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wold-style-definition-1.c [new file with mode: 0644]

index 4e637490430d08515afcd5acaeb68189a3d0f8bc..52688069332c41874e6626c24f4212d743ed2fea 100644 (file)
@@ -429,6 +429,10 @@ int warn_implicit_int;
 
 int warn_nonnull;
 
+/* Warn about old-style parameter declaration.  */
+
+int warn_old_style_definition;
+
 
 /* ObjC language option variables.  */
 
index 6ce5661c44a54f9ceb5c1790b1e53995a9410211..d9cbb2ce316128ffb662aaeda58821b393d7aaa8 100644 (file)
@@ -591,6 +591,10 @@ extern int warn_implicit_int;
       
 extern int warn_nonnull;
 
+/* Warn about old-style parameter declaration.  */
+
+extern int warn_old_style_definition;
+
 
 /* ObjC language option variables.  */
 
index da342a89aec19a7ee0d60d1abceb9081117e18dc..ee957f7487b0685e9db2d87ab14f8cf839839e71 100644 (file)
@@ -550,6 +550,10 @@ c_common_handle_option (size_t scode, const char *arg, int value)
       warn_nonnull = value;
       break;
 
+    case OPT_Wold_style_definition:
+      warn_old_style_definition = value;
+      break;
+
     case OPT_Wold_style_cast:
       warn_old_style_cast = value;
       break;
index 1338455fda5f9ea9f5e5df007356cff0d663aff5..bb9cc1a77032daf97bc80d82c39a805be1bb76f4 100644 (file)
@@ -757,9 +757,16 @@ old_style_parm_decls_1:
          if (warn_traditional && !in_system_header
              && parsing_iso_function_signature)
            warning ("traditional C rejects ISO C style function definitions");
+         if (warn_old_style_definition && !in_system_header
+             && !parsing_iso_function_signature)
+           warning ("old-style parameter declaration");
          parsing_iso_function_signature = false; /* Reset after warning.  */
        }
        | datadecls
+       {
+         if (warn_old_style_definition && !in_system_header)
+           warning ("old-style parameter declaration");
+       }
        ;
 
 /* The following are analogous to lineno_decl, decls and decl
index bfe81aa3d8f67bf9905b43e05c0913a38d0de55b..6c4d12eb433cc663de06fc6e354b9c110636989e 100644 (file)
--- a/gcc/c.opt
+++ b/gcc/c.opt
@@ -312,6 +312,10 @@ Wold-style-cast
 C++ ObjC++
 Warn if a C-style cast is used in a program
 
+Wold-style-definition
+C ObjC
+Warn if an old-style parameter definition is used
+
 Woverloaded-virtual
 C++ ObjC++
 Warn about overloaded virtual function names
index 7637e15fc592281b6dd1481ed545135f22bf1bbb..059135f2cdad7702f23955792ed5b5b0542a03af 100644 (file)
@@ -220,7 +220,7 @@ in the following sections.
 -Wmain  -Wmissing-braces @gol
 -Wmissing-format-attribute  -Wmissing-noreturn @gol
 -Wno-multichar  -Wno-format-extra-args  -Wno-format-y2k @gol
--Wno-import  -Wnonnull  -Wpacked  -Wpadded @gol
+-Wno-import  -Wnonnull -Wold-style-definition -Wpacked  -Wpadded @gol
 -Wparentheses  -Wpointer-arith  -Wredundant-decls @gol
 -Wreturn-type  -Wsequence-point  -Wshadow @gol
 -Wsign-compare  -Wstrict-aliasing @gol
@@ -2709,6 +2709,11 @@ argument types.  (An old-style function definition is permitted without
 a warning if preceded by a declaration which specifies the argument
 types.)
 
+@item -Wold-style-definition @r{(C only)}
+@opindex Wold-style-definition
+Warn if an old-style function definition is used.  A warning is given
+even if there is a previous prototype.
+
 @item -Wmissing-prototypes @r{(C only)}
 @opindex Wmissing-prototypes
 Warn if a global function is defined without a previous prototype
index d3dc2c0b2c09690cf1ff841bfd52aed04f5b7b5f..c9c3b28ff39f3df80f074c12e73391ae6dd319dd 100644 (file)
@@ -1,3 +1,7 @@
+2003-09-15  Andreas Jaeger  <aj@suse.de>
+
+       * gcc.dg/Wold-style-definition-1.c: New test.
+
 2003-09-14  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/3907
diff --git a/gcc/testsuite/gcc.dg/Wold-style-definition-1.c b/gcc/testsuite/gcc.dg/Wold-style-definition-1.c
new file mode 100644 (file)
index 0000000..d4fb8bd
--- /dev/null
@@ -0,0 +1,24 @@
+/* Test for warning about old-style function definition.  */
+
+/* Origin: Andreas Jaeger <aj@suse.de> */
+/* { dg-do compile } */
+/* { dg-options "-Wold-style-definition" } */
+
+void
+bar (a) int a; { } /* { dg-warning "old-style parameter declaration" } */
+
+void bar1 () {} /* { dg-warning "old-style parameter declaration" } */
+
+extern void bar2 (void);
+
+void bar2 () {} /* { dg-warning "old-style parameter declaration" } */
+
+extern void bar3 (int);
+
+void bar3 (a) {} /* { dg-warning "old-style parameter declaration" } */
+
+void bar4 (a) {} /* { dg-warning "old-style parameter declaration" } */
+
+void bar5 (int a) {}
+
+void bar6 (void) {}