We treat System.Address as equivalent to void* for functions imported from C
and other languages, but the existing implementation was not very robust.
Tested on x86_64-suse-linux, applied on the mainline and 7 branch.
2017-12-13 Eric Botcazou <ebotca...@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity): Robustify test for types
descendant of System.Address.
(gnat_to_gnu_subprog_type): Likewise.
--
Eric Botcazou
Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c (revision 255578)
+++ gcc-interface/decl.c (working copy)
@@ -659,7 +659,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
/* Get the type after elaborating the renamed object. */
if (Has_Foreign_Convention (gnat_entity)
- && Is_Descendant_Of_Address (gnat_type))
+ && Is_Descendant_Of_Address (Underlying_Type (gnat_type)))
gnu_type = ptr_type_node;
else
{
@@ -5594,7 +5594,7 @@ gnat_to_gnu_subprog_type (Entity_Id gnat
/* For foreign convention subprograms, return System.Address as void *
or equivalent. Note that this comprises GCC builtins. */
if (Has_Foreign_Convention (gnat_subprog)
- && Is_Descendant_Of_Address (gnat_return_type))
+ && Is_Descendant_Of_Address (Underlying_Type (gnat_return_type)))
gnu_return_type = ptr_type_node;
else
gnu_return_type = gnat_to_gnu_profile_type (gnat_return_type);
@@ -5761,7 +5761,7 @@ gnat_to_gnu_subprog_type (Entity_Id gnat
/* For foreign convention subprograms, pass System.Address as void *
or equivalent. Note that this comprises GCC builtins. */
if (Has_Foreign_Convention (gnat_subprog)
- && Is_Descendant_Of_Address (gnat_param_type))
+ && Is_Descendant_Of_Address (Underlying_Type (gnat_param_type)))
gnu_param_type = ptr_type_node;
else
gnu_param_type = gnat_to_gnu_profile_type (gnat_param_type);