diff options
author | Jakub Jelinek <jakub@redhat.com> | 2018-01-02 19:04:19 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2018-01-02 19:04:19 +0100 |
commit | 0a552ae22a4b7d4a71afab9f845398597a4d230d (patch) | |
tree | 428a95327cf02965ce2f196924807666ad0e43d7 /gcc | |
parent | a9ec0cfc364b811d25bf8c84ad47e4d85f9a4766 (diff) | |
download | gcc-0a552ae22a4b7d4a71afab9f845398597a4d230d.zip gcc-0a552ae22a4b7d4a71afab9f845398597a4d230d.tar.gz gcc-0a552ae22a4b7d4a71afab9f845398597a4d230d.tar.bz2 |
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: r256086
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/tree.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/pr83556.C | 28 |
4 files changed, 52 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 985f871..a0da31c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. + 2018-01-02 Nathan Sidwell <nathan@acm.org> * constexpr.c (cxx_bind_parameters_in_call): Remove unneeded local diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 5528fa9..37f5484 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -3106,6 +3106,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; @@ -3125,7 +3130,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; @@ -3133,6 +3138,8 @@ replace_placeholders_r (tree* t, int* walk_subtrees, void* data_) } default: + if (d->pset->add (*t)) + *walk_subtrees = false; break; } @@ -3161,7 +3168,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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b77e73f..684a993 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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/45689 diff --git a/gcc/testsuite/g++.dg/cpp0x/pr83556.C b/gcc/testsuite/g++.dg/cpp0x/pr83556.C new file mode 100644 index 0000000..bab06a5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr83556.C @@ -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 (); +} |