public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/107188] using concept type-constraint declared in nested namespace causes incorrect compilation error
Date: Thu, 15 Dec 2022 21:08:05 +0000	[thread overview]
Message-ID: <bug-107188-4-sElt6lHYXz@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107188-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107188

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:147e276b580b674a46bc3b9c461ae7837fd48aba

commit r13-4731-g147e276b580b674a46bc3b9c461ae7837fd48aba
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Dec 15 16:07:09 2022 -0500

    c++: class-scope qualified constrained auto [PR107188]

    Here when parsing the class-scope auto constrained by a qualified
    concept-id, we first tentatively parse the overall member-declaration as
    a deprecated access-declaration, during which we parse C<int> as a
    standalone TEMPLATE_ID_EXPR (separate from the auto) and end up emitting
    the stray error

    concepts-placeholder11.C:9:6: error: wrong number of template arguments (1,
should be 2)
        9 |   N::C<int> auto f() { return 0; }
          |      ^~~~~~
    concepts-placeholder11.C:5:34: note: provided for âtemplate<class, class>
concept N::Câ
        5 |   template<class, class> concept C = true;
          |                                  ^

    from build_concept_id called from cp_parser_template_id_expr.

    We could fix this by adding a complain parameter to build_concept_id and
    passing tf_none when parsing tentatively.  However, it seems this can
    also be fixed in a more general way that might benefit non-concepts
    code: when tentatively parsing an access-declaration, abort the parse
    early if the qualifying scope isn't possibly a class or enumeration
    type, so that we avoid parsing C<int> as a TEMPLATE_ID_EXPR here in the
    first place.  This patch takes this latter approach.

            PR c++/107188

    gcc/cp/ChangeLog:

            * parser.cc (cp_parser_using_declaration): Give up early if the
            scope of an access-declaration isn't possibly a class type.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/concepts-placeholder11.C: New test.

  parent reply	other threads:[~2022-12-15 21:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-09  0:29 [Bug c++/107188] New: " Mark_B53 at yahoo dot com
2022-10-10 13:55 ` [Bug c++/107188] " ppalka at gcc dot gnu.org
2022-12-15 21:08 ` cvs-commit at gcc dot gnu.org [this message]
2024-03-08 21:46 ` ppalka at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-107188-4-sElt6lHYXz@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).