From: Piotr Trojanek <troja...@adacore.com> There is no need to guard against calling First on a No_List, in which case the call intentionally returns Empty. Code cleanup; semantics is unaffected.
gcc/ada/ChangeLog: * contracts.adb (Create_Generic_Contract): Remove calls to Present. * sem_util.adb (Normalize_Actuals): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/contracts.adb | 16 ++++------------ gcc/ada/sem_util.adb | 9 ++------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/gcc/ada/contracts.adb b/gcc/ada/contracts.adb index 7e66a54b675..7eb41f7f107 100644 --- a/gcc/ada/contracts.adb +++ b/gcc/ada/contracts.adb @@ -2122,9 +2122,7 @@ package body Contracts is if Nkind (Templ) = N_Generic_Package_Declaration then Mutate_Ekind (Templ_Id, E_Generic_Package); - if Present (Visible_Declarations (Specification (Templ))) then - Decl := First (Visible_Declarations (Specification (Templ))); - end if; + Decl := First (Visible_Declarations (Specification (Templ))); -- A generic package body carries contract-related source pragmas in its -- declarations. @@ -2132,9 +2130,7 @@ package body Contracts is elsif Nkind (Templ) = N_Package_Body then Mutate_Ekind (Templ_Id, E_Package_Body); - if Present (Declarations (Templ)) then - Decl := First (Declarations (Templ)); - end if; + Decl := First (Declarations (Templ)); -- Generic subprogram declaration @@ -2149,9 +2145,7 @@ package body Contracts is -- the Pragmas_After list for contract-related source pragmas. if Nkind (Context) = N_Compilation_Unit then - if Present (Aux_Decls_Node (Context)) - and then Present (Pragmas_After (Aux_Decls_Node (Context))) - then + if Present (Aux_Decls_Node (Context)) then Decl := First (Pragmas_After (Aux_Decls_Node (Context))); end if; @@ -2168,9 +2162,7 @@ package body Contracts is elsif Nkind (Templ) = N_Subprogram_Body then Mutate_Ekind (Templ_Id, E_Subprogram_Body); - if Present (Declarations (Templ)) then - Decl := First (Declarations (Templ)); - end if; + Decl := First (Declarations (Templ)); end if; -- Inspect the relevant declarations looking for contract-related source diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 44a87298c6e..6bc50c44291 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -25119,9 +25119,7 @@ package body Sem_Util is -- Find if there is a named association, and verify that no positional -- associations appear after named ones. - if Present (Actuals) then - Actual := First (Actuals); - end if; + Actual := First (Actuals); while Present (Actual) and then Nkind (Actual) /= N_Parameter_Association @@ -25169,10 +25167,7 @@ package body Sem_Util is Next (Actual); end loop; - if Present (Actuals) then - Actual := First (Actuals); - end if; - + Actual := First (Actuals); Formal := First_Formal (S); while Present (Formal) loop -- 2.43.0