diff options
author | Jason Merrill <jason@redhat.com> | 2010-10-26 14:10:53 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2010-10-26 14:10:53 -0400 |
commit | 534ecb17516c5db7a96245ebb90beb206e22eaff (patch) | |
tree | 0f1b677728d44296d9537a0c12aa3f3f1615257d /gcc/cp/init.c | |
parent | 73c982bc87c8eb33a37ba3242f8d82bc512e4189 (diff) | |
download | gcc-534ecb17516c5db7a96245ebb90beb206e22eaff.zip gcc-534ecb17516c5db7a96245ebb90beb206e22eaff.tar.gz gcc-534ecb17516c5db7a96245ebb90beb206e22eaff.tar.bz2 |
tree.c (build_vec_init_expr): Split out from...
* tree.c (build_vec_init_expr): Split out from...
(build_array_copy): ...here.
* init.c (perform_member_init): Use it.
* cp-tree.h: Declare it.
* cp-gimplify.c (cp_gimplify_init_expr): Don't gimplify the slot for
VEC_INIT_EXPR and AGGR_INIT_EXPR here. Drop pre/post parameters.
(cp_gimplify_expr): Handle array default-initialization via
VEC_INIT_EXPR.
From-SVN: r165976
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r-- | gcc/cp/init.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 72fcf78..9c2afba 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -486,16 +486,23 @@ perform_member_init (tree member, tree init) } else if (TYPE_NEEDS_CONSTRUCTING (type)) { - if (init != NULL_TREE - && TREE_CODE (type) == ARRAY_TYPE - && TREE_CHAIN (init) == NULL_TREE - && TREE_CODE (TREE_TYPE (TREE_VALUE (init))) == ARRAY_TYPE) + if (TREE_CODE (type) == ARRAY_TYPE) { - /* Initialization of one array from another. */ - finish_expr_stmt (build_vec_init (decl, NULL_TREE, TREE_VALUE (init), - /*explicit_value_init_p=*/false, - /* from_array=*/1, - tf_warning_or_error)); + if (init) + { + gcc_assert (TREE_CHAIN (init) == NULL_TREE); + init = TREE_VALUE (init); + } + if (init == NULL_TREE + || same_type_ignoring_top_level_qualifiers_p (type, + TREE_TYPE (init))) + { + init = build_vec_init_expr (type, init); + init = build2 (INIT_EXPR, type, decl, init); + finish_expr_stmt (init); + } + else + error ("invalid initializer for array member %q#D", member); } else { |