aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorJavier Miranda <miranda@adacore.com>2020-07-06 08:04:01 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-19 05:53:36 -0400
commitb9d685922c7d960ab5b0beae348cfb37df08d115 (patch)
tree2e915c0693d2b1d09285725eeb0b62a476e11271 /gcc/ada
parentc95f21001dc9b7dbe717ef84924220192c7b48ae (diff)
downloadgcc-b9d685922c7d960ab5b0beae348cfb37df08d115.zip
gcc-b9d685922c7d960ab5b0beae348cfb37df08d115.tar.gz
gcc-b9d685922c7d960ab5b0beae348cfb37df08d115.tar.bz2
[Ada] Crash in expression function defined in protected object
gcc/ada/ * sem_ch8.adb (Find_Direct_Name): Do not trust in the decoration of the Entity attribute in constants associated with discriminals of protected types.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/sem_ch8.adb17
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
index 73f73c6..c831ed0 100644
--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -5627,6 +5627,21 @@ package body Sem_Ch8 is
if Is_Type (Entity (N)) then
Set_Etype (N, Entity (N));
+ -- The exception to this general rule are constants associated with
+ -- discriminals of protected types because for each protected op
+ -- a new set of discriminals is internally created by the frontend
+ -- (see Exp_Ch9.Set_Discriminals), and the current decoration of the
+ -- entity pointer may have been set as part of a preanalysis, where
+ -- discriminals still reference the first subprogram or entry to be
+ -- expanded (see Expand_Protected_Body_Declarations).
+
+ elsif Full_Analysis
+ and then Ekind (Entity (N)) = E_Constant
+ and then Present (Discriminal_Link (Entity (N)))
+ and then Is_Protected_Type (Scope (Discriminal_Link (Entity (N))))
+ then
+ goto Find_Name;
+
else
declare
Entyp : constant Entity_Id := Etype (Entity (N));
@@ -5667,6 +5682,8 @@ package body Sem_Ch8 is
return;
end if;
+ <<Find_Name>>
+
-- Preserve relevant elaboration-related attributes of the context which
-- are no longer available or very expensive to recompute once analysis,
-- resolution, and expansion are over.