diff options
author | Jason Merrill <jason@redhat.com> | 2021-09-13 16:45:42 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2021-09-15 00:05:33 -0400 |
commit | f53a89fe722958d29fded71b444ff0f09b57b2c4 (patch) | |
tree | 3c6d701c78b6be00ddfbcc9694a04cf93ad6288e /gcc/cp/parser.c | |
parent | 4633d623d7c112a8e239b84b2d85caaef02d316c (diff) | |
download | gcc-f53a89fe722958d29fded71b444ff0f09b57b2c4.zip gcc-f53a89fe722958d29fded71b444ff0f09b57b2c4.tar.gz gcc-f53a89fe722958d29fded71b444ff0f09b57b2c4.tar.bz2 |
c++: tweak C++20 destructor template-id rule
While working on a larger change to destructor lookup I noticed that this
rule talks about declarators, but we weren't limiting the error to the case
where we're parsing a declarator. I don't know if this actually broke
anything, since a CPP_TEMPLATE_ID would have to have been parsed once
before, but it's more correct this way.
gcc/cp/ChangeLog:
* parser.c (cp_parser_unqualified_id): Only complain about ~A<T> in
a declarator.
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index e44c5c6..ab1dc81 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -6379,7 +6379,8 @@ cp_parser_unqualified_id (cp_parser* parser, /* DR 2237 (C++20 only): A simple-template-id is no longer valid as the declarator-id of a constructor or destructor. */ - if (token->type == CPP_TEMPLATE_ID && cxx_dialect >= cxx20) + if (token->type == CPP_TEMPLATE_ID && declarator_p + && cxx_dialect >= cxx20) { if (!cp_parser_simulate_error (parser)) error_at (tilde_loc, "template-id not allowed for destructor"); |