On 2/8/24 16:26, Marek Polacek wrote:
This patch does *not* fix
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202#c8>
where the C++20 diagnostic is missing altogether.
What would it take to fix that as well?
* doc/invoke.texi: Document -Wdeprecated-template-id-cdtor.
Was it ever deprecated? I'm not seeing that in
https://timsong-cpp.github.io/cppwp/n4659/#depr (C++17)
Let's drop the word "deprecated" from the option name and documentation.
@@ -32331,11 +32338,11 @@ cp_parser_constructor_declarator_p (cp_parser
*parser, cp_parser_flags flags,
if (next_token->type != CPP_NAME
&& next_token->type != CPP_SCOPE
&& next_token->type != CPP_NESTED_NAME_SPECIFIER
- /* DR 2237 (C++20 only): A simple-template-id is no longer valid as the
- declarator-id of a constructor or destructor. */
- && (next_token->type != CPP_TEMPLATE_ID || cxx_dialect >= cxx20))
+ && next_token->type != CPP_TEMPLATE_ID)
return false;
+ const bool saw_template_id = (next_token->type == CPP_TEMPLATE_ID);
Please incorporate your "further DR2237 fix" patch into this one.
@@ -32552,6 +32559,19 @@ cp_parser_constructor_declarator_p (cp_parser *parser,
cp_parser_flags flags,
/* We did not really want to consume any tokens. */
cp_parser_abort_tentative_parse (parser);
+ /* DR 2237 (C++20 only): A simple-template-id is no longer valid as the
+ declarator-id of a constructor or destructor. */
+ if (constructor_p && saw_template_id)
+ {
+ gcc_checking_assert
+ (!cp_parser_uncommitted_to_tentative_parse_p (parser));
Now I see the abort_ just above, so this seems unnecessary after all.
Thanks,
Jason