* [Ada] Simplify redundant checks for non-empty lists
@ 2021-07-08 13:50 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-07-08 13:50 UTC (permalink / raw)
To: gcc-patches; +Cc: Piotr Trojanek
[-- Attachment #1: Type: text/plain, Size: 341 bytes --]
Simplify "Present (L) and then not Is_Empty_List (L)" into "not
Is_Empty_List (L)", since Is_Empty_List can be called on No_List
and returns True.
Code cleanup; semantics is unaffected.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_ch12.adb, sem_ch6.adb, sem_ch9.adb, sprint.adb: Simplify
checks for non-empty lists.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 2398 bytes --]
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -9724,7 +9724,6 @@ package body Sem_Ch12 is
if Nkind (Par_N) = N_Package_Specification
and then Decls = Visible_Declarations (Par_N)
- and then Present (Private_Declarations (Par_N))
and then not Is_Empty_List (Private_Declarations (Par_N))
then
Decls := Private_Declarations (Par_N);
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -549,7 +549,6 @@ package body Sem_Ch6 is
else
if Nkind (Par) = N_Package_Specification
and then Decls = Visible_Declarations (Par)
- and then Present (Private_Declarations (Par))
and then not Is_Empty_List (Private_Declarations (Par))
then
Decls := Private_Declarations (Par);
diff --git a/gcc/ada/sem_ch9.adb b/gcc/ada/sem_ch9.adb
--- a/gcc/ada/sem_ch9.adb
+++ b/gcc/ada/sem_ch9.adb
@@ -1955,9 +1955,7 @@ package body Sem_Ch9 is
Tasking_Used := True;
Analyze_Declarations (Visible_Declarations (N));
- if Present (Private_Declarations (N))
- and then not Is_Empty_List (Private_Declarations (N))
- then
+ if not Is_Empty_List (Private_Declarations (N)) then
Last_Id := Last_Entity (Prot_Typ);
Analyze_Declarations (Private_Declarations (N));
diff --git a/gcc/ada/sprint.adb b/gcc/ada/sprint.adb
--- a/gcc/ada/sprint.adb
+++ b/gcc/ada/sprint.adb
@@ -1065,16 +1065,12 @@ package body Sprint is
if Present (Expressions (Node)) then
Sprint_Comma_List (Expressions (Node));
- if Present (Component_Associations (Node))
- and then not Is_Empty_List (Component_Associations (Node))
- then
+ if not Is_Empty_List (Component_Associations (Node)) then
Write_Str (", ");
end if;
end if;
- if Present (Component_Associations (Node))
- and then not Is_Empty_List (Component_Associations (Node))
- then
+ if not Is_Empty_List (Component_Associations (Node)) then
Indent_Begin;
declare
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-08 13:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-08 13:50 [Ada] Simplify redundant checks for non-empty lists Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).