]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c/49644 (post-increment of promoted operand is incorrect.)
authorJakub Jelinek <jakub@redhat.com>
Tue, 19 Jul 2011 13:07:23 +0000 (15:07 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 19 Jul 2011 13:07:23 +0000 (15:07 +0200)
Backport from mainline
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.

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

From-SVN: r176456

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

index be911bca5785f905d01f3fbc978d89c60ffc777a..13ce2dee8dc53d04f3a54d4aef3b4633c0ab4ad3 100644 (file)
@@ -3,6 +3,11 @@
        Backport from mainline
        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.
+
        PR middle-end/49640
        * gimplify.c (gimplify_compound_lval): For last 2 ARRAY_*REF
        operands and last COMPONENT_REF operand call gimplify_expr on it
index e1ba16b1fe1f625de659fdf4c858358464160e0a..66b95127aba531b425d2141fe5096eb5c2c81654 100644 (file)
@@ -9655,6 +9655,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:
@@ -9675,6 +9676,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 209f4a2c03be1318ef25aefe47c54bf64baf8aa1..d758a7612e64085b6a8cf3726cea55721bdd138c 100644 (file)
@@ -3,6 +3,9 @@
        Backport from mainline
        2011-07-07  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c/49644
+       * gcc.c-torture/execute/pr49644.c: New test.
+
        PR middle-end/49640
        * gcc.dg/gomp/pr49640.c: New test.
 
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;
+}