diff options
author | Joseph Myers <jsm28@cam.ac.uk> | 2001-04-23 23:55:32 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2001-04-23 23:55:32 +0100 |
commit | c3cd9c8b70d46393e5486f7215e887de64c09076 (patch) | |
tree | e56281c646b5d3025e6590d3b59fc38691173903 /gcc/c-convert.c | |
parent | 910e8539cb5a59b129ae4a95b6ffd47d88bbad41 (diff) | |
download | gcc-c3cd9c8b70d46393e5486f7215e887de64c09076.zip gcc-c3cd9c8b70d46393e5486f7215e887de64c09076.tar.gz gcc-c3cd9c8b70d46393e5486f7215e887de64c09076.tar.bz2 |
c-convert.c (convert): When converting to a BOOLEAN_TYPE, avoid passing nested NOP_EXPRs to fold.
* 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.
From-SVN: r41508
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 7f57725..6585f3c 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) |