diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2021-01-12 21:37:26 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-05-05 04:19:04 -0400 |
commit | 7faaabcc4813dcee031ca1c9a0810673a31a153b (patch) | |
tree | d623f70c0fe89cec1b9242814f5b65ded6be38e6 | |
parent | a119897355ddbc3d7a82b53d32a6a297fc2cb137 (diff) | |
download | gcc-7faaabcc4813dcee031ca1c9a0810673a31a153b.zip gcc-7faaabcc4813dcee031ca1c9a0810673a31a153b.tar.gz gcc-7faaabcc4813dcee031ca1c9a0810673a31a153b.tar.bz2 |
[Ada] Remove redundant checks for empty lists
gcc/ada/
* exp_ch4.adb (Variant_Is_Unconstrained_UU): Remove redundant
check for empty list.
* exp_disp.adb (Find_Entry_Index): Simplify by removing
redundant check and counting from zero; fix type of a local
variable.
* sem_ch12.adb (Save_Global_Descendant): Remove an unnecessary
special-case for empty lists.
-rw-r--r-- | gcc/ada/exp_ch4.adb | 22 | ||||
-rw-r--r-- | gcc/ada/exp_disp.adb | 29 | ||||
-rw-r--r-- | gcc/ada/sem_ch12.adb | 15 |
3 files changed, 25 insertions, 41 deletions
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index cfdfefc..ca23727 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -8170,26 +8170,18 @@ package body Exp_Ch4 is (Variant : Node_Id) return Boolean is Clist : constant Node_Id := Component_List (Variant); + Comp : Node_Id := First (Component_Items (Clist)); begin - if Is_Empty_List (Component_Items (Clist)) then - return False; - end if; - -- We only need to test one component - declare - Comp : Node_Id := First (Component_Items (Clist)); - - begin - while Present (Comp) loop - if Component_Is_Unconstrained_UU (Comp) then - return True; - end if; + while Present (Comp) loop + if Component_Is_Unconstrained_UU (Comp) then + return True; + end if; - Next (Comp); - end loop; - end; + Next (Comp); + end loop; -- None of the components withing the variant were of -- unconstrained Unchecked_Union type. diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb index fcc719a..8bb72eb 100644 --- a/gcc/ada/exp_disp.adb +++ b/gcc/ada/exp_disp.adb @@ -6640,28 +6640,25 @@ package body Exp_Disp is ---------------------- function Find_Entry_Index (E : Entity_Id) return Uint is - Index : Uint := Uint_1; - Subp_Decl : Entity_Id; + Index : Uint := Uint_0; + Subp_Decl : Node_Id; begin - if Present (Decls) - and then not Is_Empty_List (Decls) - then - Subp_Decl := First (Decls); - while Present (Subp_Decl) loop - if Nkind (Subp_Decl) = N_Entry_Declaration then - if Defining_Identifier (Subp_Decl) = E then - return Index; - end if; + Subp_Decl := First (Decls); + while Present (Subp_Decl) loop + if Nkind (Subp_Decl) = N_Entry_Declaration then + Index := Index + 1; - Index := Index + 1; + if Defining_Identifier (Subp_Decl) = E then + exit; end if; - Next (Subp_Decl); - end loop; - end if; + end if; + + Next (Subp_Decl); + end loop; - return Uint_0; + return Index; end Find_Entry_Index; -- Local variables diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index f635f25..a0f1c11 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -16169,16 +16169,11 @@ package body Sem_Ch12 is pragma Assert (D /= Union_Id (No_List)); -- Because No_List = Empty, which is in Node_Range above - if Is_Empty_List (List_Id (D)) then - null; - - else - N1 := First (List_Id (D)); - while Present (N1) loop - Save_References (N1); - Next (N1); - end loop; - end if; + N1 := First (List_Id (D)); + while Present (N1) loop + Save_References (N1); + Next (N1); + end loop; -- Element list or other non-node field, nothing to do |