From: Piotr Trojanek <troja...@adacore.com> Private type entities have Is_Constrained set when they have no discriminants and no unknown discriminants; it is now set slightly later, but simpler (this change could only affect Process_Discriminants, but this flag should not be needed there).
Also, we now reuse this flag to detect private types with discriminants. Code cleanup; behavior is unaffected. gcc/ada/ * sem_ch7.adb (New_Private_Type): Simplify setting of Is_Constrained flag. * sem_prag.adb (Is_Unconstrained_Or_Tagged_Item): Simplify detection of private types with no discriminant. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch7.adb | 7 +++---- gcc/ada/sem_prag.adb | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/gcc/ada/sem_ch7.adb b/gcc/ada/sem_ch7.adb index 74646224452..a70d72c94c1 100644 --- a/gcc/ada/sem_ch7.adb +++ b/gcc/ada/sem_ch7.adb @@ -2746,10 +2746,6 @@ package body Sem_Ch7 is Set_Is_First_Subtype (Id); Reinit_Size_Align (Id); - Set_Is_Constrained (Id, - No (Discriminant_Specifications (N)) - and then not Unknown_Discriminants_Present (N)); - -- Set tagged flag before processing discriminants, to catch illegal -- usage. @@ -2765,6 +2761,9 @@ package body Sem_Ch7 is elsif Unknown_Discriminants_Present (N) then Set_Has_Unknown_Discriminants (Id); + + else + Set_Is_Constrained (Id); end if; Set_Private_Dependents (Id, New_Elmt_List); diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 0302cdb00ba..e57f42d9a54 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -32978,8 +32978,7 @@ package body Sem_Prag is return Has_Discriminants (Typ) and then not Is_Constrained (Typ); elsif Is_Private_Type (Typ) then - return Has_Discriminants (Typ) - or else Has_Unknown_Discriminants (Typ); + return not Is_Constrained (Typ); else return False; -- 2.43.2