Commit 010c4d9c by Roger Sayle Committed by Roger Sayle

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
parent 9368fb8f
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> 2005-01-05 Joseph S. Myers <joseph@codesourcery.com>
* c-parse.in (asm_string): Add trailing semicolon. * c-parse.in (asm_string): Add trailing semicolon.
......
...@@ -46,6 +46,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -46,6 +46,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "hashtab.h" #include "hashtab.h"
#include "tree-mudflap.h" #include "tree-mudflap.h"
#include "opts.h" #include "opts.h"
#include "real.h"
cpp_reader *parse_in; /* Declared in c-pragma.h. */ cpp_reader *parse_in; /* Declared in c-pragma.h. */
...@@ -2326,17 +2327,24 @@ c_common_truthvalue_conversion (tree expr) ...@@ -2326,17 +2327,24 @@ c_common_truthvalue_conversion (tree expr)
case TRUTH_OR_EXPR: case TRUTH_OR_EXPR:
case TRUTH_XOR_EXPR: case TRUTH_XOR_EXPR:
case TRUTH_NOT_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; return expr;
case ERROR_MARK: case ERROR_MARK:
return expr; return expr;
case INTEGER_CST: 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: 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: 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> 2005-01-05 Joseph S. Myers <joseph@codesourcery.com>
* gcc.dg/asm-wide-1.c: New test. * gcc.dg/asm-wide-1.c: New test.
......
/* 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment