diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2013-11-14 20:16:51 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2013-11-14 20:16:51 +0000 |
commit | 4699e99ae8aae2dcb12b84d7d9516a08f5c8dc8a (patch) | |
tree | 6d59cdf20f8923f0d77ccbba3fdef079f1e2533b /gcc | |
parent | 03a231f7521b62a593fd7a4ce7067102288bd28f (diff) | |
download | gcc-4699e99ae8aae2dcb12b84d7d9516a08f5c8dc8a.zip gcc-4699e99ae8aae2dcb12b84d7d9516a08f5c8dc8a.tar.gz gcc-4699e99ae8aae2dcb12b84d7d9516a08f5c8dc8a.tar.bz2 |
re PR c++/57887 (nested non-type template parameters not declared in this scope)
/cp
2013-11-14 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/57887
* parser.c (cp_parser_late_parsing_nsdmi): Call
maybe_begin_member_template_processing.
* pt.c (maybe_begin_member_template_processing): Handle NSDMIs.
(inline_needs_template_parms): Adjust.
/testsuite
2013-11-14 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/57887
* g++.dg/cpp0x/nsdmi-template3.C: New.
* g++.dg/cpp0x/nsdmi-template4.C: Likewise.
From-SVN: r204818
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/parser.c | 4 | ||||
-rw-r--r-- | gcc/cp/pt.c | 19 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/nsdmi-template3.C | 16 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/nsdmi-template4.C | 24 |
6 files changed, 71 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 54e424f..b252637 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2013-11-14 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/57887 + * parser.c (cp_parser_late_parsing_nsdmi): Call + maybe_begin_member_template_processing. + * pt.c (maybe_begin_member_template_processing): Handle NSDMIs. + (inline_needs_template_parms): Adjust. + 2013-11-14 Andrew MacLeod <amacleod@redhat.com> * class.c: Include only gimplify.h and gimple.h as needed. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index eaad8e4..ab33257 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -23378,12 +23378,16 @@ cp_parser_late_parsing_nsdmi (cp_parser *parser, tree field) { tree def; + maybe_begin_member_template_processing (field); + push_unparsed_function_queues (parser); def = cp_parser_late_parse_one_default_arg (parser, field, DECL_INITIAL (field), NULL_TREE); pop_unparsed_function_queues (parser); + maybe_end_member_template_processing (); + DECL_INITIAL (field) = def; } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index b80591d..e714e79 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -152,7 +152,7 @@ static int for_each_template_parm (tree, tree_fn_t, void*, struct pointer_set_t*, bool); static tree expand_template_argument_pack (tree); static tree build_template_parm_index (int, int, int, tree, tree); -static bool inline_needs_template_parms (tree); +static bool inline_needs_template_parms (tree, bool); static void push_inline_template_parms_recursive (tree, int); static tree retrieve_local_specialization (tree); static void register_local_specialization (tree, tree); @@ -378,9 +378,9 @@ template_class_depth (tree type) Returns true if processing DECL needs us to push template parms. */ static bool -inline_needs_template_parms (tree decl) +inline_needs_template_parms (tree decl, bool nsdmi) { - if (! DECL_TEMPLATE_INFO (decl)) + if (!decl || (!nsdmi && ! DECL_TEMPLATE_INFO (decl))) return false; return (TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (most_general_template (decl))) @@ -449,16 +449,23 @@ push_inline_template_parms_recursive (tree parmlist, int levels) } } -/* Restore the template parameter context for a member template or - a friend template defined in a class definition. */ +/* Restore the template parameter context for a member template, a + friend template defined in a class definition, or a non-template + member of template class. */ void maybe_begin_member_template_processing (tree decl) { tree parms; int levels = 0; + bool nsdmi = TREE_CODE (decl) == FIELD_DECL; - if (inline_needs_template_parms (decl)) + if (nsdmi) + decl = (CLASSTYPE_TEMPLATE_INFO (DECL_CONTEXT (decl)) + ? CLASSTYPE_TI_TEMPLATE (DECL_CONTEXT (decl)) + : NULL_TREE); + + if (inline_needs_template_parms (decl, nsdmi)) { parms = DECL_TEMPLATE_PARMS (most_general_template (decl)); levels = TMPL_PARMS_DEPTH (parms) - processing_template_decl; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dd787dd..2077304 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2013-11-14 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/57887 + * g++.dg/cpp0x/nsdmi-template3.C: New. + * g++.dg/cpp0x/nsdmi-template4.C: Likewise. + 2013-11-14 Ulrich Weigand <Ulrich.Weigand@de.ibm.com> * gcc.target/powerpc/ppc64-abi-1.c (stack_frame_t): Remove diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-template3.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template3.C new file mode 100644 index 0000000..8a6f913 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template3.C @@ -0,0 +1,16 @@ +// PR c++/58760 +// { dg-do compile { target c++11 } } + +enum en +{ + a,b,c +}; + +struct B +{ + template<en N> + struct A + { + const int X = N; + }; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-template4.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template4.C new file mode 100644 index 0000000..ff8dc7e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template4.C @@ -0,0 +1,24 @@ +// PR c++/57887 +// { dg-do compile { target c++11 } } + +struct B +{ + template<int N> + struct A + { + int X = N; + }; +}; + +template<int M> +struct C +{ + int Y = M; + + template<int N> + struct A + { + int X = N; + int Y = M; + }; +}; |