The recent addition of Pragma_Unsigned_Base_Range to the enumeration type
Pragma_Id has made it exceed 256 enumeration values and thus overflow the
unsigned 8-bit type used for it on the C side. This should have stopped
the build, except that a glitch in the Snames machinery causes one value
to be dropped on the C side, leaving it at just 256 enumeration values.
This fixes both issues, i.e. ensures that the number of enumeration values is
the same on both sides and bumps the size of the C type to 16 bits.
Tested on x86-64/Linux, applied on the mainline.
2025-09-10 Eric Botcazou <[email protected]>
PR ada/121885
* snames.ads-tmpl (Pragma_Id): Rename Unknown_Pragma to
Pragma_Unknown for the sake of XSnamesT.
* snames.adb-tmpl (Get_Pragma_Id): Adjust to above renaming.
* snames.h-tmpl (Attribute_Id): Change underlying type to Byte.
(Get_Attribute_Id): Use Byte as return value.
(Pragma_Id): Change underlying type to Word.
(Get_Pragma_Id): Use Word as return value.
* types.h (Word): New typedef.
* exp_prag.adb (Expand_N_Pragma): Remove useless comment.
* par-prag.adb (Prag): Adjust to above renaming.
* sem_prag.adb (Analyze_Pragma): Likewise.
(Sig_Flags): Likewise.
--
Eric Botcazou
diff --git a/gcc/ada/exp_prag.adb b/gcc/ada/exp_prag.adb
index f60bca0e896..f19b9f36287 100644
--- a/gcc/ada/exp_prag.adb
+++ b/gcc/ada/exp_prag.adb
@@ -191,8 +191,7 @@ package body Exp_Prag is
when Pragma_Suppress_Initialization =>
Expand_Pragma_Suppress_Initialization (N);
- -- All other pragmas need no expander action (includes
- -- Unknown_Pragma).
+ -- All other pragmas need no expander action
when others => null;
end case;
diff --git a/gcc/ada/par-prag.adb b/gcc/ada/par-prag.adb
index c4e6cce0271..3723e644c24 100644
--- a/gcc/ada/par-prag.adb
+++ b/gcc/ada/par-prag.adb
@@ -305,7 +305,7 @@ begin
-- it is a semantic error, not a syntactic one (we have already checked
-- the syntax for the unrecognized pragma as required by (RM 2.8(11)).
- if Prag_Id = Unknown_Pragma then
+ if Prag_Id = Pragma_Unknown then
return Pragma_Node;
end if;
@@ -1622,12 +1622,12 @@ begin
null;
--------------------
- -- Unknown_Pragma --
+ -- Pragma_Unknown --
--------------------
-- Should be impossible, since we excluded this case earlier on
- when Unknown_Pragma =>
+ when Pragma_Unknown =>
raise Program_Error;
end case;
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 32da63fa8b4..753ccda6675 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -28915,13 +28915,13 @@ package body Sem_Prag is
null;
--------------------
- -- Unknown_Pragma --
+ -- Pragma_Unknown --
--------------------
-- Should be impossible, since the case of an unknown pragma is
-- separately processed before the case statement is entered.
- when Unknown_Pragma =>
+ when Pragma_Unknown =>
raise Program_Error;
end case;
@@ -34811,7 +34811,7 @@ package body Sem_Prag is
Pragma_Warnings => 0,
Pragma_Weak_External => 0,
Pragma_Wide_Character_Encoding => 0,
- Unknown_Pragma => 0);
+ Pragma_Unknown => 0);
function Is_Non_Significant_Pragma_Reference (N : Node_Id) return Boolean is
Id : Pragma_Id;
diff --git a/gcc/ada/snames.adb-tmpl b/gcc/ada/snames.adb-tmpl
index 12662e30314..fcfd3901e17 100644
--- a/gcc/ada/snames.adb-tmpl
+++ b/gcc/ada/snames.adb-tmpl
@@ -286,7 +286,7 @@ package body Snames is
when First_Pragma_Name .. Last_Pragma_Name =>
return Pragma_Id'Val (N - First_Pragma_Name);
when others =>
- return Unknown_Pragma;
+ return Pragma_Unknown;
end case;
end Get_Pragma_Id;
diff --git a/gcc/ada/snames.ads-tmpl b/gcc/ada/snames.ads-tmpl
index e83f6671668..d6fe60ba89a 100644
--- a/gcc/ada/snames.ads-tmpl
+++ b/gcc/ada/snames.ads-tmpl
@@ -2046,7 +2046,7 @@ package Snames is
-- The value to represent an unknown or unrecognized pragma
- Unknown_Pragma);
+ Pragma_Unknown);
-----------------------------------
-- Queuing Policy ID definitions --
@@ -2167,7 +2167,7 @@ package Snames is
-- to call this function with a name that is not the name of a check.
function Get_Pragma_Id (N : Name_Id) return Pragma_Id;
- -- Returns Id of pragma corresponding to given name. Returns Unknown_Pragma
+ -- Returns Id of pragma corresponding to given name. Returns Pragma_Unknown
-- if N is not a name of a known (Ada defined or GNAT-specific) pragma.
-- Note that the function also works correctly for names of pragmas that
-- are not included in the main list of pragma Names (e.g. Name_CPU returns
diff --git a/gcc/ada/snames.h-tmpl b/gcc/ada/snames.h-tmpl
index f01642ffbff..a9370235438 100644
--- a/gcc/ada/snames.h-tmpl
+++ b/gcc/ada/snames.h-tmpl
@@ -35,7 +35,7 @@ enum Name_Id : Int
/* Define the numeric values for attributes. */
-enum Attribute_Id : unsigned char
+enum Attribute_Id : Byte
{
Attr_ !! TEMPLATE INSERTION POINT
};
@@ -46,7 +46,7 @@ enum Attribute_Id : unsigned char
static inline Attribute_Id
Get_Attribute_Id (int id)
{
- extern unsigned char snames__get_attribute_id (int);
+ extern Byte snames__get_attribute_id (int);
return (Attribute_Id) snames__get_attribute_id (id);
}
@@ -64,7 +64,7 @@ extern Boolean Is_Pragma_Name (Name_Id);
/* Define the numeric values for the pragmas. */
-enum Pragma_Id : Byte
+enum Pragma_Id : Word
{
Pragma_ !! TEMPLATE_INSERTION_POINT
};
@@ -75,7 +75,7 @@ enum Pragma_Id : Byte
static inline Pragma_Id
Get_Pragma_Id (int id)
{
- extern unsigned char snames__get_pragma_id (int);
+ extern Word snames__get_pragma_id (int);
return (Pragma_Id) snames__get_pragma_id (id);
}
diff --git a/gcc/ada/types.h b/gcc/ada/types.h
index d0a1a04f979..98ef06089fc 100644
--- a/gcc/ada/types.h
+++ b/gcc/ada/types.h
@@ -57,6 +57,9 @@ typedef Int Pos;
/* 8-bit unsigned integer */
typedef unsigned char Byte;
+/* 16-bit unsigned integer */
+typedef unsigned short Word;
+
/* 8-Bit Character and String Types: */
/* 8-bit character type */