aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/method.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-09-24 22:25:52 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-09-24 22:25:52 -0400
commit0e5f8a598de1c8dc44fb59c6d0ea0dcd557f695a (patch)
treee73c67449ead609eb0ffca593088981be94efd13 /gcc/cp/method.c
parent77236534b98427544513ef4c159cbabdb333efd0 (diff)
downloadgcc-0e5f8a598de1c8dc44fb59c6d0ea0dcd557f695a.zip
gcc-0e5f8a598de1c8dc44fb59c6d0ea0dcd557f695a.tar.gz
gcc-0e5f8a598de1c8dc44fb59c6d0ea0dcd557f695a.tar.bz2
Implement C++11 non-static data member initializers.
* cp-tree.h (enum cpp_warn_str): Add CPP0X_NSDMI. * error.c (maybe_warn_cpp0x): Handle it. * call.c (convert_like_real) [ck_user]: Don't complain about using an explicit constructor for direct-initialization. * class.c (check_field_decl): Fix ancient typo. (check_field_decls): NSDMIs make the default ctor non-trivial. * decl.c (cp_finish_decl): Record NSDMI. (grokdeclarator): Allow NSDMI. * decl2.c (grokfield): Allow NSDMI. Correct LOOKUP flags. * init.c (perform_member_init): Use NSDMI. * method.c (walk_field_subobs): Check for NSDMI. * parser.c (cp_parser_member_declaration): Parse { } init. * semantics.c (register_constexpr_fundef): Don't talk about a return statement in a constexpr constructor. (cxx_eval_call_expression): Check DECL_INITIAL instead of DECL_SAVED_TREE. From-SVN: r179155
Diffstat (limited to 'gcc/cp/method.c')
-rw-r--r--gcc/cp/method.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 88bb2a9..734c23b 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -1036,10 +1036,20 @@ walk_field_subobs (tree fields, tree fnname, special_function_kind sfk,
if (bad && deleted_p)
*deleted_p = true;
+ if (DECL_INITIAL (field))
+ {
+ if (msg && DECL_INITIAL (field) == error_mark_node)
+ inform (0, "initializer for %q+#D is invalid", field);
+ if (trivial_p)
+ *trivial_p = false;
+
+ /* Don't do the normal processing. */
+ continue;
+ }
+
/* For an implicitly-defined default constructor to be constexpr,
- every member must have a user-provided default constructor. */
- /* FIXME will need adjustment for non-static data member
- initializers. */
+ every member must have a user-provided default constructor or
+ an explicit initializer. */
if (constexpr_p && !CLASS_TYPE_P (mem_type))
{
*constexpr_p = false;