* gcc-interface/trans.c (build_return_expr): Use void_type_node for
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 11 Sep 2011 18:28:05 +0000 (18:28 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 11 Sep 2011 18:28:05 +0000 (18:28 +0000)
MODIFY_EXPR.
* gcc-interface/utils2.c (build_binary_op) <MODIFY_EXPR>: Assert that
the result type is null if ENABLE_CHECKING.  Set operation_type at the
end unconditionally if not set in the previous cases.
Use build2 and void_type_node for MODIFY_EXPR.
(build_allocator): Use NULL_TREE for MODIFY_EXPR.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178761 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 74b3cfb..259677a 100644 (file)
@@ -1,3 +1,13 @@
+2011-09-11  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/trans.c (build_return_expr): Use void_type_node for
+       MODIFY_EXPR.
+       * gcc-interface/utils2.c (build_binary_op) <MODIFY_EXPR>: Assert that
+       the result type is null if ENABLE_CHECKING.  Set operation_type at the
+       end unconditionally if not set in the previous cases.
+       Use build2 and void_type_node for MODIFY_EXPR.
+       (build_allocator): Use NULL_TREE for MODIFY_EXPR.
+
 2011-09-08  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/utils.c (unchecked_convert): Use a field of the right
index 13df71f..b831918 100644 (file)
@@ -2482,7 +2482,7 @@ build_return_expr (tree ret_obj, tree ret_val)
       if (operation_type != TREE_TYPE (ret_val))
        ret_val = convert (operation_type, ret_val);
 
-      result_expr = build2 (MODIFY_EXPR, operation_type, ret_obj, ret_val);
+      result_expr = build2 (MODIFY_EXPR, void_type_node, ret_obj, ret_val);
     }
   else
     result_expr = ret_obj;
index 897f328..977f881 100644 (file)
@@ -518,8 +518,9 @@ nonbinary_modular_operation (enum tree_code op_code, tree type, tree lhs,
 \f
 /* Make a binary operation of kind OP_CODE.  RESULT_TYPE is the type
    desired for the result.  Usually the operation is to be performed
-   in that type.  For MODIFY_EXPR and ARRAY_REF, RESULT_TYPE may be 0
-   in which case the type to be used will be derived from the operands.
+   in that type.  For INIT_EXPR and MODIFY_EXPR, RESULT_TYPE must be
+   NULL_TREE.  For ARRAY_REF, RESULT_TYPE may be NULL_TREE, in which
+   case the type to be used will be derived from the operands.
 
    This function is very much unlike the ones for C and C++ since we
    have already done any type conversion and matching required.  All we
@@ -557,6 +558,9 @@ build_binary_op (enum tree_code op_code, tree result_type,
     {
     case INIT_EXPR:
     case MODIFY_EXPR:
+#ifdef ENABLE_CHECKING
+      gcc_assert (result_type == NULL_TREE);
+#endif
       /* If there were integral or pointer conversions on the LHS, remove
         them; we'll be putting them back below if needed.  Likewise for
         conversions between array and record types, except for justified
@@ -633,7 +637,7 @@ build_binary_op (enum tree_code op_code, tree result_type,
        operation_type = best_type;
 
       /* Otherwise use the LHS type.  */
-      else if (!operation_type)
+      else
        operation_type = left_type;
 
       /* Ensure everything on the LHS is valid.  If we have a field reference,
@@ -955,6 +959,8 @@ build_binary_op (enum tree_code op_code, tree result_type,
   else if (op_code == ARRAY_REF || op_code == ARRAY_RANGE_REF)
     result = fold (build4 (op_code, operation_type, left_operand,
                           right_operand, NULL_TREE, NULL_TREE));
+  else if (op_code == INIT_EXPR || op_code == MODIFY_EXPR)
+    result = build2 (op_code, void_type_node, left_operand, right_operand);
   else
     result
       = fold_build2 (op_code, operation_type, left_operand, right_operand);
@@ -2114,7 +2120,7 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc,
            (result_type,
             build2 (COMPOUND_EXPR, storage_ptr_type,
                     build_binary_op
-                    (MODIFY_EXPR, storage_type,
+                    (MODIFY_EXPR, NULL_TREE,
                      build_unary_op (INDIRECT_REF, NULL_TREE,
                                      convert (storage_ptr_type, storage)),
                      gnat_build_constructor (storage_type, v)),
@@ -2124,7 +2130,7 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc,
        return build2
          (COMPOUND_EXPR, result_type,
           build_binary_op
-          (MODIFY_EXPR, template_type,
+          (MODIFY_EXPR, NULL_TREE,
            build_component_ref
            (build_unary_op (INDIRECT_REF, NULL_TREE,
                             convert (storage_ptr_type, storage)),