Commit 1f6f3d15 by Ian Lance Taylor Committed by Ian Lance Taylor

convert.c (convert_to_integer): Don't test for ENUMERAL_TYPE in NEGATE_EXPR/BIT_NOT_EXPR case.

	* convert.c (convert_to_integer): Don't test for ENUMERAL_TYPE in
	NEGATE_EXPR/BIT_NOT_EXPR case.

From-SVN: r104615
parent 8028abd7
2005-09-24 Ian Lance Taylor <ian@airs.com>
* convert.c (convert_to_integer): Don't test for ENUMERAL_TYPE in
NEGATE_EXPR/BIT_NOT_EXPR case.
2005-09-24 Richard Henderson <rth@redhat.com> 2005-09-24 Richard Henderson <rth@redhat.com>
* c-common.c (handle_mode_attribute): When not modifying in place, * c-common.c (handle_mode_attribute): When not modifying in place,
......
...@@ -620,30 +620,18 @@ convert_to_integer (tree type, tree expr) ...@@ -620,30 +620,18 @@ convert_to_integer (tree type, tree expr)
/* This is not correct for ABS_EXPR, /* This is not correct for ABS_EXPR,
since we must test the sign before truncation. */ since we must test the sign before truncation. */
{ {
tree typex = type; tree typex;
/* Can't do arithmetic in enumeral types /* Don't do unsigned arithmetic where signed was wanted,
so use an integer type that will hold the values. */ or vice versa. */
if (TREE_CODE (typex) == ENUMERAL_TYPE) if (TYPE_UNSIGNED (TREE_TYPE (expr)))
typex = lang_hooks.types.type_for_size typex = lang_hooks.types.unsigned_type (type);
(TYPE_PRECISION (typex), TYPE_UNSIGNED (typex)); else
typex = lang_hooks.types.signed_type (type);
/* But now perhaps TYPEX is as wide as INPREC. return convert (type,
In that case, do nothing special here. fold_build1 (ex_form, typex,
(Otherwise would recurse infinitely in convert. */ convert (typex,
if (TYPE_PRECISION (typex) != inprec) TREE_OPERAND (expr, 0))));
{
/* Don't do unsigned arithmetic where signed was wanted,
or vice versa. */
if (TYPE_UNSIGNED (TREE_TYPE (expr)))
typex = lang_hooks.types.unsigned_type (typex);
else
typex = lang_hooks.types.signed_type (typex);
return convert (type,
fold_build1 (ex_form, typex,
convert (typex,
TREE_OPERAND (expr, 0))));
}
} }
case NOP_EXPR: case NOP_EXPR:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment