trans.c (Pragma_to_gnu): Push a diagnostics state for pragma Warnings (Off) before...
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 18 Dec 2019 09:51:14 +0000 (09:51 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Wed, 18 Dec 2019 09:51:14 +0000 (09:51 +0000)
* 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).

From-SVN: r279519

gcc/ada/ChangeLog
gcc/ada/gcc-interface/trans.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/warn32.adb [new file with mode: 0644]

index aa37e62d9ebbcd6b3d777aea7541a46660a32b8e..bfc838f48f2fb2738941628501c75e8fc8befb03 100644 (file)
@@ -1,3 +1,9 @@
+2019-12-18  Eric Botcazou  <ebotcazou@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  Justin Squirek  <squirek@adacore.com>
 
        * sem_ch6.adb (Analyze_Function_Return): Modify handling of
index e6914cc470c03513fdd4a45c6760d70bea3ba0c0..5f87bc3dca8b0fee27cf913486d29d24f81a0638 100644 (file)
@@ -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;
          }
index 3020a95efdf52a0aa51c13a00825db79a2043bdc..a0b25efde5ba9d51af6fe0b33c42d5f69ff98f54 100644 (file)
@@ -1,3 +1,7 @@
+2019-12-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/warn32.adb: New test.
+
 2019-12-17  Martin Sebor  <msebor@redhat.com>
 
        PR c++/61339
diff --git a/gcc/testsuite/gnat.dg/warn32.adb b/gcc/testsuite/gnat.dg/warn32.adb
new file mode 100644 (file)
index 0000000..e3ffefb
--- /dev/null
@@ -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;