This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PATCH: put setjmp warnings under control of -W


Marc Lehmann <pcg@opengroup.org> writes:

> This patch puts the "clobbered by setjmp" warnings under control of -W
> (formerly they were under control of -Wuninitialized).
> 
> This makes the behaviour consistent with the documentation.

You need to look at the current version of the documentation, which
says that the warnings are under control of -Wuninitialized.

If you really want to have them separate, there is a patch on the
Cygnus tree which gives them their very own option (this patch has
been hand-edited, so it probably needs to be applied by hand---it used
to also include tree-management comments for Cygnus):

        * toplev.c (W_options): Add -Wlongjmp-clobbers.
        (main): Warn about it without -O.
        * function.c (uninitialized_vars_warning): Honour it.

--- /sloth/disk0/co/mainline/devo/gcc/function.c        Tue Aug 10 12:49:57 1999
+++ devo/gcc/function.c Fri Aug 20 16:34:26 1999
@@ -5079,6 +5079,9 @@ uninitialized_vars_warning (block)
   for (decl = BLOCK_VARS (block); decl; decl = TREE_CHAIN (decl))
     {
       if (TREE_CODE (decl) == VAR_DECL
+         && warn_uninitialized != 3
          /* These warnings are unreliable for and aggregates
             because assigning the fields one by one can fail to convince
             flow.c that the entire aggregate was initialized.
--- /sloth/disk0/co/mainline/devo/gcc/toplev.c  Wed Aug 18 15:56:20 1999
+++ devo/gcc/toplev.c   Fri Aug 20 16:58:05 1999
@@ -1289,7 +1289,14 @@ int warnings_are_errors = 0;
 
 int warn_unused;
 
-/* Nonzero to warn about variables used before they are initialized.  */
+/* Nonzero to warn about variables used before they are initialized. 
+   Specifically,
+   0 : don't warn
+   1 : -Wuninitialized specified
+   2 : -Wall specified
+   3 : -Wlongjmp-clobbers specified.  */
 
 int warn_uninitialized;
 
@@ -1349,6 +1356,10 @@ lang_independent_options W_options[] =
    "Warn about pointer casts which increase alignment" },
   {"uninitialized", &warn_uninitialized, 1,
    "Warn about unitialized automatic variables"},
+  {"longjmp-clobbers", &warn_uninitialized, 3,
+   "Warn about variables that setjmp() might invalidate"},
   {"inline", &warn_inline, 1,
    "Warn when an inlined function cannot be inlined"}
 };
@@ -5673,6 +5684,10 @@ main (argc, argv)
         lots of errors for people who don't realize what -Wall does.  */
       if (warn_uninitialized == 1)
        warning ("-Wuninitialized is not supported without -O");
+      else if (warn_uninitialized == 3)
+       warning ("-Wlongjmp-clobbers is not supported without -O");
     }
 
 #ifdef OVERRIDE_OPTIONS


There were also corresponding documentation changes.

It didn't go in the mainline tree because it adds another option for
little benefit; but if people think there is a benefit, then there's
no problem.

You shouldn't change the behaviour of -Wuninitialized, because there
are probably people using -Werror -Wno-uninitialized and this would
break their builds.

-- 
Geoffrey Keating <geoffk@cygnus.com>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]