From 1d1e5e2e2cd122e4836f05072dbe430a451870fd Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Tue, 23 Jun 2020 21:45:31 +0200 Subject: [PATCH] [Ada] Explain predicate function not being inherited by index type gcc/ada/ * sem_ch3.adb (Analyze_Subtype_Declaration): Fix style. (Make_Index): Refactor to avoid repeated detection of subtype indication; add comment. --- gcc/ada/sem_ch3.adb | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index c9b1f18f3cd..63779e82629 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -5279,8 +5279,8 @@ package body Sem_Ch3 is (N : Node_Id; Skip : Boolean := False) is - Id : constant Entity_Id := Defining_Identifier (N); - T : Entity_Id; + Id : constant Entity_Id := Defining_Identifier (N); + T : Entity_Id; begin Generate_Definition (Id); @@ -19374,18 +19374,23 @@ package body Sem_Ch3 is Set_Scalar_Range (Def_Id, R); Conditional_Delay (Def_Id, T); + -- In the subtype indication case inherit properties of the parent + if Nkind (N) = N_Subtype_Indication then + + -- It is enough to inherit predicate flags and not the predicate + -- functions, because predicates on an index type are illegal + -- anyway and the flags are enough to detect them. + Inherit_Predicate_Flags (Def_Id, Entity (Subtype_Mark (N))); - end if; - -- In the subtype indication case, if the immediate parent of the - -- new subtype is nonstatic, then the subtype we create is nonstatic, - -- even if its bounds are static. + -- If the immediate parent of the new subtype is nonstatic, then + -- the subtype we create is nonstatic as well, even if its bounds + -- are static. - if Nkind (N) = N_Subtype_Indication - and then not Is_OK_Static_Subtype (Entity (Subtype_Mark (N))) - then - Set_Is_Non_Static_Subtype (Def_Id); + if not Is_OK_Static_Subtype (Entity (Subtype_Mark (N))) then + Set_Is_Non_Static_Subtype (Def_Id); + end if; end if; end if; -- 2.30.2