From 30a633dfcdb599166e80b74d20e4b8c7e03a7cc1 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 23 Apr 2018 20:31:17 +0000 Subject: [PATCH] re PR middle-end/85496 (internal compiler error: in emit_move_insn, at expr.c:3722) PR middle-end/85496 * expr.c (store_field): In the bitfield case, if the value comes from a function call and is returned in registers by means of a PARALLEL, do not change the mode of the temporary unless BLKmode and VOIDmode. From-SVN: r259577 --- gcc/ChangeLog | 7 +++++++ gcc/expr.c | 5 +++-- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/torture/pr85496.C | 18 ++++++++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr85496.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2631728fc5f6..b7155e69dae5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-04-23 Eric Botcazou + + PR middle-end/85496 + * expr.c (store_field): In the bitfield case, if the value comes from + a function call and is returned in registers by means of a PARALLEL, + do not change the mode of the temporary unless BLKmode and VOIDmode. + 2018-04-18 Thomas Preud'homme Backport from mainline diff --git a/gcc/expr.c b/gcc/expr.c index 554175758fd3..b26de6da765f 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -6693,8 +6693,9 @@ store_field (rtx target, HOST_WIDE_INT bitsize, HOST_WIDE_INT bitpos, if (GET_CODE (temp) == PARALLEL) { HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp)); - machine_mode temp_mode - = smallest_mode_for_size (size * BITS_PER_UNIT, MODE_INT); + machine_mode temp_mode = GET_MODE (temp); + if (temp_mode == BLKmode || temp_mode == VOIDmode) + temp_mode = smallest_mode_for_size (size * BITS_PER_UNIT, MODE_INT); rtx temp_target = gen_reg_rtx (temp_mode); emit_group_store (temp_target, temp, TREE_TYPE (exp), size); temp = temp_target; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a03fe2e98102..adaf01837ab6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-04-23 Eric Botcazou + + * g++.dg/torture/pr85496.C: New test. + 2018-04-18 Thomas Preud'homme Backport from mainline diff --git a/gcc/testsuite/g++.dg/torture/pr85496.C b/gcc/testsuite/g++.dg/torture/pr85496.C new file mode 100644 index 000000000000..3f504a377914 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr85496.C @@ -0,0 +1,18 @@ +// PR middle-end/85496 +// Reported by Marek Polacek + +template class complex; +template complex<_Tp> operator*(complex<_Tp>, complex<_Tp>); +template <> struct complex { _Complex float _M_value; }; +class A { + complex _f0, _f1; + +public: + complex &m_fn1() { return _f1; } +}; +complex a; +void cos() { + A b; + complex c; + b.m_fn1() = c * a; +} -- 2.47.2