diff options
author | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2006-12-22 15:54:05 +0000 |
---|---|---|
committer | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2006-12-22 15:54:05 +0000 |
commit | 2b0017242d6888e91146422831551f64e9854698 (patch) | |
tree | b213317c3f34e3c03d9cc572db411c63b2179ffe | |
parent | 24fc18b98c30f23c5de5bce0fb6b90f5929fe453 (diff) | |
download | gcc-2b0017242d6888e91146422831551f64e9854698.zip gcc-2b0017242d6888e91146422831551f64e9854698.tar.gz gcc-2b0017242d6888e91146422831551f64e9854698.tar.bz2 |
re PR middle-end/7651 (Define -Wextra strictly in terms of other warning flags)
2006-12-22 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR middle-end/7651
* c.opt (Wclobbered): New.
* doc/invoke.texi (Wclobbered): Document it.
(Wextra): Enabled by -Wextra.
* c-opts.c (c_common_post_options): Enabled by -Wextra.
* flow.c (rest_of_handle_life): Replace Wextra with Wclobbered.
* function.c (setjmp_vars_warning): Only warn for Wclobbered.
(setjmp_args_warning): Likewise.
testsuite/
* gcc.dg/attr-returns_twice-1.c: Replace Wextra with Wclobbered.
* gcc.dg/setjmp-1.c: Add explicit Wclobbered.
From-SVN: r120151
-rw-r--r-- | gcc/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/c-opts.c | 4 | ||||
-rw-r--r-- | gcc/c.opt | 4 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 9 | ||||
-rw-r--r-- | gcc/flow.c | 2 | ||||
-rw-r--r-- | gcc/function.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/attr-returns_twice-1.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/setjmp-1.c | 2 |
9 files changed, 39 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 212d0ca..4ceb90f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2006-12-22 Manuel Lopez-Ibanez <manu@gcc.gnu.org> + + PR middle-end/7651 + * c.opt (Wclobbered): New. + * doc/invoke.texi (Wclobbered): Document it. + (Wextra): Enabled by -Wextra. + * c-opts.c (c_common_post_options): Enabled by -Wextra. + * flow.c (rest_of_handle_life): Replace Wextra with Wclobbered. + * function.c (setjmp_vars_warning): Only warn for Wclobbered. + (setjmp_args_warning): Likewise. + 2006-12-22 Kazu Hirata <kazu@codesourcery.com> * config/elfos.h, config/spu/spu.c, tree-ssa-operands.h, diff --git a/gcc/c-opts.c b/gcc/c-opts.c index 9a5d6f6..12caf1b 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -1025,9 +1025,11 @@ c_common_post_options (const char **pfilename) if (flag_objc_exceptions && !flag_objc_sjlj_exceptions) flag_exceptions = 1; - /* -Wextra implies -Wempty-body, -Wsign-compare, + /* -Wextra implies -Wclobbered, -Wempty-body, -Wsign-compare, -Wmissing-field-initializers and -Woverride-init, but not if explicitly overridden. */ + if (warn_clobbered == -1) + warn_clobbered = extra_warnings; if (warn_empty_body == -1) warn_empty_body = extra_warnings; if (warn_sign_compare == -1) @@ -141,6 +141,10 @@ Wchar-subscripts C ObjC C++ ObjC++ Var(warn_char_subscripts) Warn about subscripts whose type is \"char\" +Wclobbered +C ObjC C++ ObjC++ Var(warn_clobbered) Init(-1) +Warn about variables that might be changed by \"longjmp\" or \"vfork\" + Wcomment C ObjC C++ ObjC++ Warn about possibly nested block comments, and C++ comments spanning more than one physical line diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 1c3c9df..b65280b 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -222,7 +222,8 @@ Objective-C and Objective-C++ Dialects}. @xref{Warning Options,,Options to Request or Suppress Warnings}. @gccoptlist{-fsyntax-only -pedantic -pedantic-errors @gol -w -Wextra -Wall -Waggregate-return -Walways-true -Wno-attributes @gol --Wc++-compat -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol +-Wc++-compat -Wcast-align -Wcast-qual -Wchar-subscripts @gol +-Wclobbered -Wcomment @gol -Wconversion -Wno-deprecated-declarations @gol -Wdisabled-optimization -Wno-div-by-zero @gol -Wempty-body -Wno-endif-labels @gol @@ -2925,6 +2926,7 @@ A pointer is compared against integer zero with @samp{<}, @samp{<=}, @item A variable might be changed by @samp{longjmp} or @samp{vfork}. +This warning can be independently controlled by @option{-Wclobbered}. @item Any of several floating-point events that often indicate errors, such as @@ -3157,6 +3159,11 @@ only if you have been very careful about using @code{const} in declarations and prototypes. Otherwise, it will just be a nuisance; this is why we did not make @option{-Wall} request these warnings. +@item -Wclobbered +@opindex Wclobbered +Warn for variables that might be changed by @samp{longjmp} or +@samp{vfork}. This warning is also enabled by @option{-Wextra}. + @item -Wconversion @opindex Wconversion Warn for implicit conversions that may alter a value. This includes @@ -4695,7 +4695,7 @@ rest_of_handle_life (void) cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE | CLEANUP_LOG_LINKS | (flag_thread_jumps ? CLEANUP_THREADING : 0)); - if (extra_warnings) + if (warn_clobbered) { setjmp_vars_warning (DECL_INITIAL (current_function_decl)); setjmp_args_warning (); diff --git a/gcc/function.c b/gcc/function.c index b61b900..581c083 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -3536,9 +3536,8 @@ setjmp_vars_warning (tree block) && DECL_RTL_SET_P (decl) && REG_P (DECL_RTL (decl)) && regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl)))) - warning (0, "variable %q+D might be clobbered by %<longjmp%>" - " or %<vfork%>", - decl); + warning (OPT_Wclobbered, "variable %q+D might be clobbered by" + " %<longjmp%> or %<vfork%>", decl); } for (sub = BLOCK_SUBBLOCKS (block); sub; sub = TREE_CHAIN (sub)) @@ -3557,7 +3556,8 @@ setjmp_args_warning (void) if (DECL_RTL (decl) != 0 && REG_P (DECL_RTL (decl)) && regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl)))) - warning (0, "argument %q+D might be clobbered by %<longjmp%> or %<vfork%>", + warning (OPT_Wclobbered, + "argument %q+D might be clobbered by %<longjmp%> or %<vfork%>", decl); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f49fa37..5fc63cf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2006-12-22 Manuel Lopez-Ibanez <manu@gcc.gnu.org> + + PR middle-end/7651 + * gcc.dg/attr-returns_twice-1.c: Replace Wextra with Wclobbered. + * gcc.dg/setjmp-1.c: Add explicit Wclobbered. + 2006-12-21 Andrew Pinski <pinskia@gmail.com> PR C++/30168 diff --git a/gcc/testsuite/gcc.dg/attr-returns_twice-1.c b/gcc/testsuite/gcc.dg/attr-returns_twice-1.c index 9eb082f..e2e725e 100644 --- a/gcc/testsuite/gcc.dg/attr-returns_twice-1.c +++ b/gcc/testsuite/gcc.dg/attr-returns_twice-1.c @@ -1,5 +1,5 @@ /* { dg-do compile { target i?86-*-* x86_64-*-* } } */ -/* { dg-options "-W" } */ +/* { dg-options "-Wclobbered" } */ int newsetjmp(void) __attribute__((returns_twice)); void g(int); diff --git a/gcc/testsuite/gcc.dg/setjmp-1.c b/gcc/testsuite/gcc.dg/setjmp-1.c index 35e192d..b5c84fc 100644 --- a/gcc/testsuite/gcc.dg/setjmp-1.c +++ b/gcc/testsuite/gcc.dg/setjmp-1.c @@ -2,7 +2,7 @@ Inspired by cse.c:simplify_relational_operation. */ /* { dg-do compile } */ -/* { dg-options "-O -W -Wall" } */ +/* { dg-options "-O -Wclobbered -Wextra -Wall" } */ #include <setjmp.h> |