Commit c9529354 by Richard Kenner

(convert_to_integer): When changing type of truthvalue operation,

change types of inputs too.

From-SVN: r6771
parent 2e15b172
/* Utility routines for data type conversion for GNU C. /* Utility routines for data type conversion for GNU C.
Copyright (C) 1987, 1988, 1991, 1992 Free Software Foundation, Inc. Copyright (C) 1987, 1988, 1991, 1992, 1994 Free Software Foundation, Inc.
This file is part of GNU C. This file is part of GNU C.
...@@ -143,16 +143,30 @@ convert_to_integer (type, expr) ...@@ -143,16 +143,30 @@ convert_to_integer (type, expr)
/* If we are widening the type, put in an explicit conversion. /* If we are widening the type, put in an explicit conversion.
Similarly if we are not changing the width. However, if this is Similarly if we are not changing the width. However, if this is
a logical operation that just returns 0 or 1, we can change the a logical operation that just returns 0 or 1, we can change the
type of the expression (see below). */ type of the expression. For logical operations, we must
also change the types of the operands to maintain type
correctness. */
if (TREE_CODE_CLASS (ex_form) == '<' if (TREE_CODE_CLASS (ex_form) == '<')
|| ex_form == TRUTH_AND_EXPR || ex_form == TRUTH_ANDIF_EXPR
|| ex_form == TRUTH_OR_EXPR || ex_form == TRUTH_ORIF_EXPR
|| ex_form == TRUTH_XOR_EXPR || ex_form == TRUTH_NOT_EXPR)
{ {
TREE_TYPE (expr) = type; TREE_TYPE (expr) = type;
return expr; return expr;
} }
else if (ex_form == TRUTH_AND_EXPR || ex_form == TRUTH_ANDIF_EXPR
|| ex_form == TRUTH_OR_EXPR || ex_form == TRUTH_ORIF_EXPR
|| ex_form == TRUTH_XOR_EXPR)
{
TREE_OPERAND (expr, 0) = convert (type, TREE_OPERAND (expr, 0));
TREE_OPERAND (expr, 1) = convert (type, TREE_OPERAND (expr, 1));
TREE_TYPE (expr) = type;
return expr;
}
else if (ex_form == TRUTH_NOT_EXPR)
{
TREE_OPERAND (expr, 0) = convert (type, TREE_OPERAND (expr, 0));
TREE_TYPE (expr) = type;
return expr;
}
else if (outprec >= inprec) else if (outprec >= inprec)
return build1 (NOP_EXPR, type, expr); return build1 (NOP_EXPR, type, 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