OSDN Git Service

PR c/49644
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 7 Jul 2011 19:14:38 +0000 (19:14 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 7 Jul 2011 19:14:38 +0000 (19:14 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@176005 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 37b795a..ee096ba 100644 (file)
@@ -1,5 +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.
+
        PR debug/49522
        * df-problems.c (dead_debug_reset): Remove dead_debug_uses
        referencing debug insns that have been reset.
index 6ae9b4c..e086d1d 100644 (file)
@@ -10033,6 +10033,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:
@@ -10053,6 +10054,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 ff03954..360cecd 100644 (file)
@@ -1,5 +1,8 @@
 2011-07-07  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c/49644
+       * gcc.c-torture/execute/pr49644.c: New test.
+
        PR debug/49522
        * gcc.dg/debug/pr49522.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;
+}