]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
trans.c (Subprogram_Body_to_gnu): Evaluate the expressions of the parameter cache...
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 4 Jan 2011 09:44:16 +0000 (09:44 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Tue, 4 Jan 2011 09:44:16 +0000 (09:44 +0000)
* gcc-interface/trans.c (Subprogram_Body_to_gnu): Evaluate the
expressions of the parameter cache within the statement group of
the CICO mechanism.

From-SVN: r168457

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

index f704279b07bdbafdfdf6f282f4b6b0cd1bafb2a9..4cc3a956c724ad23b81e0faff8e80acd09f8b7c4 100644 (file)
@@ -1,3 +1,9 @@
+2011-01-04  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/trans.c (Subprogram_Body_to_gnu): Evaluate the
+       expressions of the parameter cache within the statement group of
+       the CICO mechanism.
+
 2010-12-16  Release Manager
 
        * GCC 4.5.2 released.
index 59a63320b466afdfb4dbeb22366f0795dc7fe30f..d9fb3f1946e6cdb58bb46a7f9fc9a336f95d1399 100644 (file)
@@ -2303,6 +2303,31 @@ Subprogram_Body_to_gnu (Node_Id gnat_node)
   gnat_poplevel ();
   gnu_result = end_stmt_group ();
 
+  /* If we populated the parameter attributes cache, we need to make sure that
+     the cached expressions are evaluated on all the possible paths leading to
+     their uses.  So we force their evaluation on entry of the function.  */
+  cache = DECL_STRUCT_FUNCTION (gnu_subprog_decl)->language->parm_attr_cache;
+  if (cache)
+    {
+      struct parm_attr_d *pa;
+      int i;
+
+      start_stmt_group ();
+
+      for (i = 0; VEC_iterate (parm_attr, cache, i, pa); i++)
+       {
+         if (pa->first)
+           add_stmt_with_node (pa->first, gnat_node);
+         if (pa->last)
+           add_stmt_with_node (pa->last, gnat_node);
+         if (pa->length)
+           add_stmt_with_node (pa->length, gnat_node);
+       }
+
+      add_stmt (gnu_result);
+      gnu_result = end_stmt_group ();
+    }
+
   /* If we are dealing with a return from an Ada procedure with parameters
      passed by copy-in/copy-out, we need to return a record containing the
      final values of these parameters.  If the list contains only one entry,
@@ -2341,30 +2366,6 @@ Subprogram_Body_to_gnu (Node_Id gnat_node)
 
   pop_stack (&gnu_return_label_stack);
 
-  /* If we populated the parameter attributes cache, we need to make sure
-     that the cached expressions are evaluated on all possible paths.  */
-  cache = DECL_STRUCT_FUNCTION (gnu_subprog_decl)->language->parm_attr_cache;
-  if (cache)
-    {
-      struct parm_attr_d *pa;
-      int i;
-
-      start_stmt_group ();
-
-      for (i = 0; VEC_iterate (parm_attr, cache, i, pa); i++)
-       {
-         if (pa->first)
-           add_stmt_with_node (pa->first, gnat_node);
-         if (pa->last)
-           add_stmt_with_node (pa->last, gnat_node);
-         if (pa->length)
-           add_stmt_with_node (pa->length, gnat_node);
-       }
-
-      add_stmt (gnu_result);
-      gnu_result = end_stmt_group ();
-    }
-
   /* Set the end location.  */
   Sloc_to_locus
     ((Present (End_Label (Handled_Statement_Sequence (gnat_node)))