Commit c034f121 by Andreas Jaeger Committed by Andreas Jaeger

invoke.texi (Warning Options): Describe -Wold-style-definition.

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
parent 863d938c
...@@ -429,6 +429,10 @@ int warn_implicit_int; ...@@ -429,6 +429,10 @@ int warn_implicit_int;
int warn_nonnull; int warn_nonnull;
/* Warn about old-style parameter declaration. */
int warn_old_style_definition;
/* ObjC language option variables. */ /* ObjC language option variables. */
......
...@@ -591,6 +591,10 @@ extern int warn_implicit_int; ...@@ -591,6 +591,10 @@ extern int warn_implicit_int;
extern int warn_nonnull; extern int warn_nonnull;
/* Warn about old-style parameter declaration. */
extern int warn_old_style_definition;
/* ObjC language option variables. */ /* ObjC language option variables. */
......
...@@ -550,6 +550,10 @@ c_common_handle_option (size_t scode, const char *arg, int value) ...@@ -550,6 +550,10 @@ c_common_handle_option (size_t scode, const char *arg, int value)
warn_nonnull = value; warn_nonnull = value;
break; break;
case OPT_Wold_style_definition:
warn_old_style_definition = value;
break;
case OPT_Wold_style_cast: case OPT_Wold_style_cast:
warn_old_style_cast = value; warn_old_style_cast = value;
break; break;
......
...@@ -757,9 +757,16 @@ old_style_parm_decls_1: ...@@ -757,9 +757,16 @@ old_style_parm_decls_1:
if (warn_traditional && !in_system_header if (warn_traditional && !in_system_header
&& parsing_iso_function_signature) && parsing_iso_function_signature)
warning ("traditional C rejects ISO C style function definitions"); 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. */ parsing_iso_function_signature = false; /* Reset after warning. */
} }
| datadecls | datadecls
{
if (warn_old_style_definition && !in_system_header)
warning ("old-style parameter declaration");
}
; ;
/* The following are analogous to lineno_decl, decls and decl /* The following are analogous to lineno_decl, decls and decl
......
...@@ -312,6 +312,10 @@ Wold-style-cast ...@@ -312,6 +312,10 @@ Wold-style-cast
C++ ObjC++ C++ ObjC++
Warn if a C-style cast is used in a program 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 Woverloaded-virtual
C++ ObjC++ C++ ObjC++
Warn about overloaded virtual function names Warn about overloaded virtual function names
......
...@@ -220,7 +220,7 @@ in the following sections. ...@@ -220,7 +220,7 @@ in the following sections.
-Wmain -Wmissing-braces @gol -Wmain -Wmissing-braces @gol
-Wmissing-format-attribute -Wmissing-noreturn @gol -Wmissing-format-attribute -Wmissing-noreturn @gol
-Wno-multichar -Wno-format-extra-args -Wno-format-y2k @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 -Wparentheses -Wpointer-arith -Wredundant-decls @gol
-Wreturn-type -Wsequence-point -Wshadow @gol -Wreturn-type -Wsequence-point -Wshadow @gol
-Wsign-compare -Wstrict-aliasing @gol -Wsign-compare -Wstrict-aliasing @gol
...@@ -2709,6 +2709,11 @@ argument types. (An old-style function definition is permitted without ...@@ -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 a warning if preceded by a declaration which specifies the argument
types.) 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)} @item -Wmissing-prototypes @r{(C only)}
@opindex Wmissing-prototypes @opindex Wmissing-prototypes
Warn if a global function is defined without a previous prototype Warn if a global function is defined without a previous prototype
......
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> 2003-09-14 Mark Mitchell <mark@codesourcery.com>
PR c++/3907 PR c++/3907
......
/* 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) {}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment