We cannot support at the same time [] aggregate notation and the
["XXXX"] wide character notation, and there's no agreement yet on the
proper syntax for [] aggregates, so resolve this temporarily by
supporting only [] as an aggregate under -gnatX and only the wide chars
legacy notation otherwise.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

        * par-ch4.adb (P_Aggregate_Or_Paren_Expr): Simplify code since
        we are always under -gnatX if we encounter a Tok_Left_Bracket.
        * scng.adb (Scan): [] is an aggregate under -gnatX and a wide
        character otherwise.
diff --git a/gcc/ada/par-ch4.adb b/gcc/ada/par-ch4.adb
--- a/gcc/ada/par-ch4.adb
+++ b/gcc/ada/par-ch4.adb
@@ -1395,7 +1395,7 @@ package body Ch4 is
 
    begin
       Lparen_Sloc := Token_Ptr;
-      if Token = Tok_Left_Bracket and then Ada_Version >= Ada_2020 then
+      if Token = Tok_Left_Bracket then
          Scan;
 
          --  Special case for null aggregate in Ada 2020


diff --git a/gcc/ada/scng.adb b/gcc/ada/scng.adb
--- a/gcc/ada/scng.adb
+++ b/gcc/ada/scng.adb
@@ -1378,14 +1378,19 @@ package body Scng is
          --  Left bracket
 
          when '[' =>
-            if Source (Scan_Ptr + 1) = '"' then
-               goto Scan_Wide_Character;
 
-            elsif Ada_Version >= Ada_2020 then
+            --  [] under -gnatX is an aggregate notation and the special
+            --  wide character notation becomes unsupported since the two
+            --  are ambiguous.
+
+            if Extensions_Allowed then
                Scan_Ptr := Scan_Ptr + 1;
                Token := Tok_Left_Bracket;
                return;
 
+            elsif Source (Scan_Ptr + 1) = '"' then
+               goto Scan_Wide_Character;
+
             else
                Error_Msg_S ("illegal character, replaced by ""(""");
                Scan_Ptr := Scan_Ptr + 1;


Reply via email to