From edb7c512888ad65f3804585a43448ada0d10f690 Mon Sep 17 00:00:00 2001 From: Jason Merrill <jason@redhat.com> Date: Mon, 8 Nov 2010 22:54:12 -0500 Subject: [PATCH] re PR c++/46335 ([C++0X] [4.6 Regression] ICE: in gimple_add_tmp_var, at gimplify.c:701) PR c++/46335 * tree.c (bot_manip): Check TREE_SIDE_EFFECTS as well. From-SVN: r166470 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/tree.c | 5 ++--- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/cpp0x/constexpr-defarg.C | 12 ++++++++++++ 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-defarg.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4f08ec396175..2408adbf0357 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2010-11-08 Jason Merrill <jason@redhat.com> + PR c++/46335 + * tree.c (bot_manip): Check TREE_SIDE_EFFECTS as well. + Correct conversion/overflow behavior. * cvt.c (ignore_overflows): Move here from typeck.c. (ocp_convert): Use it. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 5440e10204e2..462e35f3b714 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1763,11 +1763,10 @@ bot_manip (tree* tp, int* walk_subtrees, void* data) splay_tree target_remap = ((splay_tree) data); tree t = *tp; - if (!TYPE_P (t) && TREE_CONSTANT (t)) + if (!TYPE_P (t) && TREE_CONSTANT (t) && !TREE_SIDE_EFFECTS (t)) { /* There can't be any TARGET_EXPRs or their slot variables below - this point. We used to check !TREE_SIDE_EFFECTS, but then we - failed to copy an ADDR_EXPR of the slot VAR_DECL. */ + this point. */ *walk_subtrees = 0; return NULL_TREE; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e94dceff0437..1211aa299ed6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-11-08 Jason Merrill <jason@redhat.com> + + * g++.dg/cpp0x/constexpr-defarg.C: New. + 2010-11-08 Xinliang David Li <davidxl@google.com> PR/46316 diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-defarg.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-defarg.C new file mode 100644 index 000000000000..1413b24bd842 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-defarg.C @@ -0,0 +1,12 @@ +// PR c++/46335 +// { dg-options -std=c++0x } + +struct T { }; +struct A { + A(const T &tr =T()) {} +}; +struct B { + A k; +}; +B kk_; +A fk_; -- GitLab