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 r11-6064] [Ada] Reuse Append_New in parsing aggregates
Date: Tue, 15 Dec 2020 11:44:32 +0000 (GMT)	[thread overview]
Message-ID: <20201215114432.66812384B106@sourceware.org> (raw)

https://gcc.gnu.org/g:320be7e2b4bcf78028c78b0c46f6757ee0597a6f

commit r11-6064-g320be7e2b4bcf78028c78b0c46f6757ee0597a6f
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Wed Nov 25 12:27:23 2020 +0100

    [Ada] Reuse Append_New in parsing aggregates
    
    gcc/ada/
    
            * par-ch4.adb (P_Aggregate_Or_Paren_Expr): Simplify with
            Append_New.

Diff:
---
 gcc/ada/par-ch4.adb | 36 ++++++------------------------------
 1 file changed, 6 insertions(+), 30 deletions(-)

diff --git a/gcc/ada/par-ch4.adb b/gcc/ada/par-ch4.adb
index a14690239b6..b4eebfec5fa 100644
--- a/gcc/ada/par-ch4.adb
+++ b/gcc/ada/par-ch4.adb
@@ -1580,11 +1580,7 @@ package body Ch4 is
          --  Deal with others association first. This is a named association
 
          if No (Expr_Node) then
-            if No (Assoc_List) then
-               Assoc_List := New_List;
-            end if;
-
-            Append (P_Record_Or_Array_Component_Association, Assoc_List);
+            Append_New (P_Record_Or_Array_Component_Association, Assoc_List);
 
          --  Improper use of WITH
 
@@ -1612,11 +1608,7 @@ package body Ch4 is
          elsif Nkind (Expr_Node) in
            N_Iterated_Component_Association | N_Iterated_Element_Association
          then
-            if No (Assoc_List) then
-               Assoc_List := New_List (Expr_Node);
-            else
-               Append_To (Assoc_List, Expr_Node);
-            end if;
+            Append_New (Expr_Node, Assoc_List);
 
          elsif Token = Tok_Comma
            or else Token = Tok_Right_Paren
@@ -1630,11 +1622,7 @@ package body Ch4 is
                   & "named association)");
             end if;
 
-            if No (Expr_List) then
-               Expr_List := New_List;
-            end if;
-
-            Append (Expr_Node, Expr_List);
+            Append_New (Expr_Node, Expr_List);
 
          --  Check for aggregate followed by left parent, maybe missing comma
 
@@ -1643,18 +1631,10 @@ package body Ch4 is
          then
             T_Comma;
 
-            if No (Expr_List) then
-               Expr_List := New_List;
-            end if;
-
-            Append (Expr_Node, Expr_List);
+            Append_New (Expr_Node, Expr_List);
 
          elsif Token = Tok_Right_Bracket then
-            if No (Expr_List) then
-               Expr_List := New_List;
-            end if;
-
-            Append (Expr_Node, Expr_List);
+            Append_New (Expr_Node, Expr_List);
             exit;
 
          --  Anything else is assumed to be a named association
@@ -1662,11 +1642,7 @@ package body Ch4 is
          else
             Restore_Scan_State (Scan_State); -- to start of expression
 
-            if No (Assoc_List) then
-               Assoc_List := New_List;
-            end if;
-
-            Append (P_Record_Or_Array_Component_Association, Assoc_List);
+            Append_New (P_Record_Or_Array_Component_Association, Assoc_List);
          end if;
 
          exit when not Comma_Present;


                 reply	other threads:[~2020-12-15 11:44 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=20201215114432.66812384B106@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: 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).