diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2020-03-13 21:32:25 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-06-12 04:29:16 -0400 |
commit | 51ebdbc91a8bbbd7509273075f3953b335b8c7c1 (patch) | |
tree | 519defffe4f7d330b586c92ce08043f5dd726f78 | |
parent | ec772e4b269206a943b3caa5544d9c7ac1d8de1a (diff) | |
download | gcc-51ebdbc91a8bbbd7509273075f3953b335b8c7c1.zip gcc-51ebdbc91a8bbbd7509273075f3953b335b8c7c1.tar.gz gcc-51ebdbc91a8bbbd7509273075f3953b335b8c7c1.tar.bz2 |
[Ada] Simplify getting discriminant value from a list of constraints
2020-06-12 Piotr Trojanek <trojanek@adacore.com>
gcc/ada/
* sem_ch3.adb (Get_Discr_Value): Cleanup.
-rw-r--r-- | gcc/ada/sem_ch3.adb | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index ff1f6db..2e9a3d0 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -13112,8 +13112,8 @@ package body Sem_Ch3 is function Is_Discriminant (Expr : Node_Id) return Boolean; -- Returns True if Expr is a discriminant - function Get_Discr_Value (Discrim : Entity_Id) return Node_Id; - -- Find the value of discriminant Discrim in Constraint + function Get_Discr_Value (Discr_Expr : Node_Id) return Node_Id; + -- Find the value of a discriminant named by Discr_Expr in Constraints ----------------------------------- -- Build_Constrained_Access_Type -- @@ -13335,7 +13335,11 @@ package body Sem_Ch3 is -- Get_Discr_Value -- --------------------- - function Get_Discr_Value (Discrim : Entity_Id) return Node_Id is + function Get_Discr_Value (Discr_Expr : Node_Id) return Node_Id is + Discr_Id : constant Entity_Id := Entity (Discr_Expr); + -- Entity of a discriminant that appear as a standalone expression in + -- the constraint of a component. + D : Entity_Id; E : Elmt_Id; @@ -13351,9 +13355,9 @@ package body Sem_Ch3 is E := First_Elmt (Constraints); while Present (D) loop - if D = Entity (Discrim) - or else D = CR_Discriminant (Entity (Discrim)) - or else Corresponding_Discriminant (D) = Entity (Discrim) + if D = Discr_Id + or else D = CR_Discriminant (Discr_Id) + or else Corresponding_Discriminant (D) = Discr_Id then return Node (E); end if; @@ -13373,12 +13377,12 @@ package body Sem_Ch3 is -- be present when the component is a discriminated task type? if Is_Derived_Type (Typ) - and then Scope (Entity (Discrim)) = Etype (Typ) + and then Scope (Discr_Id) = Etype (Typ) then D := First_Discriminant (Etype (Typ)); E := First_Elmt (Constraints); while Present (D) loop - if D = Entity (Discrim) then + if D = Discr_Id then return Node (E); end if; |