aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2024-12-05 15:14:58 +0100
committerMarc Poulhiès <dkm@gcc.gnu.org>2025-01-03 16:39:14 +0100
commitbfa8e6f2137ba80dcd1ca7106be2cfe967810426 (patch)
tree17e2ab1dcaa458a17be512bd0e07f11d67006b11 /gcc
parent586fa60bdb385a94d0c11cca2940b8377df7a185 (diff)
downloadgcc-bfa8e6f2137ba80dcd1ca7106be2cfe967810426.zip
gcc-bfa8e6f2137ba80dcd1ca7106be2cfe967810426.tar.gz
gcc-bfa8e6f2137ba80dcd1ca7106be2cfe967810426.tar.bz2
ada: Remove guards against empty lists
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/contracts.adb16
-rw-r--r--gcc/ada/sem_util.adb9
2 files changed, 6 insertions, 19 deletions
diff --git a/gcc/ada/contracts.adb b/gcc/ada/contracts.adb
index 7e66a54..7eb41f7 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 44a8729..6bc50c4 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