OSDN Git Service

2006-10-31 Bob Duff <duff@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / trans.c
index 30c0fb5..fe820bf 100644 (file)
@@ -1510,7 +1510,7 @@ Subprogram_Body_to_gnu (Node_Id gnat_node)
      we must turn a condition into the corresponding exception even if there
      is no applicable Ada handler, and need at least one condition handler per
      possible call chain involving GNAT code.  OTOH, establishing the handler
-     has a cost so we want to mimize the number of subprograms into which this
+     has a cost so we want to minimize the number of subprograms into which this
      happens.  The foreign or exported condition is expected to satisfy all
      the constraints.  */
   if (TARGET_ABI_OPEN_VMS
@@ -1775,18 +1775,12 @@ call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target)
                       && (TYPE_JUSTIFIED_MODULAR_P (gnu_name_type)))
                gnu_name = convert (gnu_name_type, gnu_name);
 
+             /* Make a SAVE_EXPR to both properly account for potential side
+                effects and handle the creation of a temporary copy.  Special
+                code in gnat_gimplify_expr ensures that the same temporary is
+                used as the actual and copied back after the call.  */
              gnu_actual = save_expr (gnu_name);
 
-             /* Since we're going to take the address of the SAVE_EXPR, we
-                don't want it to be marked as unchanging. So set
-                TREE_ADDRESSABLE.  */
-             gnu_temp = skip_simple_arithmetic (gnu_actual);
-             if (TREE_CODE (gnu_temp) == SAVE_EXPR)
-               {
-                 TREE_ADDRESSABLE (gnu_temp) = 1;
-                 TREE_READONLY (gnu_temp) = 0;
-               }
-
              /* Set up to move the copy back to the original.  */
              gnu_temp = build_binary_op (MODIFY_EXPR, NULL_TREE,
                                          gnu_copy, gnu_actual);
@@ -2173,6 +2167,11 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node)
                                          build_call_0_expr (get_jmpbuf_decl),
                                          false, false, false, false, NULL,
                                          gnat_node);
+      /* The __builtin_setjmp receivers will immediately reinstall it.  Now
+        because of the unstructured form of EH used by setjmp_longjmp, there
+        might be forward edges going to __builtin_setjmp receivers on which
+        it is uninitialized, although they will never be actually taken.  */
+      TREE_NO_WARNING (gnu_jmpsave_decl) = 1;
       gnu_jmpbuf_decl = create_var_decl (get_identifier ("JMP_BUF"),
                                         NULL_TREE, jmpbuf_type,
                                         NULL_TREE, false, false, false, false,
@@ -4697,6 +4696,19 @@ gnat_gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p ATTRIBUTE_UNUSED)
          return GS_ALL_DONE;
        }
 
+      /* If we are taking the address of a SAVE_EXPR, we are typically
+        processing a misaligned argument to be passed by reference in a
+        procedure call.  We just mark the operand as addressable + not
+        readonly here and let the common gimplifier code perform the
+        temporary creation, initialization, and "instantiation" in place of
+        the SAVE_EXPR in further operands, in particular in the copy back
+        code inserted after the call.  */
+      else if (TREE_CODE (op) == SAVE_EXPR)
+       {
+         TREE_ADDRESSABLE (op) = 1;
+         TREE_READONLY (op) = 0;
+       }
+
       /* Otherwise, if we are taking the address of something that is neither
         reference, declaration, or constant, make a variable for the operand
         here and then take its address.  If we don't do it this way, we may
@@ -4829,7 +4841,7 @@ gnat_gimplify_stmt (tree *stmt_p)
 /* The reason for this routine's existence is two-fold.
    First, with some debugging formats, notably MDEBUG on SGI
    IRIX, the linker will remove duplicate debugging information if two
-   clients have identical debugguing information.  With the normal scheme
+   clients have identical debugging information.  With the normal scheme
    of elaboration, this does not usually occur, since entities in with'ed
    packages are elaborated on demand, and if clients have different usage
    patterns, the normal case, then the order and selection of entities