aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2024-10-09 21:31:13 +0200
committerEric Botcazou <ebotcazou@adacore.com>2024-10-09 23:44:23 +0200
commit7ac96b05cfa7478706dce175e7c7b09cbf559451 (patch)
treeef09a908b6b64bc46ce0fe76049cb402112573c3 /gcc
parent820cd5266e714750888dd2cdf4793cde8741c1db (diff)
downloadgcc-7ac96b05cfa7478706dce175e7c7b09cbf559451.zip
gcc-7ac96b05cfa7478706dce175e7c7b09cbf559451.tar.gz
gcc-7ac96b05cfa7478706dce175e7c7b09cbf559451.tar.bz2
Fix LTO bootstrap failure with -Werror=lto-type-mismatch
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/fe.h6
-rw-r--r--gcc/ada/par-ch3.adb2
-rw-r--r--gcc/ada/sinput.adb6
-rw-r--r--gcc/ada/sinput.ads12
4 files changed, 12 insertions, 14 deletions
diff --git a/gcc/ada/fe.h b/gcc/ada/fe.h
index 36f5e9b..e3e65fe 100644
--- a/gcc/ada/fe.h
+++ b/gcc/ada/fe.h
@@ -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);
diff --git a/gcc/ada/par-ch3.adb b/gcc/ada/par-ch3.adb
index a5f4319..04246dc 100644
--- a/gcc/ada/par-ch3.adb
+++ b/gcc/ada/par-ch3.adb
@@ -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
diff --git a/gcc/ada/sinput.adb b/gcc/ada/sinput.adb
index f2e6dda..2b7439f 100644
--- a/gcc/ada/sinput.adb
+++ b/gcc/ada/sinput.adb
@@ -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);
diff --git a/gcc/ada/sinput.ads b/gcc/ada/sinput.ads
index ce47fef..d33c470 100644
--- a/gcc/ada/sinput.ads
+++ b/gcc/ada/sinput.ads
@@ -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);