re PR middle-end/19100 (Wrong code for ?-operator with casted ?-operator predicat)
PR middle-end/19100 * c-common.c: Include real.h. (c_common_truthvalue_conversion): Avoid destructively modifying expr. Correctly handle TREE_CONSTANT_OVERFLOW for INTEGER_CST. Correctly handle TREE_CONSTANT_OVERFLOW and NaNs for REAL_CST. * Makefile.in (c-common.o): Update dependencies. * gcc.dg/conv-3.c: New test case. From-SVN: r92957
This commit is contained in:
parent
9368fb8fbc
commit
010c4d9c14
@ -1,3 +1,12 @@
|
||||
2005-01-05 Roger Sayle <roger@eyesopen.com>
|
||||
|
||||
PR middle-end/19100
|
||||
* c-common.c: Include real.h.
|
||||
(c_common_truthvalue_conversion): Avoid destructively modifying expr.
|
||||
Correctly handle TREE_CONSTANT_OVERFLOW for INTEGER_CST.
|
||||
Correctly handle TREE_CONSTANT_OVERFLOW and NaNs for REAL_CST.
|
||||
* Makefile.in (c-common.o): Update dependencies.
|
||||
|
||||
2005-01-05 Joseph S. Myers <joseph@codesourcery.com>
|
||||
|
||||
* c-parse.in (asm_string): Add trailing semicolon.
|
||||
|
@ -46,6 +46,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
#include "hashtab.h"
|
||||
#include "tree-mudflap.h"
|
||||
#include "opts.h"
|
||||
#include "real.h"
|
||||
|
||||
cpp_reader *parse_in; /* Declared in c-pragma.h. */
|
||||
|
||||
@ -2326,17 +2327,24 @@ c_common_truthvalue_conversion (tree expr)
|
||||
case TRUTH_OR_EXPR:
|
||||
case TRUTH_XOR_EXPR:
|
||||
case TRUTH_NOT_EXPR:
|
||||
TREE_TYPE (expr) = truthvalue_type_node;
|
||||
if (TREE_TYPE (expr) != truthvalue_type_node)
|
||||
return build2 (TREE_CODE (expr), truthvalue_type_node,
|
||||
TREE_OPERAND (expr, 0), TREE_OPERAND (expr, 1));
|
||||
return expr;
|
||||
|
||||
case ERROR_MARK:
|
||||
return expr;
|
||||
|
||||
case INTEGER_CST:
|
||||
return integer_zerop (expr) ? truthvalue_false_node : truthvalue_true_node;
|
||||
/* Avoid integer_zerop to ignore TREE_CONSTANT_OVERFLOW. */
|
||||
return (TREE_INT_CST_LOW (expr) != 0 || TREE_INT_CST_HIGH (expr) != 0)
|
||||
? truthvalue_true_node
|
||||
: truthvalue_false_node;
|
||||
|
||||
case REAL_CST:
|
||||
return real_zerop (expr) ? truthvalue_false_node : truthvalue_true_node;
|
||||
return real_compare (NE_EXPR, &TREE_REAL_CST (expr), &dconst0)
|
||||
? truthvalue_true_node
|
||||
: truthvalue_false_node;
|
||||
|
||||
case ADDR_EXPR:
|
||||
{
|
||||
|
@ -1,3 +1,8 @@
|
||||
2005-01-05 Roger Sayle <roger@eyesopen.com>
|
||||
|
||||
PR middle-end/19100
|
||||
* gcc.dg/conv-3.c: New test case.
|
||||
|
||||
2005-01-05 Joseph S. Myers <joseph@codesourcery.com>
|
||||
|
||||
* gcc.dg/asm-wide-1.c: New test.
|
||||
|
18
gcc/testsuite/gcc.dg/conv-3.c
Normal file
18
gcc/testsuite/gcc.dg/conv-3.c
Normal file
@ -0,0 +1,18 @@
|
||||
/* PR middle-end/19100 */
|
||||
/* { dg-do run } */
|
||||
/* { dg-options "-O2" } */
|
||||
|
||||
void abort (void);
|
||||
|
||||
int test (int v)
|
||||
{
|
||||
return ((signed char) (v ? 0x100 : 0)) ? 17 : 18;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
if (test (2) != 18)
|
||||
abort ();
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user