re PR c++/38427 (crash for reference init code)
PR c++/38427 * init.c (perform_member_init): For value-initialized references call permerror instead of warning and don't emit any INIT_EXPR. * g++.dg/init/ctor9.C: New test. From-SVN: r142818
This commit is contained in:
parent
baafc53472
commit
0f737a30c0
|
@ -1,3 +1,10 @@
|
||||||
|
2008-12-18 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
PR c++/38427
|
||||||
|
* init.c (perform_member_init): For value-initialized
|
||||||
|
references call permerror instead of warning and don't emit any
|
||||||
|
INIT_EXPR.
|
||||||
|
|
||||||
2008-12-18 Jason Merrill <jason@redhat.com>
|
2008-12-18 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
PR c++/38485
|
PR c++/38485
|
||||||
|
|
|
@ -435,19 +435,25 @@ perform_member_init (tree member, tree init)
|
||||||
{
|
{
|
||||||
/* mem() means value-initialization. */
|
/* mem() means value-initialization. */
|
||||||
if (TREE_CODE (type) == ARRAY_TYPE)
|
if (TREE_CODE (type) == ARRAY_TYPE)
|
||||||
init = build_vec_init (decl, NULL_TREE, NULL_TREE,
|
{
|
||||||
/*explicit_value_init_p=*/true,
|
init = build_vec_init (decl, NULL_TREE, NULL_TREE,
|
||||||
/* from_array=*/0,
|
/*explicit_value_init_p=*/true,
|
||||||
tf_warning_or_error);
|
/* from_array=*/0,
|
||||||
|
tf_warning_or_error);
|
||||||
|
finish_expr_stmt (init);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (TREE_CODE (type) == REFERENCE_TYPE)
|
if (TREE_CODE (type) == REFERENCE_TYPE)
|
||||||
warning (0, "%Jdefault-initialization of %q#D, "
|
permerror (input_location, "%Jvalue-initialization of %q#D, "
|
||||||
"which has reference type",
|
"which has reference type",
|
||||||
current_function_decl, member);
|
current_function_decl, member);
|
||||||
init = build2 (INIT_EXPR, type, decl, build_value_init (type));
|
else
|
||||||
|
{
|
||||||
|
init = build2 (INIT_EXPR, type, decl, build_value_init (type));
|
||||||
|
finish_expr_stmt (init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finish_expr_stmt (init);
|
|
||||||
}
|
}
|
||||||
/* Deal with this here, as we will get confused if we try to call the
|
/* Deal with this here, as we will get confused if we try to call the
|
||||||
assignment op for an anonymous union. This can happen in a
|
assignment op for an anonymous union. This can happen in a
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2008-12-18 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
PR c++/38427
|
||||||
|
* g++.dg/init/ctor9.C: New test.
|
||||||
|
|
||||||
2008-12-18 Jason Merrill <jason@redhat.com>
|
2008-12-18 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
PR c++/38485
|
PR c++/38485
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
// PR c++/38427
|
||||||
|
// { dg-do compile }
|
||||||
|
|
||||||
|
struct S
|
||||||
|
{
|
||||||
|
int &ref;
|
||||||
|
S() : ref() {}; // { dg-error "value-initialization of" }
|
||||||
|
};
|
Loading…
Reference in New Issue