diff options
author | Ed Schonberg <schonberg@adacore.com> | 2018-12-11 11:11:42 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-12-11 11:11:42 +0000 |
commit | 619bfd9fef74000750b1683efc79909798104940 (patch) | |
tree | d945d5736bed089227b5406ea0ea73c30586af46 | |
parent | 78326189ea22b44e238daeb79cde3aa9171b8d15 (diff) | |
download | gcc-619bfd9fef74000750b1683efc79909798104940.zip gcc-619bfd9fef74000750b1683efc79909798104940.tar.gz gcc-619bfd9fef74000750b1683efc79909798104940.tar.bz2 |
[Ada] Fix setting of Has_Predicate flag for aggregate subtypes
This patch enures that the subtype of an aggregate has the Has_Predicate
flag properly set if the array component has a predicate, including the
case the predicate function for the component has not been constructed
yet.
2018-12-11 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_aggr.adb (Array_Aggr_Subtype. Resolve_Aggr_Expr): Indicate
that aggregate subtype has a predicate if the component type has
a predicate; do not rely on exisatence of predicate function for
component, in case component is a type no yet frozen, for which
predicate function has not been created yet.
From-SVN: r267007
-rw-r--r-- | gcc/ada/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/ada/sem_aggr.adb | 14 |
2 files changed, 20 insertions, 2 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index c2305be..d9dfb22 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,11 @@ +2018-12-11 Ed Schonberg <schonberg@adacore.com> + + * sem_aggr.adb (Array_Aggr_Subtype. Resolve_Aggr_Expr): Indicate + that aggregate subtype has a predicate if the component type has + a predicate; do not rely on exisatence of predicate function for + component, in case component is a type no yet frozen, for which + predicate function has not been created yet. + 2018-12-11 Eric Botcazou <ebotcazou@adacore.com> * exp_aggr.adb (Packed_Array_Aggregate_Handled): Bail out for diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index 5e8705f..304ff5d 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -611,6 +611,16 @@ package body Sem_Aggr is Set_Is_Constrained (Itype, True); Set_Is_Internal (Itype, True); + if Has_Predicates (Typ) then + Set_Has_Predicates (Itype); + + if Present (Predicate_Function (Typ)) then + Set_Predicate_Function (Itype, Predicate_Function (Typ)); + else + Set_Predicated_Parent (Itype, Predicated_Parent (Typ)); + end if; + end if; + -- A simple optimization: purely positional aggregates of static -- components should be passed to gigi unexpanded whenever possible, and -- regardless of the staticness of the bounds themselves. Subsequent @@ -1627,7 +1637,7 @@ package body Sem_Aggr is -- component assignments. If the expression covers several components -- the analysis and the predicate check take place later. - if Present (Predicate_Function (Component_Typ)) + if Has_Predicates (Component_Typ) and then Analyzed (Expr) then Apply_Predicate_Check (Expr, Component_Typ); @@ -4194,7 +4204,7 @@ package body Sem_Aggr is -- because the aggegate might not be expanded into individual -- component assignments. - if Present (Predicate_Function (Expr_Type)) + if Has_Predicates (Expr_Type) and then Analyzed (Expr) then Apply_Predicate_Check (Expr, Expr_Type); |