The earlier patch fixed the testcase, but it seemed to me that
build_aggr_init still ought to do the right thing here.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit cfde6c1e56ecbbd098de20451cc718cedeb8dffd
Author: Jason Merrill <ja...@redhat.com>
Date: Wed Nov 6 09:33:24 2013 -0500
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.
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index fd43a4f..d7b0643 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -1508,7 +1508,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,