+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.
#include "hashtab.h"
#include "tree-mudflap.h"
#include "opts.h"
+#include "real.h"
cpp_reader *parse_in; /* Declared in c-pragma.h. */
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:
{
+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.
--- /dev/null
+/* 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;
+}
+