From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Piotr Trojanek <trojanek@adacore.com>
Subject: [COMMITTED] ada: Remove redundant protection against empty lists
Date: Mon, 15 May 2023 11:43:46 +0200 [thread overview]
Message-ID: <20230515094346.1408423-1-poulhies@adacore.com> (raw)
From: Piotr Trojanek <trojanek@adacore.com>
Calls to First on No_List intentionally return Empty node, so explicit
guards against No_List are unnecessary. Code cleanup; semantics is
unaffected.
gcc/ada/
* sem_util.adb (New_Copy_Tree): Remove redundant calls to Present.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/sem_util.adb | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 5ec0140d090..eb0d08a1851 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -24167,14 +24167,12 @@ package body Sem_Util is
-- Note that the element of a syntactic list is always a node, never
-- an entity or itype, hence the call to Visit_Node.
- if Present (List) then
- Elmt := First (List);
- while Present (Elmt) loop
- Visit_Node (Elmt);
+ Elmt := First (List);
+ while Present (Elmt) loop
+ Visit_Node (Elmt);
- Next (Elmt);
- end loop;
- end if;
+ Next (Elmt);
+ end loop;
end Visit_List;
----------------
@@ -24206,8 +24204,7 @@ package body Sem_Util is
-- If the node is a block, we need to process all declarations
-- in the block and make new entities for each.
- if Nkind (N) = N_Block_Statement and then Present (Declarations (N))
- then
+ if Nkind (N) = N_Block_Statement then
declare
Decl : Node_Id := First (Declarations (N));
--
2.40.0
next reply other threads:[~2023-05-15 9:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-15 9:43 Marc Poulhiès [this message]
2023-05-22 8:50 Marc Poulhiès
2023-05-26 7:36 Marc Poulhiès
2023-05-29 8:29 Marc Poulhiès
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=20230515094346.1408423-1-poulhies@adacore.com \
--to=poulhies@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).