diff options
author | Jason Merrill <jason@redhat.com> | 2011-09-24 22:25:52 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-09-24 22:25:52 -0400 |
commit | 0e5f8a598de1c8dc44fb59c6d0ea0dcd557f695a (patch) | |
tree | e73c67449ead609eb0ffca593088981be94efd13 /gcc/cp/decl2.c | |
parent | 77236534b98427544513ef4c159cbabdb333efd0 (diff) | |
download | gcc-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/decl2.c')
-rw-r--r-- | gcc/cp/decl2.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 68e9b9b..1e06280 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -795,7 +795,7 @@ grokfield (const cp_declarator *declarator, { tree value; const char *asmspec = 0; - int flags = LOOKUP_ONLYCONVERTING; + int flags; tree name; if (init @@ -919,9 +919,10 @@ grokfield (const cp_declarator *declarator, value); } } - else if (pedantic && TREE_CODE (value) != VAR_DECL) - /* Already complained in grokdeclarator. */ - init = NULL_TREE; + else if (TREE_CODE (value) == FIELD_DECL) + /* C++11 NSDMI, keep going. */; + else if (TREE_CODE (value) != VAR_DECL) + gcc_unreachable (); else if (!processing_template_decl) { if (TREE_CODE (init) == CONSTRUCTOR) @@ -955,6 +956,12 @@ grokfield (const cp_declarator *declarator, if (attrlist) cplus_decl_attributes (&value, attrlist, 0); + if (init && BRACE_ENCLOSED_INITIALIZER_P (init) + && CONSTRUCTOR_IS_DIRECT_INIT (init)) + flags = LOOKUP_NORMAL; + else + flags = LOOKUP_IMPLICIT; + switch (TREE_CODE (value)) { case VAR_DECL: @@ -969,7 +976,6 @@ grokfield (const cp_declarator *declarator, init = error_mark_node; cp_finish_decl (value, init, /*init_const_expr_p=*/false, NULL_TREE, flags); - DECL_INITIAL (value) = init; DECL_IN_AGGR_P (value) = 1; return value; |