This changes pragma Warnings (On) from reenabling all the warnings previously
silenced to reenabling only those warnings which were enabled when the latest
pragma Warnings (Off) was processed (excluding the front-end warnings which
are handled separately by the front-end).
Tested on x86_64-suse-linux, applied on the mainline.
2019-12-18 Eric Botcazou <ebotca...@adacore.com>
* gcc-interface/trans.c (Pragma_to_gnu) <Pragma_Warnings>: Push a
diagnostics state for pragma Warnings (Off) before turning off all
the warnings and only pop it for pragma Warnings (On).
2019-12-18 Eric Botcazou <ebotca...@adacore.com>
* gnat.dg/warn32.adb: New test.
--
Eric Botcazou
Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c (revision 338441)
+++ gcc-interface/trans.c (revision 338442)
@@ -1975,7 +1975,21 @@ Pragma_to_gnu (Node_Id gnat_node)
gnat_expr = Expression (Next (gnat_temp));
}
else
- gnat_expr = Empty;
+ {
+ gnat_expr = Empty;
+
+ /* For pragma Warnings (Off), we save the current state... */
+ if (kind == DK_IGNORED)
+ diagnostic_push_diagnostics (global_dc, location);
+
+ /* ...so that, for pragma Warnings (On), we do not enable all
+ the warnings but just restore the previous state. */
+ else
+ {
+ diagnostic_pop_diagnostics (global_dc, location);
+ break;
+ }
+ }
imply = false;
}
-- { dg-do compile }
-- { dg-options "-O -gnatn -Winline -cargs --param max-inline-insns-single=50 -margs" }
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO;
procedure Warn32 is
type Selected_Block_T is record
Contents : Unbounded_String;
File_Name : Unbounded_String;
end record;
pragma Warnings (Off, "-Winline");
package Selected_Block_List is
new Ada.Containers.Vectors (Natural, Selected_Block_T);
begin
Ada.Text_Io.Put_Line ("Hello World!");
end;