diff options
author | kenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4> | 1994-03-14 02:16:38 +0000 |
---|---|---|
committer | kenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4> | 1994-03-14 02:16:38 +0000 |
commit | 2b1fba9ff3c8e6a7a052d8ff368f2377a136c031 (patch) | |
tree | 15921bcd2f67062eed44668b46339c56c3eba8af /gcc/convert.c | |
parent | ab9363efaba668bda88ef9edca65e526c254c71c (diff) | |
download | gcc-2b1fba9ff3c8e6a7a052d8ff368f2377a136c031.tar.gz |
(convert_to_integer): When changing type of truthvalue operation,
change types of inputs too.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@6771 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/convert.c')
-rw-r--r-- | gcc/convert.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/gcc/convert.c b/gcc/convert.c index 032bb516899..0060b60e37c 100644 --- a/gcc/convert.c +++ b/gcc/convert.c @@ -1,5 +1,5 @@ /* 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. @@ -143,16 +143,30 @@ convert_to_integer (type, expr) /* If we are widening the type, put in an explicit conversion. 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 - 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) == '<' - || 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) + if (TREE_CODE_CLASS (ex_form) == '<') { TREE_TYPE (expr) = type; 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) return build1 (NOP_EXPR, type, expr); |