From 04598eb03b1b44c4fc3c253841a7672066835ed9 Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Fri, 15 Jan 2021 14:01:59 +0100 Subject: [PATCH] [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. --- gcc/ada/exp_ch3.adb | 20 +++++++------------- gcc/ada/freeze.adb | 5 ++--- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index 6037e8d2d44d..6d7d178f35aa 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 806677a97862..ce5de2194e15 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)) -- 2.47.2