]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Clear is_unbraced_* when parsing declaration_seq_opt [PR114917]
authorNathaniel Shead <nathanieloshead@gmail.com>
Thu, 2 May 2024 02:55:24 +0000 (12:55 +1000)
committerNathaniel Shead <nathanieloshead@gmail.com>
Thu, 2 May 2024 13:52:44 +0000 (23:52 +1000)
commit7317d62a1200dbd3685015e5d6b811497a27fe5f
treeb85d523902cb77ced9b47eb2e0983494ac29addf
parent67e66c973ce31e375caa9611b2db290fbfc1904d
c++: Clear is_unbraced_* when parsing declaration_seq_opt [PR114917]

Currently we incorrectly retain "in_unbraced_linkage_specification_p"
and "in_unbraced_export_declaration_p" when parsing a (braced)
declaration-seq.  This patch ensures that we clear these flags before
parsing the toplevel declarations.

Strictly speaking we don't need to save and restore the flags around the
parsing because there's currently no way to provide new declarations
within the unbraced context after the closing brace, but this patch does
it anyway in case this ever changes and for consistency with other
places that these flags are adjusted.

PR c++/114917

gcc/cp/ChangeLog:

* parser.cc (cp_parser_declaration_seq_opt): Clear
parser->in_unbraced_* flags when parsing toplevel declarations.

gcc/testsuite/ChangeLog:

* g++.dg/modules/export-5_a.C: New test.
* g++.dg/modules/export-5_b.C: New test.
* g++.dg/parse/linkage4.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
gcc/cp/parser.cc
gcc/testsuite/g++.dg/modules/export-5_a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/export-5_b.C [new file with mode: 0644]
gcc/testsuite/g++.dg/parse/linkage4.C [new file with mode: 0644]