aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/rtsfind.adb
diff options
context:
space:
mode:
authorSteve Baird <baird@adacore.com>2024-02-07 11:47:22 -0800
committerMarc Poulhiès <poulhies@adacore.com>2024-05-14 10:19:52 +0200
commitb2453909f68aa3e6810e4995bdcb0a555aab3902 (patch)
tree3f87ba1881a168748b799f9400a9d7c3e52eb71c /gcc/ada/rtsfind.adb
parentcad2744cb385413d4762057a19f972fcb74233d6 (diff)
downloadgcc-b2453909f68aa3e6810e4995bdcb0a555aab3902.zip
gcc-b2453909f68aa3e6810e4995bdcb0a555aab3902.tar.gz
gcc-b2453909f68aa3e6810e4995bdcb0a555aab3902.tar.bz2
ada: Rtsfind should not trash state used in analyzing instantiations.
During analysis of an instantiation, Sem_Ch12 manages formal/actual binding information in package state (see Sem_Ch12.Generic_Renamings_HTable). A call to rtsfind can cause another unit to be loaded and compiled. If this occurs during the analysis of an instantiation, and if the loaded unit contains a second instantiation, then the Sem_Ch12 state needed for analyzing the first instantiation can be trashed during the analysis of the second instantiation. Rtsfind calls that can include the analysis of an instantiation need to save and restore Sem_Ch12's state. gcc/ada/ * sem_ch12.ads: Declare new Instance_Context package, which declares a private type Context with operations Save_And_Reset and Restore. * sem_ch12.adb: Provide body for new Instance_Context package. * rtsfind.adb (Load_RTU): Wrap an Instance_Context Save/Restore call pair around the call to Semantics. * table.ads: Add initial value for Last_Val (because Save_And_Reset expects Last_Val to be initialized).
Diffstat (limited to 'gcc/ada/rtsfind.adb')
-rw-r--r--gcc/ada/rtsfind.adb9
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/ada/rtsfind.adb b/gcc/ada/rtsfind.adb
index 8933ca6..7c9935e 100644
--- a/gcc/ada/rtsfind.adb
+++ b/gcc/ada/rtsfind.adb
@@ -47,6 +47,7 @@ with Restrict; use Restrict;
with Sem; use Sem;
with Sem_Aux; use Sem_Aux;
with Sem_Ch7; use Sem_Ch7;
+with Sem_Ch12; use Sem_Ch12;
with Sem_Dist; use Sem_Dist;
with Sem_Util; use Sem_Util;
with Sinfo; use Sinfo;
@@ -1185,7 +1186,13 @@ package body Rtsfind is
else
Save_Private_Visibility;
- Semantics (Cunit (U.Unum));
+ declare
+ Saved_Instance_Context : constant Instance_Context.Context
+ := Instance_Context.Save_And_Reset;
+ begin
+ Semantics (Cunit (U.Unum));
+ Instance_Context.Restore (Saved_Instance_Context);
+ end;
Restore_Private_Visibility;
if Fatal_Error (U.Unum) = Error_Detected then