From e834d8486a88ee5664c0c2e17b4c2dbd811c0c65 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 7 Jul 2011 21:41:55 +0200 Subject: [PATCH] re PR c/49644 (post-increment of promoted operand is incorrect.) PR c/49644 * typeck.c (cp_build_binary_op): For MULT_EXPR and TRUNC_DIV_EXPR with one non-complex and one complex argument, call save_expr on both operands. * g++.dg/torture/pr49644.C: New test. From-SVN: r176006 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/typeck.c | 2 ++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/torture/pr49644.C | 17 +++++++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 gcc/testsuite/g++.dg/torture/pr49644.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3957d5a..c5c83d0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2011-07-07 Jakub Jelinek + + PR c/49644 + * typeck.c (cp_build_binary_op): For MULT_EXPR and TRUNC_DIV_EXPR with + one non-complex and one complex argument, call save_expr on both + operands. + 2011-07-06 Jason Merrill PR c++/49353 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 7af76b1..2acb18e 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -4338,6 +4338,7 @@ cp_build_binary_op (location_t location, { case MULT_EXPR: case TRUNC_DIV_EXPR: + op1 = save_expr (op1); imag = build2 (resultcode, real_type, imag, op1); /* Fall through. */ case PLUS_EXPR: @@ -4356,6 +4357,7 @@ cp_build_binary_op (location_t location, switch (code) { case MULT_EXPR: + op0 = 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 a7eda91..3aa5f91 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,9 @@ 2011-07-07 Jakub Jelinek PR c/49644 + * g++.dg/torture/pr49644.C: New test. + + PR c/49644 * gcc.c-torture/execute/pr49644.c: New test. 2011-07-07 H.J. Lu diff --git a/gcc/testsuite/g++.dg/torture/pr49644.C b/gcc/testsuite/g++.dg/torture/pr49644.C new file mode 100644 index 0000000..5fb82e0 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr49644.C @@ -0,0 +1,17 @@ +// PR c/49644 +// { dg-do run } + +extern "C" void abort (); + +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; +} -- 2.7.4