re PR c/49644 (post-increment of promoted operand is incorrect.)
authorJakub Jelinek <jakub@redhat.com>
Thu, 7 Jul 2011 19:11:27 +0000 (21:11 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 7 Jul 2011 19:11:27 +0000 (21:11 +0200)
PR c/49644
* c-typeck.c (build_binary_op): For MULT_EXPR and TRUNC_DIV_EXPR with
one non-complex and one complex argument, call c_save_expr on both
operands.

* gcc.c-torture/execute/pr49644.c: New test.

From-SVN: r176004

gcc/ChangeLog
gcc/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr49644.c [new file with mode: 0644]

index dbeb8e68cd6a55a9b409a8afd4f8006623d78e6a..a93f5a1a0e607b263fa57f8c03a7cbe75a70f168 100644 (file)
@@ -1,3 +1,10 @@
+2011-07-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/49644
+       * c-typeck.c (build_binary_op): For MULT_EXPR and TRUNC_DIV_EXPR with
+       one non-complex and one complex argument, call c_save_expr on both
+       operands.
+
 2011-07-07  Martin Jambor  <mjambor@suse.cz>
 
        PR middle-end/49495
index a4516064e509f1243d9e1b6ccfb9e5f818caf052..bd2d685f8bc2548020ea703d0d7b77eee080c254 100644 (file)
@@ -10040,6 +10040,7 @@ build_binary_op (location_t location, enum tree_code code,
                {
                case MULT_EXPR:
                case TRUNC_DIV_EXPR:
+                 op1 = c_save_expr (op1);
                  imag = build2 (resultcode, real_type, imag, op1);
                  /* Fall through.  */
                case PLUS_EXPR:
@@ -10060,6 +10061,7 @@ build_binary_op (location_t location, enum tree_code code,
              switch (code)
                {
                case MULT_EXPR:
+                 op0 = c_save_expr (op0);
                  imag = build2 (resultcode, real_type, op0, imag);
                  /* Fall through.  */
                case PLUS_EXPR:
index ff76bb04342f7b818f9ed3c72581b75c8a5185dd..a7eda91c69e25fc9039c0c2cf03e5f3756250473 100644 (file)
@@ -1,3 +1,8 @@
+2011-07-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/49644
+       * gcc.c-torture/execute/pr49644.c: New test.
+
 2011-07-07  H.J. Lu  <hongjiu.lu@intel.com>
 
        * lib/target-supports.exp (check_effective_target_ia32): New.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr49644.c b/gcc/testsuite/gcc.c-torture/execute/pr49644.c
new file mode 100644 (file)
index 0000000..88be23c
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR c/49644 */
+
+extern void abort (void);
+
+int
+main ()
+{
+  _Complex double a[12], *c = a, s = 3.0 + 1.0i;
+  double b[12] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }, *d = b;
+  int i;
+  for (i = 0; i < 6; i++)
+    *c++ = *d++ * s;
+  if (c != a + 6 || d != b + 6)
+    abort ();
+  return 0;
+}