* gcc-interface/decl.c (gnat_to_gnu_entity): Use boolean_type_node in
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Apr 2010 12:07:02 +0000 (12:07 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Apr 2010 12:07:02 +0000 (12:07 +0000)
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.

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

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

index e14bd9a..4e6367c 100644 (file)
@@ -1,5 +1,36 @@
 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...
index 1a42ff7..4db6c11 100644 (file)
@@ -1916,7 +1916,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
            /* Compute the size of this dimension.  */
            gnu_max
              = build3 (COND_EXPR, gnu_index_base_type,
-                       build2 (GE_EXPR, integer_type_node, gnu_high, gnu_low),
+                       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,
@@ -2214,7 +2214,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
                    gnu_high
                      = build_cond_expr (sizetype,
                                         build_binary_op (GE_EXPR,
-                                                         integer_type_node,
+                                                         boolean_type_node,
                                                          gnu_orig_max,
                                                          gnu_orig_min),
                                         gnu_max, gnu_high);
@@ -6335,13 +6335,11 @@ choices_to_gnu (tree operand, Node_Id choices)
          low = gnat_to_gnu (Low_Bound (choice));
          high = gnat_to_gnu (High_Bound (choice));
 
-         /* There's no good type to use here, so we might as well use
-            integer_type_node.  */
          this_test
-           = build_binary_op (TRUTH_ANDIF_EXPR, integer_type_node,
-                              build_binary_op (GE_EXPR, integer_type_node,
+           = build_binary_op (TRUTH_ANDIF_EXPR, boolean_type_node,
+                              build_binary_op (GE_EXPR, boolean_type_node,
                                                operand, low),
-                              build_binary_op (LE_EXPR, integer_type_node,
+                              build_binary_op (LE_EXPR, boolean_type_node,
                                                operand, high));
 
          break;
@@ -6352,10 +6350,10 @@ choices_to_gnu (tree operand, Node_Id choices)
          high = gnat_to_gnu (High_Bound (gnat_temp));
 
          this_test
-           = build_binary_op (TRUTH_ANDIF_EXPR, integer_type_node,
-                              build_binary_op (GE_EXPR, integer_type_node,
+           = build_binary_op (TRUTH_ANDIF_EXPR, boolean_type_node,
+                              build_binary_op (GE_EXPR, boolean_type_node,
                                                operand, low),
-                              build_binary_op (LE_EXPR, integer_type_node,
+                              build_binary_op (LE_EXPR, boolean_type_node,
                                                operand, high));
          break;
 
@@ -6373,10 +6371,10 @@ choices_to_gnu (tree operand, Node_Id choices)
              high = TYPE_MAX_VALUE (type);
 
              this_test
-               = build_binary_op (TRUTH_ANDIF_EXPR, integer_type_node,
-                                  build_binary_op (GE_EXPR, integer_type_node,
+               = build_binary_op (TRUTH_ANDIF_EXPR, boolean_type_node,
+                                  build_binary_op (GE_EXPR, boolean_type_node,
                                                    operand, low),
-                                  build_binary_op (LE_EXPR, integer_type_node,
+                                  build_binary_op (LE_EXPR, boolean_type_node,
                                                    operand, high));
              break;
            }
@@ -6386,7 +6384,7 @@ choices_to_gnu (tree operand, Node_Id choices)
        case N_Character_Literal:
        case N_Integer_Literal:
          single = gnat_to_gnu (choice);
-         this_test = build_binary_op (EQ_EXPR, integer_type_node, operand,
+         this_test = build_binary_op (EQ_EXPR, boolean_type_node, operand,
                                       single);
          break;
 
@@ -6398,8 +6396,8 @@ choices_to_gnu (tree operand, Node_Id choices)
          gcc_unreachable ();
        }
 
-      result = build_binary_op (TRUTH_ORIF_EXPR, integer_type_node,
-                               result, this_test);
+      result = build_binary_op (TRUTH_ORIF_EXPR, boolean_type_node, result,
+                               this_test);
     }
 
   return result;
index 144d8c5..b446e07 100644 (file)
@@ -1212,7 +1212,7 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute)
          gnu_expr = gnat_protect_expr (gnu_expr);
          gnu_expr
            = emit_check
-             (build_binary_op (EQ_EXPR, integer_type_node,
+             (build_binary_op (EQ_EXPR, boolean_type_node,
                                gnu_expr,
                                attribute == Attr_Pred
                                ? TYPE_MIN_VALUE (gnu_result_type)
@@ -1677,7 +1677,7 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute)
                gnu_result
                  = build_cond_expr (comp_type,
                                     build_binary_op (GE_EXPR,
-                                                     integer_type_node,
+                                                     boolean_type_node,
                                                      hb, lb),
                                     gnu_result,
                                     convert (comp_type, integer_zero_node));
@@ -2259,7 +2259,7 @@ Loop_Statement_to_gnu (Node_Id gnat_node)
          test_code = NE_EXPR;
          gnu_cond_expr
            = build3 (COND_EXPR, void_type_node,
-                     build_binary_op (LE_EXPR, integer_type_node,
+                     build_binary_op (LE_EXPR, boolean_type_node,
                                       gnu_low, gnu_high),
                      NULL_TREE, alloc_stmt_list ());
          set_expr_location_from_node (gnu_cond_expr, gnat_loop_spec);
@@ -2280,7 +2280,7 @@ Loop_Statement_to_gnu (Node_Id gnat_node)
 
       /* 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
@@ -2359,7 +2359,7 @@ establish_gnat_vms_condition_handler (void)
       gnat_vms_condition_handler_decl
        = create_subprog_decl (get_identifier ("__gnat_handle_vms_condition"),
                               NULL_TREE,
-                              build_function_type_list (integer_type_node,
+                              build_function_type_list (boolean_type_node,
                                                         ptr_void_type_node,
                                                         ptr_void_type_node,
                                                         NULL_TREE),
@@ -3386,7 +3386,7 @@ Exception_Handler_to_gnu_sjlj (Node_Id gnat_node)
          else
            this_choice
              = build_binary_op
-               (EQ_EXPR, integer_type_node,
+               (EQ_EXPR, boolean_type_node,
                 convert
                 (integer_type_node,
                  build_component_ref
@@ -3413,7 +3413,7 @@ Exception_Handler_to_gnu_sjlj (Node_Id gnat_node)
 
          this_choice
            = build_binary_op
-             (EQ_EXPR, integer_type_node, TREE_VALUE (gnu_except_ptr_stack),
+             (EQ_EXPR, boolean_type_node, TREE_VALUE (gnu_except_ptr_stack),
               convert (TREE_TYPE (TREE_VALUE (gnu_except_ptr_stack)),
                        build_unary_op (ADDR_EXPR, NULL_TREE, gnu_expr)));
 
@@ -3430,8 +3430,8 @@ Exception_Handler_to_gnu_sjlj (Node_Id gnat_node)
 
              this_choice
                = build_binary_op
-                 (TRUTH_ORIF_EXPR, integer_type_node,
-                  build_binary_op (EQ_EXPR, integer_type_node, gnu_comp,
+                 (TRUTH_ORIF_EXPR, boolean_type_node,
+                  build_binary_op (EQ_EXPR, boolean_type_node, gnu_comp,
                                    build_int_cst (TREE_TYPE (gnu_comp), 'V')),
                   this_choice);
            }
@@ -3439,7 +3439,7 @@ Exception_Handler_to_gnu_sjlj (Node_Id gnat_node)
       else
        gcc_unreachable ();
 
-      gnu_choice = build_binary_op (TRUTH_ORIF_EXPR, integer_type_node,
+      gnu_choice = build_binary_op (TRUTH_ORIF_EXPR, boolean_type_node,
                                    gnu_choice, this_choice);
     }
 
@@ -4166,14 +4166,14 @@ gnat_to_gnu (Node_Id gnat_node)
            gnu_expr_type = get_base_type (gnu_index_type);
 
            /* Test whether the minimum slice value is too small.  */
-           gnu_expr_l = build_binary_op (LT_EXPR, integer_type_node,
+           gnu_expr_l = build_binary_op (LT_EXPR, boolean_type_node,
                                          convert (gnu_expr_type,
                                                   gnu_min_expr),
                                          convert (gnu_expr_type,
                                                   gnu_base_min_expr));
 
            /* Test whether the maximum slice value is too large.  */
-           gnu_expr_h = build_binary_op (GT_EXPR, integer_type_node,
+           gnu_expr_h = build_binary_op (GT_EXPR, boolean_type_node,
                                          convert (gnu_expr_type,
                                                   gnu_max_expr),
                                          convert (gnu_expr_type,
@@ -4182,7 +4182,7 @@ gnat_to_gnu (Node_Id gnat_node)
            /* Build a slice index check that returns the low bound,
               assuming the slice is not empty.  */
            gnu_expr = emit_check
-             (build_binary_op (TRUTH_ORIF_EXPR, integer_type_node,
+             (build_binary_op (TRUTH_ORIF_EXPR, boolean_type_node,
                                gnu_expr_l, gnu_expr_h),
               gnu_min_expr, CE_Index_Check_Failed, gnat_node);
 
@@ -4621,7 +4621,7 @@ gnat_to_gnu (Node_Id gnat_node)
          gnu_result
            = build_cond_expr
              (gnu_type,
-              build_binary_op (GE_EXPR, integer_type_node,
+              build_binary_op (GE_EXPR, boolean_type_node,
                                gnu_rhs,
                                convert (TREE_TYPE (gnu_rhs),
                                         TYPE_SIZE (gnu_type))),
@@ -6523,7 +6523,7 @@ build_unary_op_trapv (enum tree_code code, tree gnu_type, tree operand,
 
   operand = gnat_protect_expr (operand);
 
-  return emit_check (build_binary_op (EQ_EXPR, integer_type_node,
+  return emit_check (build_binary_op (EQ_EXPR, boolean_type_node,
                                      operand, TYPE_MIN_VALUE (gnu_type)),
                     build_unary_op (code, gnu_type, operand),
                     CE_Overflow_Check_Failed, gnat_node);
@@ -6567,8 +6567,8 @@ build_binary_op_trapv (enum tree_code code, tree gnu_type, tree left,
     }
 
   rhs_lt_zero = tree_expr_nonnegative_p (rhs)
-               ? integer_zero_node
-               : build_binary_op (LT_EXPR, integer_type_node, rhs, zero);
+               ? boolean_false_node
+               : build_binary_op (LT_EXPR, boolean_type_node, rhs, zero);
 
   /* ??? Should use more efficient check for operand_equal_p (lhs, rhs, 0) */
 
@@ -6604,10 +6604,10 @@ build_binary_op_trapv (enum tree_code code, tree gnu_type, tree left,
                                              convert (wide_type, rhs));
 
          tree check = build_binary_op
-           (TRUTH_ORIF_EXPR, integer_type_node,
-            build_binary_op (LT_EXPR, integer_type_node, wide_result,
+           (TRUTH_ORIF_EXPR, boolean_type_node,
+            build_binary_op (LT_EXPR, boolean_type_node, wide_result,
                              convert (wide_type, type_min)),
-            build_binary_op (GT_EXPR, integer_type_node, wide_result,
+            build_binary_op (GT_EXPR, boolean_type_node, wide_result,
                              convert (wide_type, type_max)));
 
          tree result = convert (gnu_type, wide_result);
@@ -6630,9 +6630,9 @@ build_binary_op_trapv (enum tree_code code, tree gnu_type, tree left,
          /* Overflow when (rhs < 0) ^ (wrapped_expr < lhs)), for addition
             or when (rhs < 0) ^ (wrapped_expr > lhs) for subtraction.  */
          tree check = build_binary_op
-           (TRUTH_XOR_EXPR, integer_type_node, rhs_lt_zero,
+           (TRUTH_XOR_EXPR, boolean_type_node, rhs_lt_zero,
             build_binary_op (code == PLUS_EXPR ? LT_EXPR : GT_EXPR,
-                             integer_type_node, wrapped_expr, lhs));
+                             boolean_type_node, wrapped_expr, lhs));
 
          return
            emit_check (check, result, CE_Overflow_Check_Failed, gnat_node);
@@ -6643,24 +6643,24 @@ build_binary_op_trapv (enum tree_code code, tree gnu_type, tree left,
     {
     case PLUS_EXPR:
       /* When rhs >= 0, overflow when lhs > type_max - rhs.  */
-      check_pos = build_binary_op (GT_EXPR, integer_type_node, lhs,
+      check_pos = build_binary_op (GT_EXPR, boolean_type_node, lhs,
                                   build_binary_op (MINUS_EXPR, gnu_type,
                                                    type_max, rhs)),
 
       /* When rhs < 0, overflow when lhs < type_min - rhs.  */
-      check_neg = build_binary_op (LT_EXPR, integer_type_node, lhs,
+      check_neg = build_binary_op (LT_EXPR, boolean_type_node, lhs,
                                   build_binary_op (MINUS_EXPR, gnu_type,
                                                    type_min, rhs));
       break;
 
     case MINUS_EXPR:
       /* When rhs >= 0, overflow when lhs < type_min + rhs.  */
-      check_pos = build_binary_op (LT_EXPR, integer_type_node, lhs,
+      check_pos = build_binary_op (LT_EXPR, boolean_type_node, lhs,
                                   build_binary_op (PLUS_EXPR, gnu_type,
                                                    type_min, rhs)),
 
       /* When rhs < 0, overflow when lhs > type_max + rhs.  */
-      check_neg = build_binary_op (GT_EXPR, integer_type_node, lhs,
+      check_neg = build_binary_op (GT_EXPR, boolean_type_node, lhs,
                                   build_binary_op (PLUS_EXPR, gnu_type,
                                                    type_max, rhs));
       break;
@@ -6678,19 +6678,31 @@ build_binary_op_trapv (enum tree_code code, tree gnu_type, tree left,
       tmp1 = build_binary_op (TRUNC_DIV_EXPR, gnu_type, type_max, rhs);
       tmp2 = build_binary_op (TRUNC_DIV_EXPR, gnu_type, type_min, rhs);
 
-      check_pos = build_binary_op (TRUTH_ANDIF_EXPR, integer_type_node,
-                   build_binary_op (NE_EXPR, integer_type_node, zero, rhs),
-                   build_binary_op (TRUTH_ORIF_EXPR, integer_type_node,
-                     build_binary_op (GT_EXPR, integer_type_node, lhs, tmp1),
-                     build_binary_op (LT_EXPR, integer_type_node, lhs, tmp2)));
-
-      check_neg = fold_build3 (COND_EXPR, integer_type_node,
-                   build_binary_op (EQ_EXPR, integer_type_node, rhs,
-                                    build_int_cst (gnu_type, -1)),
-                   build_binary_op (EQ_EXPR, integer_type_node, lhs, type_min),
-                   build_binary_op (TRUTH_ORIF_EXPR, integer_type_node,
-                     build_binary_op (GT_EXPR, integer_type_node, lhs, tmp2),
-                     build_binary_op (LT_EXPR, integer_type_node, lhs, tmp1)));
+      check_pos
+       = build_binary_op (TRUTH_ANDIF_EXPR, boolean_type_node,
+                          build_binary_op (NE_EXPR, boolean_type_node, zero,
+                                           rhs),
+                          build_binary_op (TRUTH_ORIF_EXPR, boolean_type_node,
+                                           build_binary_op (GT_EXPR,
+                                                            boolean_type_node,
+                                                            lhs, tmp1),
+                                           build_binary_op (LT_EXPR,
+                                                            boolean_type_node,
+                                                            lhs, tmp2)));
+
+      check_neg
+       = fold_build3 (COND_EXPR, boolean_type_node,
+                      build_binary_op (EQ_EXPR, boolean_type_node, rhs,
+                                       build_int_cst (gnu_type, -1)),
+                      build_binary_op (EQ_EXPR, boolean_type_node, lhs,
+                                       type_min),
+                      build_binary_op (TRUTH_ORIF_EXPR, boolean_type_node,
+                                       build_binary_op (GT_EXPR,
+                                                        boolean_type_node,
+                                                        lhs, tmp2),
+                                       build_binary_op (LT_EXPR,
+                                                        boolean_type_node,
+                                                        lhs, tmp1)));
       break;
 
     default:
@@ -6704,8 +6716,8 @@ build_binary_op_trapv (enum tree_code code, tree gnu_type, tree left,
   if (TREE_CONSTANT (gnu_expr))
     return gnu_expr;
 
-  check = fold_build3 (COND_EXPR, integer_type_node,
-                      rhs_lt_zero,  check_neg, check_pos);
+  check = fold_build3 (COND_EXPR, boolean_type_node, rhs_lt_zero, check_neg,
+                      check_pos);
 
   return emit_check (check, gnu_expr, CE_Overflow_Check_Failed, gnat_node);
 }
@@ -6739,19 +6751,18 @@ emit_range_check (tree gnu_expr, Entity_Id gnat_range_type, Node_Id gnat_node)
   /* Checked expressions must be evaluated only once.  */
   gnu_expr = gnat_protect_expr (gnu_expr);
 
-  /* There's no good type to use here, so we might as well use
-     integer_type_node. Note that the form of the check is
+  /* Note that the form of the check is
        (not (expr >= lo)) or (not (expr <= hi))
      the reason for this slightly convoluted form is that NaNs
      are not considered to be in range in the float case.  */
   return emit_check
-    (build_binary_op (TRUTH_ORIF_EXPR, integer_type_node,
+    (build_binary_op (TRUTH_ORIF_EXPR, boolean_type_node,
                      invert_truthvalue
-                     (build_binary_op (GE_EXPR, integer_type_node,
+                     (build_binary_op (GE_EXPR, boolean_type_node,
                                       convert (gnu_compare_type, gnu_expr),
                                       convert (gnu_compare_type, gnu_low))),
                      invert_truthvalue
-                     (build_binary_op (LE_EXPR, integer_type_node,
+                     (build_binary_op (LE_EXPR, boolean_type_node,
                                        convert (gnu_compare_type, gnu_expr),
                                        convert (gnu_compare_type,
                                                 gnu_high)))),
@@ -6788,15 +6799,13 @@ emit_index_check (tree gnu_array_object, tree gnu_expr, tree gnu_low,
   gnu_low = SUBSTITUTE_PLACEHOLDER_IN_EXPR (gnu_low, gnu_array_object);
   gnu_high = SUBSTITUTE_PLACEHOLDER_IN_EXPR (gnu_high, gnu_array_object);
 
-  /* There's no good type to use here, so we might as well use
-     integer_type_node.   */
   return emit_check
-    (build_binary_op (TRUTH_ORIF_EXPR, integer_type_node,
-                     build_binary_op (LT_EXPR, integer_type_node,
+    (build_binary_op (TRUTH_ORIF_EXPR, boolean_type_node,
+                     build_binary_op (LT_EXPR, boolean_type_node,
                                       gnu_expr_check,
                                       convert (TREE_TYPE (gnu_expr_check),
                                                gnu_low)),
-                     build_binary_op (GT_EXPR, integer_type_node,
+                     build_binary_op (GT_EXPR, boolean_type_node,
                                       gnu_expr_check,
                                       convert (TREE_TYPE (gnu_expr_check),
                                                gnu_high))),
@@ -6909,7 +6918,7 @@ convert_with_check (Entity_Id gnat_type, tree gnu_expr, bool overflowp,
             : 1))
        gnu_cond
          = invert_truthvalue
-           (build_binary_op (GE_EXPR, integer_type_node,
+           (build_binary_op (GE_EXPR, boolean_type_node,
                              gnu_input, convert (gnu_in_basetype,
                                                  gnu_out_lb)));
 
@@ -6920,9 +6929,9 @@ convert_with_check (Entity_Id gnat_type, tree gnu_expr, bool overflowp,
                                 TREE_REAL_CST (gnu_in_lb))
             : 1))
        gnu_cond
-         = build_binary_op (TRUTH_ORIF_EXPR, integer_type_node, gnu_cond,
+         = build_binary_op (TRUTH_ORIF_EXPR, boolean_type_node, gnu_cond,
                             invert_truthvalue
-                            (build_binary_op (LE_EXPR, integer_type_node,
+                            (build_binary_op (LE_EXPR, boolean_type_node,
                                               gnu_input,
                                               convert (gnu_in_basetype,
                                                        gnu_out_ub))));
@@ -6980,7 +6989,7 @@ convert_with_check (Entity_Id gnat_type, tree gnu_expr, bool overflowp,
       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
index 68a0d0f..916a432 100644 (file)
@@ -3025,7 +3025,7 @@ convert_vms_descriptor64 (tree gnu_type, tree gnu_expr, Entity_Id gnat_subprog)
          /* Test that we really have a SB descriptor, like DEC Ada.  */
          t = build3 (COMPONENT_REF, TREE_TYPE (klass), desc, klass, NULL);
          u = convert (TREE_TYPE (klass), DECL_INITIAL (klass));
-         u = build_binary_op (EQ_EXPR, integer_type_node, t, u);
+         u = build_binary_op (EQ_EXPR, boolean_type_node, t, u);
          /* If so, there is already a template in the descriptor and
             it is located right after the POINTER field.  The fields are
              64bits so they must be repacked. */
@@ -3063,12 +3063,12 @@ convert_vms_descriptor64 (tree gnu_type, tree gnu_expr, Entity_Id gnat_subprog)
          /* Raise CONSTRAINT_ERROR if either more than 1 dimension
             or FL_COEFF or FL_BOUNDS not set.  */
          u = build_int_cst (TREE_TYPE (aflags), 192);
-         u = build_binary_op (TRUTH_OR_EXPR, integer_type_node,
-                              build_binary_op (NE_EXPR, integer_type_node,
+         u = build_binary_op (TRUTH_OR_EXPR, boolean_type_node,
+                              build_binary_op (NE_EXPR, boolean_type_node,
                                                dimct,
                                                convert (TREE_TYPE (dimct),
                                                         size_one_node)),
-                              build_binary_op (NE_EXPR, integer_type_node,
+                              build_binary_op (NE_EXPR, boolean_type_node,
                                                build2 (BIT_AND_EXPR,
                                                        TREE_TYPE (aflags),
                                                        aflags, u),
@@ -3173,7 +3173,7 @@ convert_vms_descriptor32 (tree gnu_type, tree gnu_expr, Entity_Id gnat_subprog)
          /* Test that we really have a SB descriptor, like DEC Ada.  */
          t = build3 (COMPONENT_REF, TREE_TYPE (klass), desc, klass, NULL);
          u = convert (TREE_TYPE (klass), DECL_INITIAL (klass));
-         u = build_binary_op (EQ_EXPR, integer_type_node, t, u);
+         u = build_binary_op (EQ_EXPR, boolean_type_node, t, u);
          /* If so, there is already a template in the descriptor and
             it is located right after the POINTER field.  */
          t = TREE_CHAIN (pointer);
@@ -3196,12 +3196,12 @@ convert_vms_descriptor32 (tree gnu_type, tree gnu_expr, Entity_Id gnat_subprog)
          /* Raise CONSTRAINT_ERROR if either more than 1 dimension
             or FL_COEFF or FL_BOUNDS not set.  */
          u = build_int_cst (TREE_TYPE (aflags), 192);
-         u = build_binary_op (TRUTH_OR_EXPR, integer_type_node,
-                              build_binary_op (NE_EXPR, integer_type_node,
+         u = build_binary_op (TRUTH_OR_EXPR, boolean_type_node,
+                              build_binary_op (NE_EXPR, boolean_type_node,
                                                dimct,
                                                convert (TREE_TYPE (dimct),
                                                         size_one_node)),
-                              build_binary_op (NE_EXPR, integer_type_node,
+                              build_binary_op (NE_EXPR, boolean_type_node,
                                                build2 (BIT_AND_EXPR,
                                                        TREE_TYPE (aflags),
                                                        aflags, u),
@@ -3263,11 +3263,11 @@ convert_vms_descriptor (tree gnu_type, tree gnu_expr, tree gnu_expr_alt_type,
   mbo = build3 (COMPONENT_REF, TREE_TYPE (mbo), desc, mbo, NULL_TREE);
   mbmo = build3 (COMPONENT_REF, TREE_TYPE (mbmo), desc, mbmo, NULL_TREE);
   is64bit
-    = build_binary_op (TRUTH_ANDIF_EXPR, integer_type_node,
-                      build_binary_op (EQ_EXPR, integer_type_node,
+    = build_binary_op (TRUTH_ANDIF_EXPR, boolean_type_node,
+                      build_binary_op (EQ_EXPR, boolean_type_node,
                                        convert (integer_type_node, mbo),
                                        integer_one_node),
-                      build_binary_op (EQ_EXPR, integer_type_node,
+                      build_binary_op (EQ_EXPR, boolean_type_node,
                                        convert (integer_type_node, mbmo),
                                        integer_minus_one_node));
 
index b6bd268..33f3a61 100644 (file)
@@ -242,11 +242,11 @@ find_common_type (tree t1, tree t2)
 static tree
 compare_arrays (tree result_type, tree a1, tree a2)
 {
+  tree result = convert (result_type, boolean_true_node);
+  tree a1_is_null = convert (result_type, boolean_false_node);
+  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;
@@ -310,7 +310,7 @@ compare_arrays (tree result_type, tree a1, tree a2)
 
          length_zero_p = true;
          this_a1_is_null = comparison;
-         this_a2_is_null = convert (result_type, integer_one_node);
+         this_a2_is_null = convert (result_type, boolean_true_node);
        }
 
       /* If the length is some other constant value, we know that the
@@ -339,7 +339,7 @@ compare_arrays (tree result_type, tree a1, tree a2)
          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.  */
@@ -491,7 +491,7 @@ nonbinary_modular_operation (enum tree_code op_code, tree type, tree lhs,
     {
       result = gnat_protect_expr (result);
       result = fold_build3 (COND_EXPR, op_type,
-                           fold_build2 (LT_EXPR, integer_type_node, result,
+                           fold_build2 (LT_EXPR, boolean_type_node, result,
                                         convert (op_type, integer_zero_node)),
                            fold_build2 (PLUS_EXPR, op_type, result, modulus),
                            result);
@@ -502,7 +502,7 @@ nonbinary_modular_operation (enum tree_code op_code, tree type, tree lhs,
     {
       result = gnat_protect_expr (result);
       result = fold_build3 (COND_EXPR, op_type,
-                           fold_build2 (GE_EXPR, integer_type_node,
+                           fold_build2 (GE_EXPR, boolean_type_node,
                                         result, modulus),
                            fold_build2 (MINUS_EXPR, op_type,
                                         result, modulus),
@@ -716,16 +716,28 @@ build_binary_op (enum tree_code op_code, tree result_type,
       modulus = NULL_TREE;
       break;
 
+    case TRUTH_ANDIF_EXPR:
+    case TRUTH_ORIF_EXPR:
+    case TRUTH_AND_EXPR:
+    case TRUTH_OR_EXPR:
+    case TRUTH_XOR_EXPR:
+#ifdef ENABLE_CHECKING
+      gcc_assert (TREE_CODE (get_base_type (result_type)) == BOOLEAN_TYPE);
+#endif
+      operation_type = left_base_type;
+      left_operand = convert (operation_type, left_operand);
+      right_operand = convert (operation_type, right_operand);
+      break;
+
     case GE_EXPR:
     case LE_EXPR:
     case GT_EXPR:
     case LT_EXPR:
-      gcc_assert (!POINTER_TYPE_P (left_type));
-
-      /* ... fall through ... */
-
     case EQ_EXPR:
     case NE_EXPR:
+#ifdef ENABLE_CHECKING
+      gcc_assert (TREE_CODE (get_base_type (result_type)) == BOOLEAN_TYPE);
+#endif
       /* If either operand is a NULL_EXPR, just return a new one.  */
       if (TREE_CODE (left_operand) == NULL_EXPR)
        return build2 (op_code, result_type,
@@ -842,13 +854,6 @@ build_binary_op (enum tree_code op_code, tree result_type,
       modulus = NULL_TREE;
       break;
 
-    case PREINCREMENT_EXPR:
-    case PREDECREMENT_EXPR:
-    case POSTINCREMENT_EXPR:
-    case POSTDECREMENT_EXPR:
-      /* These operations are not used anymore.  */
-      gcc_unreachable ();
-
     case LSHIFT_EXPR:
     case RSHIFT_EXPR:
     case LROTATE_EXPR:
@@ -1001,7 +1006,9 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand)
       break;
 
     case TRUTH_NOT_EXPR:
-      gcc_assert (result_type == base_type);
+#ifdef ENABLE_CHECKING
+      gcc_assert (TREE_CODE (get_base_type (result_type)) == BOOLEAN_TYPE);
+#endif
       result = invert_truthvalue (operand);
       break;
 
@@ -1259,7 +1266,7 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand)
 
                result = fold_build3 (COND_EXPR, operation_type,
                                      fold_build2 (NE_EXPR,
-                                                  integer_type_node,
+                                                  boolean_type_node,
                                                   operand,
                                                   convert
                                                     (operation_type,
@@ -2088,12 +2095,11 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc,
 tree
 fill_vms_descriptor (tree expr, Entity_Id gnat_formal, Node_Id gnat_actual)
 {
-  tree field;
   tree parm_decl = get_gnu_tree (gnat_formal);
-  tree const_list = NULL_TREE;
   tree record_type = TREE_TYPE (TREE_TYPE (parm_decl));
-  int do_range_check =
-      strcmp ("MBO",
+  tree const_list = NULL_TREE, field;
+  const bool do_range_check
+    = strcmp ("MBO",
              IDENTIFIER_POINTER (DECL_NAME (TYPE_FIELDS (record_type))));
 
   expr = maybe_unconstrained_array (expr);
@@ -2105,19 +2111,19 @@ fill_vms_descriptor (tree expr, Entity_Id gnat_formal, Node_Id gnat_actual)
                              SUBSTITUTE_PLACEHOLDER_IN_EXPR
                              (DECL_INITIAL (field), expr));
 
-      /* Check to ensure that only 32bit pointers are passed in
-        32bit descriptors */
-      if (do_range_check &&
-          strcmp (IDENTIFIER_POINTER (DECL_NAME (field)), "POINTER") == 0)
+      /* Check to ensure that only 32-bit pointers are passed in
+        32-bit descriptors */
+      if (do_range_check
+          && strcmp (IDENTIFIER_POINTER (DECL_NAME (field)), "POINTER") == 0)
         {
-         tree pointer64type =
-            build_pointer_type_for_mode (void_type_node, DImode, false);
+         tree pointer64type
+           = build_pointer_type_for_mode (void_type_node, DImode, false);
          tree addr64expr = build_unary_op (ADDR_EXPR, pointer64type, expr);
-         tree malloc64low =
-            build_int_cstu (long_integer_type_node, 0x80000000);
+         tree malloc64low
+           = build_int_cstu (long_integer_type_node, 0x80000000);
 
          add_stmt (build3 (COND_EXPR, void_type_node,
-                           build_binary_op (GE_EXPR, long_integer_type_node,
+                           build_binary_op (GE_EXPR, boolean_type_node,
                                             convert (long_integer_type_node,
                                                      addr64expr),
                                             malloc64low),