aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/tree.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2010-11-06 20:46:45 -0400
committerJason Merrill <jason@gcc.gnu.org>2010-11-06 20:46:45 -0400
commit4de2f020aaca3d0a8112acc6234a34bb5d578fa0 (patch)
tree45f9728915ac3c72a301c98db3b78300411445b1 /gcc/cp/tree.c
parentacd6cc816df8ceee71651b20fb028b00cb4a7e96 (diff)
downloadgcc-4de2f020aaca3d0a8112acc6234a34bb5d578fa0.zip
gcc-4de2f020aaca3d0a8112acc6234a34bb5d578fa0.tar.gz
gcc-4de2f020aaca3d0a8112acc6234a34bb5d578fa0.tar.bz2
init.c (perform_member_init): Use build_vec_init_expr for value-init of arrays, too.
* init.c (perform_member_init): Use build_vec_init_expr for value-init of arrays, too. * cp-gimplify.c (cp_gimplify_expr): Use VEC_INIT_EXPR_VALUE_INIT. * cp-tree.h (VEC_INIT_EXPR_IS_CONSTEXPR): New macro. (VEC_INIT_EXPR_VALUE_INIT): New macro. * semantics.c (potential_constant_expression): No longer static. Check VEC_INIT_EXPR_IS_CONSTEXPR. * tree.c (build_vec_init_expr): Handle value-init. Set VEC_INIT_EXPR_IS_CONSTEXPR and VEC_INIT_EXPR_VALUE_INIT. From-SVN: r166413
Diffstat (limited to 'gcc/cp/tree.c')
-rw-r--r--gcc/cp/tree.c50
1 files changed, 35 insertions, 15 deletions
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index d1d306e..5440e10 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -462,34 +462,54 @@ build_vec_init_expr (tree type, tree init)
{
tree slot;
tree inner_type = strip_array_types (type);
-
- gcc_assert (init == NULL_TREE
- || (same_type_ignoring_top_level_qualifiers_p
- (type, TREE_TYPE (init))));
+ tree elt_init = integer_zero_node;
+ bool value_init = false;
/* Since we're deferring building the actual constructor calls until
gimplification time, we need to build one now and throw it away so
that the relevant constructor gets mark_used before cgraph decides
what functions are needed. Here we assume that init is either
- NULL_TREE or another array to copy. */
- if (CLASS_TYPE_P (inner_type))
+ NULL_TREE, void_type_node (indicating value-initialization), or
+ another array to copy. */
+ if (init == void_type_node)
{
- VEC(tree,gc) *argvec = make_tree_vector ();
- if (init)
+ elt_init = build_value_init (inner_type, tf_warning_or_error);
+ value_init = true;
+ init = NULL_TREE;
+ }
+ else
+ {
+ gcc_assert (init == NULL_TREE
+ || (same_type_ignoring_top_level_qualifiers_p
+ (type, TREE_TYPE (init))));
+
+ if (CLASS_TYPE_P (inner_type))
{
- tree dummy = build_dummy_object (inner_type);
- if (!real_lvalue_p (init))
- dummy = move (dummy);
- VEC_quick_push (tree, argvec, dummy);
+ VEC(tree,gc) *argvec = make_tree_vector ();
+ if (init)
+ {
+ tree dummy = build_dummy_object (inner_type);
+ if (!real_lvalue_p (init))
+ dummy = move (dummy);
+ VEC_quick_push (tree, argvec, dummy);
+ }
+ elt_init
+ = build_special_member_call (NULL_TREE, complete_ctor_identifier,
+ &argvec, inner_type, LOOKUP_NORMAL,
+ tf_warning_or_error);
}
- build_special_member_call (NULL_TREE, complete_ctor_identifier,
- &argvec, inner_type, LOOKUP_NORMAL,
- tf_warning_or_error);
}
slot = build_local_temp (type);
init = build2 (VEC_INIT_EXPR, type, slot, init);
SET_EXPR_LOCATION (init, input_location);
+
+ if (current_function_decl
+ && DECL_DECLARED_CONSTEXPR_P (current_function_decl)
+ && potential_constant_expression (elt_init, tf_warning_or_error))
+ VEC_INIT_EXPR_IS_CONSTEXPR (init) = true;
+ VEC_INIT_EXPR_VALUE_INIT (init) = value_init;
+
init = build_target_expr (slot, init);
TARGET_EXPR_IMPLICIT_P (init) = 1;