diff options
author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-04-23 22:55:32 +0000 |
---|---|---|
committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-04-23 22:55:32 +0000 |
commit | 780b5c1b45463717d90f1958a6dc73fb523498f6 (patch) | |
tree | e56281c646b5d3025e6590d3b59fc38691173903 /gcc/c-convert.c | |
parent | e46566dab0db7d1e3a5a0feb0d6fe2ac146181fe (diff) | |
download | gcc-780b5c1b45463717d90f1958a6dc73fb523498f6.tar.gz |
* c-convert.c (convert): When converting to a BOOLEAN_TYPE, avoid
passing nested NOP_EXPRs to fold.
testsuite:
* gcc.c-torture/compile/20010423-1.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@41508 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-convert.c')
-rw-r--r-- | gcc/c-convert.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/gcc/c-convert.c b/gcc/c-convert.c index 7f57725b7c1..6585f3cb4f6 100644 --- a/gcc/c-convert.c +++ b/gcc/c-convert.c @@ -89,7 +89,15 @@ convert (type, expr) if (code == INTEGER_TYPE || code == ENUMERAL_TYPE) return fold (convert_to_integer (type, e)); if (code == BOOLEAN_TYPE) - return fold (build1 (NOP_EXPR, type, truthvalue_conversion (expr))); + { + 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 (). */ + if (TREE_CODE (t) == NOP_EXPR) + return fold (build1 (NOP_EXPR, type, TREE_OPERAND (t, 0))); + else + return fold (build1 (NOP_EXPR, type, t)); + } if (code == POINTER_TYPE || code == REFERENCE_TYPE) return fold (convert_to_pointer (type, e)); if (code == REAL_TYPE) |