]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix -Wlto-type-mismatch warning during GNAT LTO build
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 10 Sep 2025 13:00:59 +0000 (15:00 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Wed, 10 Sep 2025 14:15:29 +0000 (16:15 +0200)
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.

gcc/ada/
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.

gcc/ada/exp_prag.adb
gcc/ada/par-prag.adb
gcc/ada/sem_prag.adb
gcc/ada/snames.adb-tmpl
gcc/ada/snames.ads-tmpl
gcc/ada/snames.h-tmpl
gcc/ada/types.h

index f60bca0e8966e9e5d3c321de94052f6fc020b69b..f19b9f36287d18c9012f5aad5ead40cf1cfc45e3 100644 (file)
@@ -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;
index c4e6cce027188a14fc94fe609cccd1604cc76bea..3723e644c2445e8d207f74a52ce5a777d6b09b23 100644 (file)
@@ -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;
index 32da63fa8b4373ed03a758a3dadd565fa38bfd83..753ccda66756f5c2b680db9ed723cb427a4498a8 100644 (file)
@@ -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;
index 12662e30314fb83de579fe209ea03522f1f7744c..fcfd3901e17b4879df13596804b0cdde9bacf5f6 100644 (file)
@@ -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;
 
index e83f6671668b29f13cf67af641fbe6839e462bc0..d6fe60ba89ac42193ced5b855da0ceeae92634f7 100644 (file)
@@ -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
index f01642ffbff80e6f645383cf73e0c368acbe7d6a..a9370235438f242257d7fa022e58709a7f1de0e9 100644 (file)
@@ -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);
 }
 
index d0a1a04f979f60da5fc763bfa5a01cb39ef3d7fc..98ef06089fcef5e6b9969c10a03f6532f4d981ba 100644 (file)
@@ -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 */