backport: re PR c++/82159 (ICE: in assign_temp, at function.c:961)

Backported from mainline
	2017-09-27  Jakub Jelinek  <jakub@redhat.com>

	PR c++/82159
	* gimplify.c (gimplify_modify_expr): Don't optimize away zero sized
	lhs from calls if the lhs has addressable type.

	* g++.dg/opt/pr82159.C: New test.

From-SVN: r253318
This commit is contained in:
Jakub Jelinek 2017-09-30 10:25:02 +02:00 committed by Jakub Jelinek
parent f11eb23ea3
commit 4eb003869d
4 changed files with 41 additions and 1 deletions

View File

@ -1,3 +1,12 @@
2017-09-30 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
2017-09-27 Jakub Jelinek <jakub@redhat.com>
PR c++/82159
* gimplify.c (gimplify_modify_expr): Don't optimize away zero sized
lhs from calls if the lhs has addressable type.
2017-09-29 Krister Walfridsson <krister.walfridsson@gmail.com>
Backport from mainline

View File

@ -5434,7 +5434,12 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
side as statements and throw away the assignment. Do this after
gimplify_modify_expr_rhs so we handle TARGET_EXPRs of addressable
types properly. */
if (zero_sized_type (TREE_TYPE (*from_p)) && !want_value)
if (zero_sized_type (TREE_TYPE (*from_p))
&& !want_value
/* Don't do this for calls that return addressable types, expand_call
relies on those having a lhs. */
&& !(TREE_ADDRESSABLE (TREE_TYPE (*from_p))
&& TREE_CODE (*from_p) == CALL_EXPR))
{
gimplify_stmt (from_p, pre_p);
gimplify_stmt (to_p, pre_p);

View File

@ -1,3 +1,11 @@
2017-09-30 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
2017-09-27 Jakub Jelinek <jakub@redhat.com>
PR c++/82159
* g++.dg/opt/pr82159.C: New test.
2017-09-27 Christophe Lyon <christophe.lyon@linaro.org>
Backport from trunk r249639.

View File

@ -0,0 +1,18 @@
// PR c++/82159
// { dg-do compile }
// { dg-options "" }
template<int N>
struct S
{
~S () {}
template<int M> S<M> foo () { return S<M> (); }
unsigned char data[N];
};
int
main ()
{
S<16> d;
S<0> t = d.foo<0> ();
}