aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/method.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-10-14 15:12:45 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-10-14 15:12:45 -0400
commit37d8632b512e4b4b04aea3f951f52af8bd440bfe (patch)
treebec75e49be0d594387c1a64a48851279bbe40227 /gcc/cp/method.c
parentc3646b46fadff29620b2f188b9f566c95d40c580 (diff)
downloadgcc-37d8632b512e4b4b04aea3f951f52af8bd440bfe.zip
gcc-37d8632b512e4b4b04aea3f951f52af8bd440bfe.tar.gz
gcc-37d8632b512e4b4b04aea3f951f52af8bd440bfe.tar.bz2
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
Diffstat (limited to 'gcc/cp/method.c')
-rw-r--r--gcc/cp/method.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index f4a3ea6..0718f47 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -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. */