This patch corrects an issue introduced by Q220-025 where the use of pragma
warnings off applied to an unreferenced variable is not warned about the
possibility of replacing with the more specific pragma unreferenced when using
the -gnatw.w.

------------
-- Source --
------------

--  p.adb

procedure P is
   X : Integer;
   pragma Warnings (Off, X);
begin
   X := 12 + 53;
end;

----------------------------
-- Compilation and output --
----------------------------

& gnatmake p.adb -gnatw.w -q
p.adb:3:11: warning: could use Unreferenced instead of Warnings Off for "X"

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

2017-10-14  Justin Squirek  <squi...@adacore.com>

        * sem_elab.adb (Is_Suitable_Variable_Assignment): Replace call to
        Has_Warnings_Off with Warnings_Off.

Index: sem_elab.adb
===================================================================
--- sem_elab.adb        (revision 253753)
+++ sem_elab.adb        (working copy)
@@ -5186,7 +5186,7 @@
         --  The variable must be a source entity and susceptible to warnings
 
         Comes_From_Source (Var_Id)
-          and then not Has_Warnings_Off (Var_Id)
+          and then not Warnings_Off (Var_Id)
 
           --  The variable must be declared in the spec of compilation unit U
 

Reply via email to