[Ada] Fix type mismatch warnings during LTO bootstrap #1

Message ID 20210507093823.GA140727@adacore.com
State New
Headers show
  • [Ada] Fix type mismatch warnings during LTO bootstrap #1
Related show

Commit Message

Pierre-Marie de Rodat May 7, 2021, 9:38 a.m.
This sets convention C on enumeration types and functions declarations
involving System.Address, and makes adjustements to fe.h accordingly.

Tested on x86_64-pc-linux-gnu, committed on trunk


	* errout.ads (Set_Identifier_Casing): Add pragma Convention C.
	* eval_fat.ads (Rounding_Mode): Likewise.
	(Machine): Add WARNING comment line.
	* exp_code.ads (Clobber_Get_Next): Add pragma Convention C.
	* fe.h (Compiler_Abort): Fix return type.
	(Set_Identifier_Casing): Change type of parameters.
	(Clobber_Get_Next): Change return type.
	* gcc-interface/trans.c (gnat_to_gnu) <N_Code_Statement>: Add cast.


diff --git a/gcc/ada/errout.ads b/gcc/ada/errout.ads
--- a/gcc/ada/errout.ads
+++ b/gcc/ada/errout.ads
@@ -987,6 +987,7 @@  package Errout is
    procedure Set_Identifier_Casing
      (Identifier_Name : System.Address;
       File_Name       : System.Address);
+   pragma Convention (C, Set_Identifier_Casing);
    --  This subprogram can be used by the back end for the purposes of
    --  concocting error messages that are not output via Errout, e.g.
    --  the messages generated by the gcc back end.

diff --git a/gcc/ada/eval_fat.ads b/gcc/ada/eval_fat.ads
--- a/gcc/ada/eval_fat.ads
+++ b/gcc/ada/eval_fat.ads
@@ -85,8 +85,8 @@  package Eval_Fat is
    type Rounding_Mode is (Floor, Ceiling, Round, Round_Even);
    for Rounding_Mode use (0, 1, 2, 3);
+   pragma Convention (C, Rounding_Mode);
    --  Used to indicate rounding mode for Machine attribute
-   --  Note that C code in gigi knows that Round_Even is 3
    --  The Machine attribute is special, in that it takes an extra argument
    --  indicating the rounding mode, and also an argument Enode that is a
@@ -99,6 +99,8 @@  package Eval_Fat is
       Mode  : Rounding_Mode;
       Enode : Node_Id) return T;
+   --  WARNING: There is a matching C declaration of this function in urealp.h
    procedure Decompose_Int
      (RT       : R;
       X        : T;

diff --git a/gcc/ada/exp_code.ads b/gcc/ada/exp_code.ads
--- a/gcc/ada/exp_code.ads
+++ b/gcc/ada/exp_code.ads
@@ -53,6 +53,7 @@  package Exp_Code is
    --  with subsequent calls to Clobber_Get_Next.
    function Clobber_Get_Next return System.Address;
+   pragma Convention (C, Clobber_Get_Next);
    --  Can only be called after a previous call to Clobber_Setup. The
    --  returned value is a pointer to a null terminated (C format) string
    --  for the next register argument. Null_Address is returned when there

diff --git a/gcc/ada/fe.h b/gcc/ada/fe.h
--- a/gcc/ada/fe.h
+++ b/gcc/ada/fe.h
@@ -55,7 +55,7 @@  extern Nat Serious_Errors_Detected;
 #define Compiler_Abort		comperr__compiler_abort
-extern int Compiler_Abort (String_Pointer, String_Pointer, Boolean) ATTRIBUTE_NORETURN;
+extern void Compiler_Abort (String_Pointer, String_Pointer, Boolean) ATTRIBUTE_NORETURN;
 /* debug: */
@@ -103,7 +103,7 @@  extern Node_Id Get_Attribute_Definition_Clause (Entity_Id, unsigned char);
 extern void Error_Msg_N			(String_Pointer, Node_Id);
 extern void Error_Msg_NE		(String_Pointer, Node_Id, Entity_Id);
-extern void Set_Identifier_Casing	(Char *, const Char *);
+extern void Set_Identifier_Casing	(void *, const void *);
 /* err_vars: */
@@ -145,7 +145,7 @@  extern Node_Id Asm_Input_Value		(void);
 extern Node_Id Asm_Output_Constraint	(void);
 extern Node_Id Asm_Output_Variable	(void);
 extern Node_Id Asm_Template		(Node_Id);
-extern char *Clobber_Get_Next		(void);
+extern void *Clobber_Get_Next		(void);
 extern void Clobber_Setup		(Node_Id);
 extern Boolean Is_Asm_Volatile		(Node_Id);
 extern void Next_Asm_Input		(void);

diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -7993,7 +7993,7 @@  gnat_to_gnu (Node_Id gnat_node)
 	  Clobber_Setup (gnat_node);
-	  while ((clobber = Clobber_Get_Next ()))
+	  while ((clobber = (char *) Clobber_Get_Next ()))
 	      = tree_cons (NULL_TREE,
 			   build_string (strlen (clobber) + 1, clobber),