From: Jakub Jelinek Date: Mon, 25 Jun 2018 16:46:54 +0000 (+0200) Subject: backport: re PR c++/82159 (ICE: in assign_temp, at function.c:961) X-Git-Tag: releases/gcc-6.5.0~253 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55cafa8ea10c3379bc03642eb82b81e5a0fbf059;p=thirdparty%2Fgcc.git backport: re PR c++/82159 (ICE: in assign_temp, at function.c:961) Backported from mainline 2017-10-12 Jakub Jelinek PR c++/82159 * expr.c (store_field): Don't optimize away bitsize == 0 store from CALL_EXPR with addressable return type. * g++.dg/opt/pr82159-2.C: New test. From-SVN: r262030 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e0da88cd08c7..e06e6a3283a4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,12 @@ 2018-06-25 Jakub Jelinek Backported from mainline + 2017-10-12 Jakub Jelinek + + PR c++/82159 + * expr.c (store_field): Don't optimize away bitsize == 0 store + from CALL_EXPR with addressable return type. + 2017-09-27 Jakub Jelinek PR c++/82159 diff --git a/gcc/expr.c b/gcc/expr.c index b26de6da765f..fd49fe0f74f5 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -6598,8 +6598,11 @@ store_field (rtx target, HOST_WIDE_INT bitsize, HOST_WIDE_INT bitpos, return const0_rtx; /* If we have nothing to store, do nothing unless the expression has - side-effects. */ - if (bitsize == 0) + side-effects. Don't do that for zero sized addressable lhs of + calls. */ + if (bitsize == 0 + && (!TREE_ADDRESSABLE (TREE_TYPE (exp)) + || TREE_CODE (exp) != CALL_EXPR)) return expand_expr (exp, const0_rtx, VOIDmode, EXPAND_NORMAL); if (GET_CODE (target) == CONCAT) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 65ee8dae05e1..e52f2fcf1600 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2018-06-25 Jakub Jelinek Backported from mainline + 2017-10-12 Jakub Jelinek + + PR c++/82159 + * g++.dg/opt/pr82159-2.C: New test. + 2017-09-29 Jakub Jelinek PR c/82340 diff --git a/gcc/testsuite/g++.dg/opt/pr82159-2.C b/gcc/testsuite/g++.dg/opt/pr82159-2.C new file mode 100644 index 000000000000..f153c29ddac0 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr82159-2.C @@ -0,0 +1,65 @@ +// PR c++/82159 +// { dg-do compile } +// { dg-options "" } + +template struct D { T e; }; +struct F : D { + F(const F &); +}; +struct G : F { + template G operator-(T); +}; +template struct I { + typedef typename T::template J ak; +}; +template struct K { typename I::ak an; }; +struct H { + G l; +}; +struct C { + ~C(); +}; +template struct M : T { + template M(U, V); + H h; + virtual void foo() { T::bar(&h); } +}; +template class A; +template struct B { + typedef int BT; + struct BC {}; + template struct BD { + G g; + BD(BT, T n) : g(n.l - 0) {} + }; + B(BT, BC); +}; +template struct O; +template +struct O > > : public B >::BC {}; +struct L : B > { + struct P : C { + void bar(H *x) { + BT a; + BD(a, *x); + } + }; + template L(U x, V n) : B(x, n) {} + int ll; + virtual int baz() { M

(this, ll); } +}; +template class Q { + O > > q; + virtual L baz() { L(0, q); } +}; +template