[Ada] Ease interface with builtins that returns void *
Arnaud Charlet
charlet@adacore.com
Mon Jul 16 13:11:00 GMT 2012
The natural way to import a builtin that returns void * is to use
System.Address in Ada, which is in fact an integral type.
Addressed by this patch, which makes it possible to e.g. compile:
with System;
procedure Btins1 is
function Frame_Address (Level : Integer) return System.Address;
pragma Import (Intrinsic, Frame_Address, "__builtin_frame_address");
Ptr : System.Address;
pragma Volatile (Ptr);
begin
Ptr := Frame_Address (0);
end;
Tested on x86_64-pc-linux-gnu, committed on trunk
2012-07-16 Tristan Gingold <gingold@adacore.com>
* gcc-interface/decl.c (intrin_return_compatible_p): Map Address to
void *.
-------------- next part --------------
Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c (revision 189524)
+++ gcc-interface/decl.c (working copy)
@@ -8046,6 +8046,10 @@
&& !VOID_TYPE_P (btin_return_type))
return true;
+ /* If return type is Address (integer type), map it to void *. */
+ if (Is_Descendent_Of_Address (Etype (inb->gnat_entity)))
+ ada_return_type = ptr_void_type_node;
+
/* Check return types compatibility otherwise. Note that this
handles void/void as well. */
if (intrin_types_incompatible_p (btin_return_type, ada_return_type))
More information about the Gcc-patches
mailing list