]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (gnat_to_gnu_entity): Translate System.Address into ptr_type_node for every...
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 7 Dec 2016 11:47:25 +0000 (11:47 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Wed, 7 Dec 2016 11:47:25 +0000 (11:47 +0000)
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Translate
System.Address into ptr_type_node for every foreign convention.
(gnat_to_gnu_subprog_type): Likewise for result and parameter types.
(gnat_to_gnu_param): Do not do it here for GCC builtins.
(intrin_return_compatible_p): Likewise.

From-SVN: r243340

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c

index 3087a1b72cdbfaceb9ba1280953c9b5c330005c3..2380adcaccac0cfb1607caabe53caef2f0ef8239 100644 (file)
@@ -1,3 +1,11 @@
+2016-12-07  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Translate
+       System.Address into ptr_type_node for every foreign convention.
+       (gnat_to_gnu_subprog_type): Likewise for result and parameter types.
+       (gnat_to_gnu_param): Do not do it here for GCC builtins.
+       (intrin_return_compatible_p): Likewise.
+
 2016-12-07  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Enumeration_Subtype>:
index 2412a36d984231d58b89c330e727c96c3bc6f094..a6e8367d842ff2a67395ac51b31c9b47cb1ddeb0 100644 (file)
@@ -645,7 +645,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
          }
 
        /* Get the type after elaborating the renamed object.  */
-       if (Convention (gnat_entity) == Convention_C
+       if (Has_Foreign_Convention (gnat_entity)
            && Is_Descendant_Of_Address (gnat_type))
          gnu_type = ptr_type_node;
        else
@@ -5404,12 +5404,6 @@ gnat_to_gnu_param (Entity_Id gnat_param, tree gnu_param_type, bool first,
     gnu_param_type
       = TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (gnu_param_type))));
 
-  /* For GCC builtins, pass Address integer types as (void *)  */
-  if (Convention (gnat_subprog) == Convention_Intrinsic
-      && Present (Interface_Name (gnat_subprog))
-      && Is_Descendant_Of_Address (gnat_param_type))
-    gnu_param_type = ptr_type_node;
-
   /* Arrays are passed as pointers to element type for foreign conventions.  */
   if (foreign && mech != By_Copy && TREE_CODE (gnu_param_type) == ARRAY_TYPE)
     {
@@ -5784,7 +5778,9 @@ gnat_to_gnu_subprog_type (Entity_Id gnat_subprog, bool definition,
 
   else
     {
-      if (Convention (gnat_subprog) == Convention_C
+      /* 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))
        gnu_return_type = ptr_type_node;
       else
@@ -5949,7 +5945,9 @@ gnat_to_gnu_subprog_type (Entity_Id gnat_subprog, bool definition,
        {
          Entity_Id gnat_param_type = Etype (gnat_param);
 
-         if (Convention (gnat_subprog) == Convention_C
+         /* 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))
            gnu_param_type = ptr_type_node;
          else
@@ -8910,10 +8908,6 @@ intrin_return_compatible_p (intrin_binding_t * inb)
       && !VOID_TYPE_P (btin_return_type))
     return true;
 
-  /* If return type is Address (integer type), map it to void *.  */
-  if (Is_Descendant_Of_Address (Etype (inb->gnat_entity)))
-    ada_return_type = ptr_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))