From e335bd2e6ebc23050d48ad17584323f590733d50 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Thu, 2 Jul 2020 06:10:28 -0400 Subject: [PATCH] [Ada] Clean up support of square brackets 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. --- gcc/ada/par-ch4.adb | 2 +- gcc/ada/scng.adb | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gcc/ada/par-ch4.adb b/gcc/ada/par-ch4.adb index e4ce02fa3af..cc5ed032bbb 100644 --- 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 index 2bac3a8b09b..a2bd176e4fe 100644 --- 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; -- 2.30.2