From 4eaee921faac4b20bcc81988ec2b1af4cc087efc Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 7 Dec 2012 22:31:25 -0500 Subject: [PATCH] re PR c++/55419 (ICE in gimplify_init_ctor_preeval, at gimplify.c:3587) PR c++/55419 * tree.c (build_target_expr): Don't set TREE_CONSTANT. From-SVN: r194317 --- gcc/cp/ChangeLog | 5 ++++ gcc/cp/tree.c | 2 -- .../g++.dg/cpp0x/constexpr-initlist6.C | 27 +++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-initlist6.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cee5db6c9ec..78e7d40d4a5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2012-12-07 Jason Merrill + + PR c++/55419 + * tree.c (build_target_expr): Don't set TREE_CONSTANT. + 2012-12-07 Aldy Hernandez PR c++/55513 diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index ca209eb91e3..00fe53f5214 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -329,8 +329,6 @@ build_target_expr (tree decl, tree value, tsubst_flags_t complain) side-effects, then the optimizer should be able to get rid of whatever code is generated anyhow. */ TREE_SIDE_EFFECTS (t) = 1; - if (literal_type_p (type)) - TREE_CONSTANT (t) = TREE_CONSTANT (value); return t; } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist6.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist6.C new file mode 100644 index 00000000000..6b822a1f777 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist6.C @@ -0,0 +1,27 @@ +// PR c++/55419 +// { dg-options -std=c++11 } + +struct P +{ + P () = default; + explicit constexpr P (int x) : p (x) {} + int p; +}; + +struct Q +{ + constexpr Q () : q (0x7f) {} + int q; +}; + +struct R +{ + Q q; + P p; +}; + +void +foo (R *x) +{ + *x = {}; +} -- 2.30.2