Identifier_Char (J) := (Fold_Upper (J) /= ' ');
end loop;
- -- Always add [ as an identifier character to deal with the brackets
- -- notation for wide characters used in identifiers. Note that if
- -- we are not allowing wide characters in identifiers, then any use
- -- of this notation will be flagged as an error in Scan_Identifier.
+ -- Add [ as an identifier character to deal with the brackets notation
+ -- for wide characters used in identifiers for versions up to Ada 2012.
+ -- Note that if we are not allowing wide characters in identifiers, then
+ -- any use of this notation will be flagged as an error in
+ -- Scan_Identifier.
- Identifier_Char ('[') := True;
+ Identifier_Char ('[') := Ada_Version < Ada_2022;
-- Add entry for ESC if wide characters in use with a wide character
-- encoding method active that uses the ESC code for encoding.
subtype WC is Wide_Character;
Control_Ranges : aliased constant Wide_Character_Ranges :=
- [ (W.NUL, W.US),
- (W.DEL, W.APC)];
+ [(W.NUL, W.US),
+ (W.DEL, W.APC)];
Control_Set : constant Wide_Character_Set :=
(AF.Controlled with
Control_Ranges'Unrestricted_Access);
Graphic_Ranges : aliased constant Wide_Character_Ranges :=
- [ (W.Space, W.Tilde),
- (WC'Val (256), WC'Last)];
+ [(W.Space, W.Tilde),
+ (WC'Val (256), WC'Last)];
Graphic_Set : constant Wide_Character_Set :=
(AF.Controlled with
Graphic_Ranges'Unrestricted_Access);
Letter_Ranges : aliased constant Wide_Character_Ranges :=
- [ ('A', 'Z'),
- (W.LC_A, W.LC_Z),
- (W.UC_A_Grave, W.UC_O_Diaeresis),
- (W.UC_O_Oblique_Stroke, W.LC_O_Diaeresis),
- (W.LC_O_Oblique_Stroke, W.LC_Y_Diaeresis)];
+ [('A', 'Z'),
+ (W.LC_A, W.LC_Z),
+ (W.UC_A_Grave, W.UC_O_Diaeresis),
+ (W.UC_O_Oblique_Stroke, W.LC_O_Diaeresis),
+ (W.LC_O_Oblique_Stroke, W.LC_Y_Diaeresis)];
Letter_Set : constant Wide_Character_Set :=
(AF.Controlled with
Basic_Ranges'Unrestricted_Access);
Decimal_Digit_Ranges : aliased constant Wide_Character_Ranges :=
- [ ('0', '9')];
+ [('0', '9')];
Decimal_Digit_Set : constant Wide_Character_Set :=
(AF.Controlled with
Special_Graphic_Ranges'Unrestricted_Access);
ISO_646_Ranges : aliased constant Wide_Character_Ranges :=
- [ (W.NUL, W.DEL)];
+ [(W.NUL, W.DEL)];
ISO_646_Set : constant Wide_Character_Set :=
(AF.Controlled with
ISO_646_Ranges'Unrestricted_Access);
Character_Ranges : aliased constant Wide_Character_Ranges :=
- [ (W.NUL, WC'Val (255))];
+ [(W.NUL, WC'Val (255))];
Character_Set : constant Wide_Character_Set :=
(AF.Controlled with
subtype WC is Wide_Wide_Character;
Control_Ranges : aliased constant Wide_Wide_Character_Ranges :=
- [ (W.NUL, W.US),
- (W.DEL, W.APC)];
+ [(W.NUL, W.US),
+ (W.DEL, W.APC)];
Control_Set : constant Wide_Wide_Character_Set :=
(AF.Controlled with
Control_Ranges'Unrestricted_Access);
Graphic_Ranges : aliased constant Wide_Wide_Character_Ranges :=
- [ (W.Space, W.Tilde),
- (WC'Val (256), WC'Last)];
+ [(W.Space, W.Tilde),
+ (WC'Val (256), WC'Last)];
Graphic_Set : constant Wide_Wide_Character_Set :=
(AF.Controlled with
Graphic_Ranges'Unrestricted_Access);
Letter_Ranges : aliased constant Wide_Wide_Character_Ranges :=
- [ ('A', 'Z'),
- (W.LC_A, W.LC_Z),
- (W.UC_A_Grave, W.UC_O_Diaeresis),
- (W.UC_O_Oblique_Stroke, W.LC_O_Diaeresis),
- (W.LC_O_Oblique_Stroke, W.LC_Y_Diaeresis)];
+ [('A', 'Z'),
+ (W.LC_A, W.LC_Z),
+ (W.UC_A_Grave, W.UC_O_Diaeresis),
+ (W.UC_O_Oblique_Stroke, W.LC_O_Diaeresis),
+ (W.LC_O_Oblique_Stroke, W.LC_Y_Diaeresis)];
Letter_Set : constant Wide_Wide_Character_Set :=
(AF.Controlled with
Basic_Ranges'Unrestricted_Access);
Decimal_Digit_Ranges : aliased constant Wide_Wide_Character_Ranges :=
- [ ('0', '9')];
+ [('0', '9')];
Decimal_Digit_Set : constant Wide_Wide_Character_Set :=
(AF.Controlled with
Special_Graphic_Ranges'Unrestricted_Access);
ISO_646_Ranges : aliased constant Wide_Wide_Character_Ranges :=
- [ (W.NUL, W.DEL)];
+ [(W.NUL, W.DEL)];
ISO_646_Set : constant Wide_Wide_Character_Set :=
(AF.Controlled with
ISO_646_Ranges'Unrestricted_Access);
Character_Ranges : aliased constant Wide_Wide_Character_Ranges :=
- [ (W.NUL, WC'Val (255))];
+ [(W.NUL, WC'Val (255))];
Character_Set : constant Wide_Wide_Character_Set :=
(AF.Controlled with
-- --
------------------------------------------------------------------------------
+with Csets; use Csets;
+
package body Opt is
-------------------------
Prefix_Exception_Messages := True;
Uneval_Old := 'E';
Use_VADS_Size := False;
+ Identifier_Char ('[') := False;
-- Note: we do not need to worry about Warnings_As_Errors_Count since
-- we do not expect to get any warnings from compiling such a unit.
Token := Tok_Left_Paren;
if Style_Check then
- Style.Check_Left_Paren;
+ Style.Check_Left_Paren_Square_Bracket;
end if;
return;
if Ada_Version >= Ada_2022 then
Scan_Ptr := Scan_Ptr + 1;
Token := Tok_Left_Bracket;
+
+ if Style_Check then
+ Style.Check_Left_Paren_Square_Bracket;
+ end if;
+
return;
elsif Source (Scan_Ptr + 1) = '"' then
-- is that the starting column is appropriate to the indentation rules if
-- Token_Ptr is the first token on the line.
- procedure Check_Left_Paren
- renames Style_Inst.Check_Left_Paren;
- -- Called after scanning out a left parenthesis to check spacing
+ procedure Check_Left_Paren_Square_Bracket
+ renames Style_Inst.Check_Left_Paren_Square_Bracket;
+ -- Called after scanning out a left parenthesis to check spacing. If
+ -- Ada_Version >= Ada_2022 then called similarly for a left square bracket.
procedure Check_Line_Terminator (Len : Int)
renames Style_Inst.Check_Line_Terminator;
end if;
end Check_Indentation;
- ----------------------
- -- Check_Left_Paren --
- ----------------------
+ -------------------------------------
+ -- Check_Left_Paren_Square_Bracket --
+ -------------------------------------
-- In check token mode (-gnatyt), left paren must not be preceded by an
-- identifier character or digit (a separating space is required) and may
-- never be followed by a space.
+ -- Same applies for the left square bracket starting from Ada version 2022.
- procedure Check_Left_Paren is
+ procedure Check_Left_Paren_Square_Bracket is
begin
if Style_Check_Tokens then
if Token_Ptr > Source_First (Current_Source_File)
Check_No_Space_After;
end if;
- end Check_Left_Paren;
+ end Check_Left_Paren_Square_Bracket;
---------------------------
-- Check_Line_Max_Length --
-- is that the starting column is appropriate to the indentation rules if
-- Token_Ptr is the first token on the line.
- procedure Check_Left_Paren;
- -- Called after scanning out a left parenthesis to check spacing
+ procedure Check_Left_Paren_Square_Bracket;
+ -- Called after scanning out a left parenthesis to check spacing. If
+ -- Ada_Version >= Ada_2022 then called similarly for a left square bracket.
procedure Check_Line_Max_Length (Len : Nat);
-- Called with Scan_Ptr pointing to the first line terminator character