re PR c++/83556 (ICE in gimplify_expr, at gimplify.c:12004)

PR c++/83556
	* tree.c (replace_placeholders_r): Pass NULL as last argument to
	cp_walk_tree instead of d->pset.  If non-TREE_CONSTANT and
	non-PLACEHOLDER_EXPR tree has been seen already, set *walk_subtrees
	to false and return.
	(replace_placeholders): Pass NULL instead of &pset as last argument
	to cp_walk_tree.

	* g++.dg/cpp0x/pr83556.C: New test.

From-SVN: r256087
This commit is contained in:
Jakub Jelinek 2018-01-02 19:07:41 +01:00 committed by Jakub Jelinek
parent 52535f91db
commit 27f04c8cc7
4 changed files with 52 additions and 2 deletions

View File

@ -1,3 +1,13 @@
2018-01-02 Jakub Jelinek <jakub@redhat.com>
PR c++/83556
* tree.c (replace_placeholders_r): Pass NULL as last argument to
cp_walk_tree instead of d->pset. If non-TREE_CONSTANT and
non-PLACEHOLDER_EXPR tree has been seen already, set *walk_subtrees
to false and return.
(replace_placeholders): Pass NULL instead of &pset as last argument
to cp_walk_tree.
2017-12-19 Marek Polacek <polacek@redhat.com>
Backported from mainline

View File

@ -2804,6 +2804,11 @@ replace_placeholders_r (tree* t, int* walk_subtrees, void* data_)
{
constructor_elt *ce;
vec<constructor_elt,va_gc> *v = CONSTRUCTOR_ELTS (*t);
if (d->pset->add (*t))
{
*walk_subtrees = false;
return NULL_TREE;
}
for (unsigned i = 0; vec_safe_iterate (v, i, &ce); ++i)
{
tree *valp = &ce->value;
@ -2823,7 +2828,7 @@ replace_placeholders_r (tree* t, int* walk_subtrees, void* data_)
valp = &TARGET_EXPR_INITIAL (*valp);
}
d->obj = subob;
cp_walk_tree (valp, replace_placeholders_r, data_, d->pset);
cp_walk_tree (valp, replace_placeholders_r, data_, NULL);
d->obj = obj;
}
*walk_subtrees = false;
@ -2831,6 +2836,8 @@ replace_placeholders_r (tree* t, int* walk_subtrees, void* data_)
}
default:
if (d->pset->add (*t))
*walk_subtrees = false;
break;
}
@ -2859,7 +2866,7 @@ replace_placeholders (tree exp, tree obj, bool *seen_p)
replace_placeholders_t data = { obj, false, &pset };
if (TREE_CODE (exp) == TARGET_EXPR)
tp = &TARGET_EXPR_INITIAL (exp);
cp_walk_tree (tp, replace_placeholders_r, &data, &pset);
cp_walk_tree (tp, replace_placeholders_r, &data, NULL);
if (seen_p)
*seen_p = data.seen;
return exp;

View File

@ -1,3 +1,8 @@
2018-01-02 Jakub Jelinek <jakub@redhat.com>
PR c++/83556
* g++.dg/cpp0x/pr83556.C: New test.
2018-01-02 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/83650

View File

@ -0,0 +1,28 @@
// PR c++/83556
// { dg-do run { target c++11 } }
int
foo ()
{
return 1;
}
struct A
{
int a = foo ();
int b = 1;
int c = a ? 1 * b : 2 * b;
};
struct B
{
A d {};
};
int
main ()
{
B e {};
if (e.d.c != 1)
__builtin_abort ();
}