From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Piotr Trojanek <trojanek@adacore.com>
Subject: [Ada] Remove unnecessary guards for appending non-empty lists
Date: Fri, 7 Jan 2022 16:27:02 +0000 [thread overview]
Message-ID: <20220107162702.GA948210@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 350 bytes --]
Calls to Append_List and Append_List_To applied with empty lists do
nothing, so there is no need to explicitly guard against such calls.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* exp_ch3.adb (Build_Init_Procedure): Remove unnecessary guard.
* exp_disp.adb (Make_DT): Likewise.
* sem_ch12.adb (Analyze_Associations): Likewise.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1528 bytes --]
diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -2885,9 +2885,7 @@ package body Exp_Ch3 is
Fixed_Comps => False,
Variable_Comps => True);
- if Is_Non_Empty_List (Init_Tags_List) then
- Append_List_To (Body_Stmts, Init_Tags_List);
- end if;
+ Append_List_To (Body_Stmts, Init_Tags_List);
end if;
end if;
diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb
--- a/gcc/ada/exp_disp.adb
+++ b/gcc/ada/exp_disp.adb
@@ -6379,9 +6379,7 @@ package body Exp_Disp is
New_List (New_Occurrence_Of (DT_Ptr, Loc))));
end if;
- if not Is_Empty_List (Elab_Code) then
- Append_List_To (Result, Elab_Code);
- end if;
+ Append_List_To (Result, Elab_Code);
-- Populate the two auxiliary tables used for dispatching asynchronous,
-- conditional and timed selects for synchronized types that implement
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
@@ -2248,9 +2248,7 @@ package body Sem_Ch12 is
-- explicit box associations for the formals that are covered by an
-- Others_Choice.
- if not Is_Empty_List (Default_Formals) then
- Append_List (Default_Formals, Formals);
- end if;
+ Append_List (Default_Formals, Formals);
return Assoc_List;
end Analyze_Associations;
reply other threads:[~2022-01-07 16:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220107162702.GA948210@adacore.com \
--to=derodat@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=trojanek@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).