aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2021-01-15 14:01:59 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2021-05-06 03:51:21 -0400
commit04598eb03b1b44c4fc3c253841a7672066835ed9 (patch)
tree916208a2a3b8a851e5e6dadf5baa967500ffe593
parentc2f94a898f16d790e21533a6e0d345c23dd379a0 (diff)
downloadgcc-04598eb03b1b44c4fc3c253841a7672066835ed9.zip
gcc-04598eb03b1b44c4fc3c253841a7672066835ed9.tar.gz
gcc-04598eb03b1b44c4fc3c253841a7672066835ed9.tar.bz2
[Ada] Remove excessive conditions in iterations across components
gcc/ada/ * exp_ch3.adb (Expand_Freeze_Array_Type): Remove excessive condition. (Expand_N_Object_Declaration): Likewise. (Build_Equivalent_Aggregate): Likewise. (Initialization_Warning): Likewise; change another excessive condition into assertion. * freeze.adb (Freeze_Entity): Remove excessive condition.
-rw-r--r--gcc/ada/exp_ch3.adb20
-rw-r--r--gcc/ada/freeze.adb5
2 files changed, 9 insertions, 16 deletions
diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
index 6037e8d..6d7d178 100644
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -5477,9 +5477,7 @@ package body Exp_Ch3 is
First_Component (Base_Type (Underlying_Type (Etype (Typ))));
Comp := First_Component (Typ);
while Present (Comp) loop
- if Ekind (Comp) = E_Component
- and then Chars (Comp) = Chars (Old_Comp)
- then
+ if Chars (Comp) = Chars (Old_Comp) then
Set_Discriminant_Checking_Func
(Comp, Discriminant_Checking_Func (Old_Comp));
end if;
@@ -6153,8 +6151,7 @@ package body Exp_Ch3 is
Comp := First_Component (Full_Type);
while Present (Comp) loop
- if Ekind (Comp) = E_Component
- and then Present (Expression (Parent (Comp)))
+ if Present (Expression (Parent (Comp)))
and then
not Is_OK_Static_Expression (Expression (Parent (Comp)))
then
@@ -6186,9 +6183,7 @@ package body Exp_Ch3 is
Comp := First_Component (Full_Type);
while Present (Comp) loop
- if Ekind (Comp) = E_Component
- and then Present (Expression (Parent (Comp)))
- then
+ if Present (Expression (Parent (Comp))) then
Append_To (Component_Associations (Aggr),
Make_Component_Association (Loc,
Choices => New_List (New_Occurrence_Of (Comp, Loc)),
@@ -9001,11 +8996,10 @@ package body Exp_Ch3 is
begin
Comp := First_Component (E);
while Present (Comp) loop
- if Ekind (Comp) = E_Discriminant
- or else
- (Nkind (Parent (Comp)) = N_Component_Declaration
- and then Present (Expression (Parent (Comp))))
- then
+ pragma Assert
+ (Nkind (Parent (Comp)) = N_Component_Declaration);
+
+ if Present (Expression (Parent (Comp))) then
Warning_Needed := True;
exit;
end if;
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index 806677a..ce5de21 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -6847,10 +6847,9 @@ package body Freeze is
begin
Comp := First_Component (E);
while Present (Comp) loop
- Typ := Etype (Comp);
+ Typ := Etype (Comp);
- if Ekind (Comp) = E_Component
- and then Is_Access_Type (Typ)
+ if Is_Access_Type (Typ)
and then Scope (Typ) /= E
and then Base_Type (Designated_Type (Typ)) = E
and then Is_Itype (Designated_Type (Typ))