From: Ronan Desplanques <[email protected]>

Init_Or_Norm_Scalars was a global variable used to store the boolean
disjunction of two other global variables. This patch replaces it with
an expression function to make things simpler.

gcc/ada/ChangeLog:

        * opt.ads (Init_Or_Norm_Scalars): Turn into expression function.
        * opt.adb (Restore_Config_Switches, Set_Config_Switches): Remove
        assignment.
        * frontend.adb (Frontend): Remove assignment.
        * sem_prag.adb (Do_Initialize_Scalars, Analyze_Pragma): Remove
        assignment.
        * targparm.adb (Get_Target_Parameters): Remove assignment.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/frontend.adb |  1 -
 gcc/ada/opt.adb      | 15 ---------------
 gcc/ada/opt.ads      | 11 ++++-------
 gcc/ada/sem_prag.adb |  2 --
 gcc/ada/targparm.adb |  1 -
 5 files changed, 4 insertions(+), 26 deletions(-)

diff --git a/gcc/ada/frontend.adb b/gcc/ada/frontend.adb
index 0ab416a7d32..9c47dc78154 100644
--- a/gcc/ada/frontend.adb
+++ b/gcc/ada/frontend.adb
@@ -381,7 +381,6 @@ begin
 
       if Initialize_Scalars and then Is_Predefined_Unit (Main_Unit) then
          Initialize_Scalars   := False;
-         Init_Or_Norm_Scalars := Normalize_Scalars;
       end if;
 
       --  Now on to the semantics. Skip if in syntax only mode
diff --git a/gcc/ada/opt.adb b/gcc/ada/opt.adb
index 87bd743f6fd..6e970cd5aad 100644
--- a/gcc/ada/opt.adb
+++ b/gcc/ada/opt.adb
@@ -112,13 +112,6 @@ package body Opt is
       Uneval_Old                     := Save.Uneval_Old;
       Use_VADS_Size                  := Save.Use_VADS_Size;
       Warnings_As_Errors_Count       := Save.Warnings_As_Errors_Count;
-
-      --  Update consistently the value of Init_Or_Norm_Scalars. The value of
-      --  Normalize_Scalars is not saved/restored because after set to True its
-      --  value is never changed. That is, if a compilation unit has pragma
-      --  Normalize_Scalars then it forces that value for all with'ed units.
-
-      Init_Or_Norm_Scalars := Initialize_Scalars or Normalize_Scalars;
    end Restore_Config_Switches;
 
    --------------------------
@@ -241,14 +234,6 @@ package body Opt is
          Uneval_Old                  := Uneval_Old_Config;
          Use_VADS_Size               := Use_VADS_Size_Config;
          Warnings_As_Errors_Count    := Warnings_As_Errors_Count_Config;
-
-         --  Update consistently the value of Init_Or_Norm_Scalars. The value
-         --  of Normalize_Scalars is not saved/restored because once set to
-         --  True its value is never changed. That is, if a compilation unit
-         --  has pragma Normalize_Scalars then it forces that value for all
-         --  with'ed units.
-
-         Init_Or_Norm_Scalars := Initialize_Scalars or Normalize_Scalars;
       end if;
 
       --  Values set for all units
diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads
index fd0b46d3feb..a30b0ec114c 100644
--- a/gcc/ada/opt.ads
+++ b/gcc/ada/opt.ads
@@ -845,15 +845,9 @@ package Opt is
    --  allowed to cause implicit packing instead of generating an error
    --  message. Set by use of pragma Implicit_Packing.
 
-   Init_Or_Norm_Scalars : Boolean := False;
-   --  GNAT, GNATBIND
-   --  Set True if a pragma Initialize_Scalars applies to the current unit.
-   --  Also set True if a pragma Restriction (Normalize_Scalars) applies.
-
    Initialize_Scalars : Boolean := False;
    --  GNAT
    --  Set True if a pragma Initialize_Scalars applies to the current unit.
-   --  Note that Init_Or_Norm_Scalars is also set to True if this is True.
 
    Initialize_Scalars_Mode1 : Character := 'I';
    Initialize_Scalars_Mode2 : Character := 'N';
@@ -1168,7 +1162,6 @@ package Opt is
    Normalize_Scalars : Boolean := False;
    --  GNAT, GNATBIND
    --  Set True if a pragma Normalize_Scalars applies to the current unit.
-   --  Note that Init_Or_Norm_Scalars is also set to True if this is True.
 
    Object_Directory_Present : Boolean := False;
    --  GNATMAKE
@@ -1726,6 +1719,10 @@ package Opt is
    --  Do no formatting (no title, no leading spaces, no empty lines) in
    --  auxiliary outputs (-e, -K, -l, -R).
 
+   function Init_Or_Norm_Scalars return Boolean
+   is (Initialize_Scalars or Normalize_Scalars);
+   --  A convenience shortcut for a common expression
+
    ----------------------------
    -- Configuration Settings --
    ----------------------------
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 3cc78ebcdd4..7762797bba3 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -20809,7 +20809,6 @@ package body Sem_Prag is
                   Pop_Scope;
                end if;
 
-               Init_Or_Norm_Scalars := True;
                Initialize_Scalars   := True;
             end if;
          end Do_Initialize_Scalars;
@@ -23313,7 +23312,6 @@ package body Sem_Prag is
 
             if not (CodePeer_Mode or GNATprove_Mode) then
                Normalize_Scalars := True;
-               Init_Or_Norm_Scalars := True;
             end if;
 
          -----------------
diff --git a/gcc/ada/targparm.adb b/gcc/ada/targparm.adb
index 8cda67c1ffa..64850e88391 100644
--- a/gcc/ada/targparm.adb
+++ b/gcc/ada/targparm.adb
@@ -630,7 +630,6 @@ package body Targparm is
 
          elsif Looking_At_Skip ("pragma Normalize_Scalars;") then
             Opt.Normalize_Scalars := True;
-            Opt.Init_Or_Norm_Scalars := True;
             goto Line_Loop_Continue;
 
          --  Partition_Elaboration_Policy
-- 
2.53.0

Reply via email to