c-common.c (truthvalue_conversion): Rename, update.

* 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
This commit is contained in:
Neil Booth 2002-04-04 22:19:58 +00:00 committed by Neil Booth
parent 3900216066
commit 78ef5b895f
29 changed files with 146 additions and 80 deletions

View 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.

View 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));

View 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

View 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);

View 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:

View File

@ -1577,8 +1577,9 @@ min_precision (value, unsignedp)
return log + 1 + ! unsignedp;
}
/* 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));
}

View 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));

View 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

View 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

View 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

View 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

View 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.

View 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

View 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.

View 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);

View 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)

View 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. */

View 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.

View 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,

View 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:

View 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.

View 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 ();
}

View 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));

View 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

View 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, \

View 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));

View 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

View 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);

View 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));