aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/opt.adb
diff options
context:
space:
mode:
authorHristian Kirtchev <kirtchev@adacore.com>2018-07-17 08:11:28 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-07-17 08:11:28 +0000
commit9cc97ad523d17ce6ae643030e5f99fe5acb68bea (patch)
tree23ba3b31f1558c7507493b0c189898086dd8d135 /gcc/ada/opt.adb
parent03b4b15ec70e28f945fab896d4574e3953fa2272 (diff)
downloadgcc-9cc97ad523d17ce6ae643030e5f99fe5acb68bea.zip
gcc-9cc97ad523d17ce6ae643030e5f99fe5acb68bea.tar.gz
gcc-9cc97ad523d17ce6ae643030e5f99fe5acb68bea.tar.bz2
[Ada] Configuration state not observed for instance bodies
This patch ensures that the processing of instantiated and inlined bodies uses the proper configuration context available at the point of the instantiation or inlining. Previously configuration pragmas which appear prior to the context items of a unit would lose their effect when a body is instantiated or inlined. 2018-07-17 Hristian Kirtchev <kirtchev@adacore.com> gcc/ada/ * frontend.adb (Frontend): Update the call to Register_Config_Switches. * inline.ads: Add new component Config_Switches to record Pending_Body_Info which captures the configuration state of the pending body. Remove components Version, Version_Pragma, SPARK_Mode, and SPARK_Mode_Pragma from record Pending_Body_Info because they are already captured in component Config_Switches. * opt.adb (Register_Opt_Config_Switches): Rename to Register_Config_Switches. (Restore_Opt_Config_Switches): Rename to Restore_Config_Switches. (Save_Opt_Config_Switches): Rename to Save_Config_Switches. This routine is now a function, and returns the saved configuration state as an aggregate to avoid missing an attribute. (Set_Opt_Config_Switches): Rename to Set_Config_Switches. * opt.ads (Register_Opt_Config_Switches): Rename to Register_Config_Switches. (Restore_Opt_Config_Switches): Rename to Restore_Config_Switches. (Save_Opt_Config_Switches): Rename to Save_Config_Switches. This routine is now a function. (Set_Opt_Config_Switches): Rename to Set_Config_Switches. * par.adb (Par): Update the calls to configuration switch-related subprograms. * sem.adb (Semantics): Update the calls to configuration switch-related subprograms. * sem_ch10.adb (Analyze_Package_Body_Stub): Update the calls to configuration switch-related subprograms. (Analyze_Protected_Body_Stub): Update the calls to configuration switch-related subprograms. (Analyze_Subprogram_Body_Stub): Update calls to configuration switch-related subprograms. * sem_ch12.adb (Add_Pending_Instantiation): Update the capture of pending instantiation attributes. (Inline_Instance_Body): Update the capture of pending instantiation attributes. It is no longer needed to explicitly manipulate the SPARK mode. (Instantiate_Package_Body): Update the restoration of the context attributes. (Instantiate_Subprogram_Body): Update the restoration of context attributes. (Load_Parent_Of_Generic): Update the capture of pending instantiation attributes. (Set_Instance_Env): Update the way relevant configuration attributes are saved and restored. gcc/testsuite/ * gnat.dg/config_pragma1.adb, gnat.dg/config_pragma1_pkg.ads: New testcase. From-SVN: r262794
Diffstat (limited to 'gcc/ada/opt.adb')
-rw-r--r--gcc/ada/opt.adb98
1 files changed, 51 insertions, 47 deletions
diff --git a/gcc/ada/opt.adb b/gcc/ada/opt.adb
index 54f9123..1f12889 100644
--- a/gcc/ada/opt.adb
+++ b/gcc/ada/opt.adb
@@ -80,11 +80,11 @@ package body Opt is
return Exception_Mechanism = Back_End_ZCX;
end ZCX_Exceptions;
- ----------------------------------
- -- Register_Opt_Config_Switches --
- ----------------------------------
+ ------------------------------
+ -- Register_Config_Switches --
+ ------------------------------
- procedure Register_Opt_Config_Switches is
+ procedure Register_Config_Switches is
begin
Ada_Version_Config := Ada_Version;
Ada_Version_Pragma_Config := Ada_Version_Pragma;
@@ -118,13 +118,13 @@ package body Opt is
-- but that's not a local setting.
Optimize_Alignment_Local := False;
- end Register_Opt_Config_Switches;
+ end Register_Config_Switches;
- ---------------------------------
- -- Restore_Opt_Config_Switches --
- ---------------------------------
+ -----------------------------
+ -- Restore_Config_Switches --
+ -----------------------------
- procedure Restore_Opt_Config_Switches (Save : Config_Switches_Type) is
+ procedure Restore_Config_Switches (Save : Config_Switches_Type) is
begin
Ada_Version := Save.Ada_Version;
Ada_Version_Pragma := Save.Ada_Version_Pragma;
@@ -160,48 +160,50 @@ package body Opt is
-- 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;
+ end Restore_Config_Switches;
- ------------------------------
- -- Save_Opt_Config_Switches --
- ------------------------------
+ --------------------------
+ -- Save_Config_Switches --
+ --------------------------
- procedure Save_Opt_Config_Switches (Save : out Config_Switches_Type) is
+ function Save_Config_Switches return Config_Switches_Type is
begin
- Save.Ada_Version := Ada_Version;
- Save.Ada_Version_Pragma := Ada_Version_Pragma;
- Save.Ada_Version_Explicit := Ada_Version_Explicit;
- Save.Assertions_Enabled := Assertions_Enabled;
- Save.Assume_No_Invalid_Values := Assume_No_Invalid_Values;
- Save.Check_Float_Overflow := Check_Float_Overflow;
- Save.Check_Policy_List := Check_Policy_List;
- Save.Default_Pool := Default_Pool;
- Save.Default_SSO := Default_SSO;
- Save.Dynamic_Elaboration_Checks := Dynamic_Elaboration_Checks;
- Save.Exception_Locations_Suppressed := Exception_Locations_Suppressed;
- Save.Extensions_Allowed := Extensions_Allowed;
- Save.External_Name_Exp_Casing := External_Name_Exp_Casing;
- Save.External_Name_Imp_Casing := External_Name_Imp_Casing;
- Save.Fast_Math := Fast_Math;
- Save.Initialize_Scalars := Initialize_Scalars;
- Save.No_Component_Reordering := No_Component_Reordering;
- Save.Optimize_Alignment := Optimize_Alignment;
- Save.Optimize_Alignment_Local := Optimize_Alignment_Local;
- Save.Persistent_BSS_Mode := Persistent_BSS_Mode;
- Save.Polling_Required := Polling_Required;
- Save.Prefix_Exception_Messages := Prefix_Exception_Messages;
- Save.SPARK_Mode := SPARK_Mode;
- Save.SPARK_Mode_Pragma := SPARK_Mode_Pragma;
- Save.Uneval_Old := Uneval_Old;
- Save.Use_VADS_Size := Use_VADS_Size;
- Save.Warnings_As_Errors_Count := Warnings_As_Errors_Count;
- end Save_Opt_Config_Switches;
+ return
+ (Ada_Version => Ada_Version,
+ Ada_Version_Pragma => Ada_Version_Pragma,
+ Ada_Version_Explicit => Ada_Version_Explicit,
+ Assertions_Enabled => Assertions_Enabled,
+ Assume_No_Invalid_Values => Assume_No_Invalid_Values,
+ Check_Float_Overflow => Check_Float_Overflow,
+ Check_Policy_List => Check_Policy_List,
+ Default_Pool => Default_Pool,
+ Default_SSO => Default_SSO,
+ Dynamic_Elaboration_Checks => Dynamic_Elaboration_Checks,
+ Exception_Locations_Suppressed => Exception_Locations_Suppressed,
+ Extensions_Allowed => Extensions_Allowed,
+ External_Name_Exp_Casing => External_Name_Exp_Casing,
+ External_Name_Imp_Casing => External_Name_Imp_Casing,
+ Fast_Math => Fast_Math,
+ Initialize_Scalars => Initialize_Scalars,
+ No_Component_Reordering => No_Component_Reordering,
+ Normalize_Scalars => Normalize_Scalars,
+ Optimize_Alignment => Optimize_Alignment,
+ Optimize_Alignment_Local => Optimize_Alignment_Local,
+ Persistent_BSS_Mode => Persistent_BSS_Mode,
+ Polling_Required => Polling_Required,
+ Prefix_Exception_Messages => Prefix_Exception_Messages,
+ SPARK_Mode => SPARK_Mode,
+ SPARK_Mode_Pragma => SPARK_Mode_Pragma,
+ Uneval_Old => Uneval_Old,
+ Use_VADS_Size => Use_VADS_Size,
+ Warnings_As_Errors_Count => Warnings_As_Errors_Count);
+ end Save_Config_Switches;
- -----------------------------
- -- Set_Opt_Config_Switches --
- -----------------------------
+ -------------------------
+ -- Set_Config_Switches --
+ -------------------------
- procedure Set_Opt_Config_Switches
+ procedure Set_Config_Switches
(Internal_Unit : Boolean;
Main_Unit : Boolean)
is
@@ -244,12 +246,14 @@ package body Opt is
Check_Policy_List := Check_Policy_List_Config;
SPARK_Mode := SPARK_Mode_Config;
SPARK_Mode_Pragma := SPARK_Mode_Pragma_Config;
+
else
if GNAT_Mode_Config then
Assertions_Enabled := Assertions_Enabled_Config;
else
Assertions_Enabled := False;
end if;
+
Assume_No_Invalid_Values := False;
Check_Policy_List := Empty;
SPARK_Mode := None;
@@ -299,7 +303,7 @@ package body Opt is
Exception_Locations_Suppressed := Exception_Locations_Suppressed_Config;
Fast_Math := Fast_Math_Config;
Polling_Required := Polling_Required_Config;
- end Set_Opt_Config_Switches;
+ end Set_Config_Switches;
---------------
-- Tree_Read --