diff options
author | Jason Merrill <jason@redhat.com> | 2011-09-24 22:26:08 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-09-24 22:26:08 -0400 |
commit | 6fd44881415e619bc3daaa47f3012bb39beab0c8 (patch) | |
tree | b327fbf614dfbb2f1e3840e506d35735750d4de5 /gcc/cp | |
parent | eb02633818a908b78e8fc0939be2e4774ed840c6 (diff) | |
download | gcc-6fd44881415e619bc3daaa47f3012bb39beab0c8.zip gcc-6fd44881415e619bc3daaa47f3012bb39beab0c8.tar.gz gcc-6fd44881415e619bc3daaa47f3012bb39beab0c8.tar.bz2 |
init.c (perform_member_init): Instantiate NSDMI here.
* init.c (perform_member_init): Instantiate NSDMI here.
* pt.c (tsubst_decl) [FIELD_DECL]: Not here.
From-SVN: r179157
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/init.c | 12 | ||||
-rw-r--r-- | gcc/cp/pt.c | 13 |
3 files changed, 22 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f1496b6..fc5436a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-09-24 Jason Merrill <jason@redhat.com> + * init.c (perform_member_init): Instantiate NSDMI here. + * pt.c (tsubst_decl) [FIELD_DECL]: Not here. + Handle deferred parsing of NSDMIs. * parser.h (cp_unparsed_functions_entry): Add nsdmis field. * parser.c (unparsed_nsdmis, cp_parser_save_nsdmi): New. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index f5904d5..f246286 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -496,7 +496,17 @@ perform_member_init (tree member, tree init) /* Use the non-static data member initializer if there was no mem-initializer for this field. */ if (init == NULL_TREE) - init = break_out_target_exprs (DECL_INITIAL (member)); + { + if (CLASSTYPE_TEMPLATE_INSTANTIATION (DECL_CONTEXT (member))) + /* Do deferred instantiation of the NSDMI. */ + init = (tsubst_copy_and_build + (DECL_INITIAL (member), + CLASSTYPE_TI_ARGS (DECL_CONTEXT (member)), + tf_warning_or_error, member, /*function_p=*/false, + /*integral_constant_expression_p=*/false)); + else + init = break_out_target_exprs (DECL_INITIAL (member)); + } /* Effective C++ rule 12 requires that all data members be initialized. */ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index af5ca5c..ebadebf 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10264,11 +10264,14 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) TREE_TYPE (r) = type; cp_apply_type_quals_to_decl (cp_type_quals (type), r); - /* DECL_INITIAL gives the number of bits in a bit-field. */ - DECL_INITIAL (r) - = tsubst_expr (DECL_INITIAL (t), args, - complain, in_decl, - /*integral_constant_expression_p=*/true); + if (DECL_C_BIT_FIELD (r)) + /* For bit-fields, DECL_INITIAL gives the number of bits. For + non-bit-fields DECL_INITIAL is a non-static data member + initializer, which gets deferred instantiation. */ + DECL_INITIAL (r) + = tsubst_expr (DECL_INITIAL (t), args, + complain, in_decl, + /*integral_constant_expression_p=*/true); /* We don't have to set DECL_CONTEXT here; it is set by finish_member_declaration. */ DECL_CHAIN (r) = NULL_TREE; |