]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Fix ICE with delayed parsing of noexcept-specifier [PR95562]
authorMarek Polacek <polacek@redhat.com>
Wed, 10 Jun 2020 14:49:08 +0000 (10:49 -0400)
committerMarek Polacek <polacek@redhat.com>
Wed, 10 Jun 2020 15:33:24 +0000 (11:33 -0400)
commit977a173c196dc5ba5ac2e1b890083beb0451cf60
tree5fa83e0eef464c2873fa63fc4c83291423baeccf
parentcc00eb0af30ab3281d4dbade9f2c1b3a4b63f99f
c++: Fix ICE with delayed parsing of noexcept-specifier [PR95562]

Here we ICE because a DEFERRED_PARSE expression leaked to tsubst_copy.
We create these expressions for deferred noexcept-specifiers in
cp_parser_save_noexcept; they are supposed to be re-parsed in
cp_parser_late_noexcept_specifier.  In this case we never got around
to re-parsing it because the noexcept-specifier was attached to a
pointer to a function, not to a function declaration.  But we should
not have delayed the parsing here in the first place; we already
avoid delaying the parsing for alias-decls, typedefs, and friend
function declarations.  (Clang++ also doesn't delay the parsing
for pointers to function.)

gcc/cp/ChangeLog:

PR c++/95562
* parser.c (cp_parser_direct_declarator): Clear
CP_PARSER_FLAGS_DELAY_NOEXCEPT if the declarator kind is not
cdk_id.

gcc/testsuite/ChangeLog:

PR c++/95562
* g++.dg/cpp0x/noexcept60.C: New test.
gcc/cp/parser.c
gcc/testsuite/g++.dg/cpp0x/noexcept60.C [new file with mode: 0644]