diff mbox series

[Ada] pragma Warnings (Off) disabled if warning treated as error

Message ID 20171109102722.GA22719@adacore.com
State New
Headers show
Series [Ada] pragma Warnings (Off) disabled if warning treated as error | expand

Commit Message

Pierre-Marie de Rodat Nov. 9, 2017, 10:27 a.m. UTC
The filtering of warnings set by pragma Warnings (Off) may be disabled if an
unfiltered warning is issued by the compiler and this warning is treated as
an error, e.g. by means of -gnatwe.

This behavior clearly goes against the Principle of Least Surprise and is
therefore changed.  The following package must be compiled with the same
single warning about the value not in range, with or without -gnatwe:

with Ada.Unchecked_Conversion;

package P is

  pragma Warnings (Off,"types for unchecked conversion have different sizes");

  function F is new Ada.Unchecked_Conversion (Character, Integer);

  A : Positive := -1;

end P;

Tested on x86_64-pc-linux-gnu, committed on trunk

2017-11-09  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat1drv.adb (Gnat1drv): Call Errout.Finalize (Last_Call => True)
	before Errout.Output_Messages also in the case of compilation errors.
diff mbox series

Patch

Index: gnat1drv.adb
===================================================================
--- gnat1drv.adb	(revision 254563)
+++ gnat1drv.adb	(working copy)
@@ -1180,6 +1180,7 @@ 
       if Compilation_Errors then
          Treepr.Tree_Dump;
          Post_Compilation_Validation_Checks;
+         Errout.Finalize (Last_Call => True);
          Errout.Output_Messages;
          Namet.Finalize;
 
@@ -1190,7 +1191,6 @@ 
             Tree_Gen;
          end if;
 
-         Errout.Finalize (Last_Call => True);
          Exit_Program (E_Errors);
       end if;