public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-4683] [Ada] Simplify iteration of record components when expanding equality
@ 2021-10-25 15:09 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-10-25 15:09 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:234815d4c38608eb1bff20f68d6dd4c233f07725
commit r12-4683-g234815d4c38608eb1bff20f68d6dd4c233f07725
Author: Piotr Trojanek <trojanek@adacore.com>
Date: Mon Oct 11 14:09:42 2021 +0200
[Ada] Simplify iteration of record components when expanding equality
gcc/ada/
* exp_ch4.adb (Expand_Composite_Equality): Fix style.
(Element_To_Compare): Simplify loop.
(Expand_Record_Equality): Adapt calls to Element_To_Compare.
Diff:
---
gcc/ada/exp_ch4.adb | 48 +++++++++++++++++++++---------------------------
1 file changed, 21 insertions(+), 27 deletions(-)
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 8dcfa85e756..3dd0cc4f1af 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -2583,7 +2583,7 @@ package body Exp_Ch4 is
return
Make_Function_Call (Loc,
- Name => New_Occurrence_Of (Eq_Op, Loc),
+ Name => New_Occurrence_Of (Eq_Op, Loc),
Parameter_Associations =>
New_List
(Unchecked_Convert_To (Etype (First_Formal (Eq_Op)), Lhs),
@@ -2606,7 +2606,7 @@ package body Exp_Ch4 is
begin
return
Make_Function_Call (Loc,
- Name => New_Occurrence_Of (Eq_Op, Loc),
+ Name => New_Occurrence_Of (Eq_Op, Loc),
Parameter_Associations => New_List (
OK_Convert_To (T, Lhs),
OK_Convert_To (T, Rhs)));
@@ -13116,41 +13116,35 @@ package body Exp_Ch4 is
------------------------
function Element_To_Compare (C : Entity_Id) return Entity_Id is
- Comp : Entity_Id;
+ Comp : Entity_Id := C;
begin
- Comp := C;
- loop
- -- Exit loop when the next element to be compared is found, or
- -- there is no more such element.
-
- exit when No (Comp);
-
- exit when Ekind (Comp) in E_Discriminant | E_Component
- and then not (
+ while Present (Comp) loop
+ -- Skip inherited components
- -- Skip inherited components
+ -- Note: for a tagged type, we always generate the "=" primitive
+ -- for the base type (not on the first subtype), so the test for
+ -- Comp /= Original_Record_Component (Comp) is True for inherited
+ -- components only.
- -- Note: for a tagged type, we always generate the "=" primitive
- -- for the base type (not on the first subtype), so the test for
- -- Comp /= Original_Record_Component (Comp) is True for
- -- inherited components only.
-
- (Is_Tagged_Type (Typ)
+ if (Is_Tagged_Type (Typ)
and then Comp /= Original_Record_Component (Comp))
- -- Skip _Tag
+ -- Skip _Tag
or else Chars (Comp) = Name_uTag
- -- Skip interface elements (secondary tags???)
-
- or else Is_Interface (Etype (Comp)));
+ -- Skip interface elements (secondary tags???)
- Next_Entity (Comp);
+ or else Is_Interface (Etype (Comp))
+ then
+ Next_Component_Or_Discriminant (Comp);
+ else
+ return Comp;
+ end if;
end loop;
- return Comp;
+ return Empty;
end Element_To_Compare;
-- Start of processing for Expand_Record_Equality
@@ -13166,7 +13160,7 @@ package body Exp_Ch4 is
-- and then Lhs.Cmpn = Rhs.Cmpn
Result := New_Occurrence_Of (Standard_True, Loc);
- C := Element_To_Compare (First_Entity (Typ));
+ C := Element_To_Compare (First_Component_Or_Discriminant (Typ));
while Present (C) loop
declare
New_Lhs : Node_Id;
@@ -13224,7 +13218,7 @@ package body Exp_Ch4 is
end;
First_Time := False;
- C := Element_To_Compare (Next_Entity (C));
+ C := Element_To_Compare (Next_Component_Or_Discriminant (C));
end loop;
return Result;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-25 15:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25 15:09 [gcc r12-4683] [Ada] Simplify iteration of record components when expanding equality Pierre-Marie de Rodat
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).