2010-04-16 Eric Botcazou <ebotcazou@adacore.com>
+ * gcc-interface/decl.c (gnat_to_gnu_entity): Use boolean_type_node in
+ lieu of integer_type_node for boolean operations.
+ (choices_to_gnu): Likewise.
+ * gcc-interface/trans.c (Attribute_to_gnu): Likewise.
+ (Loop_Statement_to_gnu): Likewise.
+ (establish_gnat_vms_condition_handler): Likewise.
+ (Exception_Handler_to_gnu_sjlj): Likewise.
+ (gnat_to_gnu): Likewise.
+ (build_unary_op_trapv): Likewise.
+ (build_binary_op_trapv): Likewise.
+ (emit_range_check): Likewise.
+ (emit_index_check): Likewise.
+ (convert_with_check): Likewise.
+ * gcc-interface/utils.c (convert_vms_descriptor64): Likewise.
+ (convert_vms_descriptor32): Likewise.
+ (convert_vms_descriptor): Likewise.
+ * gcc-interface/utils2.c (nonbinary_modular_operation): Likewise.
+ (compare_arrays): Use boolean instead of integer constants.
+ (build_binary_op) <TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR, TRUTH_AND_EXPR,
+ TRUTH_OR_EXPR, TRUTH_XOR_EXPR>: New case. Check that the result type
+ is a boolean type.
+ <GE_EXPR, LE_EXPR, GT_EXPR, LT_EXPR>: Remove obsolete assertion.
+ <EQ_EXPR, NE_EXPR>: Check that the result type is a boolean type.
+ <PREINC/PREDECREMENT_EXPR, POSTINC/POSTDECREMENT_EXPR>: Delete.
+ <TRUTH_NOT_EXPR>: Check that the result type is a boolean type.
+ (build_unary_op): Use boolean_type_node in lieu of integer_type_node
+ for boolean operations.
+ (fill_vms_descriptor): Likewise. Fix formatting nits.
+
+2010-04-16 Eric Botcazou <ebotcazou@adacore.com>
+
* gcc-interface/ada-tree.def (LOOP_STMT): Change to 4-operand nodes.
* gcc-interface/ada-tree.h (LOOP_STMT_TOP_COND, LOOP_STMT_BOT_COND):
Merge into...
/* We can't use build_component_ref here since the template type
isn't complete yet. */
- gnu_orig_min = build3 (COMPONENT_REF, gnu_index_base_type,
- gnu_template_reference, gnu_lb_field,
- NULL_TREE);
- gnu_orig_max = build3 (COMPONENT_REF, gnu_index_base_type,
- gnu_template_reference, gnu_hb_field,
- NULL_TREE);
- TREE_READONLY (gnu_orig_min) = TREE_READONLY (gnu_orig_max) = 1;
-
- gnu_min = convert (sizetype, gnu_orig_min);
- gnu_max = convert (sizetype, gnu_orig_max);
-
- /* Compute the size of this dimension. See the E_Array_Subtype
- case below for the rationale. */
- gnu_high
- = build3 (COND_EXPR, sizetype,
- build2 (GE_EXPR, boolean_type_node,
- gnu_orig_max, gnu_orig_min),
- gnu_max,
- size_binop (MINUS_EXPR, gnu_min, size_one_node));
+ gnu_low = build3 (COMPONENT_REF, gnu_index_base_type,
+ gnu_template_reference, gnu_low_field,
+ NULL_TREE);
+ gnu_high = build3 (COMPONENT_REF, gnu_index_base_type,
+ gnu_template_reference, gnu_high_field,
+ NULL_TREE);
+ TREE_READONLY (gnu_low) = TREE_READONLY (gnu_high) = 1;
+
+ /* Compute the size of this dimension. */
+ gnu_max
+ = build3 (COND_EXPR, gnu_index_base_type,
+ build2 (GE_EXPR, boolean_type_node, gnu_high, gnu_low),
+ gnu_high,
+ build2 (MINUS_EXPR, gnu_index_base_type,
+ gnu_low, fold_convert (gnu_index_base_type,
+ integer_one_node)));
/* Make a range type with the new range in the Ada base type.
Then make an index type with the size range in sizetype. */
else if (TREE_CODE (gnu_max) == INTEGER_CST
&& TREE_CODE (gnu_min) != INTEGER_CST)
{
- gnu_high = gnu_max;
- gnu_min
- = build_cond_expr (sizetype,
- build_binary_op (GE_EXPR,
- boolean_type_node,
- gnu_orig_max,
- gnu_orig_min),
- gnu_min,
- size_binop (PLUS_EXPR, gnu_max,
- size_one_node));
+ gnu_high = size_binop (MINUS_EXPR, gnu_min, size_one_node);
+ gnu_low = size_binop (PLUS_EXPR, gnu_max, size_one_node);
+
+ /* If gnu_high is a constant that has overflowed, the low
+ bound is the smallest integer so cannot be the maximum.
+ If gnu_low is a constant that has overflowed, the high
+ bound is the highest integer so cannot be the minimum. */
+ if ((TREE_CODE (gnu_high) == INTEGER_CST
+ && TREE_OVERFLOW (gnu_high))
+ || (TREE_CODE (gnu_low) == INTEGER_CST
+ && TREE_OVERFLOW (gnu_low)))
+ gnu_high = gnu_max;
+
+ /* If the index type is a subrange and gnu_high a constant
+ that hasn't overflowed, we can use the maximum. */
+ else if (subrange_p && TREE_CODE (gnu_high) == INTEGER_CST)
+ gnu_high = size_binop (MAX_EXPR, gnu_max, gnu_high);
+
+ /* If the index type is a subrange and gnu_low a constant
+ that hasn't overflowed, we can use the minimum. */
+ else if (subrange_p && TREE_CODE (gnu_low) == INTEGER_CST)
+ {
+ gnu_high = gnu_max;
+ gnu_min = size_binop (MIN_EXPR, gnu_min, gnu_low);
+ }
+
+ else
+ gnu_high
+ = build_cond_expr (sizetype,
+ build_binary_op (GE_EXPR,
+ boolean_type_node,
+ gnu_orig_max,
+ gnu_orig_min),
+ gnu_max, gnu_high);
}
/* Finally we use (hb >= lb) ? hb : lb - 1 for the upper bound
/* Set either the top or bottom exit condition. */
LOOP_STMT_COND (gnu_loop_stmt)
- = build_binary_op (test_code, integer_type_node, gnu_loop_var,
+ = build_binary_op (test_code, boolean_type_node, gnu_loop_var,
gnu_last);
/* Set either the top or bottom update statement and give it the source
gnu_result = gnat_protect_expr (gnu_result);
gnu_conv = convert (calc_type, gnu_result);
gnu_comp
- = fold_build2 (GE_EXPR, integer_type_node, gnu_result, gnu_zero);
+ = fold_build2 (GE_EXPR, boolean_type_node, gnu_result, gnu_zero);
gnu_add_pred_half
= fold_build2 (PLUS_EXPR, calc_type, gnu_conv, gnu_pred_half);
gnu_subtract_pred_half
tree a2_is_null = convert (result_type, boolean_false_node);
tree t1 = TREE_TYPE (a1);
tree t2 = TREE_TYPE (a2);
- tree result = convert (result_type, integer_one_node);
- tree a1_is_null = convert (result_type, integer_zero_node);
- tree a2_is_null = convert (result_type, integer_zero_node);
bool a1_side_effects_p = TREE_SIDE_EFFECTS (a1);
bool a2_side_effects_p = TREE_SIDE_EFFECTS (a2);
bool length_zero_p = false;
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, integer_zero_node);
+ this_a2_is_null = convert (result_type, boolean_false_node);
}
/* Otherwise, compare the computed lengths. */