trans.c (Call_to_gnu): Do not initialize the temporary created out of addressability...
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 27 May 2019 11:43:17 +0000 (11:43 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Mon, 27 May 2019 11:43:17 +0000 (11:43 +0000)
* gcc-interface/trans.c (Call_to_gnu): Do not initialize the temporary
created out of addressability concerns if it's for the _Init parameter
of an initialization procedure.

From-SVN: r271659

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

index 82fb6e56363cc4d88f9df936882bfa34c5cc2614..8c3e7fb88ae1b67252daa529ef2028a129fcd002 100644 (file)
@@ -1,3 +1,9 @@
+2019-05-27  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/trans.c (Call_to_gnu): Do not initialize the temporary
+       created out of addressability concerns if it's for the _Init parameter
+       of an initialization procedure.
+
 2019-05-27  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/ada-builtin-types.def: New file.
index 59c4c07a319b472ce2b57e58b5cf7c685096b796..be9cbd4f6267c9d73b8dd8f078be6ac06421d853 100644 (file)
@@ -5313,13 +5313,23 @@ Call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target,
          /* Create an explicit temporary holding the copy.  */
          if (atomic_p)
            gnu_name = build_atomic_load (gnu_name, sync);
-         gnu_temp
-           = create_init_temporary ("A", gnu_name, &gnu_stmt, gnat_actual);
 
-         /* But initialize it on the fly like for an implicit temporary as
-            we aren't necessarily having a statement list.  */
-         gnu_name = build_compound_expr (TREE_TYPE (gnu_name), gnu_stmt,
-                                         gnu_temp);
+         /* Do not initialize it for the _Init parameter of an initialization
+            procedure since no data is meant to be passed in.  */
+         if (Ekind (gnat_formal) == E_Out_Parameter
+             && Is_Entity_Name (Name (gnat_node))
+             && Is_Init_Proc (Entity (Name (gnat_node))))
+           gnu_name = gnu_temp = create_temporary ("A", TREE_TYPE (gnu_name));
+
+         /* Initialize it on the fly like for an implicit temporary in the
+            other cases, as we don't necessarily have a statement list.  */
+         else
+           {
+             gnu_temp = create_init_temporary ("A", gnu_name, &gnu_stmt,
+                                               gnat_actual);
+             gnu_name = build_compound_expr (TREE_TYPE (gnu_name), gnu_stmt,
+                                             gnu_temp);
+           }
 
          /* Set up to move the copy back to the original if needed.  */
          if (!in_param)