diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2020-06-23 21:45:31 +0200 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-10-15 05:39:11 -0400 |
commit | 1d1e5e2e2cd122e4836f05072dbe430a451870fd (patch) | |
tree | 722aa42516bf6aa8d8541fa36e3eca035d3fa06e | |
parent | 2b47f13daba17a6e77e74a94ac0daeadbd30a482 (diff) | |
download | gcc-1d1e5e2e2cd122e4836f05072dbe430a451870fd.zip gcc-1d1e5e2e2cd122e4836f05072dbe430a451870fd.tar.gz gcc-1d1e5e2e2cd122e4836f05072dbe430a451870fd.tar.bz2 |
[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.
-rw-r--r-- | gcc/ada/sem_ch3.adb | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index c9b1f18..63779e8 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; |