From 80945b46eab860f88dd1abc6913e7fe2af31936c Mon Sep 17 00:00:00 2001 From: jason Date: Sat, 23 Nov 2013 16:28:57 +0000 Subject: [PATCH] PR c++/58868 * init.c (build_aggr_init): Don't clobber the type of init if we got an INIT_EXPR back from build_vec_init. (build_vec_init): Do digest_init on trivial initialization. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205311 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/init.c | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 05aa444..91e4132 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2013-11-23 Jason Merrill + + PR c++/58868 + * init.c (build_aggr_init): Don't clobber the type of init + if we got an INIT_EXPR back from build_vec_init. + (build_vec_init): Do digest_init on trivial initialization. + 2013-11-23 Alexander Ivchenko PR c++/58525 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index dc40989..1e6e691 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1507,7 +1507,8 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain) TREE_READONLY (exp) = was_const; TREE_THIS_VOLATILE (exp) = was_volatile; TREE_TYPE (exp) = type; - if (init) + /* Restore the type of init unless it was used directly. */ + if (init && TREE_CODE (stmt_expr) != INIT_EXPR) TREE_TYPE (init) = itype; return stmt_expr; } @@ -3421,6 +3422,8 @@ build_vec_init (tree base, tree maxindex, tree init, brace-enclosed initializers. In this case, digest_init and store_constructor will handle the semantics for us. */ + if (BRACE_ENCLOSED_INITIALIZER_P (init)) + init = digest_init (atype, init, complain); stmt_expr = build2 (INIT_EXPR, atype, base, init); if (length_check) stmt_expr = build3 (COND_EXPR, atype, length_check, -- 2.7.4