aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/csets.adb
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/csets.adb
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/csets.adb')
-rw-r--r--gcc/ada/csets.adb46
1 files changed, 36 insertions, 10 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;