summaryrefslogtreecommitdiff
path: root/gcc/cp/method.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2011-09-25 02:25:52 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2011-09-25 02:25:52 +0000
commitd9c249a43e1f66197c141a37300fe3ee2289bf13 (patch)
treee73c67449ead609eb0ffca593088981be94efd13 /gcc/cp/method.c
parent8cdaae17e0eb6b765a53b55c9f1eee2a84541652 (diff)
downloadgcc-d9c249a43e1f66197c141a37300fe3ee2289bf13.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179155 138bc75d-0d04-0410-961f-82ee72b054a4
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 88bb2a9ef21..734c23b0d6c 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;