mirror of git://gcc.gnu.org/git/gcc.git
A partially initialized variable isn't constant.
* constexpr.c (reduced_constant_expression_p): If CONSTRUCTOR_NO_IMPLICIT_ZERO, check that all fields are initialized. From-SVN: r251948
This commit is contained in:
parent
84284f0264
commit
7368cfa498
|
|
@ -1,3 +1,8 @@
|
||||||
|
2017-09-09 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
* constexpr.c (reduced_constant_expression_p): If
|
||||||
|
CONSTRUCTOR_NO_IMPLICIT_ZERO, check that all fields are initialized.
|
||||||
|
|
||||||
2017-09-09 Eric Botcazou <ebotcazou@adacore.com>
|
2017-09-09 Eric Botcazou <ebotcazou@adacore.com>
|
||||||
|
|
||||||
PR bootstrap/81926
|
PR bootstrap/81926
|
||||||
|
|
|
||||||
|
|
@ -1732,15 +1732,30 @@ reduced_constant_expression_p (tree t)
|
||||||
|
|
||||||
case CONSTRUCTOR:
|
case CONSTRUCTOR:
|
||||||
/* And we need to handle PTRMEM_CST wrapped in a CONSTRUCTOR. */
|
/* And we need to handle PTRMEM_CST wrapped in a CONSTRUCTOR. */
|
||||||
tree elt; unsigned HOST_WIDE_INT idx;
|
tree idx, val, field; unsigned HOST_WIDE_INT i;
|
||||||
FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (t), idx, elt)
|
if (CONSTRUCTOR_NO_IMPLICIT_ZERO (t))
|
||||||
|
field = next_initializable_field (TYPE_FIELDS (TREE_TYPE (t)));
|
||||||
|
else
|
||||||
|
field = NULL_TREE;
|
||||||
|
FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t), i, idx, val)
|
||||||
{
|
{
|
||||||
if (!elt)
|
if (!val)
|
||||||
/* We're in the middle of initializing this element. */
|
/* We're in the middle of initializing this element. */
|
||||||
return false;
|
return false;
|
||||||
if (!reduced_constant_expression_p (elt))
|
if (!reduced_constant_expression_p (val))
|
||||||
return false;
|
return false;
|
||||||
|
if (field)
|
||||||
|
{
|
||||||
|
if (idx != field)
|
||||||
|
return false;
|
||||||
|
field = next_initializable_field (DECL_CHAIN (field));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (field)
|
||||||
|
return false;
|
||||||
|
else if (CONSTRUCTOR_NO_IMPLICIT_ZERO (t))
|
||||||
|
/* All the fields are initialized. */
|
||||||
|
CONSTRUCTOR_NO_IMPLICIT_ZERO (t) = false;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue