aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2011-07-07 21:11:27 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2011-07-07 21:11:27 +0200
commitc4603e7ce0b0e007db25abc234a85d1562a9c988 (patch)
tree0b97ba80ee1dfb0fc4d489e1971200c80e0c2519
parent489319d5aa1448a8d9ce9062247c6c48f9cd745f (diff)
downloadgcc-c4603e7ce0b0e007db25abc234a85d1562a9c988.zip
gcc-c4603e7ce0b0e007db25abc234a85d1562a9c988.tar.gz
gcc-c4603e7ce0b0e007db25abc234a85d1562a9c988.tar.bz2
re PR c/49644 (post-increment of promoted operand is incorrect.)
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
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/c-typeck.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr49644.c16
4 files changed, 30 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index dbeb8e6..a93f5a1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index a451606..bd2d685 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -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:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ff76bb0..a7eda91 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..88be23c
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr49644.c
@@ -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;
+}