diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2024-03-05 13:06:18 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-05-17 10:21:00 +0200 |
commit | 8e4069566e5ce4f2d936635187fd90c300e475e9 (patch) | |
tree | 66a7f4c9e77da2f21516614be504f9d72dd04778 /gcc/ada | |
parent | 4b5eeb74a20028e493b520887cc9fd97d6fc0f3d (diff) | |
download | gcc-8e4069566e5ce4f2d936635187fd90c300e475e9.zip gcc-8e4069566e5ce4f2d936635187fd90c300e475e9.tar.gz gcc-8e4069566e5ce4f2d936635187fd90c300e475e9.tar.bz2 |
ada: Simplify code for private types with unknown discriminants
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.
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/sem_ch7.adb | 7 | ||||
-rw-r--r-- | 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 7464622..a70d72c 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 0302cdb..e57f42d 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; |