diff options
author | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2007-01-02 17:33:25 +0000 |
---|---|---|
committer | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2007-01-02 17:33:25 +0000 |
commit | b1ed4cb43c9b43a57b28d35c46062607af6e6a64 (patch) | |
tree | 2b0687af1952de91d3b3f408b09402cfbbfa1bba /gcc | |
parent | d887a68299b172a03c4648b16fdfbef9dcf25ce0 (diff) | |
download | gcc-b1ed4cb43c9b43a57b28d35c46062607af6e6a64.zip gcc-b1ed4cb43c9b43a57b28d35c46062607af6e6a64.tar.gz gcc-b1ed4cb43c9b43a57b28d35c46062607af6e6a64.tar.bz2 |
re PR middle-end/7651 (Define -Wextra strictly in terms of other warning flags)
2007-01-02 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR middle-end/7651
* c.opt (Wold-style-declaration): New.
* doc/invoke.texi (C-only Warning Options): New.
(Wold-style-declaration): Document it.
(Wextra): Enabled by -Wextra.
* c-opts.c (c_common_post_options): Enabled by -Wextra.
* c-decl.c (declspecs_add_scspec): Replace -Wextra with
-Wold-style-declaration.
testsuite/
* gcc.dg/declspec-3.c: Replace -W with -Wold-style-declaration.
* gcc.dg/declspec-3-Wextra.c: New.
* gcc.dg/declspec-3-no.c: New
From-SVN: r120347
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/c-decl.c | 5 | ||||
-rw-r--r-- | gcc/c-opts.c | 5 | ||||
-rw-r--r-- | gcc/c.opt | 4 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 19 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/declspec-3-Wextra.c | 32 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/declspec-3-no.c | 32 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/declspec-3.c | 2 |
9 files changed, 108 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6b3103e..78b8ce8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2007-01-02 Manuel Lopez-Ibanez <manu@gcc.gnu.org> + + PR middle-end/7651 + * c.opt (Wold-style-declaration): New. + * doc/invoke.texi (C-only Warning Options): New. + (Wold-style-declaration): Document it. + (Wextra): Enabled by -Wextra. + * c-opts.c (c_common_post_options): Enabled by -Wextra. + * c-decl.c (declspecs_add_scspec): Replace -Wextra with + -Wold-style-declaration. + 2007-01-02 Kazu Hirata <kazu@codesourcery.com> * alias.c (init_alias_analysis): Use VEC_safe_grow_cleared. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index a9506e1..f669a47 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -7613,8 +7613,9 @@ declspecs_add_scspec (struct c_declspecs *specs, tree scspec) gcc_assert (TREE_CODE (scspec) == IDENTIFIER_NODE && C_IS_RESERVED_WORD (scspec)); i = C_RID_CODE (scspec); - if (extra_warnings && specs->non_sc_seen_p) - warning (OPT_Wextra, "%qE is not at beginning of declaration", scspec); + if (specs->non_sc_seen_p) + warning (OPT_Wold_style_declaration, + "%qE is not at beginning of declaration", scspec); switch (i) { case RID_INLINE: diff --git a/gcc/c-opts.c b/gcc/c-opts.c index 5390a05..acba12b 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -1026,7 +1026,8 @@ c_common_post_options (const char **pfilename) flag_exceptions = 1; /* -Wextra implies -Wclobbered, -Wempty-body, -Wsign-compare, - -Wmissing-field-initializers, -Wmissing-parameter-type and -Woverride-init, + -Wmissing-field-initializers, -Wmissing-parameter-type + -Wold-style-declaration, and -Woverride-init, but not if explicitly overridden. */ if (warn_clobbered == -1) warn_clobbered = extra_warnings; @@ -1038,6 +1039,8 @@ c_common_post_options (const char **pfilename) warn_missing_field_initializers = extra_warnings; if (warn_missing_parameter_type == -1) warn_missing_parameter_type = extra_warnings; + if (warn_old_style_declaration == -1) + warn_old_style_declaration = extra_warnings; if (warn_override_init == -1) warn_override_init = extra_warnings; @@ -319,6 +319,10 @@ Wold-style-cast C++ ObjC++ Var(warn_old_style_cast) Warn if a C-style cast is used in a program +Wold-style-declaration +C ObjC Var(warn_old_style_declaration) Init(-1) +Warn for obsolescent usage in a declaration + Wold-style-definition C ObjC Var(warn_old_style_definition) Warn if an old-style parameter definition is used diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index ff463c7..2101192 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -256,8 +256,8 @@ Objective-C and Objective-C++ Dialects}. @item C-only Warning Options @gccoptlist{-Wbad-function-cast -Wmissing-declarations @gol --Wmissing-parameter-type -Wmissing-prototypes @gol --Wnested-externs -Wold-style-definition @gol +-Wmissing-parameter-type -Wmissing-prototypes -Wnested-externs @gol +-Wold-style-declaration -Wold-style-definition @gol -Wstrict-prototypes -Wtraditional -Wtraditional-conversion @gol -Wdeclaration-after-statement -Wpointer-sign} @@ -2885,9 +2885,11 @@ but @samp{x[(void)i,j]} will not. @item An unsigned value is compared against zero with @samp{<} or @samp{>=}. -@item -Storage-class specifiers like @code{static} are not the first things in -a declaration. According to the C Standard, this usage is obsolescent. +@item @r{(C only)} +Storage-class specifiers like @code{static} are not the first things +in a declaration. According to the C Standard, this usage is +obsolescent. This warning can be independently controlled by +@option{-Wold-style-declaration}. @item If @option{-Wall} or @option{-Wunused} is also specified, warn about unused @@ -3214,6 +3216,13 @@ 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-declaration @r{(C only)} +@opindex Wold-style-declaration +Warn for obsolescent usages, according to the C Standard, in a +declaration. For example, warn if storage-class specifiers like +@code{static} are not the first things in a declaration. This warning +is also enabled by @option{-Wextra}. + @item -Wold-style-definition @r{(C only)} @opindex Wold-style-definition Warn if an old-style function definition is used. A warning is given diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 81ac58c..e2e3d3d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2007-01-02 Manuel Lopez-Ibanez <manu@gcc.gnu.org> + + PR middle-end/7651 + * gcc.dg/declspec-3.c: Replace -W with -Wold-style-declaration. + * gcc.dg/declspec-3-Wextra.c: New. + * gcc.dg/declspec-3-no.c: New + 2007-01-02 Paul Thomas <pault@gcc.gnu.org> PR fortran/20896 diff --git a/gcc/testsuite/gcc.dg/declspec-3-Wextra.c b/gcc/testsuite/gcc.dg/declspec-3-Wextra.c new file mode 100644 index 0000000..66378cc --- /dev/null +++ b/gcc/testsuite/gcc.dg/declspec-3-Wextra.c @@ -0,0 +1,32 @@ +/* See declspec-3.c . Test -Wold-style-declaration is enabled by -Wextra. */ +/* { dg-do compile } */ +/* { dg-options "-Wextra" } */ + +static int x0; +int static x1; /* { dg-warning "not at beginning" } */ + +extern int x2; +int extern x3; /* { dg-warning "not at beginning" } */ + +typedef int x4; +int typedef x5; /* { dg-warning "not at beginning" } */ + +void g (int); + +void +f (void) +{ + auto int x6 = 0; + int auto x7 = 0; /* { dg-warning "not at beginning" } */ + register int x8 = 0; + int register x9 = 0; /* { dg-warning "not at beginning" } */ + g (x6 + x7 + x8 + x9); +} + +const static int x10; /* { dg-warning "not at beginning" } */ + +/* Attributes are OK before storage class specifiers, since some + attributes are like such specifiers themselves. */ + +__attribute__((format(printf, 1, 2))) static void h (const char *, ...); +__attribute__((format(printf, 1, 2))) void static i (const char *, ...); /* { dg-warning "not at beginning" } */ diff --git a/gcc/testsuite/gcc.dg/declspec-3-no.c b/gcc/testsuite/gcc.dg/declspec-3-no.c new file mode 100644 index 0000000..678b4f2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/declspec-3-no.c @@ -0,0 +1,32 @@ +/* See declspec-3.c . Test disabling -Wold-style-declaration. */ +/* { dg-do compile } */ +/* { dg-options "-Wextra -Wno-old-style-declaration" } */ + +static int x0; +int static x1; /* { dg-bogus "not at beginning" } */ + +extern int x2; +int extern x3; /* { dg-bogus "not at beginning" } */ + +typedef int x4; +int typedef x5; /* { dg-bogus "not at beginning" } */ + +void g (int); + +void +f (void) +{ + auto int x6 = 0; + int auto x7 = 0; /* { dg-bogus "not at beginning" } */ + register int x8 = 0; + int register x9 = 0; /* { dg-bogus "not at beginning" } */ + g (x6 + x7 + x8 + x9); +} + +const static int x10; /* { dg-bogus "not at beginning" } */ + +/* Attributes are OK before storage class specifiers, since some + attributes are like such specifiers themselves. */ + +__attribute__((format(printf, 1, 2))) static void h (const char *, ...); +__attribute__((format(printf, 1, 2))) void static i (const char *, ...); /* { dg-bogus "not at beginning" } */ diff --git a/gcc/testsuite/gcc.dg/declspec-3.c b/gcc/testsuite/gcc.dg/declspec-3.c index 19b1fa2..95052a9 100644 --- a/gcc/testsuite/gcc.dg/declspec-3.c +++ b/gcc/testsuite/gcc.dg/declspec-3.c @@ -2,7 +2,7 @@ specifiers not at start. */ /* Origin: Joseph Myers <jsm@polyomino.org.uk> */ /* { dg-do compile } */ -/* { dg-options "-W" } */ +/* { dg-options "-Wold-style-declaration" } */ static int x0; int static x1; /* { dg-warning "not at beginning" } */ |