diff options
author | Ed Schonberg <schonberg@adacore.com> | 2019-09-18 08:33:32 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-09-18 08:33:32 +0000 |
commit | 0cff31f0f67a88fd1bf76bab430eaa0adac94ffa (patch) | |
tree | 849b0df78fdbcbaac14da6e1c1a9bc1c6b4a4f3d /gcc | |
parent | b8411279b0674cd76850b0fa8266e8db21724e0e (diff) | |
download | gcc-0cff31f0f67a88fd1bf76bab430eaa0adac94ffa.zip gcc-0cff31f0f67a88fd1bf76bab430eaa0adac94ffa.tar.gz gcc-0cff31f0f67a88fd1bf76bab430eaa0adac94ffa.tar.bz2 |
[Ada] Use static discriminant value for discriminated task record
This patch allows the construction of a static subtype for the generated
constrained Secondary_Stack component of a task for which a stack size
is specified, when compiling for a restricted run-time that forbids
dynamic allocation. Needed for LLVM.
2019-09-18 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch3.adb (Constrain_Component_Type): For a discriminated
type, handle the case of a constraint given by a conversion of a
discriminant of the enclosing type. Necessary when compiling a
discriminated task for a restricted run-time, when the generated
Secondary_Stack component may be set by means of an aspect on
the task type.
From-SVN: r275863
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/ada/sem_ch3.adb | 21 |
2 files changed, 29 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 92782aab..d9b552a 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,14 @@ 2019-09-18 Ed Schonberg <schonberg@adacore.com> + * sem_ch3.adb (Constrain_Component_Type): For a discriminated + type, handle the case of a constraint given by a conversion of a + discriminant of the enclosing type. Necessary when compiling a + discriminated task for a restricted run-time, when the generated + Secondary_Stack component may be set by means of an aspect on + the task type. + +2019-09-18 Ed Schonberg <schonberg@adacore.com> + * exp_aggr.adb (Expand_Record_Aggregate, Rewrite_Discriminant): After rewriting a reference to an outer discriminant as a selected component of the enclosing object, analyze the selected diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 864b08e..35be35a 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -13258,7 +13258,9 @@ package body Sem_Ch3 is function Build_Constrained_Discriminated_Type (Old_Type : Entity_Id) return Entity_Id; - -- Ditto for record components + -- Ditto for record components. Handle the case where the constraint + -- is a conversion of the discriminant value, introduced during + -- expansion. function Build_Constrained_Access_Type (Old_Type : Entity_Id) return Entity_Id; @@ -13443,6 +13445,17 @@ package body Sem_Ch3 is if Is_Discriminant (Expr) then Need_To_Create_Itype := True; + + -- After expansion of discriminated task types, the value + -- of the discriminant may be converted to a run-time type + -- for restricted run-times. Propagate the value of the + -- discriminant ss well, so that e.g. the secondary stack + -- component has a static constraint. Necessry for LLVM. + + elsif Nkind (Expr) = N_Type_Conversion + and then Is_Discriminant (Expression (Expr)) + then + Need_To_Create_Itype := True; end if; Next_Elmt (Old_Constraint); @@ -13457,6 +13470,12 @@ package body Sem_Ch3 is if Is_Discriminant (Expr) then Expr := Get_Discr_Value (Expr); + + elsif Nkind (Expr) = N_Type_Conversion + and then Is_Discriminant (Expression (Expr)) + then + Expr := New_Copy_Tree (Expr); + Set_Expression (Expr, Get_Discr_Value (Expression (Expr))); end if; Append (New_Copy_Tree (Expr), To => Constr_List); |