c-common.c (truthvalue_conversion): Rename, update.
authorNeil Booth <neil@daikokuya.demon.co.uk>
Thu, 4 Apr 2002 22:19:58 +0000 (22:19 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Thu, 4 Apr 2002 22:19:58 +0000 (22:19 +0000)
* c-common.c (truthvalue_conversion): Rename, update.
* c-common.h (c_common_truthvalue_conversion): New.
* c-convert.c (convert): Update.
* c-lang.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Redefine.
* c-parse.in (expr_no_commas, if_prefix, select_or_iter_stmt): Update.
* c-typeck.c (build_binary_op, build_unary_op,
build_conditional_expr): Update.
* fold-const.c (constant_boolean_node, fold): Use langhook.
* langhooks-def.h (LANGHOOK_INITIALIZER): Update.
* langhooks.h (struct lang_hooks): New hook.
* stmt.c (expand_decl_cleanup): Use langhook.
* tree.h (truthvalue_conversion): Remove.
ada:
* gigi.h (truthvalue_conversion): Rename.
* misc.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Redefine.
* trans.c (tree_transform): Update.
* utils2.c (truthvalue_conversion): Rename, update.
(build_binary_op, build_unary_op): Update.
cp:
* cp-lang.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Redefine.
* cvt.c: Update comment.
* init.c (expand_cleanup_for_base): Update.
* semantics.c (finish_parenthesized_expr): Update.
* typeck.c (cp_truthvalue_conversion): Update.
f:
* com.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Redefine.
(truthvalue_conversion): Rename.  Update.  Make static.
(ffecom_truth_value): Update.
java:
* expr.c (truthvalue_conversion): Rename.  Update.
(expand_compare): Update.
* java-tree.h (java_truthvalue_conversion): New.
* lang.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Redefine.
objc:
* objc-lang.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Redefine.

From-SVN: r51880

29 files changed:
gcc/ada/ChangeLog
gcc/ada/gigi.h
gcc/ada/misc.c
gcc/ada/trans.c
gcc/ada/utils2.c
gcc/c-common.c
gcc/c-common.h
gcc/c-convert.c
gcc/c-lang.c
gcc/c-parse.in
gcc/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/cp-lang.c
gcc/cp/cvt.c
gcc/cp/init.c
gcc/cp/semantics.c
gcc/cp/typeck.c
gcc/f/ChangeLog
gcc/f/com.c
gcc/fold-const.c
gcc/java/ChangeLog
gcc/java/expr.c
gcc/java/java-tree.h
gcc/java/lang.c
gcc/langhooks-def.h
gcc/langhooks.h
gcc/objc/objc-lang.c
gcc/stmt.c
gcc/tree.h

index 1e89ad8..23ad1a9 100644 (file)
@@ -1,3 +1,11 @@
+2002-04-04  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+       * gigi.h (truthvalue_conversion): Rename.
+       * misc.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Redefine.
+       * trans.c (tree_transform): Update.
+       * utils2.c (truthvalue_conversion): Rename, update.
+       (build_binary_op, build_unary_op): Update.
+
 2002-04-04  Laurent Guerby  <guerby@acm.org>
 
        * make.adb: Implement -margs, remove restriction about file name placement.
index 7342117..4819ac9 100644 (file)
@@ -654,7 +654,7 @@ extern tree unchecked_convert               PARAMS ((tree, tree));
    The resulting type should always be the same as the input type.
    This function is simpler than the corresponding C version since
    the only possible operands will be things of Boolean type.  */
-extern tree truthvalue_conversion      PARAMS((tree));
+extern tree gnat_truthvalue_conversion      PARAMS((tree));
 
 /* Return the base type of TYPE.  */
 extern tree get_base_type      PARAMS((tree));
index 520b029..1246d4b 100644 (file)
@@ -116,6 +116,8 @@ static rtx gnat_expand_expr         PARAMS ((tree, rtx, enum machine_mode,
 #define LANG_HOOKS_EXPAND_EXPR         gnat_expand_expr
 #undef LANG_HOOKS_MARK_ADDRESSABLE
 #define LANG_HOOKS_MARK_ADDRESSABLE    gnat_mark_addressable
+#undef LANG_HOOKS_TRUTHVALUE_CONVERSION
+#define LANG_HOOKS_TRUTHVALUE_CONVERSION gnat_truthvalue_conversion
 #undef LANG_HOOKS_PRINT_DECL
 #define LANG_HOOKS_PRINT_DECL          gnat_print_decl
 #undef LANG_HOOKS_PRINT_TYPE
index 371f7f2..38ae69c 100644 (file)
@@ -1907,7 +1907,7 @@ tree_transform (gnat_node)
 
        gnu_result_type = get_unpadded_type (Etype (gnat_node));
        gnu_result = build_cond_expr (gnu_result_type,
-                                     truthvalue_conversion (gnu_cond),
+                                     gnat_truthvalue_conversion (gnu_cond),
                                      gnu_true, gnu_false);
       }
       break;
@@ -2411,9 +2411,8 @@ tree_transform (gnat_node)
              TREE_LOOP_ID (get_gnu_tree (Entity (Name (gnat_node))));
 
        if (Present (Condition (gnat_node)))
-         gnu_cond
-           = invert_truthvalue
-             (truthvalue_conversion (gnat_to_gnu (Condition (gnat_node))));
+         gnu_cond = invert_truthvalue (gnat_truthvalue_conversion
+                                       (gnat_to_gnu (Condition (gnat_node))));
 
        set_lineno (gnat_node, 1);
        expand_exit_loop_if_false (loop_id, gnu_cond);
index 0e8ada4..6d76a41 100644 (file)
@@ -66,7 +66,7 @@ static tree build_simple_component_ref        PARAMS ((tree, tree, tree));
    the only possible operands will be things of Boolean type.  */
 
 tree
-truthvalue_conversion (expr)
+gnat_truthvalue_conversion (expr)
      tree expr;
 {
   tree type = TREE_TYPE (expr);
@@ -85,13 +85,14 @@ truthvalue_conversion (expr)
 
     case COND_EXPR:
       /* Distribute the conversion into the arms of a COND_EXPR.  */
-      return fold (build (COND_EXPR, type, TREE_OPERAND (expr, 0),
-                         truthvalue_conversion (TREE_OPERAND (expr, 1)),
-                         truthvalue_conversion (TREE_OPERAND (expr, 2))));
+      return fold
+       (build (COND_EXPR, type, TREE_OPERAND (expr, 0),
+               gnat_truthvalue_conversion (TREE_OPERAND (expr, 1)),
+               gnat_truthvalue_conversion (TREE_OPERAND (expr, 2))));
 
     case WITH_RECORD_EXPR:
       return build (WITH_RECORD_EXPR, type,
-                   truthvalue_conversion (TREE_OPERAND (expr, 0)),
+                   gnat_truthvalue_conversion (TREE_OPERAND (expr, 0)),
                    TREE_OPERAND (expr, 1));
 
     default:
@@ -983,8 +984,8 @@ build_binary_op (op_code, result_type, left_operand, right_operand)
     case TRUTH_AND_EXPR:
     case TRUTH_OR_EXPR:
     case TRUTH_XOR_EXPR:
-      left_operand = truthvalue_conversion (left_operand);
-      right_operand = truthvalue_conversion (right_operand);
+      left_operand = gnat_truthvalue_conversion (left_operand);
+      right_operand = gnat_truthvalue_conversion (right_operand);
       goto common;
 
     case BIT_AND_EXPR:
@@ -1115,7 +1116,7 @@ build_unary_op (op_code, result_type, operand)
       if (result_type != base_type)
        gigi_abort (508);
 
-      result = invert_truthvalue (truthvalue_conversion (operand));
+      result = invert_truthvalue (gnat_truthvalue_conversion (operand));
       break;
 
     case ATTR_ADDR_EXPR:
index 04cd3c4..1c9f4a0 100644 (file)
@@ -1577,8 +1577,9 @@ min_precision (value, unsignedp)
   return log + 1 + ! unsignedp;
 }
 \f
-/* Print an error message for invalid operands to arith operation CODE.
-   NOP_EXPR is used as a special case (see truthvalue_conversion).  */
+/* Print an error message for invalid operands to arith operation
+   CODE.  NOP_EXPR is used as a special case (see
+   c_common_truthvalue_conversion).  */
 
 void
 binary_op_error (code)
@@ -2106,7 +2107,7 @@ pointer_int_sum (resultcode, ptrop, intop)
    The resulting type should always be `boolean_type_node'.  */
 
 tree
-truthvalue_conversion (expr)
+c_common_truthvalue_conversion (expr)
      tree expr;
 {
   if (TREE_CODE (expr) == ERROR_MARK)
@@ -2172,8 +2173,8 @@ truthvalue_conversion (expr)
     case COMPLEX_EXPR:
       return build_binary_op ((TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1))
                               ? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
-                             truthvalue_conversion (TREE_OPERAND (expr, 0)),
-                             truthvalue_conversion (TREE_OPERAND (expr, 1)),
+               c_common_truthvalue_conversion (TREE_OPERAND (expr, 0)),
+               c_common_truthvalue_conversion (TREE_OPERAND (expr, 1)),
                              0);
 
     case NEGATE_EXPR:
@@ -2181,7 +2182,7 @@ truthvalue_conversion (expr)
     case FLOAT_EXPR:
     case FFS_EXPR:
       /* These don't change whether an object is non-zero or zero.  */
-      return truthvalue_conversion (TREE_OPERAND (expr, 0));
+      return c_common_truthvalue_conversion (TREE_OPERAND (expr, 0));
 
     case LROTATE_EXPR:
     case RROTATE_EXPR:
@@ -2189,15 +2190,15 @@ truthvalue_conversion (expr)
         we can't ignore them if their second arg has side-effects.  */
       if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1)))
        return build (COMPOUND_EXPR, boolean_type_node, TREE_OPERAND (expr, 1),
-                     truthvalue_conversion (TREE_OPERAND (expr, 0)));
+                     c_common_truthvalue_conversion (TREE_OPERAND (expr, 0)));
       else
-       return truthvalue_conversion (TREE_OPERAND (expr, 0));
+       return c_common_truthvalue_conversion (TREE_OPERAND (expr, 0));
 
     case COND_EXPR:
       /* Distribute the conversion into the arms of a COND_EXPR.  */
       return fold (build (COND_EXPR, boolean_type_node, TREE_OPERAND (expr, 0),
-                         truthvalue_conversion (TREE_OPERAND (expr, 1)),
-                         truthvalue_conversion (TREE_OPERAND (expr, 2))));
+               c_common_truthvalue_conversion (TREE_OPERAND (expr, 1)),
+               c_common_truthvalue_conversion (TREE_OPERAND (expr, 2))));
 
     case CONVERT_EXPR:
       /* Don't cancel the effect of a CONVERT_EXPR from a REFERENCE_TYPE,
@@ -2210,7 +2211,7 @@ truthvalue_conversion (expr)
       /* If this is widening the argument, we can ignore it.  */
       if (TYPE_PRECISION (TREE_TYPE (expr))
          >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (expr, 0))))
-       return truthvalue_conversion (TREE_OPERAND (expr, 0));
+       return c_common_truthvalue_conversion (TREE_OPERAND (expr, 0));
       break;
 
     case MINUS_EXPR:
@@ -2255,12 +2256,12 @@ truthvalue_conversion (expr)
 
   if (TREE_CODE (TREE_TYPE (expr)) == COMPLEX_TYPE)
     {
-      tree tem = save_expr (expr);
+      tree t = save_expr (expr);
       return (build_binary_op
              ((TREE_SIDE_EFFECTS (expr)
                ? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
-              truthvalue_conversion (build_unary_op (REALPART_EXPR, tem, 0)),
-              truthvalue_conversion (build_unary_op (IMAGPART_EXPR, tem, 0)),
+       c_common_truthvalue_conversion (build_unary_op (REALPART_EXPR, t, 0)),
+       c_common_truthvalue_conversion (build_unary_op (IMAGPART_EXPR, t, 0)),
               0));
     }
 
index cb49b52..462e5bd 100644 (file)
@@ -513,6 +513,7 @@ extern tree c_common_type_for_size          PARAMS ((unsigned int, int));
 extern tree c_common_unsigned_type             PARAMS ((tree));
 extern tree c_common_signed_type               PARAMS ((tree));
 extern tree c_common_signed_or_unsigned_type   PARAMS ((int, tree));
+extern tree c_common_truthvalue_conversion     PARAMS ((tree));
 extern void c_apply_type_quals_to_decl         PARAMS ((int, tree));
 extern tree c_sizeof                           PARAMS ((tree));
 extern tree c_alignof                          PARAMS ((tree));
index 947c79b..b38eab2 100644 (file)
@@ -42,7 +42,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
    Here is a list of all the functions that assume that widening and
    narrowing is always done with a NOP_EXPR:
      In convert.c, convert_to_integer.
-     In c-typeck.c, build_binary_op (boolean ops), and truthvalue_conversion.
+     In c-typeck.c, build_binary_op (boolean ops), and
+       c_common_truthvalue_conversion.
      In expr.c: expand_expr, for operands of a MULT_EXPR.
      In fold-const.c: fold.
      In tree.c: get_narrower and get_unwidened.  */
@@ -90,9 +91,9 @@ convert (type, expr)
     return fold (convert_to_integer (type, e));
   if (code == BOOLEAN_TYPE)
     {
-      tree t = truthvalue_conversion (expr);
-      /* If truthvalue_conversion returns a NOP_EXPR, we must fold it here
-        to avoid infinite recursion between fold () and convert ().  */
+      tree t = c_common_truthvalue_conversion (expr);
+      /* If it returns a NOP_EXPR, we must fold it here to avoid
+        infinite recursion between fold () and convert ().  */
       if (TREE_CODE (t) == NOP_EXPR)
        return fold (build1 (NOP_EXPR, type, TREE_OPERAND (t, 0)));
       else
index f11dce4..57d8196 100644 (file)
@@ -58,6 +58,8 @@ static void c_post_options PARAMS ((void));
 #define LANG_HOOKS_MARK_ADDRESSABLE c_mark_addressable
 #undef LANG_HOOKS_PARSE_FILE
 #define LANG_HOOKS_PARSE_FILE c_common_parse_file
+#undef LANG_HOOKS_TRUTHVALUE_CONVERSION
+#define LANG_HOOKS_TRUTHVALUE_CONVERSION c_common_truthvalue_conversion
 #undef LANG_HOOKS_INSERT_DEFAULT_ATTRIBUTES
 #define LANG_HOOKS_INSERT_DEFAULT_ATTRIBUTES c_insert_default_attributes
 #undef LANG_HOOKS_FINISH_INCOMPLETE_DECL
index fa56bfc..e6d6137 100644 (file)
@@ -566,19 +566,22 @@ expr_no_commas:
        | expr_no_commas '^' expr_no_commas
                { $$ = parser_build_binary_op ($2, $1, $3); }
        | expr_no_commas ANDAND
-               { $1 = truthvalue_conversion (default_conversion ($1));
+               { $1 = c_common_truthvalue_conversion
+                   (default_conversion ($1));
                  skip_evaluation += $1 == boolean_false_node; }
          expr_no_commas
                { skip_evaluation -= $1 == boolean_false_node;
                  $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
        | expr_no_commas OROR
-               { $1 = truthvalue_conversion (default_conversion ($1));
+               { $1 = c_common_truthvalue_conversion
+                   (default_conversion ($1));
                  skip_evaluation += $1 == boolean_true_node; }
          expr_no_commas
                { skip_evaluation -= $1 == boolean_true_node;
                  $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
        | expr_no_commas '?'
-               { $1 = truthvalue_conversion (default_conversion ($1));
+               { $1 = c_common_truthvalue_conversion
+                   (default_conversion ($1));
                  skip_evaluation += $1 == boolean_false_node; }
           expr ':'
                { skip_evaluation += (($1 == boolean_true_node)
@@ -591,7 +594,8 @@ expr_no_commas:
                    pedwarn ("ISO C forbids omitting the middle term of a ?: expression");
                  /* Make sure first operand is calculated only once.  */
                  $<ttype>2 = save_expr ($1);
-                 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
+                 $1 = c_common_truthvalue_conversion
+                   (default_conversion ($<ttype>2));
                  skip_evaluation += $1 == boolean_true_node; }
          ':' expr_no_commas
                { skip_evaluation -= $1 == boolean_true_node;
@@ -606,7 +610,8 @@ expr_no_commas:
        | expr_no_commas ASSIGN expr_no_commas
                { char class;
                  $$ = build_modify_expr ($1, $2, $3);
-                 /* This inhibits warnings in truthvalue_conversion.  */
+                 /* This inhibits warnings in
+                    c_common_truthvalue_conversion.  */
                  class = TREE_CODE_CLASS (TREE_CODE ($$));
                  if (IS_EXPR_CODE_CLASS (class))
                    C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK);
@@ -2189,7 +2194,7 @@ if_prefix:
           IF
                 { $<ttype>$ = c_begin_if_stmt (); }
             '(' expr ')'
-               { c_expand_start_cond (truthvalue_conversion ($4), 
+               { c_expand_start_cond (c_common_truthvalue_conversion ($4), 
                                       compstmt_count,$<ttype>2);
                  $<itype>$ = stmt_count;
                  if_stmt_file = $<filename>-2;
@@ -2301,15 +2306,15 @@ select_or_iter_stmt:
                 { stmt_count++; 
                  $<ttype>$ = c_begin_while_stmt (); }
          '(' expr ')'
-                { $4 = truthvalue_conversion ($4);
-                 c_finish_while_stmt_cond (truthvalue_conversion ($4),
-                                           $<ttype>2);
+                { $4 = c_common_truthvalue_conversion ($4);
+                 c_finish_while_stmt_cond
+                   (c_common_truthvalue_conversion ($4), $<ttype>2);
                  $<ttype>$ = add_stmt ($<ttype>2); }
          c99_block_lineno_labeled_stmt
                { RECHAIN_STMTS ($<ttype>6, WHILE_BODY ($<ttype>6)); }
        | do_stmt_start
          '(' expr ')' ';'
-                { DO_COND ($1) = truthvalue_conversion ($3); }
+                { DO_COND ($1) = c_common_truthvalue_conversion ($3); }
        | do_stmt_start error
                { }
        | FOR
@@ -2321,7 +2326,8 @@ select_or_iter_stmt:
                  RECHAIN_STMTS ($<ttype>2, FOR_INIT_STMT ($<ttype>2)); }
          xexpr ';'
                 { if ($6) 
-                   FOR_COND ($<ttype>2) = truthvalue_conversion ($6); }
+                   FOR_COND ($<ttype>2)
+                     = c_common_truthvalue_conversion ($6); }
          xexpr ')'
                { FOR_EXPR ($<ttype>2) = $9; }
          c99_block_lineno_labeled_stmt
index 7bca9aa..91abd80 100644 (file)
@@ -2084,8 +2084,8 @@ build_binary_op (code, orig_op0, orig_op1, convert_p)
             but that does not mean the operands should be
             converted to ints!  */
          result_type = integer_type_node;
-         op0 = truthvalue_conversion (op0);
-         op1 = truthvalue_conversion (op1);
+         op0 = c_common_truthvalue_conversion (op0);
+         op1 = c_common_truthvalue_conversion (op1);
          converted = 1;
        }
       break;
@@ -2801,7 +2801,7 @@ build_unary_op (code, xarg, flag)
          error ("wrong type argument to unary exclamation mark");
          return error_mark_node;
        }
-      arg = truthvalue_conversion (arg);
+      arg = c_common_truthvalue_conversion (arg);
       return invert_truthvalue (arg);
 
     case NOP_EXPR:
@@ -3365,7 +3365,7 @@ build_conditional_expr (ifexp, op1, op2)
   tree result_type = NULL;
   tree orig_op1 = op1, orig_op2 = op2;
 
-  ifexp = truthvalue_conversion (default_conversion (ifexp));
+  ifexp = c_common_truthvalue_conversion (default_conversion (ifexp));
 
 #if 0 /* Produces wrong result if within sizeof.  */
   /* Don't promote the operands separately if they promote
index 756d2b3..cd2e919 100644 (file)
@@ -1,3 +1,11 @@
+2002-04-04  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+       * cp-lang.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Redefine.
+       * cvt.c: Update comment.
+       * init.c (expand_cleanup_for_base): Update.
+       * semantics.c (finish_parenthesized_expr): Update.
+       * typeck.c (cp_truthvalue_conversion): Update.
+
 2002-04-04  Jason Merrill  <jason@redhat.com>
 
        * semantics.c (finish_eh_cleanup): New fn.
index 3c086ca..0292719 100644 (file)
@@ -62,6 +62,8 @@ static bool cxx_warn_unused_global_decl PARAMS ((tree));
 #define LANG_HOOKS_UNSAVE_EXPR_NOW cxx_unsave_expr_now
 #undef LANG_HOOKS_MAYBE_BUILD_CLEANUP
 #define LANG_HOOKS_MAYBE_BUILD_CLEANUP cxx_maybe_build_cleanup
+#undef LANG_HOOKS_TRUTHVALUE_CONVERSION
+#define LANG_HOOKS_TRUTHVALUE_CONVERSION c_common_truthvalue_conversion
 #undef LANG_HOOKS_INSERT_DEFAULT_ATTRIBUTES
 #define LANG_HOOKS_INSERT_DEFAULT_ATTRIBUTES cxx_insert_default_attributes
 #undef LANG_HOOKS_MARK_TREE
index d934df0..d0f9945 100644 (file)
@@ -52,7 +52,7 @@ static void warn_ref_binding PARAMS ((tree, tree, tree));
    narrowing is always done with a NOP_EXPR:
      In convert.c, convert_to_integer.
      In c-typeck.c, build_binary_op_nodefault (boolean ops),
-        and truthvalue_conversion.
+        and c_common_truthvalue_conversion.
      In expr.c: expand_expr, for operands of a MULT_EXPR.
      In fold-const.c: fold.
      In tree.c: get_narrower and get_unwidened.
index 8b7e1f2..57b3dba 100644 (file)
@@ -841,7 +841,7 @@ expand_cleanup_for_base (binfo, flag)
          (current_class_ref, binfo, base_dtor_identifier, NULL_TREE));
   if (flag)
     expr = fold (build (COND_EXPR, void_type_node,
-                       truthvalue_conversion (flag),
+                       c_common_truthvalue_conversion (flag),
                        expr, integer_zero_node));
 
   finish_eh_cleanup (expr);
index ee609f4..39f9567 100644 (file)
@@ -1140,7 +1140,7 @@ finish_parenthesized_expr (expr)
      tree expr;
 {
   if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (expr))))
-    /* This inhibits warnings in truthvalue_conversion.  */
+    /* This inhibits warnings in c_common_truthvalue_conversion.  */
     C_SET_EXP_ORIGINAL_CODE (expr, ERROR_MARK); 
 
   if (TREE_CODE (expr) == OFFSET_REF)
index 7596d29..593e2bb 100644 (file)
@@ -4191,8 +4191,9 @@ build_x_unary_op (code, xarg)
   return exp;
 }
 
-/* Like truthvalue_conversion, but handle pointer-to-member constants, where
-   a null value is represented by an INTEGER_CST of -1.  */
+/* Like c_common_truthvalue_conversion, but handle pointer-to-member
+   constants, where a null value is represented by an INTEGER_CST of
+   -1.  */
 
 tree
 cp_truthvalue_conversion (expr)
@@ -4202,7 +4203,7 @@ cp_truthvalue_conversion (expr)
   if (TYPE_PTRMEM_P (type))
     return build_binary_op (NE_EXPR, expr, integer_zero_node, 1);
   else
-    return truthvalue_conversion (expr);
+    return c_common_truthvalue_conversion (expr);
 }
 
 /* Just like cp_truthvalue_conversion, but we want a CLEANUP_POINT_EXPR.  */
index e0fbdcd..d522ff8 100644 (file)
@@ -1,3 +1,9 @@
+Thu Apr  4 23:29:48 2002  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+       * com.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Redefine.
+       (truthvalue_conversion): Rename.  Update.  Make static.
+       (ffecom_truth_value): Update.
+
 Mon Apr  1 21:39:36 2002  Neil Booth  <neil@daikokuya.demon.co.uk>
 
        * com.c (LANG_HOOKS_MARK_ADDRESSABLE): Redefine.
index 97d245a..f99c209 100644 (file)
@@ -267,6 +267,7 @@ static tree ffe_unsigned_type PARAMS ((tree));
 static tree ffe_signed_type PARAMS ((tree));
 static tree ffe_signed_or_unsigned_type PARAMS ((int, tree));
 static bool ffe_mark_addressable PARAMS ((tree));
+static tree ffe_truthvalue_conversion PARAMS ((tree));
 static void ffecom_init_decl_processing PARAMS ((void));
 static tree ffecom_arglist_expr_ (const char *argstring, ffebld args);
 static tree ffecom_widest_expr_type_ (ffebld list);
@@ -13012,7 +13013,7 @@ ffecom_temp_label ()
 tree
 ffecom_truth_value (tree expr)
 {
-  return truthvalue_conversion (expr);
+  return ffe_truthvalue_conversion (expr);
 }
 
 /* Return the inversion of a truth value (the inversion of what
@@ -14236,6 +14237,8 @@ static void ffe_mark_tree (tree);
 #define LANG_HOOKS_DECL_PRINTABLE_NAME ffe_printable_name
 #undef  LANG_HOOKS_PRINT_ERROR_FUNCTION
 #define LANG_HOOKS_PRINT_ERROR_FUNCTION ffe_print_error_function
+#undef  LANG_HOOKS_TRUTHVALUE_CONVERSION
+#define LANG_HOOKS_TRUTHVALUE_CONVERSION ffe_truthvalue_conversion
 
 #undef  LANG_HOOKS_TYPE_FOR_MODE
 #define LANG_HOOKS_TYPE_FOR_MODE       ffe_type_for_mode
@@ -14841,8 +14844,8 @@ ffe_signed_type (type)
 
    The resulting type should always be `integer_type_node'.  */
 
-tree
-truthvalue_conversion (expr)
+static tree
+ffe_truthvalue_conversion (expr)
      tree expr;
 {
   if (TREE_CODE (expr) == ERROR_MARK)
@@ -14919,15 +14922,15 @@ truthvalue_conversion (expr)
       return ffecom_2 ((TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1))
                        ? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
                       integer_type_node,
-                      truthvalue_conversion (TREE_OPERAND (expr, 0)),
-                      truthvalue_conversion (TREE_OPERAND (expr, 1)));
+                      ffe_truthvalue_conversion (TREE_OPERAND (expr, 0)),
+                      ffe_truthvalue_conversion (TREE_OPERAND (expr, 1)));
 
     case NEGATE_EXPR:
     case ABS_EXPR:
     case FLOAT_EXPR:
     case FFS_EXPR:
       /* These don't change whether an object is non-zero or zero.  */
-      return truthvalue_conversion (TREE_OPERAND (expr, 0));
+      return ffe_truthvalue_conversion (TREE_OPERAND (expr, 0));
 
     case LROTATE_EXPR:
     case RROTATE_EXPR:
@@ -14935,15 +14938,15 @@ truthvalue_conversion (expr)
         we can't ignore them if their second arg has side-effects.  */
       if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1)))
        return build (COMPOUND_EXPR, integer_type_node, TREE_OPERAND (expr, 1),
-                     truthvalue_conversion (TREE_OPERAND (expr, 0)));
+                     ffe_truthvalue_conversion (TREE_OPERAND (expr, 0)));
       else
-       return truthvalue_conversion (TREE_OPERAND (expr, 0));
+       return ffe_truthvalue_conversion (TREE_OPERAND (expr, 0));
 
     case COND_EXPR:
       /* Distribute the conversion into the arms of a COND_EXPR.  */
       return fold (build (COND_EXPR, integer_type_node, TREE_OPERAND (expr, 0),
-                         truthvalue_conversion (TREE_OPERAND (expr, 1)),
-                         truthvalue_conversion (TREE_OPERAND (expr, 2))));
+                         ffe_truthvalue_conversion (TREE_OPERAND (expr, 1)),
+                         ffe_truthvalue_conversion (TREE_OPERAND (expr, 2))));
 
     case CONVERT_EXPR:
       /* Don't cancel the effect of a CONVERT_EXPR from a REFERENCE_TYPE,
@@ -14956,7 +14959,7 @@ truthvalue_conversion (expr)
       /* If this is widening the argument, we can ignore it.  */
       if (TYPE_PRECISION (TREE_TYPE (expr))
          >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (expr, 0))))
-       return truthvalue_conversion (TREE_OPERAND (expr, 0));
+       return ffe_truthvalue_conversion (TREE_OPERAND (expr, 0));
       break;
 
     case MINUS_EXPR:
@@ -15001,12 +15004,12 @@ truthvalue_conversion (expr)
            ((TREE_SIDE_EFFECTS (expr)
              ? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
             integer_type_node,
-            truthvalue_conversion (ffecom_1 (REALPART_EXPR,
-                                             TREE_TYPE (TREE_TYPE (expr)),
-                                             expr)),
-            truthvalue_conversion (ffecom_1 (IMAGPART_EXPR,
-                                             TREE_TYPE (TREE_TYPE (expr)),
-                                             expr))));
+            ffe_truthvalue_conversion (ffecom_1 (REALPART_EXPR,
+                                                 TREE_TYPE (TREE_TYPE (expr)),
+                                                 expr)),
+            ffe_truthvalue_conversion (ffecom_1 (IMAGPART_EXPR,
+                                                 TREE_TYPE (TREE_TYPE (expr)),
+                                                 expr))));
 
   return ffecom_2 (NE_EXPR, integer_type_node,
                   expr,
index 26bdd66..10a92fe 100644 (file)
@@ -4139,8 +4139,8 @@ constant_boolean_node (value, type)
   if (type == integer_type_node)
     return value ? integer_one_node : integer_zero_node;
   else if (TREE_CODE (type) == BOOLEAN_TYPE)
-    return truthvalue_conversion (value ? integer_one_node :
-                                 integer_zero_node);
+    return (*lang_hooks.truthvalue_conversion) (value ? integer_one_node :
+                                               integer_zero_node);
   else
     {
       tree t = build_int_2 (value, 0);
@@ -6405,7 +6405,7 @@ fold (expr)
 
       TREE_TYPE (t1) = type;
       if (TREE_CODE (type) == BOOLEAN_TYPE)
-       return truthvalue_conversion (t1);
+       return (*lang_hooks.truthvalue_conversion) (t1);
       return t1;
 
     case COND_EXPR:
index 8b5ef4e..ae70901 100644 (file)
@@ -1,3 +1,10 @@
+2002-04-04  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+       * expr.c (truthvalue_conversion): Rename.  Update.
+       (expand_compare): Update.
+       * java-tree.h (java_truthvalue_conversion): New.
+       * lang.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Redefine.
+
 2002-04-01  Neil Booth  <neil@daikokuya.demon.co.uk>
 
        * java-tree.h (java_mark_addressable): New.
index a4ecfb0..bba81d5 100644 (file)
@@ -152,7 +152,7 @@ init_expr_processing()
 }
 
 tree
-truthvalue_conversion (expr)
+java_truthvalue_conversion (expr)
      tree expr;
 {
   /* It is simpler and generates better code to have only TRUTH_*_EXPR
@@ -183,19 +183,19 @@ truthvalue_conversion (expr)
     case FLOAT_EXPR:
     case FFS_EXPR:
       /* These don't change whether an object is non-zero or zero.  */
-      return truthvalue_conversion (TREE_OPERAND (expr, 0));
+      return java_truthvalue_conversion (TREE_OPERAND (expr, 0));
 
     case COND_EXPR:
       /* Distribute the conversion into the arms of a COND_EXPR.  */
       return fold (build (COND_EXPR, boolean_type_node, TREE_OPERAND (expr, 0),
-                          truthvalue_conversion (TREE_OPERAND (expr, 1)),
-                          truthvalue_conversion (TREE_OPERAND (expr, 2))));
+                          java_truthvalue_conversion (TREE_OPERAND (expr, 1)),
+                          java_truthvalue_conversion (TREE_OPERAND (expr, 2))));
 
     case NOP_EXPR:
       /* If this is widening the argument, we can ignore it.  */
       if (TYPE_PRECISION (TREE_TYPE (expr))
           >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (expr, 0))))
-        return truthvalue_conversion (TREE_OPERAND (expr, 0));
+        return java_truthvalue_conversion (TREE_OPERAND (expr, 0));
       /* fall through to default */
 
     default:
@@ -1656,7 +1656,7 @@ expand_compare (condition, value1, value2, target_pc)
 {
   tree target = lookup_label (target_pc);
   tree cond = fold (build (condition, boolean_type_node, value1, value2));
-  expand_start_cond (truthvalue_conversion (cond), 0);
+  expand_start_cond (java_truthvalue_conversion (cond), 0);
   expand_goto (target);
   expand_end_cond ();
 }
index ae26b61..84a2afb 100644 (file)
@@ -1045,6 +1045,7 @@ extern tree java_type_for_size PARAMS ((unsigned int, int));
 extern tree java_unsigned_type PARAMS ((tree));
 extern tree java_signed_type PARAMS ((tree));
 extern tree java_signed_or_unsigned_type PARAMS ((int, tree));
+extern tree java_truthvalue_conversion PARAMS ((tree));
 extern void add_assume_compiled PARAMS ((const char *, int));
 extern tree lookup_class PARAMS ((tree));
 extern tree lookup_java_constructor PARAMS ((tree, tree));
index 53e11be..dbd41ee 100644 (file)
@@ -233,6 +233,8 @@ static int dependency_tracking = 0;
 #define LANG_HOOKS_MARK_ADDRESSABLE java_mark_addressable
 #undef LANG_HOOKS_EXPAND_EXPR
 #define LANG_HOOKS_EXPAND_EXPR java_expand_expr
+#undef LANG_HOOKS_TRUTHVALUE_CONVERSION
+#define LANG_HOOKS_TRUTHVALUE_CONVERSION java_truthvalue_conversion
 #undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
 #define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL java_dup_lang_specific_decl
 #undef LANG_HOOKS_DECL_PRINTABLE_NAME
index d073ddf..3ad37f8 100644 (file)
@@ -204,6 +204,7 @@ int lhd_tree_dump_type_quals                        PARAMS ((tree));
   LANG_HOOKS_GET_ALIAS_SET, \
   LANG_HOOKS_EXPAND_CONSTANT, \
   LANG_HOOKS_EXPAND_EXPR, \
+  LANG_HOOKS_TRUTHVALUE_CONVERSION, \
   LANG_HOOKS_INSERT_DEFAULT_ATTRIBUTES, \
   LANG_HOOKS_SAFE_FROM_P, \
   LANG_HOOKS_FINISH_INCOMPLETE_DECL, \
index 83e2e5a..2a50aa7 100644 (file)
@@ -200,6 +200,19 @@ struct lang_hooks
      Fourth argument is actually an enum expand_modifier.  */
   rtx (*expand_expr) PARAMS ((tree, rtx, enum machine_mode, int));
 
+  /* Prepare expr to be an argument of a TRUTH_NOT_EXPR or other logical
+     operation.
+
+     This preparation consists of taking the ordinary representation
+     of an expression expr and producing a valid tree boolean
+     expression describing whether expr is nonzero.  We could simply
+     always do build_binary_op (NE_EXPR, expr, integer_zero_node, 1),
+     but we optimize comparisons, &&, ||, and !.
+
+     The result should be an expression of boolean type (if not an
+     error_mark_node).  */
+  tree (*truthvalue_conversion) PARAMS ((tree));
+
   /* Possibly apply default attributes to a function (represented by
      a FUNCTION_DECL).  */
   void (*insert_default_attributes) PARAMS ((tree));
index b119432..6649d72 100644 (file)
@@ -52,6 +52,8 @@ static void objc_post_options                   PARAMS ((void));
 #define LANG_HOOKS_EXPAND_EXPR c_expand_expr
 #undef LANG_HOOKS_MARK_ADDRESSABLE
 #define LANG_HOOKS_MARK_ADDRESSABLE c_mark_addressable
+#undef LANG_HOOKS_TRUTHVALUE_CONVERSION
+#define LANG_HOOKS_TRUTHVALUE_CONVERSION c_common_truthvalue_conversion
 #undef LANG_HOOKS_INSERT_DEFAULT_ATTRIBUTES
 #define LANG_HOOKS_INSERT_DEFAULT_ATTRIBUTES c_insert_default_attributes
 #undef LANG_HOOKS_FINISH_INCOMPLETE_DECL
index 2e8aeb6..4f0cb17 100644 (file)
@@ -4119,7 +4119,7 @@ expand_decl_cleanup (decl, cleanup)
 
          /* Conditionalize the cleanup.  */
          cleanup = build (COND_EXPR, void_type_node,
-                          truthvalue_conversion (cond),
+                          (*lang_hooks.truthvalue_conversion) (cond),
                           cleanup, integer_zero_node);
          cleanup = fold (cleanup);
 
index 950463f..d0646b8 100644 (file)
@@ -2946,7 +2946,6 @@ extern int lang_attribute_common;
 /* In front end.  */
 
 extern void incomplete_type_error      PARAMS ((tree, tree));
-extern tree truthvalue_conversion      PARAMS ((tree));
 
 /* In integrate.c */
 extern void save_for_inline            PARAMS ((tree));