From: Eric Botcazou Date: Wed, 18 Dec 2019 09:51:14 +0000 (+0000) Subject: trans.c (Pragma_to_gnu): Push a diagnostics state for pragma Warnings (Off) before... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e3371908b30b254f79f735abf66a8d17c188988a;p=gcc.git trans.c (Pragma_to_gnu): Push a diagnostics state for pragma Warnings (Off) before turning off all the... * gcc-interface/trans.c (Pragma_to_gnu) : Push a diagnostics state for pragma Warnings (Off) before turning off all the warnings and only pop it for pragma Warnings (On). From-SVN: r279519 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index aa37e62d9eb..bfc838f48f2 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2019-12-18 Eric Botcazou + + * gcc-interface/trans.c (Pragma_to_gnu) : 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 Justin Squirek * sem_ch6.adb (Analyze_Function_Return): Modify handling of diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index e6914cc470c..5f87bc3dca8 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3020a95efdf..a0b25efde5b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-12-18 Eric Botcazou + + * gnat.dg/warn32.adb: New test. + 2019-12-17 Martin Sebor PR c++/61339 diff --git a/gcc/testsuite/gnat.dg/warn32.adb b/gcc/testsuite/gnat.dg/warn32.adb new file mode 100644 index 00000000000..e3ffefb47ce --- /dev/null +++ b/gcc/testsuite/gnat.dg/warn32.adb @@ -0,0 +1,19 @@ +-- { 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;