diff options
author | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-06-16 01:59:55 +0000 |
---|---|---|
committer | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-06-16 01:59:55 +0000 |
commit | 6e3ecd30740d9f0203bb2f368ebdde03c6a85317 (patch) | |
tree | 732badca01be7ddf1363610c4db6dd06853b9c15 /gcc/cp/init.c | |
parent | d94396a5fafa53769265592d5a102889402fa8a3 (diff) | |
download | gcc-6e3ecd30740d9f0203bb2f368ebdde03c6a85317.tar.gz |
cp/
PR c++/58583
* cp-tree.h (DECL_INSTANTIATING_NSDMI_P): New.
* init.c (get_nsdmi): Check for DEFAULT_ARG in template case and
protect it from recursive instantiation.
testsuite/
PR c++/58583
* g++.dg/cpp0x/nsdmi-template14.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224502 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r-- | gcc/cp/init.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c index ef4f0ff65d3..aa964b9e8e3 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -541,6 +541,7 @@ get_nsdmi (tree member, bool in_ctor) tree init; tree save_ccp = current_class_ptr; tree save_ccr = current_class_ref; + if (!in_ctor) { /* Use a PLACEHOLDER_EXPR when we don't have a 'this' parameter to @@ -548,22 +549,40 @@ get_nsdmi (tree member, bool in_ctor) current_class_ref = build0 (PLACEHOLDER_EXPR, DECL_CONTEXT (member)); current_class_ptr = build_address (current_class_ref); } + if (DECL_LANG_SPECIFIC (member) && DECL_TEMPLATE_INFO (member)) { - /* Do deferred instantiation of the NSDMI. */ - init = (tsubst_copy_and_build - (DECL_INITIAL (DECL_TI_TEMPLATE (member)), - DECL_TI_ARGS (member), - tf_warning_or_error, member, /*function_p=*/false, - /*integral_constant_expression_p=*/false)); - - init = digest_nsdmi_init (member, init); + init = DECL_INITIAL (DECL_TI_TEMPLATE (member)); + if (TREE_CODE (init) == DEFAULT_ARG) + goto unparsed; + + /* Check recursive instantiation. */ + if (DECL_INSTANTIATING_NSDMI_P (member)) + { + error ("recursive instantiation of non-static data member " + "initializer for %qD", member); + init = error_mark_node; + } + else + { + DECL_INSTANTIATING_NSDMI_P (member) = 1; + + /* Do deferred instantiation of the NSDMI. */ + init = (tsubst_copy_and_build + (init, DECL_TI_ARGS (member), + tf_warning_or_error, member, /*function_p=*/false, + /*integral_constant_expression_p=*/false)); + init = digest_nsdmi_init (member, init); + + DECL_INSTANTIATING_NSDMI_P (member) = 0; + } } else { init = DECL_INITIAL (member); if (init && TREE_CODE (init) == DEFAULT_ARG) { + unparsed: error ("constructor required before non-static data member " "for %qD has been parsed", member); DECL_INITIAL (member) = error_mark_node; |