aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2020-05-27 13:26:36 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2020-07-10 05:16:18 -0400
commit8248cf4b7006af19298f0b944c212fe2b4b66bef (patch)
treeaa16477f833c4ab515f514b1629ef3417ad68736 /gcc
parent25af525c300abc790ef35bf2d8fb083a570b840a (diff)
downloadgcc-8248cf4b7006af19298f0b944c212fe2b4b66bef.zip
gcc-8248cf4b7006af19298f0b944c212fe2b4b66bef.tar.gz
gcc-8248cf4b7006af19298f0b944c212fe2b4b66bef.tar.bz2
[Ada] Revert too late setting of Ekind on discriminants
gcc/ada/ * sem_ch3.adb (Process_Discriminants): Revert recent change to location of Set_Ekind; detect effectively volatile discriminants by their type only.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_ch3.adb9
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 74946d3..68bb5fc 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -19977,7 +19977,6 @@ package body Sem_Ch3 is
end if;
Set_Etype (Defining_Identifier (Discr), Discr_Type);
- Set_Ekind (Defining_Identifier (Discr), E_Discriminant);
-- If a discriminant specification includes the assignment compound
-- delimiter followed by an expression, the expression is the default
@@ -20131,10 +20130,13 @@ package body Sem_Ch3 is
-- A discriminant cannot be effectively volatile (SPARK RM 7.1.3(4)).
-- This check is relevant only when SPARK_Mode is on as it is not a
- -- standard Ada legality rule.
+ -- standard Ada legality rule. The only way for a discriminant to be
+ -- effectively volatile is to have an effectively volatile type, so
+ -- we check this directly, because the Ekind of Discr might not be
+ -- set yet (to help preventing cascaded errors on derived types).
if SPARK_Mode = On
- and then Is_Effectively_Volatile (Defining_Identifier (Discr))
+ and then Is_Effectively_Volatile (Discr_Type)
then
Error_Msg_N ("discriminant cannot be volatile", Discr);
end if;
@@ -20176,6 +20178,7 @@ package body Sem_Ch3 is
Discr_Number := Uint_1;
while Present (Discr) loop
Id := Defining_Identifier (Discr);
+ Set_Ekind (Id, E_Discriminant);
Init_Component_Location (Id);
Init_Esize (Id);
Set_Discriminant_Number (Id, Discr_Number);