diff options
author | Ed Schonberg <schonberg@adacore.com> | 2019-07-05 07:02:32 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-07-05 07:02:32 +0000 |
commit | 7145d799a347800ea6ef5c5e3114db11469137a8 (patch) | |
tree | d874d49dca886c171bfa46dd98eb0ce2947fbdf6 /gcc/ada | |
parent | de70d01f1a3f52654d39ecb97bd769032e5e2a60 (diff) | |
download | gcc-7145d799a347800ea6ef5c5e3114db11469137a8.zip gcc-7145d799a347800ea6ef5c5e3114db11469137a8.tar.gz gcc-7145d799a347800ea6ef5c5e3114db11469137a8.tar.bz2 |
[Ada] Spurious error on aggregate with choice that is predicted subtype
This patch fixes a spurious error on a record aggregate for a variant
record when a choice in the aggregate is given by a subtype with a
static predicate. The same expansion mechanism for such a variant, used
in case statements, must be used here as well.
2019-07-05 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_util.adb (Encloing_Subprogram): If Enclosing_Dynamic_Scope
is a loop, continue climbing the scope stack to find the
enclosing subprogram.
(Gather_Components): Handle properly a choice in a record
aggregate that is given by a subtype with a static predicate.
gcc/testsuite/
* gnat.dg/aggr25.adb, gnat.dg/aggr25.ads: New testcase.
From-SVN: r273112
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/ada/sem_util.adb | 8 |
2 files changed, 15 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index ac29b92..cac6be7 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,11 @@ +2019-07-05 Ed Schonberg <schonberg@adacore.com> + + * sem_util.adb (Encloing_Subprogram): If Enclosing_Dynamic_Scope + is a loop, continue climbing the scope stack to find the + enclosing subprogram. + (Gather_Components): Handle properly a choice in a record + aggregate that is given by a subtype with a static predicate. + 2019-07-05 Javier Miranda <miranda@adacore.com> * debug.adb (-gnatd.K): Leave available this switch. diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 55e6443..5c33694 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -6895,7 +6895,7 @@ package body Sem_Util is elsif Ekind (Dyn_Scop) = E_Subprogram_Body then return Corresponding_Spec (Parent (Parent (Dyn_Scop))); - elsif Ekind_In (Dyn_Scop, E_Block, E_Return_Statement) then + elsif Ekind_In (Dyn_Scop, E_Block, E_Return_Statement, E_Loop) then return Enclosing_Subprogram (Dyn_Scop); elsif Ekind (Dyn_Scop) = E_Entry then @@ -8939,6 +8939,12 @@ package body Sem_Util is begin Find_Discrete_Value : while Present (Variant) loop + + -- If a choice is a subtype with a static predicate, it must + -- be rewritten as an explicit list of non-predicated choices. + + Expand_Static_Predicates_In_Choices (Variant); + Discrete_Choice := First (Discrete_Choices (Variant)); while Present (Discrete_Choice) loop exit Find_Discrete_Value when |