Ada 2022 bracket syntax is only allowed for arrays and containers, not
records. This change correctly rejects record aggregates using brackets
along with few cases of brackets being used instead of parentheses.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* libgnat/a-direct.adb (Start_Search_Internal): Use parentheses
for record aggregate.
* libgnat/a-stbubo.adb (Get_UTF_8): Likewise.
* libgnat/a-stbuun.adb (Get_UTF_8): Likewise.
* libgnat/a-stzbou.ads (Null_Bounded_Wide_Wide_String):
Likewise.
* libgnat/a-swmwco.ads (Lower_Case_Mapping, Basic_Mapping):
Likewise.
* libgnat/a-szmzco.ads (Lower_Case_Mapping, Basic_Mapping):
Likewise.
* libgnat/s-statxd.adb (Fields): Likewise.
* libgnat/s-stausa.adb (Initialize): Likewise.
* sem_aggr.adb (Resolve_Record_Aggregate): Reject aggregates
using brackets.
diff --git a/gcc/ada/libgnat/a-direct.adb b/gcc/ada/libgnat/a-direct.adb
--- a/gcc/ada/libgnat/a-direct.adb
+++ b/gcc/ada/libgnat/a-direct.adb
@@ -1404,11 +1404,11 @@ package body Ada.Directories is
if Error /= 0 then
Search.State.Dir_Contents.Append
(Directory_Entry_Type'
- [Valid => True,
+ (Valid => True,
Name => To_Unbounded_String (File_Name),
Full_Name => To_Unbounded_String (Path),
Attr_Error_Code => Error,
- others => <>]);
+ others => <>));
-- Otherwise, if the file exists and matches the file kind
-- Filter, add the file to the search results. We capture
@@ -1445,14 +1445,14 @@ package body Ada.Directories is
if Found then
Search.State.Dir_Contents.Append
(Directory_Entry_Type'
- [Valid => True,
+ (Valid => True,
Name =>
To_Unbounded_String (File_Name),
Full_Name => To_Unbounded_String (Path),
Attr_Error_Code => 0,
Kind => Kind,
Modification_Time => Modification_Time (Path),
- Size => Size]);
+ Size => Size));
end if;
end if;
end;
diff --git a/gcc/ada/libgnat/a-stbubo.adb b/gcc/ada/libgnat/a-stbubo.adb
--- a/gcc/ada/libgnat/a-stbubo.adb
+++ b/gcc/ada/libgnat/a-stbubo.adb
@@ -91,9 +91,9 @@ package body Ada.Strings.Text_Buffers.Bounded is
-- forget to add corresponding assignment statement below.
Dummy : array (1 .. 0) of Buffer_Type (0) :=
[others =>
- [Max_Characters => 0, Chars => <>, Indentation => <>,
+ (Max_Characters => 0, Chars => <>, Indentation => <>,
Indent_Pending => <>, UTF_8_Length => <>, UTF_8_Column => <>,
- All_7_Bits => <>, All_8_Bits => <>, Truncated => <>]];
+ All_7_Bits => <>, All_8_Bits => <>, Truncated => <>)];
begin
Buffer.Indentation := Defaulted.Indentation;
Buffer.Indent_Pending := Defaulted.Indent_Pending;
diff --git a/gcc/ada/libgnat/a-stbuun.adb b/gcc/ada/libgnat/a-stbuun.adb
--- a/gcc/ada/libgnat/a-stbuun.adb
+++ b/gcc/ada/libgnat/a-stbuun.adb
@@ -104,9 +104,9 @@ package body Ada.Strings.Text_Buffers.Unbounded is
-- forget to add corresponding assignment statement below.
Dummy : array (1 .. 0) of Buffer_Type :=
[others =>
- [Indentation => <>, Indent_Pending => <>, UTF_8_Length => <>,
+ (Indentation => <>, Indent_Pending => <>, UTF_8_Length => <>,
UTF_8_Column => <>, All_7_Bits => <>, All_8_Bits => <>,
- List => <>, Last_Used => <>]];
+ List => <>, Last_Used => <>)];
begin
Buffer.Indentation := Defaulted.Indentation;
Buffer.Indent_Pending := Defaulted.Indent_Pending;
diff --git a/gcc/ada/libgnat/a-stzbou.ads b/gcc/ada/libgnat/a-stzbou.ads
--- a/gcc/ada/libgnat/a-stzbou.ads
+++ b/gcc/ada/libgnat/a-stzbou.ads
@@ -493,11 +493,11 @@ package Ada.Strings.Wide_Wide_Bounded is
-- the Wide_Wide_Superbounded package.
Null_Bounded_Wide_Wide_String : constant Bounded_Wide_Wide_String :=
- [Max_Length => Max_Length,
+ (Max_Length => Max_Length,
Current_Length => 0,
Data =>
[1 .. Max_Length =>
- Wide_Wide_Superbounded.Wide_Wide_NUL]];
+ Wide_Wide_Superbounded.Wide_Wide_NUL]);
pragma Inline (To_Bounded_Wide_Wide_String);
diff --git a/gcc/ada/libgnat/a-swmwco.ads b/gcc/ada/libgnat/a-swmwco.ads
--- a/gcc/ada/libgnat/a-swmwco.ads
+++ b/gcc/ada/libgnat/a-swmwco.ads
@@ -181,7 +181,7 @@ private
Character_Ranges'Unrestricted_Access);
Lower_Case_Mapping : aliased constant Wide_Character_Mapping_Values :=
- [Length => 56,
+ (Length => 56,
Domain =>
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" &
@@ -247,14 +247,14 @@ private
W.LC_U_Circumflex &
W.LC_U_Diaeresis &
W.LC_Y_Acute &
- W.LC_Icelandic_Thorn];
+ W.LC_Icelandic_Thorn);
Lower_Case_Map : constant Wide_Character_Mapping :=
(AF.Controlled with
Map => Lower_Case_Mapping'Unrestricted_Access);
Upper_Case_Mapping : aliased constant Wide_Character_Mapping_Values :=
- [Length => 56,
+ (Length => 56,
Domain =>
"abcdefghijklmnopqrstuvwxyz" &
@@ -320,14 +320,14 @@ private
W.UC_U_Circumflex &
W.UC_U_Diaeresis &
W.UC_Y_Acute &
- W.UC_Icelandic_Thorn];
+ W.UC_Icelandic_Thorn);
Upper_Case_Map : constant Wide_Character_Mapping :=
(AF.Controlled with
Upper_Case_Mapping'Unrestricted_Access);
Basic_Mapping : aliased constant Wide_Character_Mapping_Values :=
- [Length => 55,
+ (Length => 55,
Domain =>
W.UC_A_Grave &
@@ -441,7 +441,7 @@ private
'u' & -- LC_U_Circumflex
'u' & -- LC_U_Diaeresis
'y' & -- LC_Y_Acute
- 'y']; -- LC_Y_Diaeresis
+ 'y'); -- LC_Y_Diaeresis
Basic_Map : constant Wide_Character_Mapping :=
(AF.Controlled with
diff --git a/gcc/ada/libgnat/a-szmzco.ads b/gcc/ada/libgnat/a-szmzco.ads
--- a/gcc/ada/libgnat/a-szmzco.ads
+++ b/gcc/ada/libgnat/a-szmzco.ads
@@ -181,7 +181,7 @@ private
Character_Ranges'Unrestricted_Access);
Lower_Case_Mapping : aliased constant Wide_Wide_Character_Mapping_Values :=
- [Length => 56,
+ (Length => 56,
Domain =>
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" &
@@ -247,14 +247,14 @@ private
W.LC_U_Circumflex &
W.LC_U_Diaeresis &
W.LC_Y_Acute &
- W.LC_Icelandic_Thorn];
+ W.LC_Icelandic_Thorn);
Lower_Case_Map : constant Wide_Wide_Character_Mapping :=
(AF.Controlled with
Map => Lower_Case_Mapping'Unrestricted_Access);
Upper_Case_Mapping : aliased constant Wide_Wide_Character_Mapping_Values :=
- [Length => 56,
+ (Length => 56,
Domain =>
"abcdefghijklmnopqrstuvwxyz" &
@@ -320,14 +320,14 @@ private
W.UC_U_Circumflex &
W.UC_U_Diaeresis &
W.UC_Y_Acute &
- W.UC_Icelandic_Thorn];
+ W.UC_Icelandic_Thorn);
Upper_Case_Map : constant Wide_Wide_Character_Mapping :=
(AF.Controlled with
Upper_Case_Mapping'Unrestricted_Access);
Basic_Mapping : aliased constant Wide_Wide_Character_Mapping_Values :=
- [Length => 55,
+ (Length => 55,
Domain =>
W.UC_A_Grave &
@@ -441,7 +441,7 @@ private
'u' & -- LC_U_Circumflex
'u' & -- LC_U_Diaeresis
'y' & -- LC_Y_Acute
- 'y']; -- LC_Y_Diaeresis
+ 'y'); -- LC_Y_Diaeresis
Basic_Map : constant Wide_Wide_Character_Mapping :=
(AF.Controlled with
diff --git a/gcc/ada/libgnat/s-statxd.adb b/gcc/ada/libgnat/s-statxd.adb
--- a/gcc/ada/libgnat/s-statxd.adb
+++ b/gcc/ada/libgnat/s-statxd.adb
@@ -76,36 +76,36 @@ package body System.Stream_Attributes.XDR is
-- Single precision
- [E_Size => 8,
+ (E_Size => 8,
E_Bias => 127,
F_Size => 23,
E_Last => 2 ** 8 - 1,
F_Mask => 16#7F#, -- 2 ** 7 - 1,
E_Bytes => 2,
F_Bytes => 3,
- F_Bits => 23 mod US],
+ F_Bits => 23 mod US),
-- Double precision
- [E_Size => 11,
+ (E_Size => 11,
E_Bias => 1023,
F_Size => 52,
E_Last => 2 ** 11 - 1,
F_Mask => 16#0F#, -- 2 ** 4 - 1,
E_Bytes => 2,
F_Bytes => 7,
- F_Bits => 52 mod US],
+ F_Bits => 52 mod US),
-- Quadruple precision
- [E_Size => 15,
+ (E_Size => 15,
E_Bias => 16383,
F_Size => 112,
E_Last => 2 ** 8 - 1,
F_Mask => 16#FF#, -- 2 ** 8 - 1,
E_Bytes => 2,
F_Bytes => 14,
- F_Bits => 112 mod US]];
+ F_Bits => 112 mod US)];
-- The representation of all items requires a multiple of four bytes
-- (or 32 bits) of data. The bytes are numbered 0 through n-1. The bytes
diff --git a/gcc/ada/libgnat/s-stausa.adb b/gcc/ada/libgnat/s-stausa.adb
--- a/gcc/ada/libgnat/s-stausa.adb
+++ b/gcc/ada/libgnat/s-stausa.adb
@@ -128,9 +128,9 @@ package body System.Stack_Usage is
Result_Array := new Result_Array_Type (1 .. Buffer_Size);
Result_Array.all :=
[others =>
- [Task_Name => [others => ASCII.NUL],
+ (Task_Name => [others => ASCII.NUL],
Value => 0,
- Stack_Size => 0]];
+ Stack_Size => 0)];
-- Set the Is_Enabled flag to true, so that the task wrapper knows that
-- it has to handle dynamic stack analysis
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -4896,6 +4896,15 @@ package body Sem_Aggr is
return;
end if;
+ -- A record aggregate can only use parentheses
+
+ if Nkind (N) = N_Aggregate
+ and then Is_Homogeneous_Aggregate (N)
+ then
+ Error_Msg_N ("record aggregate must use () and not '[']", N);
+ return;
+ end if;
+
-- STEP 2: Verify aggregate structure
Step_2 : declare