]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Add missing regular expression syntax error check
authorSteve Baird <baird@adacore.com>
Thu, 21 Oct 2021 17:47:06 +0000 (10:47 -0700)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 9 Nov 2021 09:44:47 +0000 (09:44 +0000)
gcc/ada/

* libgnat/s-regexp.adb (Compile.Check_Well_Formed_Patern): When
a "|" operator is encountered in a pattern, check that it is not
the last character of the pattern.

gcc/ada/libgnat/s-regexp.adb

index 51ff39c3e76cd42477d208c2044a0d324400faee..79e7cda442b9b739fbbbfb1847b1a456e87285cb 100644 (file)
@@ -210,7 +210,7 @@ package body System.Regexp is
          --  or the last occurrence of an opening curly brace, if Glob=True.
 
          procedure Raise_Exception_If_No_More_Chars (K : Integer := 0);
-         --  If no more characters are raised, call Raise_Exception
+         --  If S(J + 1 .. S'Last)'Length < K then call Raise_Exception
 
          --------------------------------------
          -- Raise_Exception_If_No_More_Chars --
@@ -431,6 +431,9 @@ package body System.Regexp is
                            & "applied to a term in regular expression", J);
                      end if;
 
+                     --  A second term must follow
+                     Raise_Exception_If_No_More_Chars (K => 1);
+
                      Past_Elmt := False;
                      Past_Term := False;
                   end if;