From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1914) id E225D3858423; Tue, 9 Nov 2021 09:45:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E225D3858423 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Pierre-Marie de Rodat To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5020] [Ada] Add missing regular expression syntax error check X-Act-Checkin: gcc X-Git-Author: Steve Baird X-Git-Refname: refs/heads/master X-Git-Oldrev: ea8726cac5af33305fa81886beb4ab2255f99567 X-Git-Newrev: c9148106881e8e25efc14ec7d49a71f5af4f13f1 Message-Id: <20211109094549.E225D3858423@sourceware.org> Date: Tue, 9 Nov 2021 09:45:49 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Nov 2021 09:45:50 -0000 https://gcc.gnu.org/g:c9148106881e8e25efc14ec7d49a71f5af4f13f1 commit r12-5020-gc9148106881e8e25efc14ec7d49a71f5af4f13f1 Author: Steve Baird Date: Thu Oct 21 10:47:06 2021 -0700 [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: --- gcc/ada/libgnat/s-regexp.adb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/ada/libgnat/s-regexp.adb b/gcc/ada/libgnat/s-regexp.adb index 51ff39c3e76..79e7cda442b 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;