]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Fix error recovery in cp_hide_range_decl [PR122465]
authorJakub Jelinek <jakub@redhat.com>
Sun, 30 Nov 2025 14:52:27 +0000 (15:52 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sun, 30 Nov 2025 14:52:27 +0000 (15:52 +0100)
commitd3f638f4dfe67f50ba298890258ef6466705f0fa
tree3214da66e6b74bb98ac800abcca8c5ee6c018993
parent65a3849eb46df2fbac6b41ff78dae13c85387f9e
c++: Fix error recovery in cp_hide_range_decl [PR122465]

The following testcase shows that range_decl in cp_hide_range_decl is
sometimes also NULL_TREE and not just error_mark_node, and the function
IMHO should treat both the same, not try to hide anything in that case
because it doesn't know what should be hidden.  This ICEs during
error recovery since something like cp_hide_range_decl has been introduced
(earlier it wasn't called that way).

The fix tweaks cp_parser_simple_declaration, such that it stores error_mark_node
instead of NULL_TREE into *maybe_range_for_decl in the erroneous cases.

2025-11-30  Jakub Jelinek  <jakub@redhat.com>

PR c++/122465
* parser.cc (cp_parser_simple_declaration): Adjust function comment.
Set *maybe_range_for_decl to error_mark_node instead of keeping it
NULL_TREE in error cases or when followed by CPP_COLON.

* g++.dg/cpp0x/pr122465.C: New test.
gcc/cp/parser.cc
gcc/testsuite/g++.dg/cpp0x/pr122465.C [new file with mode: 0644]