This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix PR c/33192


I've applied this patch to fix PR 33192, __imag__ on real argument
discarding side effects when returning 0.  Bootstrapped with no
regressions on i686-pc-linux-gnu.

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.

testsuite:
2008-10-16  Joseph Myers  <joseph@codesourcery.com>

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

Index: c-typeck.c
===================================================================
--- c-typeck.c	(revision 141136)
+++ c-typeck.c	(working copy)
@@ -3038,7 +3038,7 @@
       else if (TREE_CODE (TREE_TYPE (arg)) == COMPLEX_TYPE)
 	ret = fold_build1 (IMAGPART_EXPR, TREE_TYPE (TREE_TYPE (arg)), arg);
       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;
 
     case PREINCREMENT_EXPR:
Index: testsuite/gcc.dg/imag-1.c
===================================================================
--- testsuite/gcc.dg/imag-1.c	(revision 0)
+++ testsuite/gcc.dg/imag-1.c	(revision 0)
@@ -0,0 +1,18 @@
+/* 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;
+}

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]