Thread View: gmane.comp.gcc.patches
4 messages
4 total messages
Started by Adam Butcher
Wed, 19 Mar 2014 02:46
[PATCH] Fix PR c++/60573
Author: Adam Butcher
Date: Wed, 19 Mar 2014 02:46
Date: Wed, 19 Mar 2014 02:46
65 lines
2183 bytes
2183 bytes
PR c++/60573 * parser.c (synthesize_implicit_template_parm): Handle the fact that nested class member declarations erroneously appearing in an enclosing class contain an addition scope level for the class being defined. PR c++/60573 * g++.dg/cpp1y/pr60573.C: New testcase. --- gcc/cp/parser.c | 18 ++++++++++++++++-- gcc/testsuite/g++.dg/cpp1y/pr60573.C | 13 +++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr60573.C diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 46e2453..36872c9 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -32006,9 +32006,23 @@ synthesize_implicit_template_parm (cp_parser *parser) must be injected in the scope of 'B', just beyond the scope of 'A' introduced by 'A::'. */ - while (scope->kind == sk_class - && !TYPE_BEING_DEFINED (scope->this_entity)) + while (scope->kind == sk_class) { + /* In valid cases where the class being defined is reached, we're + at the point where the template argument list should be + injected for a generic member function. In the erroneous case + of generic member function of a nested class being declared in + the enclosing class, an additional class scope for the + enclosing class has been pushed by push_nested_class via + push_scope in cp_parser_direct_declarator. This additional + scope needs to be skipped to reach the class definition scope + where the template argument list should be injected. */ + + if (TYPE_BEING_DEFINED (scope->this_entity)) + if (scope->level_chain == 0 + || scope->this_entity != scope->level_chain->this_entity) + break; + parent_scope = scope; scope = scope->level_chain; } diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60573.C b/gcc/testsuite/g++.dg/cpp1y/pr60573.C new file mode 100644 index 0000000..7f56ff4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr60573.C @@ -0,0 +1,13 @@ +// PR c++/60573 +// { dg-do compile { target c++1y } } +// { dg-options "" } + +struct A +{ + struct B + { + void foo(auto); + }; + + void B::foo(auto) {} // { dg-error "cannot define" } +}; -- 1.9.0
Re: [PATCH] Fix PR c++/60573
Author: Jason Merrill
Date: Mon, 24 Mar 2014 13:23
Date: Mon, 24 Mar 2014 13:23
8 lines
213 bytes
213 bytes
On 03/18/2014 10:46 PM, Adam Butcher wrote: > - while (scope->kind == sk_class > - && !TYPE_BEING_DEFINED (scope->this_entity)) Does it work to just change TYPE_BEING_DEFINED to currently_open_class? Jason
Re: [PATCH] Fix PR c++/60573
Author: Adam Butcher
Date: Mon, 24 Mar 2014 20:13
Date: Mon, 24 Mar 2014 20:13
16 lines
630 bytes
630 bytes
On 2014-03-24 17:23, Jason Merrill wrote: > On 03/18/2014 10:46 PM, Adam Butcher wrote: >> - while (scope->kind == sk_class >> - && !TYPE_BEING_DEFINED (scope->this_entity)) > > Does it work to just change TYPE_BEING_DEFINED to > currently_open_class? > No. The object referred to by 'scope->this_entity' is the same for each of the two levels, so unless there's something else I can pass to 'currently_open_class', the result will be equivalent; the issue is that the class being referred to *is* being defined, but I need to skip over the second class-scope for that type to arrive at the defining scope level. Adam
Re: [PATCH] Fix PR c++/60573
Author: Jason Merrill
Date: Tue, 25 Mar 2014 11:48
Date: Tue, 25 Mar 2014 11:48
13 lines
502 bytes
502 bytes
On 03/18/2014 10:46 PM, Adam Butcher wrote: > + if (TYPE_BEING_DEFINED (scope->this_entity)) > + if (scope->level_chain == 0 > + || scope->this_entity != scope->level_chain->this_entity) > + break; I don't think this is an adequate test; if you have another class wrapping B, you'll have two levels of context pushed for the declarator, so the this_entities will compare unequal. I think we need some way to designate a scope that actually corresponds to a class-specifier. Jason
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads