Patchwork Small tweak to -Wuninitialized

login
register
mail settings
Submitter Eric Botcazou
Date Dec. 3, 2012, 9:51 a.m.
Message ID <2617259.JYs7QYuLy2@polaris>
Download mbox | patch
Permalink /patch/203303/
State New
Headers show

Comments

Eric Botcazou - Dec. 3, 2012, 9:51 a.m.
Hi,

if you compile the attached testcase on x86 with -O2 -Wuninitialized, you get:

strip.adb: In function 'Strip':
strip.adb:4:4: warning: 'Last' may be used uninitialized in this function [-
Wuninitialized]
strip.adb:26:44: warning: 'First' may be used uninitialized in this function 
[-Wmaybe-uninitialized]

The same warning is apparently associated with 2 different options so, if you 
want to disable "maybe" warnings, -O2 -Wuninitialized -Wno-maybe-uninitialized 
only disables the second one:

strip.adb: In function 'Strip':
strip.adb:4:4: warning: 'Last' may be used uninitialized in this function [-
Wuninitialized]

Of course the story under the hood is a bit different, but this doesn't really 
matter to the user I think, so I propose using the -Wmaybe-uninitialized tag 
in both cases.  Tested on x86-64-suse-linux, OK for the mainline?


2012-12-03  Eric Botcazou  <ebotcazou@adacore.com>

	* tree-ssa.c (warn_uninitialized_var): Use OPT_Wmaybe_uninitialized tag
	in the non-always executed case.
Richard Guenther - Dec. 3, 2012, 11:17 a.m.
On Mon, Dec 3, 2012 at 10:51 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> if you compile the attached testcase on x86 with -O2 -Wuninitialized, you get:
>
> strip.adb: In function 'Strip':
> strip.adb:4:4: warning: 'Last' may be used uninitialized in this function [-
> Wuninitialized]
> strip.adb:26:44: warning: 'First' may be used uninitialized in this function
> [-Wmaybe-uninitialized]
>
> The same warning is apparently associated with 2 different options so, if you
> want to disable "maybe" warnings, -O2 -Wuninitialized -Wno-maybe-uninitialized
> only disables the second one:
>
> strip.adb: In function 'Strip':
> strip.adb:4:4: warning: 'Last' may be used uninitialized in this function [-
> Wuninitialized]
>
> Of course the story under the hood is a bit different, but this doesn't really
> matter to the user I think, so I propose using the -Wmaybe-uninitialized tag
> in both cases.  Tested on x86-64-suse-linux, OK for the mainline?

Ok.

Thanks,
Richard.

>
> 2012-12-03  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * tree-ssa.c (warn_uninitialized_var): Use OPT_Wmaybe_uninitialized tag
>         in the non-always executed case.
>
>
> --
> Eric Botcazou

Patch

Index: tree-ssa.c
===================================================================
--- tree-ssa.c	(revision 194049)
+++ tree-ssa.c	(working copy)
@@ -1664,7 +1664,7 @@  warn_uninitialized_vars (bool warn_possi
 			     "%qD is used uninitialized in this function",
 			     stmt);
 	      else if (warn_possibly_uninitialized)
-		warn_uninit (OPT_Wuninitialized, use,
+		warn_uninit (OPT_Wmaybe_uninitialized, use,
 			     SSA_NAME_VAR (use), SSA_NAME_VAR (use),
 			     "%qD may be used uninitialized in this function",
 			     stmt);
@@ -1696,13 +1696,13 @@  warn_uninitialized_vars (bool warn_possi
 		continue;
 
 	      if (always_executed)
-		warn_uninit (OPT_Wuninitialized, use, gimple_assign_rhs1 (stmt),
-			     base,
+		warn_uninit (OPT_Wuninitialized, use, 
+			     gimple_assign_rhs1 (stmt), base,
 			     "%qE is used uninitialized in this function",
 			     stmt);
 	      else if (warn_possibly_uninitialized)
-		warn_uninit (OPT_Wuninitialized, use, gimple_assign_rhs1 (stmt),
-			     base,
+		warn_uninit (OPT_Wmaybe_uninitialized, use,
+			     gimple_assign_rhs1 (stmt), base,
 			     "%qE may be used uninitialized in this function",
 			     stmt);
 	    }