public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Ronan Desplanques <desplanques@adacore.com>
Subject: [COMMITTED] ada: Fix non-capturing parentheses handling
Date: Mon, 14 Nov 2022 14:52:24 +0100	[thread overview]
Message-ID: <20221114135224.52966-1-poulhies@adacore.com> (raw)

From: Ronan Desplanques <desplanques@adacore.com>

Before this patch, non-capturingly parenthesized expressions with more
than one branch were processed incorrectly when part of a branch
followed by another branch. This patch fixes this by aligning the
handling of non-capturing parentheses with the handling of regular
parentheses.

gcc/ada/

	* libgnat/s-regpat.adb
	(Parse): Fix handling of non-capturing parentheses.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/libgnat/s-regpat.adb | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/libgnat/s-regpat.adb b/gcc/ada/libgnat/s-regpat.adb
index 3290f900544..3e9f880cd4e 100644
--- a/gcc/ada/libgnat/s-regpat.adb
+++ b/gcc/ada/libgnat/s-regpat.adb
@@ -920,18 +920,16 @@ package body System.Regpat is
             if Capturing then
                Ender := Emit_Node (CLOSE);
                Emit (Character'Val (Par_No));
-               Link_Tail (IP, Ender);
-
             else
-               --  Need to keep looking after the closing parenthesis
-               Ender := Emit_Ptr;
+               Ender := Emit_Node (NOTHING);
             end if;
 
          else
             Ender := Emit_Node (EOP);
-            Link_Tail (IP, Ender);
          end if;
 
+         Link_Tail (IP, Ender);
+
          if Have_Branch and then Emit_Ptr <= PM.Size + 1 then
 
             --  Hook the tails of the branches to the closing node
-- 
2.34.1


                 reply	other threads:[~2022-11-14 13:52 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=20221114135224.52966-1-poulhies@adacore.com \
    --to=poulhies@adacore.com \
    --cc=desplanques@adacore.com \
    --cc=gcc-patches@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).