public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1493] [Ada] Remove redundant protection against empty lists Date: Tue, 5 Jul 2022 08:30:59 +0000 (GMT) [thread overview] Message-ID: <20220705083059.D078238582A2@sourceware.org> (raw) https://gcc.gnu.org/g:076a6d13d1e07a72fb964579316920225829777c commit r13-1493-g076a6d13d1e07a72fb964579316920225829777c Author: Piotr Trojanek <trojanek@adacore.com> Date: Wed Jun 8 16:58:18 2022 +0200 [Ada] Remove redundant protection against empty lists 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/ * exp_code.adb (Setup_Asm_IO_Args): Remove guard against No_List. * par_sco.adb (Process_Decisions): Likewise. * sem_ch13.adb (Check_Component_List): Likewise. * sem_ch6.adb (FCL): Likewise. Diff: --- gcc/ada/exp_code.adb | 6 +----- gcc/ada/par_sco.adb | 12 +++++------- gcc/ada/sem_ch13.adb | 32 +++++++++++++++----------------- gcc/ada/sem_ch6.adb | 13 ++----------- 4 files changed, 23 insertions(+), 40 deletions(-) diff --git a/gcc/ada/exp_code.adb b/gcc/ada/exp_code.adb index 11fbc5fc29d..d144b489f2f 100644 --- a/gcc/ada/exp_code.adb +++ b/gcc/ada/exp_code.adb @@ -471,11 +471,7 @@ package body Exp_Code is -- Case of list of arguments elsif Nkind (Arg) = N_Aggregate then - if Expressions (Arg) = No_List then - Operand_Var := Empty; - else - Operand_Var := First (Expressions (Arg)); - end if; + Operand_Var := First (Expressions (Arg)); -- Otherwise must be default (no operands) case diff --git a/gcc/ada/par_sco.adb b/gcc/ada/par_sco.adb index aba863dfeb2..e8875cf28b4 100644 --- a/gcc/ada/par_sco.adb +++ b/gcc/ada/par_sco.adb @@ -480,13 +480,11 @@ package body Par_SCO is N : Node_Id; begin - if L /= No_List then - N := First (L); - while Present (N) loop - Process_Decisions (N, T, Pragma_Sloc); - Next (N); - end loop; - end if; + N := First (L); + while Present (N) loop + Process_Decisions (N, T, Pragma_Sloc); + Next (N); + end loop; end Process_Decisions; -- Version taking a node diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 27f32504999..bb654abe412 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -12135,24 +12135,22 @@ package body Sem_Ch13 is begin -- Gather discriminants into Comp - if DS /= No_List then - Citem := First (DS); - while Present (Citem) loop - if Nkind (Citem) = N_Discriminant_Specification then - declare - Ent : constant Entity_Id := - Defining_Identifier (Citem); - begin - if Ekind (Ent) = E_Discriminant then - Ncomps := Ncomps + 1; - Comps (Ncomps) := Ent; - end if; - end; - end if; + Citem := First (DS); + while Present (Citem) loop + if Nkind (Citem) = N_Discriminant_Specification then + declare + Ent : constant Entity_Id := + Defining_Identifier (Citem); + begin + if Ekind (Ent) = E_Discriminant then + Ncomps := Ncomps + 1; + Comps (Ncomps) := Ent; + end if; + end; + end if; - Next (Citem); - end loop; - end if; + Next (Citem); + end loop; -- Gather component entities into Comp diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index e5c13ed36b2..440770ad8bf 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -9988,17 +9988,8 @@ package body Sem_Ch6 is N2 : Node_Id; begin - if L1 = No_List then - N1 := Empty; - else - N1 := First (L1); - end if; - - if L2 = No_List then - N2 := Empty; - else - N2 := First (L2); - end if; + N1 := First (L1); + N2 := First (L2); -- Compare two lists, skipping rewrite insertions (we want to compare -- the original trees, not the expanded versions).
reply other threads:[~2022-07-05 8:30 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=20220705083059.D078238582A2@sourceware.org \ --to=pmderodat@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /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: linkBe 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).