]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix unexpected Program_Error raised in the parser on mismatched []
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 28 Oct 2024 10:28:53 +0000 (11:28 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 12 Nov 2024 13:05:44 +0000 (14:05 +0100)
This happens for example with:

  A : constant array (Natural range <>) of String := [ "xor" [;

The problem is that the left bracket token is incorrectly classified as
a name extension, but there is no handler in the Scan_Name_Extension_OK
part of P_Name in Par.Ch4.

gcc/ada/ChangeLog:

PR ada/112821
* scans.ads (Token_Type): Remove Tok_Left_Bracket from Namext.

gcc/ada/scans.ads

index 44c20fcf3d260c6441d9f624b125d2f43e7bf456..c445635262a40b53feacb576b920da139b2aa7b8 100644 (file)
@@ -93,10 +93,11 @@ package Scans is
       Tok_Raise,                    -- RAISE
       Tok_Right_Curly_Bracket,      -- }
 
+      Tok_Left_Bracket,    -- [
+
       Tok_Dot,             -- .            Namext
       Tok_Apostrophe,      -- '            Namext
 
-      Tok_Left_Bracket,    -- [            Namext
       Tok_Left_Paren,      -- (            Namext, Consk
 
       Tok_Delta,           -- DELTA        Atkwd, Sterm, Consk