]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: tweak C++20 destructor template-id rule
authorJason Merrill <jason@redhat.com>
Mon, 13 Sep 2021 20:45:42 +0000 (16:45 -0400)
committerJason Merrill <jason@redhat.com>
Wed, 15 Sep 2021 04:05:33 +0000 (00:05 -0400)
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.

gcc/cp/parser.c

index e44c5c6b57cdb811f08e92ff857a1628d45557dc..ab1dc81b99705d298ad17838a9d0bcc495cbaf85 100644 (file)
@@ -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");