Patchwork [Ada] Save/restore value of pragma Normalize_Scalars

login
register
mail settings
Submitter Arnaud Charlet
Date Aug. 4, 2011, 1:31 p.m.
Message ID <20110804133133.GA8028@adacore.com>
Download mbox | patch
Permalink /patch/108459/
State New
Headers show

Comments

Arnaud Charlet - Aug. 4, 2011, 1:31 p.m.
This patch reverses the previous patch which saved/restore the values of
pragma Normalize_Scalars because the value of Normalize_Scalars must not
be saved/restored because once set to true its value never changes. That
is, if a compilation unit has pragma Normalize_Scalars then it forces
that value for all with'ed units. After this patch the compilation
of the following small test must not cause an assertion failure
in the frontend.

with Ada.Text_IO;
package ImpDef is end;

pragma Normalize_Scalars;
with Impdef;
package CXH1001_0 is end;

Command: gcc -c cxh1001_0.ads

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

2011-08-04  Javier Miranda  <miranda@adacore.com>

	* opt.ads (Init_Or_Norm_Scalars_Config): Removed.
	(Normalize_Scalars_Config): Removed.
	* opt.adb
	(Register_Opt_Config_Switches): Remove registering config values of
	Init_Or_Norm_Scalars_Config and Normalize_Scalars_Config.
	(Restore_Opt_Config_Switches): Remove code which restores the values of
	Init_Or_Norm_Scalars and Normalize_Scalars. Recalculate value of
	Init_Or_Norm_Scalars.
	(Save_Opt_Config_Switches): Remove code which saves values of
	Init_Or_Norm_Scalars and Normalize_Scalars.
	(Set_Opt_Config_Switches): Remove code which restores config values of
	Init_Or_Norm_Scalars and Normalize_Scalars. Recalculate value of
	Init_Or_Norm_Scalars.

Patch

Index: opt.adb
===================================================================
--- opt.adb	(revision 177360)
+++ opt.adb	(working copy)
@@ -57,9 +57,7 @@ 
       External_Name_Exp_Casing_Config       := External_Name_Exp_Casing;
       External_Name_Imp_Casing_Config       := External_Name_Imp_Casing;
       Fast_Math_Config                      := Fast_Math;
-      Init_Or_Norm_Scalars_Config           := Init_Or_Norm_Scalars;
       Initialize_Scalars_Config             := Initialize_Scalars;
-      Normalize_Scalars_Config              := Normalize_Scalars;
       Optimize_Alignment_Config             := Optimize_Alignment;
       Persistent_BSS_Mode_Config            := Persistent_BSS_Mode;
       Polling_Required_Config               := Polling_Required;
@@ -92,15 +90,20 @@ 
       External_Name_Exp_Casing       := Save.External_Name_Exp_Casing;
       External_Name_Imp_Casing       := Save.External_Name_Imp_Casing;
       Fast_Math                      := Save.Fast_Math;
-      Init_Or_Norm_Scalars           := Save.Init_Or_Norm_Scalars;
       Initialize_Scalars             := Save.Initialize_Scalars;
-      Normalize_Scalars              := Save.Normalize_Scalars;
       Optimize_Alignment             := Save.Optimize_Alignment;
       Optimize_Alignment_Local       := Save.Optimize_Alignment_Local;
       Persistent_BSS_Mode            := Save.Persistent_BSS_Mode;
       Polling_Required               := Save.Polling_Required;
       Short_Descriptors              := Save.Short_Descriptors;
       Use_VADS_Size                  := Save.Use_VADS_Size;
+
+      --  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_Opt_Config_Switches;
 
    ------------------------------
@@ -122,9 +125,7 @@ 
       Save.External_Name_Exp_Casing       := External_Name_Exp_Casing;
       Save.External_Name_Imp_Casing       := External_Name_Imp_Casing;
       Save.Fast_Math                      := Fast_Math;
-      Save.Init_Or_Norm_Scalars           := Init_Or_Norm_Scalars;
       Save.Initialize_Scalars             := Initialize_Scalars;
-      Save.Normalize_Scalars              := Normalize_Scalars;
       Save.Optimize_Alignment             := Optimize_Alignment;
       Save.Optimize_Alignment_Local       := Optimize_Alignment_Local;
       Save.Persistent_BSS_Mode            := Persistent_BSS_Mode;
@@ -190,13 +191,19 @@ 
          External_Name_Exp_Casing    := External_Name_Exp_Casing_Config;
          External_Name_Imp_Casing    := External_Name_Imp_Casing_Config;
          Fast_Math                   := Fast_Math_Config;
-         Init_Or_Norm_Scalars        := Init_Or_Norm_Scalars_Config;
          Initialize_Scalars          := Initialize_Scalars_Config;
-         Normalize_Scalars           := Normalize_Scalars_Config;
          Optimize_Alignment          := Optimize_Alignment_Config;
          Optimize_Alignment_Local    := False;
          Persistent_BSS_Mode         := Persistent_BSS_Mode_Config;
          Use_VADS_Size               := Use_VADS_Size_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;
 
       Default_Pool                   := Default_Pool_Config;
Index: opt.ads
===================================================================
--- opt.ads	(revision 177360)
+++ opt.ads	(working copy)
@@ -1718,11 +1718,6 @@ 
    --  used to set the initial value of Fast_Math at the start of each new
    --  compilation unit.
 
-   Init_Or_Norm_Scalars_Config : Boolean;
-   --  GNAT
-   --  This is the value of the configuration switch that is set by one
-   --  of the pragmas Initialize_Scalars or Normalize_Scalars.
-
    Initialize_Scalars_Config : Boolean;
    --  GNAT
    --  This is the value of the configuration switch that is set by the
@@ -1730,13 +1725,6 @@ 
    --  This switch is not set when the pragma appears ahead of a given
    --  unit, so it does not affect the compilation of other units.
 
-   Normalize_Scalars_Config : Boolean;
-   --  GNAT
-   --  This is the value of the configuration switch that is set by the
-   --  pragma Normalize_Scalars when it appears in the gnat.adc file.
-   --  This switch is not set when the pragma appears ahead of a given
-   --  unit, so it does not affect the compilation of other units.
-
    Optimize_Alignment_Config : Character;
    --  GNAT
    --  This is the value of the configuration switch that controls the
@@ -1916,7 +1904,6 @@ 
       External_Name_Exp_Casing       : External_Casing_Type;
       External_Name_Imp_Casing       : External_Casing_Type;
       Fast_Math                      : Boolean;
-      Init_Or_Norm_Scalars           : Boolean;
       Initialize_Scalars             : Boolean;
       Normalize_Scalars              : Boolean;
       Optimize_Alignment             : Character;