]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix non-capturing parentheses handling
authorRonan Desplanques <desplanques@adacore.com>
Mon, 31 Oct 2022 17:08:37 +0000 (18:08 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 14 Nov 2022 13:46:50 +0000 (14:46 +0100)
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.

gcc/ada/libgnat/s-regpat.adb

index 3290f900544716f71181770d4cf7d3dcb9702240..3e9f880cd4e3dff1c93e3b7fda590ce8005dd0ae 100644 (file)
@@ -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