From: Steve Baird Date: Thu, 21 Oct 2021 17:47:06 +0000 (-0700) Subject: [Ada] Add missing regular expression syntax error check X-Git-Tag: basepoints/gcc-13~3293 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9148106881e8e25efc14ec7d49a71f5af4f13f1;p=thirdparty%2Fgcc.git [Ada] Add missing regular expression syntax error check 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. --- diff --git a/gcc/ada/libgnat/s-regexp.adb b/gcc/ada/libgnat/s-regexp.adb index 51ff39c3e76c..79e7cda442b9 100644 --- a/gcc/ada/libgnat/s-regexp.adb +++ b/gcc/ada/libgnat/s-regexp.adb @@ -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;