aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2021-10-31 20:52:04 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2021-11-10 08:57:40 +0000
commit0c66423ac99a0cbdb87b8019b7d5da3931b50045 (patch)
tree02d6a03a5c287a5c7ec7185c1a2857f3125b2953
parent55a213950e9584ca84e96dc52ba496ff88de7bc8 (diff)
downloadgcc-0c66423ac99a0cbdb87b8019b7d5da3931b50045.zip
gcc-0c66423ac99a0cbdb87b8019b7d5da3931b50045.tar.gz
gcc-0c66423ac99a0cbdb87b8019b7d5da3931b50045.tar.bz2
[Ada] Use predefined equality for arrays inside records
gcc/ada/ * exp_ch4.adb (Expand_Composite_Equality): Handle arrays inside records just like scalars; only records inside records need dedicated handling.
-rw-r--r--gcc/ada/exp_ch4.adb70
1 files changed, 2 insertions, 68 deletions
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 8fb0424..7e25001 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -2475,75 +2475,9 @@ package body Exp_Ch4 is
Full_Type := Underlying_Type (Full_Type);
end if;
- -- Case of array types
-
- if Is_Array_Type (Full_Type) then
-
- -- If the operand is an elementary type other than a floating-point
- -- type, then we can simply use the built-in block bitwise equality,
- -- since the predefined equality operators always apply and bitwise
- -- equality is fine for all these cases.
-
- if Is_Elementary_Type (Component_Type (Full_Type))
- and then not Is_Floating_Point_Type (Component_Type (Full_Type))
- then
- return Make_Op_Eq (Loc, Left_Opnd => Lhs, Right_Opnd => Rhs);
-
- -- For composite component types, and floating-point types, use the
- -- expansion. This deals with tagged component types (where we use
- -- the applicable equality routine) and floating-point (where we
- -- need to worry about negative zeroes), and also the case of any
- -- composite type recursively containing such fields.
-
- else
- declare
- Comp_Typ : Entity_Id;
- Hi : Node_Id;
- Indx : Node_Id;
- Ityp : Entity_Id;
- Lo : Node_Id;
-
- begin
- -- Do the comparison in the type (or its full view) and not in
- -- its unconstrained base type, because the latter operation is
- -- more complex and would also require an unchecked conversion.
-
- if Is_Private_Type (Typ) then
- Comp_Typ := Underlying_Type (Typ);
- else
- Comp_Typ := Typ;
- end if;
-
- -- Except for the case where the bounds of the type depend on a
- -- discriminant, or else we would run into scoping issues.
-
- Indx := First_Index (Comp_Typ);
- while Present (Indx) loop
- Ityp := Etype (Indx);
-
- Lo := Type_Low_Bound (Ityp);
- Hi := Type_High_Bound (Ityp);
-
- if (Nkind (Lo) = N_Identifier
- and then Ekind (Entity (Lo)) = E_Discriminant)
- or else
- (Nkind (Hi) = N_Identifier
- and then Ekind (Entity (Hi)) = E_Discriminant)
- then
- Comp_Typ := Full_Type;
- exit;
- end if;
-
- Next_Index (Indx);
- end loop;
-
- return Expand_Array_Equality (Nod, Lhs, Rhs, Bodies, Comp_Typ);
- end;
- end if;
-
-- Case of tagged record types
- elsif Is_Tagged_Type (Full_Type) then
+ if Is_Tagged_Type (Full_Type) then
Eq_Op := Find_Primitive_Eq (Typ);
pragma Assert (Present (Eq_Op));
@@ -2734,7 +2668,7 @@ package body Exp_Ch4 is
return Expand_Record_Equality (Nod, Full_Type, Lhs, Rhs, Bodies);
end if;
- -- Non-composite types (always use predefined equality)
+ -- Case of non-record types (always use predefined equality)
else
return Make_Op_Eq (Loc, Left_Opnd => Lhs, Right_Opnd => Rhs);