diff options
author | Hristian Kirtchev <kirtchev@adacore.com> | 2018-07-17 08:11:28 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-07-17 08:11:28 +0000 |
commit | 9cc97ad523d17ce6ae643030e5f99fe5acb68bea (patch) | |
tree | 23ba3b31f1558c7507493b0c189898086dd8d135 /gcc/ada/par.adb | |
parent | 03b4b15ec70e28f945fab896d4574e3953fa2272 (diff) | |
download | gcc-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/par.adb')
-rw-r--r-- | gcc/ada/par.adb | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/gcc/ada/par.adb b/gcc/ada/par.adb index 070dd6d..dd6c9b6 100644 --- a/gcc/ada/par.adb +++ b/gcc/ada/par.adb @@ -57,22 +57,22 @@ with Tbuild; use Tbuild; function Par (Configuration_Pragmas : Boolean) return List_Id is + Inside_Record_Definition : Boolean := False; + -- True within a record definition. Used to control warning for + -- redefinition of standard entities (not issued for field names). + + Loop_Block_Count : Nat := 0; + -- Counter used for constructing loop/block names (see the routine + -- Par.Ch5.Get_Loop_Block_Name). + Num_Library_Units : Natural := 0; -- Count number of units parsed (relevant only in syntax check only mode, -- since in semantics check mode only a single unit is permitted anyway). - Save_Config_Switches : Config_Switches_Type; + Save_Config_Attrs : Config_Switches_Type; -- Variable used to save values of config switches while we parse the -- new unit, to be restored on exit for proper recursive behavior. - Loop_Block_Count : Nat := 0; - -- Counter used for constructing loop/block names (see the routine - -- Par.Ch5.Get_Loop_Block_Name). - - Inside_Record_Definition : Boolean := False; - -- True within a record definition. Used to control warning for - -- redefinition of standard entities (not issued for field names). - -------------------- -- Error Recovery -- -------------------- @@ -1517,7 +1517,7 @@ begin -- Normal case of compilation unit else - Save_Opt_Config_Switches (Save_Config_Switches); + Save_Config_Attrs := Save_Config_Switches; -- The following loop runs more than once in syntax check mode -- where we allow multiple compilation units in the same file @@ -1525,7 +1525,7 @@ begin -- we get to the unit we want. for Ucount in Pos loop - Set_Opt_Config_Switches + Set_Config_Switches (Is_Internal_Unit (Current_Source_Unit), Main_Unit => Current_Source_Unit = Main_Unit); @@ -1661,7 +1661,7 @@ begin end if; - Restore_Opt_Config_Switches (Save_Config_Switches); + Restore_Config_Switches (Save_Config_Attrs); end loop; -- Now that we have completely parsed the source file, we can complete @@ -1690,7 +1690,7 @@ begin -- Restore settings of switches saved on entry - Restore_Opt_Config_Switches (Save_Config_Switches); + Restore_Config_Switches (Save_Config_Attrs); Set_Comes_From_Source_Default (False); end if; |