]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix LTO bootstrap failure with -Werror=lto-type-mismatch
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 9 Oct 2024 19:31:13 +0000 (21:31 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Wed, 9 Oct 2024 21:44:23 +0000 (23:44 +0200)
In GNAT's implementation model, using convention C (or C_Pass_By_Copy) has
no effect on the internal representation of types since the representation
is identical to that of C by default.  It's even counter-productive given
the implementation advice listed in B.3(63-71) so the interface between the
front-end and gigi does not use it and instead uses structurally identical
types on both sides.

gcc/ada
PR ada/117038
* fe.h (struct c_array): Add 'const' to declaration of pointer.
(C_Source_Buffer): Use consistent formatting.
* par-ch3.adb (P_Component_Items): Properly set Aliased_Present on
access definition.
* sinput.ads: Remove clause for Interfaces.C.
(C_Array): Change type of Length to Integer and make both components
aliased.  Remove Convention aspect.
(C_Source_Buffer): Remove all aspects.
* sinput.adb (C_Source_Buffer): Adjust to above change.

gcc/ada/fe.h
gcc/ada/par-ch3.adb
gcc/ada/sinput.adb
gcc/ada/sinput.ads

index 36f5e9bfe9eddaf45a4e9b0144f6024a8b47c8c9..e3e65fe18bd191d1fc1c20e2e6a15d6bbad71f2a 100644 (file)
@@ -348,17 +348,17 @@ extern void Set_Present_Expr              (Node_Id, Uint);
 /* sinput: */
 
 struct c_array {
-  char *pointer;
+  const char *pointer;
   int length;
 };
 
-#define C_Source_Buffer sinput__c_source_buffer
+#define C_Source_Buffer        sinput__c_source_buffer
 #define Debug_Source_Name      sinput__debug_source_name
 #define Get_Column_Number      sinput__get_column_number
 #define Get_Logical_Line_Number        sinput__get_logical_line_number
 #define Get_Source_File_Index  sinput__get_source_file_index
 
-extern struct c_array C_Source_Buffer (Source_File_Index);
+extern struct c_array C_Source_Buffer          (Source_File_Index);
 extern File_Name_Type Debug_Source_Name                (Source_File_Index);
 extern Column_Number_Type Get_Column_Number    (Source_Ptr);
 extern Line_Number_Type Get_Logical_Line_Number        (Source_Ptr);
index a5f4319debf6a14236ba8cd6e16856282e2531c1..04246dc04ebe1032db0f6bf290344bed3825d592 100644 (file)
@@ -3841,7 +3841,7 @@ package body Ch3 is
                --  end if;
 
                Set_Subtype_Indication (CompDef_Node, Empty);
-               Set_Aliased_Present    (CompDef_Node, False);
+               Set_Aliased_Present    (CompDef_Node, Aliased_Present);
                Set_Access_Definition  (CompDef_Node,
                  P_Access_Definition (Not_Null_Present));
             else
index f2e6dda1c9916d340dfe280b6af89316ca4783be..2b7439f1036a48f9344278305017b8a78375a344 100644 (file)
@@ -281,10 +281,8 @@ package body Sinput is
    ---------------------
 
    function C_Source_Buffer (S : SFI) return C_Array is
-      use type Interfaces.C.int;
-
-      Length : constant Interfaces.C.int :=
-        Interfaces.C.int (Source_Last (S) - Source_First (S));
+      Length : constant Integer :=
+        Integer (Source_Last (S) - Source_First (S));
 
       Text : constant Source_Buffer_Ptr := Source_Text (S);
 
index ce47fef76db3aa72186c54a821ebcd73db1557b6..d33c470835262e892d8d37521de1e1ec17305986 100644 (file)
@@ -56,7 +56,6 @@
 
 with Alloc;
 with Casing; use Casing;
-with Interfaces.C;
 with Namet;  use Namet;
 with System;
 with Table;
@@ -708,12 +707,13 @@ package Sinput is
    --  to avoid memory leaks.
 
    type C_Array is record
-      Pointer : access constant Character;
-      Length  : Interfaces.C.int range 0 .. Interfaces.C.int'Last;
-   end record with Convention => C_Pass_By_Copy;
+      Pointer : aliased access constant Character;
+      Length  : aliased Integer;
+   end record;
+   --  WARNING: There is a matching C declaration of this type in fe.h
 
-   function C_Source_Buffer (S : SFI) return C_Array with
-     Export, Convention => C, External_Name => "sinput__c_source_buffer";
+   function C_Source_Buffer (S : SFI) return C_Array;
+   --  WARNING: There is a matching C declaration of this subprogram in fe.h
 
 private
    pragma Inline (File_Name);