From: jason Date: Thu, 21 Mar 2013 03:25:42 +0000 (+0000) Subject: PR c++/56646 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5ec09d0d310564acd5cad00ef1a1b3b8f4c455bd;p=thirdparty%2Fgcc.git PR c++/56646 * parser.c (cp_parser_late_return_type_opt): Save and restore current_class_ptr/ref. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@196853 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 64a085c7fb5e..704583802e58 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2013-03-20 Jason Merrill + PR c++/56646 + * parser.c (cp_parser_late_return_type_opt): Save and restore + current_class_ptr/ref. + PR c++/54532 * expr.c (cplus_expand_constant): Do nothing if the class is incomplete. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 23fe3f302a0d..e04d3cea9e5c 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -17056,17 +17056,21 @@ cp_parser_late_return_type_opt (cp_parser* parser, cp_cv_quals quals) /* Consume the ->. */ cp_lexer_consume_token (parser->lexer); + tree save_ccp = current_class_ptr; + tree save_ccr = current_class_ref; if (quals >= 0) { /* DR 1207: 'this' is in scope in the trailing return type. */ - gcc_assert (current_class_ptr == NULL_TREE); inject_this_parameter (current_class_type, quals); } type = cp_parser_trailing_type_id (parser); if (quals >= 0) - current_class_ptr = current_class_ref = NULL_TREE; + { + current_class_ptr = save_ccp; + current_class_ref = save_ccr; + } return type; } diff --git a/gcc/testsuite/g++.dg/cpp0x/trailing9.C b/gcc/testsuite/g++.dg/cpp0x/trailing9.C new file mode 100644 index 000000000000..d7895b38e3ef --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/trailing9.C @@ -0,0 +1,12 @@ +// PR c++/56646 +// { dg-require-effective-target c++11 } + +struct A { + void f(); +}; + +void A::f() { + struct B { + auto g() -> void { } + }; +}