re PR c++/50707 ([C++0x] Non-static const data member initializer breaks default constructor)

PR c++/50507
	* method.c (walk_field_subobs): Check for NSDMI before
	complaining about uninitialized fields.

From-SVN: r180002
This commit is contained in:
Jason Merrill 2011-10-14 15:12:45 -04:00 committed by Jason Merrill
parent c3646b46fa
commit 37d8632b51
4 changed files with 40 additions and 19 deletions

View File

@ -1,5 +1,9 @@
2011-10-14 Jason Merrill <jason@redhat.com>
PR c++/50507
* method.c (walk_field_subobs): Check for NSDMI before
complaining about uninitialized fields.
* pt.c (tsubst_decl) [FIELD_DECL]: Use void_zero_node
instead of error_mark_node as a placeholder.

View File

@ -1016,25 +1016,7 @@ walk_field_subobs (tree fields, tree fnname, special_function_kind sfk,
}
else if (sfk == sfk_constructor)
{
bool bad = true;
if (CP_TYPE_CONST_P (mem_type)
&& default_init_uninitialized_part (mem_type))
{
if (msg)
error ("uninitialized non-static const member %q#D",
field);
}
else if (TREE_CODE (mem_type) == REFERENCE_TYPE)
{
if (msg)
error ("uninitialized non-static reference member %q#D",
field);
}
else
bad = false;
if (bad && deleted_p)
*deleted_p = true;
bool bad;
if (DECL_INITIAL (field))
{
@ -1057,6 +1039,26 @@ walk_field_subobs (tree fields, tree fnname, special_function_kind sfk,
continue;
}
bad = false;
if (CP_TYPE_CONST_P (mem_type)
&& default_init_uninitialized_part (mem_type))
{
if (msg)
error ("uninitialized non-static const member %q#D",
field);
bad = true;
}
else if (TREE_CODE (mem_type) == REFERENCE_TYPE)
{
if (msg)
error ("uninitialized non-static reference member %q#D",
field);
bad = true;
}
if (bad && deleted_p)
*deleted_p = true;
/* For an implicitly-defined default constructor to be constexpr,
every member must have a user-provided default constructor or
an explicit initializer. */

View File

@ -1,3 +1,8 @@
2011-10-14 Jason Merrill <jason@redhat.com>
PR c++/50507
* g++.dg/cpp0x/nsdmi-const1.C: New.
2011-10-14 Janus Weil <janus@gcc.gnu.org>
PR fortran/50570

View File

@ -0,0 +1,10 @@
// PR c++/50707
// { dg-options -std=c++0x }
int g;
struct S {
int const v=g;
};
S s;