diff options
Diffstat (limited to 'gcc-4.9/gcc/cp/init.c')
-rw-r--r-- | gcc-4.9/gcc/cp/init.c | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/gcc-4.9/gcc/cp/init.c b/gcc-4.9/gcc/cp/init.c index ecb103a99..283843ae9 100644 --- a/gcc-4.9/gcc/cp/init.c +++ b/gcc-4.9/gcc/cp/init.c @@ -3565,19 +3565,11 @@ build_vec_init (tree base, tree maxindex, tree init, try_block = begin_try_block (); } - /* If the initializer is {}, then all elements are initialized from {}. - But for non-classes, that's the same as value-initialization. */ + bool empty_list = false; if (init && BRACE_ENCLOSED_INITIALIZER_P (init) && CONSTRUCTOR_NELTS (init) == 0) - { - if (CLASS_TYPE_P (type)) - /* Leave init alone. */; - else - { - init = NULL_TREE; - explicit_value_init_p = true; - } - } + /* Skip over the handling of non-empty init lists. */ + empty_list = true; /* Maybe pull out constant value when from_array? */ @@ -3697,14 +3689,8 @@ build_vec_init (tree base, tree maxindex, tree init, vec_free (new_vec); } - /* Any elements without explicit initializers get {}. */ - if (cxx_dialect >= cxx11 && AGGREGATE_TYPE_P (type)) - init = build_constructor (init_list_type_node, NULL); - else - { - init = NULL_TREE; - explicit_value_init_p = true; - } + /* Any elements without explicit initializers get T{}. */ + empty_list = true; } else if (from_array) { @@ -3750,6 +3736,26 @@ build_vec_init (tree base, tree maxindex, tree init, to = build1 (INDIRECT_REF, type, base); + /* If the initializer is {}, then all elements are initialized from T{}. + But for non-classes, that's the same as value-initialization. */ + if (empty_list) + { + if (cxx_dialect >= cxx11 && AGGREGATE_TYPE_P (type)) + { + if (BRACE_ENCLOSED_INITIALIZER_P (init) + && CONSTRUCTOR_NELTS (init) == 0) + /* Reuse it. */; + else + init = build_constructor (init_list_type_node, NULL); + CONSTRUCTOR_IS_DIRECT_INIT (init) = true; + } + else + { + init = NULL_TREE; + explicit_value_init_p = true; + } + } + if (from_array) { tree from; @@ -3854,6 +3860,13 @@ build_vec_init (tree base, tree maxindex, tree init, stmt_expr = finish_init_stmts (is_global, stmt_expr, compound_stmt); + current_stmt_tree ()->stmts_are_full_exprs_p = destroy_temps; + + if (errors) + return error_mark_node; + if (const_init) + return build2 (INIT_EXPR, atype, obase, const_init); + /* Now make the result have the correct type. */ if (TREE_CODE (atype) == ARRAY_TYPE) { @@ -3863,12 +3876,6 @@ build_vec_init (tree base, tree maxindex, tree init, TREE_NO_WARNING (stmt_expr) = 1; } - current_stmt_tree ()->stmts_are_full_exprs_p = destroy_temps; - - if (const_init) - return build2 (INIT_EXPR, atype, obase, const_init); - if (errors) - return error_mark_node; return stmt_expr; } |