]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/85496 (internal compiler error: in emit_move_insn, at expr.c:3722)
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 23 Apr 2018 20:31:17 +0000 (20:31 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Mon, 23 Apr 2018 20:31:17 +0000 (20:31 +0000)
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
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr85496.C [new file with mode: 0644]

index 2631728fc5f68d1a9a25009ec859a335576fbe6e..b7155e69dae56c4c440c95b8cf490609d68df0d8 100644 (file)
@@ -1,3 +1,10 @@
+2018-04-23  Eric Botcazou  <ebotcazou@adacore.com>
+
+       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  <thomas.preudhomme@arm.com>
 
        Backport from mainline
index 554175758fd3f68d6e602dba9ea7e0dc6bc48886..b26de6da765f59d01e9126c465346a0178a40fa2 100644 (file)
@@ -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;
index a03fe2e98102b0e9576b03d77fa4ecb2c099de08..adaf01837ab61f78863008686e1368751474bf17 100644 (file)
@@ -1,3 +1,7 @@
+2018-04-23  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * g++.dg/torture/pr85496.C: New test.
+
 2018-04-18  Thomas Preud'homme  <thomas.preudhomme@arm.com>
 
        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 (file)
index 0000000..3f504a3
--- /dev/null
@@ -0,0 +1,18 @@
+// PR middle-end/85496
+// Reported by Marek Polacek <mpolacek@gcc.gnu.org>
+
+template <typename> class complex;
+template <typename _Tp> complex<_Tp> operator*(complex<_Tp>, complex<_Tp>);
+template <> struct complex<float> { _Complex float _M_value; };
+class A {
+  complex<float> _f0, _f1;
+
+public:
+  complex<float> &m_fn1() { return _f1; }
+};
+complex<float> a;
+void cos() {
+  A b;
+  complex<float> c;
+  b.m_fn1() = c * a;
+}