On 2/3/24 10:24, Marek Polacek wrote:
Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
I'm not certain OPT_Wc__20_extensions is the best thing for something
from [diff.cpp17]; would you prefer something else?
I think it wants its own flag, that is enabled in C++20 or by
-Wc++20-compat.
+ if (cxx_dialect >= cxx20)
+ {
+ if (!cp_parser_simulate_error (parser))
+ pedwarn (tilde_loc, OPT_Wc__20_extensions,
+ "template-id not allowed for destructor");
+ return error_mark_node;
+ }
+ warning_at (tilde_loc, OPT_Wc__20_compat,
+ "template-id not allowed for destructor in C++20");
After a pedwarn we should accept the code, not return error_mark_node.
I'm also concerned about pedwarn/warnings not guarded by
!cp_parser_uncommited_to_tentative_parse; that often leads to warning
about a tentative parse as a declaration that is eventually abandoned in
favor of a perfectly fine parse as an expression.
It would be good for cp_parser_context to add a vec of warnings to emit
at cp_parser_parse_definitely time, and then
cp_parser_pedwarn/cp_parser_warning to fill it...
Jason