mirror of git://gcc.gnu.org/git/gcc.git
PR c++/85618 - ICE with initialized VLA.
* tree.c (vla_type_p): New. * typeck2.c (store_init_value, split_nonconstant_init_1): Check it rather than array_of_runtime_bound_p. From-SVN: r260012
This commit is contained in:
parent
b83f5981c1
commit
1d473b8b9d
|
|
@ -1,3 +1,10 @@
|
|||
2018-05-07 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/85618 - ICE with initialized VLA.
|
||||
* tree.c (vla_type_p): New.
|
||||
* typeck2.c (store_init_value, split_nonconstant_init_1): Check it
|
||||
rather than array_of_runtime_bound_p.
|
||||
|
||||
2018-05-05 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* cvt.c (ocp_convert): Early handle the special case of a
|
||||
|
|
|
|||
|
|
@ -7097,6 +7097,7 @@ extern tree get_target_expr_sfinae (tree, tsubst_flags_t);
|
|||
extern tree build_cplus_array_type (tree, tree);
|
||||
extern tree build_array_of_n_type (tree, int);
|
||||
extern bool array_of_runtime_bound_p (tree);
|
||||
extern bool vla_type_p (tree);
|
||||
extern tree build_array_copy (tree);
|
||||
extern tree build_vec_init_expr (tree, tree, tsubst_flags_t);
|
||||
extern void diagnose_non_constexpr_vec_init (tree);
|
||||
|
|
|
|||
|
|
@ -1051,8 +1051,10 @@ build_array_of_n_type (tree elt, int n)
|
|||
return build_cplus_array_type (elt, build_index_type (size_int (n - 1)));
|
||||
}
|
||||
|
||||
/* True iff T is an N3639 array of runtime bound (VLA). These were
|
||||
approved for C++14 but then removed. */
|
||||
/* True iff T is an N3639 array of runtime bound (VLA). These were approved
|
||||
for C++14 but then removed. This should only be used for N3639
|
||||
specifically; code wondering more generally if something is a VLA should use
|
||||
vla_type_p. */
|
||||
|
||||
bool
|
||||
array_of_runtime_bound_p (tree t)
|
||||
|
|
@ -1069,6 +1071,23 @@ array_of_runtime_bound_p (tree t)
|
|||
|| (!value_dependent_expression_p (max) && !TREE_CONSTANT (max)));
|
||||
}
|
||||
|
||||
/* True iff T is a variable length array. */
|
||||
|
||||
bool
|
||||
vla_type_p (tree t)
|
||||
{
|
||||
for (; t && TREE_CODE (t) == ARRAY_TYPE;
|
||||
t = TREE_TYPE (t))
|
||||
if (tree dom = TYPE_DOMAIN (t))
|
||||
{
|
||||
tree max = TYPE_MAX_VALUE (dom);
|
||||
if (!potential_rvalue_constant_expression (max)
|
||||
|| (!value_dependent_expression_p (max) && !TREE_CONSTANT (max)))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Return a reference type node referring to TO_TYPE. If RVAL is
|
||||
true, return an rvalue reference type, otherwise return an lvalue
|
||||
reference type. If a type node exists, reuse it, otherwise create
|
||||
|
|
|
|||
|
|
@ -611,7 +611,7 @@ split_nonconstant_init_1 (tree dest, tree init)
|
|||
array_type_p = true;
|
||||
if ((TREE_SIDE_EFFECTS (init)
|
||||
&& TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type))
|
||||
|| array_of_runtime_bound_p (type))
|
||||
|| vla_type_p (type))
|
||||
{
|
||||
/* For an array, we only need/want a single cleanup region rather
|
||||
than one per element. */
|
||||
|
|
@ -861,7 +861,7 @@ store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags)
|
|||
will perform the dynamic initialization. */
|
||||
if (value != error_mark_node
|
||||
&& (TREE_SIDE_EFFECTS (value)
|
||||
|| array_of_runtime_bound_p (type)
|
||||
|| vla_type_p (type)
|
||||
|| ! reduced_constant_expression_p (value)))
|
||||
return split_nonconstant_init (decl, value);
|
||||
/* If the value is a constant, just put it in DECL_INITIAL. If DECL
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
// PR c++/85618
|
||||
// { dg-additional-options "-Wno-vla" }
|
||||
|
||||
void function(int size) {
|
||||
bool myArray[size][size] = {};
|
||||
}
|
||||
Loading…
Reference in New Issue