mirror of git://gcc.gnu.org/git/gcc.git
PR c++/72457 - ICE with list-value-initialized base.
* init.c (expand_aggr_init_1): Only handle value-init of bases. * constexpr.c (build_data_member_initialization): Handle multiple initializers for the same field. From-SVN: r238867
This commit is contained in:
parent
c63b1732d5
commit
49b5925f02
|
|
@ -1,3 +1,10 @@
|
||||||
|
2016-07-29 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
PR c++/72457
|
||||||
|
* init.c (expand_aggr_init_1): Only handle value-init of bases.
|
||||||
|
* constexpr.c (build_data_member_initialization): Handle multiple
|
||||||
|
initializers for the same field.
|
||||||
|
|
||||||
2016-07-28 Paolo Carlini <paolo.carlini@oracle.com>
|
2016-07-28 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
PR c++/71665
|
PR c++/71665
|
||||||
|
|
|
||||||
|
|
@ -391,6 +391,11 @@ build_data_member_initialization (tree t, vec<constructor_elt, va_gc> **vec)
|
||||||
gcc_assert (TREE_TYPE (member) == vtbl_ptr_type_node);
|
gcc_assert (TREE_TYPE (member) == vtbl_ptr_type_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Value-initialization can produce multiple initializers for the
|
||||||
|
same field; use the last one. */
|
||||||
|
if (!vec_safe_is_empty (*vec) && (*vec)->last().index == member)
|
||||||
|
(*vec)->last().value = init;
|
||||||
|
else
|
||||||
CONSTRUCTOR_APPEND_ELT (*vec, member, init);
|
CONSTRUCTOR_APPEND_ELT (*vec, member, init);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1818,9 +1818,9 @@ expand_aggr_init_1 (tree binfo, tree true_exp, tree exp, tree init, int flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* List-initialization from {} becomes value-initialization for non-aggregate
|
/* List-initialization from {} becomes value-initialization for non-aggregate
|
||||||
classes with default constructors. Handle this here so protected access
|
classes with default constructors. Handle this here when we're
|
||||||
works. */
|
initializing a base, so protected access works. */
|
||||||
if (init && TREE_CODE (init) == TREE_LIST)
|
if (exp != true_exp && init && TREE_CODE (init) == TREE_LIST)
|
||||||
{
|
{
|
||||||
tree elt = TREE_VALUE (init);
|
tree elt = TREE_VALUE (init);
|
||||||
if (DIRECT_LIST_INIT_P (elt)
|
if (DIRECT_LIST_INIT_P (elt)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
// PR c++/72457
|
||||||
|
// { dg-do compile { target c++11 } }
|
||||||
|
|
||||||
|
struct A {
|
||||||
|
int i;
|
||||||
|
constexpr A(): i(0) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct B: A { };
|
||||||
|
|
||||||
|
struct C
|
||||||
|
{
|
||||||
|
B b;
|
||||||
|
constexpr C() : b{} {}
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue