[Ada] Small tweak to pragma Warnings (On)

Message ID 4521178.57jyJhvGRC@polaris
State New
Headers show
Series
  • [Ada] Small tweak to pragma Warnings (On)
Related show

Commit Message

Eric Botcazou Dec. 18, 2019, 9:52 a.m.
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  <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  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/warn32.adb: New test.

-- 
Eric Botcazou

Patch

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;
 	  }