https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126024
Bug ID: 126024
Summary: ICE when parsing malformed template for statement
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: s.kimura.h41104 at gmail dot com
Target Milestone: ---
Compiler Explorer: https://godbolt.org/z/oMq9jvn7h
Reproducer(from
https://github.com/k-arrows/clang-assert-tests/blob/main/experimental/gcc/00044.cpp):
```
void foo() { template for (void bar()); }
```
Backtrace:
<source>: In function 'void foo()':
<source>:1:37: warning: declaration of 'void bar()' has 'extern' and is
initialized
1 | void foo() { template for (void bar()); }
| ^
<source>:1:38: error: expected ':' before ')' token
1 | void foo() { template for (void bar()); }
| ^
| :
<source>:1:38: internal compiler error: tree check: expected var_decl or
parm_decl or result_decl, have function_decl in cp_hide_range_decl, at
cp/parser.cc:15768
0x2a1f758 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x2a1439b internal_error(char const*, ...)
???:0
0xa34cd2 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
???:0
0xd89ca3 c_parse_file()
???:0
0xf1a489 c_common_parse_file()
???:0
This goes back to gcc-16:
https://godbolt.org/z/85Ehns8Kc