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 <ebotca...@adacore.com>
* tree-ssa.c (warn_uninitialized_var): Use OPT_Wmaybe_uninitialized tag
in the non-always executed case.
--
Eric Botcazou
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);
}
function Strip (Str : in String) return String is
First : Natural;
Last : Natural;
Blank_Str : constant String (Str'Range) := (others => ' ');
begin
if Str = "" or Str = Blank_Str then
return "";
end if;
for I in Str'Range loop
if Str (I) /= ' ' and Str (I) /= Ascii.Ht then
First := I;
exit;
end if;
end loop;
for I in reverse Str'Range loop
if Str (I) /= ' ' and Str (I) /= Ascii.Ht then
Last := I;
exit;
end if;
end loop;
declare
Ret_Str : constant String (1 .. Last - First + 1) := Str (First .. Last);
begin
return Ret_Str;
end;
end Strip;