aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorJustin Squirek <squirek@adacore.com>2024-05-09 20:16:24 +0000
committerMarc Poulhiès <poulhies@adacore.com>2024-06-21 10:34:17 +0200
commit3ebd803b861e1da85f08664915e3267f690ff611 (patch)
tree4a9bb058d144725d321f38fd59861bab6a894cb5 /gcc/ada
parent59221dc587f369695d9b0c2f73aedf8458931f0f (diff)
downloadgcc-3ebd803b861e1da85f08664915e3267f690ff611.zip
gcc-3ebd803b861e1da85f08664915e3267f690ff611.tar.gz
gcc-3ebd803b861e1da85f08664915e3267f690ff611.tar.bz2
ada: Spurious style error with mutiple square brackets
This patch fixes a spurious error in the compiler when checking for style for token separation where two square brackets are next to each other. gcc/ada/ * csets.ads (Identifier_Char): New function - replacing table. * csets.adb (Identifier_Char): Rename and move table for static values. (Initialize): Remove dynamic calculations. (Identifier_Char): New function to calculate dynamic values. * opt.adb (Set_Config_Switches): Remove setting of Identifier_Char.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/csets.adb46
-rw-r--r--gcc/ada/csets.ads14
-rw-r--r--gcc/ada/opt.adb3
3 files changed, 43 insertions, 20 deletions
diff --git a/gcc/ada/csets.adb b/gcc/ada/csets.adb
index 7e5af3f..54ebdb4 100644
--- a/gcc/ada/csets.adb
+++ b/gcc/ada/csets.adb
@@ -29,6 +29,12 @@ with System.WCh_Con; use System.WCh_Con;
package body Csets is
+ Identifier_Char_Table : Char_Array_Flags;
+ -- This table contains all statically known characters which can appear in
+ -- identifiers, but excludes characters which need to be known dynamically,
+ -- for example like those that depend on the current Ada version which may
+ -- change from file to file.
+
X_80 : constant Character := Character'Val (16#80#);
X_81 : constant Character := Character'Val (16#81#);
X_82 : constant Character := Character'Val (16#82#);
@@ -1085,6 +1091,34 @@ package body Csets is
others => ' ');
+ ---------------------
+ -- Identifier_Char --
+ ---------------------
+
+ function Identifier_Char (Item : Character) return Boolean is
+ begin
+ -- Handle explicit dynamic cases
+
+ case Item is
+
+ -- 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.
+
+ when '[' | ']' =>
+ return Ada_Version < Ada_2022;
+
+ -- Otherwise, this is a static case - use the table
+
+ when others =>
+ return Identifier_Char_Table (Item);
+ end case;
+ end Identifier_Char;
+
----------------
-- Initialize --
----------------
@@ -1144,24 +1178,16 @@ package body Csets is
-- Build Identifier_Char table from used entries of Fold_Upper
for J in Character loop
- Identifier_Char (J) := (Fold_Upper (J) /= ' ');
+ Identifier_Char_Table (J) := (Fold_Upper (J) /= ' ');
end loop;
- -- 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 ('[') := 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.
if Identifier_Character_Set = 'w'
and then Wide_Character_Encoding_Method in WC_ESC_Encoding_Method
then
- Identifier_Char (ASCII.ESC) := True;
+ Identifier_Char_Table (ASCII.ESC) := True;
end if;
end Initialize;
diff --git a/gcc/ada/csets.ads b/gcc/ada/csets.ads
index 9dc78ba..f0930df 100644
--- a/gcc/ada/csets.ads
+++ b/gcc/ada/csets.ads
@@ -80,12 +80,12 @@ package Csets is
Fold_Lower : Translate_Table;
-- Table to fold upper case identifier letters to lower case
- Identifier_Char : Char_Array_Flags;
- -- This table has True entries for all characters that can legally appear
- -- in identifiers, including digits, the underline character, all letters
- -- including upper and lower case and extended letters (as controlled by
- -- the setting of Opt.Identifier_Character_Set), left bracket for brackets
- -- notation wide characters and also ESC if wide characters are permitted
- -- in identifiers using escape sequences starting with ESC.
+ function Identifier_Char (Item : Character) return Boolean;
+ -- Return True for all characters that can legally appear in identifiers,
+ -- including digits, the underline character, all letters including upper
+ -- and lower case and extended letters (as controlled by the setting of
+ -- Opt.Identifier_Character_Set), left bracket for brackets notation wide
+ -- characters and also ESC if wide characters are permitted in identifiers
+ -- using escape sequences starting with ESC.
end Csets;
diff --git a/gcc/ada/opt.adb b/gcc/ada/opt.adb
index 5427a95..8598ce2 100644
--- a/gcc/ada/opt.adb
+++ b/gcc/ada/opt.adb
@@ -23,8 +23,6 @@
-- --
------------------------------------------------------------------------------
-with Csets; use Csets;
-
package body Opt is
--------------------
@@ -188,7 +186,6 @@ 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.