c++: Use of 'this' in parameter declaration [PR90748]
authorJason Merrill <jason@redhat.com>
Mon, 11 May 2020 19:39:44 +0000 (15:39 -0400)
committerJason Merrill <jason@redhat.com>
Mon, 11 May 2020 19:40:16 +0000 (15:40 -0400)
commitf981395c220c9afd73be138294946e085e64af78
tree03be94f1b7216f85b1fdebd157144d0f95685e5c
parent1422c2e4462c9b7c44aa035ac56af77565556181
c++: Use of 'this' in parameter declaration [PR90748]

We were incorrectly accepting the use of 'this' at parse time and then
crashing when we tried to instantiate it.  It is invalid because 'this' is
not in scope until after the function-cv-quals.  So let's hoist setting
current_class_ptr up from cp_parser_late_return_type_opt into
cp_parser_direct_declarator where it can work for noexcept as well.

gcc/cp/ChangeLog
2020-05-11  Jason Merrill  <jason@redhat.com>

PR c++/90748
* parser.c (inject_parm_decls): Set current_class_ptr here.
(cp_parser_direct_declarator): And here.
(cp_parser_late_return_type_opt): Not here.
(cp_parser_noexcept_specification_opt): Nor here.
(cp_parser_exception_specification_opt)
(cp_parser_late_noexcept_specifier): Remove unneeded parameters.
gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/g++.dg/cpp0x/noexcept59.C [new file with mode: 0644]