Blame SOURCES/gcc7-pr85496.patch

1652f9
2018-04-23  Eric Botcazou  <ebotcazou@adacore.com>
1652f9
1652f9
	PR middle-end/85496
1652f9
	* expr.c (store_field): In the bitfield case, if the value comes from
1652f9
	a function call and is returned in registers by means of a PARALLEL,
1652f9
	do not change the mode of the temporary unless BLKmode and VOIDmode.
1652f9
1652f9
	* g++.dg/torture/pr85496.C: New test.
1652f9
1652f9
--- gcc/testsuite/g++.dg/torture/pr85496.C	(nonexistent)
1652f9
+++ gcc/testsuite/g++.dg/torture/pr85496.C	(revision 259576)
1652f9
@@ -0,0 +1,18 @@
1652f9
+// PR middle-end/85496
1652f9
+// Reported by Marek Polacek <mpolacek@gcc.gnu.org>
1652f9
+
1652f9
+template <typename> class complex;
1652f9
+template <typename _Tp> complex<_Tp> operator*(complex<_Tp>, complex<_Tp>);
1652f9
+template <> struct complex<float> { _Complex float _M_value; };
1652f9
+class A {
1652f9
+  complex<float> _f0, _f1;
1652f9
+
1652f9
+public:
1652f9
+  complex<float> &m_fn1() { return _f1; }
1652f9
+};
1652f9
+complex<float> a;
1652f9
+void cos() {
1652f9
+  A b;
1652f9
+  complex<float> c;
1652f9
+  b.m_fn1() = c * a;
1652f9
+}
1652f9
--- gcc/expr.c	(revision 259575)
1652f9
+++ gcc/expr.c	(revision 259576)
1652f9
@@ -6893,8 +6893,9 @@
1652f9
       if (GET_CODE (temp) == PARALLEL)
1652f9
 	{
1652f9
 	  HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp));
1652f9
-	  machine_mode temp_mode
1652f9
-	    = smallest_mode_for_size (size * BITS_PER_UNIT, MODE_INT);
1652f9
+	  machine_mode temp_mode = GET_MODE (temp);
1652f9
+	  if (temp_mode == BLKmode || temp_mode == VOIDmode)
1652f9
+	    temp_mode = smallest_mode_for_size (size * BITS_PER_UNIT, MODE_INT);
1652f9
 	  rtx temp_target = gen_reg_rtx (temp_mode);
1652f9
 	  emit_group_store (temp_target, temp, TREE_TYPE (exp), size);
1652f9
 	  temp = temp_target;