public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/guojiufu/heads/personal-branch)] [Ada] Simplify getting discriminant value from a list of constraints
@ 2020-06-13 2:59 Jiu Fu Guo
0 siblings, 0 replies; only message in thread
From: Jiu Fu Guo @ 2020-06-13 2:59 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:51ebdbc91a8bbbd7509273075f3953b335b8c7c1
commit 51ebdbc91a8bbbd7509273075f3953b335b8c7c1
Author: Piotr Trojanek <trojanek@adacore.com>
Date: Fri Mar 13 21:32:25 2020 +0100
[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.
Diff:
---
gcc/ada/sem_ch3.adb | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index ff1f6dbd651..2e9a3d0758c 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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-06-13 2:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-13 2:59 [gcc(refs/users/guojiufu/heads/personal-branch)] [Ada] Simplify getting discriminant value from a list of constraints Jiu Fu Guo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).