From d2b73a3edb85564fce73b916ad7f7c65ea3ef74d Mon Sep 17 00:00:00 2001 From: Ed Schonberg Date: Mon, 16 Jul 2018 14:11:15 +0000 Subject: [PATCH] [Ada] Add a missing check for trivial predicates on non-discrete types 2018-07-16 Ed Schonberg gcc/ada/ * sem_ch3.adb (Inherit_Predicate_Flags): A non-discrete type may have a static predicate (for example True) but has no static_discrete_predicate. From-SVN: r262716 --- gcc/ada/ChangeLog | 6 ++++++ gcc/ada/sem_ch3.adb | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 59597a3a39b..cd1aac0971d 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2018-07-16 Ed Schonberg + + * sem_ch3.adb (Inherit_Predicate_Flags): A non-discrete type may have a + static predicate (for example True) but has no + static_discrete_predicate. + 2018-07-16 Hristian Kirtchev * exp_attr.adb (Build_Record_VS_Func): Handle corner cases dealing with diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 43055e69871..9a9c15003f6 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -18615,11 +18615,15 @@ package body Sem_Ch3 is -- A named subtype does not inherit the predicate function of its -- parent but an itype declared for a loop index needs the discrete -- predicate information of its parent to execute the loop properly. + -- A non-discrete type may has a static predicate (for example True) + -- but has no static_discrete_predicate. if Is_Itype (Subt) and then Present (Predicate_Function (Par)) then Set_Subprograms_For_Type (Subt, Subprograms_For_Type (Par)); - if Has_Static_Predicate (Par) then + if Has_Static_Predicate (Par) + and then Is_Discrete_Type (Par) + then Set_Static_Discrete_Predicate (Subt, Static_Discrete_Predicate (Par)); end if; -- 2.30.2