OSDN Git Service

2006-12-22 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
authormanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 22 Dec 2006 15:54:05 +0000 (15:54 +0000)
committermanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 22 Dec 2006 15:54:05 +0000 (15:54 +0000)
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.

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

gcc/ChangeLog
gcc/c-opts.c
gcc/c.opt
gcc/doc/invoke.texi
gcc/flow.c
gcc/function.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/attr-returns_twice-1.c
gcc/testsuite/gcc.dg/setjmp-1.c

index 212d0ca..4ceb90f 100644 (file)
@@ -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,
index 9a5d6f6..12caf1b 100644 (file)
@@ -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)
index 7914b6d..74aef8e 100644 (file)
--- a/gcc/c.opt
+++ b/gcc/c.opt
@@ -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
index 1c3c9df..b65280b 100644 (file)
@@ -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
index 1da935b..78c2328 100644 (file)
@@ -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 ();
index b61b900..581c083 100644 (file)
@@ -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);
 }
 
index f49fa37..5fc63cf 100644 (file)
@@ -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
index 9eb082f..e2e725e 100644 (file)
@@ -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);
index 35e192d..b5c84fc 100644 (file)
@@ -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>