Commit bbe67e7c by Joseph Myers Committed by Joseph Myers

re PR c/33192 (__imag operator drops side effects in subexpr)

	PR c/33192
	* c-typeck.c (build_unary_op): Use omit_one_operand for
	IMAGPART_EXPR of real argument.

testsuite:
	* gcc.dg/imag-1.c: New test.

From-SVN: r141176
parent dd9315de
2008-10-16 Joseph Myers <joseph@codesourcery.com>
PR c/33192
* c-typeck.c (build_unary_op): Use omit_one_operand for
IMAGPART_EXPR of real argument.
2008-10-16 Jakub Jelinek <jakub@redhat.com> 2008-10-16 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/37664 PR tree-optimization/37664
......
...@@ -3038,7 +3038,7 @@ build_unary_op (location_t location, ...@@ -3038,7 +3038,7 @@ build_unary_op (location_t location,
else if (TREE_CODE (TREE_TYPE (arg)) == COMPLEX_TYPE) else if (TREE_CODE (TREE_TYPE (arg)) == COMPLEX_TYPE)
ret = fold_build1 (IMAGPART_EXPR, TREE_TYPE (TREE_TYPE (arg)), arg); ret = fold_build1 (IMAGPART_EXPR, TREE_TYPE (TREE_TYPE (arg)), arg);
else else
ret = convert (TREE_TYPE (arg), integer_zero_node); ret = omit_one_operand (TREE_TYPE (arg), integer_zero_node, arg);
goto return_build_unary_op; goto return_build_unary_op;
case PREINCREMENT_EXPR: case PREINCREMENT_EXPR:
......
2008-10-16 Joseph Myers <joseph@codesourcery.com>
PR c/33192
* gcc.dg/imag-1.c: New test.
2008-10-16 Daniel Kraft <d@domob.eu> 2008-10-16 Daniel Kraft <d@domob.eu>
* gfortran.dg/elemental_intrinsic_1.f03: New test. * gfortran.dg/elemental_intrinsic_1.f03: New test.
......
/* Test for __imag__ side effects; see PR 33192. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
extern void abort (void);
extern void exit (int);
int
main (void)
{
int i, j;
i = 1;
j = __imag__ ++i;
if (i != 2 || j != 0)
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