[Ada] Accept square brackets for expression functions
Commit Message
Ada RM 6.8 allows an expression function to return an aggregate directly
at the top level (enclosed with either parentheses or square brackets).
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* par-ch6.adb (Scan_Body_Or_Expression_Function): Accept left
bracket as token to open an expression function.
@@ -841,7 +841,14 @@ package body Ch6 is
begin
-- Expression_Function case
- if Token = Tok_Left_Paren
+ -- If likely an aggregate, check we are in Ada 2022 mode
+
+ if Token = Tok_Left_Bracket then
+ Error_Msg_Ada_2022_Feature
+ ("!aggregates as expression function", Token_Ptr);
+ end if;
+
+ if Token in Tok_Left_Paren | Tok_Left_Bracket
or else Likely_Expression_Function
then
-- Check expression function allowed here