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
This commit is contained in:
parent
910e8539cb
commit
c3cd9c8b70
@ -1,3 +1,8 @@
|
|||||||
|
2001-04-23 Joseph S. Myers <jsm28@cam.ac.uk>
|
||||||
|
|
||||||
|
* c-convert.c (convert): When converting to a BOOLEAN_TYPE, avoid
|
||||||
|
passing nested NOP_EXPRs to fold.
|
||||||
|
|
||||||
Mon Apr 23 14:32:12 CEST 2001 Jan Hubicka <jh@suse.cz>
|
Mon Apr 23 14:32:12 CEST 2001 Jan Hubicka <jh@suse.cz>
|
||||||
|
|
||||||
* reg-stack.c (emit_swap_insn): Do not get pass CALL_INSNs.
|
* reg-stack.c (emit_swap_insn): Do not get pass CALL_INSNs.
|
||||||
|
@ -89,7 +89,15 @@ convert (type, expr)
|
|||||||
if (code == INTEGER_TYPE || code == ENUMERAL_TYPE)
|
if (code == INTEGER_TYPE || code == ENUMERAL_TYPE)
|
||||||
return fold (convert_to_integer (type, e));
|
return fold (convert_to_integer (type, e));
|
||||||
if (code == BOOLEAN_TYPE)
|
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)
|
if (code == POINTER_TYPE || code == REFERENCE_TYPE)
|
||||||
return fold (convert_to_pointer (type, e));
|
return fold (convert_to_pointer (type, e));
|
||||||
if (code == REAL_TYPE)
|
if (code == REAL_TYPE)
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2001-04-23 Joseph S. Myers <jsm28@cam.ac.uk>
|
||||||
|
|
||||||
|
* gcc.c-torture/compile/20010423-1.c: New test.
|
||||||
|
|
||||||
2001-04-20 Nathan Sidwell <nathan@codesourcery.com>
|
2001-04-20 Nathan Sidwell <nathan@codesourcery.com>
|
||||||
|
|
||||||
* g++.old-deja/g++.pt/typename28.C: New test.
|
* g++.old-deja/g++.pt/typename28.C: New test.
|
||||||
|
16
gcc/testsuite/gcc.c-torture/compile/20010423-1.c
Normal file
16
gcc/testsuite/gcc.c-torture/compile/20010423-1.c
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/* Origin: PR c/2618 from Cesar Eduardo Barros <cesarb@nitnet.com.br>,
|
||||||
|
adapted to a testcase by Joseph Myers <jsm28@cam.ac.uk>.
|
||||||
|
|
||||||
|
Boolean conversions were causing infinite recursion between convert
|
||||||
|
and fold in certain cases. */
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
bool x;
|
||||||
|
unsigned char y;
|
||||||
|
|
||||||
|
void
|
||||||
|
fn (void)
|
||||||
|
{
|
||||||
|
x = y & 0x1 ? 1 : 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user