OSDN Git Service

* gcc-interface/trans.c (gigi): Set DECL_IGNORED_P on EH functions.
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 15 Apr 2010 20:21:08 +0000 (20:21 +0000)
committerMasaki Muranaka <monaka@monami-software.com>
Sun, 23 May 2010 05:32:50 +0000 (14:32 +0900)
(gnat_to_gnu) <N_Op_Eq>: Restore the value of input_location
before translating the top-level node.
(lvalue_required_p) <N_Function_Call>: Return 1 if !constant.
<N_Object_Declaration>: Likewise.
<N_Assignment_Statement>: Likewise.
<N_Unchecked_Type_Conversion>: Likewise.
(call_to_gnu): Remove kludge.
(gnat_to_gnu) <N_Return_Statement>: When not optimizing, force labels
associated with user returns to be preserved.
(gnat_to_gnu): Add special code to deal with boolean rvalues.
* gcc-interface/utils2.c (compare_arrays): Set input_location on all
comparisons.
(build_unary_op) <ADDR_EXPR>: Call build_fold_addr_expr.
<INDIRECT_REF>: Call build_fold_indirect_ref.

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

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

index 0d75627..aaec1a4 100644 (file)
@@ -1,4 +1,22 @@
-2010-04-15  Joel Sherrill <joel.sherrill@oarcorp.com>
+2010-04-15  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/trans.c (gigi): Set DECL_IGNORED_P on EH functions.
+       (gnat_to_gnu) <N_Op_Eq>: Restore the value of input_location
+       before translating the top-level node.
+       (lvalue_required_p) <N_Function_Call>: Return 1 if !constant.
+       <N_Object_Declaration>: Likewise.
+       <N_Assignment_Statement>: Likewise.
+       <N_Unchecked_Type_Conversion>: Likewise.
+       (call_to_gnu): Remove kludge.
+       (gnat_to_gnu) <N_Return_Statement>: When not optimizing, force labels
+       associated with user returns to be preserved.
+       (gnat_to_gnu): Add special code to deal with boolean rvalues.
+       * gcc-interface/utils2.c (compare_arrays): Set input_location on all
+       comparisons.
+       (build_unary_op) <ADDR_EXPR>: Call build_fold_addr_expr.
+       <INDIRECT_REF>: Call build_fold_indirect_ref.
+
+2010-04-15  Joel Sherrill  <joel.sherrill@oarcorp.com>
 
        * g-socket.adb: A target can have multiple missing errno's.  This
        will result in multiple errno's being defined as -1.  Because of this
@@ -74,7 +92,7 @@
        unless necessary.  Reuse the tree for an associated class-wide type
        only if processing its root type.
 
-2010-04-13  Joel Sherrill <joel.sherrill@oarcorp.com>
+2010-04-13  Joel Sherrill  <joel.sherrill@oarcorp.com>
 
        * gsocket.h: Run-time can no longer be built without network
        OS headers available.  Changing RTEMS GNAT build procedure to
index 49dd0d7..bf0e183 100644 (file)
@@ -787,8 +787,9 @@ lvalue_required_p (Node_Id gnat_node, tree gnu_type, bool constant,
     case N_Object_Declaration:
       /* We cannot use a constructor if this is an atomic object because
         the actual assignment might end up being done component-wise.  */
-      return ((Is_Composite_Type (Underlying_Type (Etype (gnat_node)))
-              && Is_Atomic (Defining_Entity (gnat_parent)))
+      return (!constant
+             ||(Is_Composite_Type (Underlying_Type (Etype (gnat_node)))
+                && Is_Atomic (Defining_Entity (gnat_parent)))
              /* We don't use a constructor if this is a class-wide object
                 because the effective type of the object is the equivalent
                 type of the class-wide subtype and it smashes most of the
@@ -817,9 +818,10 @@ lvalue_required_p (Node_Id gnat_node, tree gnu_type, bool constant,
       /* ... fall through ... */
 
     case N_Unchecked_Type_Conversion:
-      return lvalue_required_p (gnat_parent,
-                               get_unpadded_type (Etype (gnat_parent)),
-                               constant, address_of_constant, aliased);
+      return (!constant
+             || lvalue_required_p (gnat_parent,
+                                   get_unpadded_type (Etype (gnat_parent)),
+                                   constant, address_of_constant, aliased));
 
     case N_Allocator:
       /* We should only reach here through the N_Qualified_Expression case
@@ -5535,6 +5537,23 @@ gnat_to_gnu (Node_Id gnat_node)
   if (went_into_elab_proc)
     current_function_decl = NULL_TREE;
 
+  /* When not optimizing, turn boolean rvalues B into B != false tests
+     so that the code just below can put the location information of the
+     reference to B on the inequality operator for better debug info.  */
+  if (!optimize
+      && (kind == N_Identifier
+         || kind == N_Expanded_Name
+         || kind == N_Explicit_Dereference
+         || kind == N_Function_Call
+         || kind == N_Indexed_Component
+         || kind == N_Selected_Component)
+      && TREE_CODE (get_base_type (gnu_result_type)) == BOOLEAN_TYPE
+      && !lvalue_required_p (gnat_node, gnu_result_type, false, false, false))
+    gnu_result = build_binary_op (NE_EXPR, gnu_result_type,
+                                 convert (gnu_result_type, gnu_result),
+                                 convert (gnu_result_type,
+                                          boolean_false_node));
+
   /* Set the location information on the result if it is a real expression.
      References can be reused for multiple GNAT nodes and they would get
      the location information of their last use.  Note that we may have
index 2aa8605..ec8fb5e 100644 (file)
@@ -310,6 +310,8 @@ compare_arrays (tree result_type, tree a1, tree a2)
          if (EXPR_P (comparison))
            SET_EXPR_LOCATION (comparison, input_location);
 
+         length1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (length1, a1);
+
          this_a1_is_null = comparison;
          this_a2_is_null = convert (result_type, boolean_true_node);
        }
@@ -331,17 +333,18 @@ compare_arrays (tree result_type, tree a1, tree a2)
 
          comparison
            = build_binary_op (EQ_EXPR, result_type,
-                              build_binary_op (MINUS_EXPR, bt, ub1, lb1),
-                              build_binary_op (MINUS_EXPR, bt, ub2, lb2));
+                              build_binary_op (MINUS_EXPR, nbt, ub1, lb1),
+                              build_binary_op (MINUS_EXPR, nbt, ub2, lb2));
          comparison = SUBSTITUTE_PLACEHOLDER_IN_EXPR (comparison, a1);
          if (EXPR_P (comparison))
            SET_EXPR_LOCATION (comparison, input_location);
 
+         length1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (length1, a1);
+
          this_a1_is_null = build_binary_op (LT_EXPR, result_type, ub1, lb1);
          if (EXPR_P (this_a1_is_null))
            SET_EXPR_LOCATION (this_a1_is_null, input_location);
-
-         this_a2_is_null = convert (result_type, boolean_false_node);
+         this_a2_is_null = convert (result_type, integer_zero_node);
        }
 
       /* Otherwise, compare the computed lengths.  */
@@ -355,26 +358,16 @@ compare_arrays (tree result_type, tree a1, tree a2)
          if (EXPR_P (comparison))
            SET_EXPR_LOCATION (comparison, input_location);
 
-         /* If the length expression is of the form (cond ? val : 0), assume
-            that cond is equivalent to (length != 0).  That's guaranteed by
-            construction of the array types in gnat_to_gnu_entity.  */
-         if (TREE_CODE (length1) == COND_EXPR
-             && integer_zerop (TREE_OPERAND (length1, 2)))
-           this_a1_is_null = invert_truthvalue (TREE_OPERAND (length1, 0));
-         else
-           this_a1_is_null = build_binary_op (EQ_EXPR, result_type, length1,
-                                              size_zero_node);
-          if (EXPR_P (this_a1_is_null))
+         this_a1_is_null
+           = build_binary_op (LT_EXPR, result_type, length1,
+                              convert (bt, integer_zero_node));
+         if (EXPR_P (this_a1_is_null))
            SET_EXPR_LOCATION (this_a1_is_null, input_location);
 
-         /* Likewise for the second array.  */
-         if (TREE_CODE (length2) == COND_EXPR
-             && integer_zerop (TREE_OPERAND (length2, 2)))
-           this_a2_is_null = invert_truthvalue (TREE_OPERAND (length2, 0));
-         else
-           this_a2_is_null = build_binary_op (EQ_EXPR, result_type, length2,
-                                              size_zero_node);
-          if (EXPR_P (this_a2_is_null))
+         this_a2_is_null
+           = build_binary_op (LT_EXPR, result_type, length2,
+                              convert (bt, integer_zero_node));
+         if (EXPR_P (this_a2_is_null))
            SET_EXPR_LOCATION (this_a2_is_null, input_location);
        }
 
@@ -405,8 +398,12 @@ compare_arrays (tree result_type, tree a1, tree a2)
          a2 = convert (type, a2);
        }
 
-      result = build_binary_op (TRUTH_ANDIF_EXPR, result_type, result,
-                               fold_build2 (EQ_EXPR, result_type, a1, a2));
+      comparison = fold_build2 (EQ_EXPR, result_type, a1, a2);
+      if (EXPR_P (comparison))
+       SET_EXPR_LOCATION (comparison, input_location);
+
+      result
+       = build_binary_op (TRUTH_ANDIF_EXPR, result_type, result, comparison);
     }
 
   /* The result is also true if both sizes are zero.  */