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++/102229] [11/12 Regression] 'decltype(auto)' cannot be cv-qualified
Date: Wed, 15 Dec 2021 22:48:07 +0000	[thread overview]
Message-ID: <bug-102229-4-RBINsr4CUC@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102229-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:06d5dcef72542baf49ac245cfde2ad7ecef0916b

commit r12-6008-g06d5dcef72542baf49ac245cfde2ad7ecef0916b
Author: Marek Polacek <polacek@redhat.com>
Date:   Fri Dec 10 15:38:35 2021 -0500

    c++: Allow constexpr decltype(auto) [PR102229]

    My r11-2202 was trying to enforce [dcl.type.auto.deduct]/4, which says
    "If the placeholder-type-specifier is of the form type-constraint[opt]
    decltype(auto), T shall be the placeholder alone."  But this made us
    reject 'constexpr decltype(auto)', which, after clarification from CWG,
    should be valid.  [dcl.type.auto.deduct]/4 is supposed to be a syntactic
    constraint, not semantic, so it's OK that the constexpr marks the object
    as const.

    As a consequence, checking TYPE_QUALS in do_auto_deduction is too late,
    and we have a FIXME there anyway.  So in this patch I'm attempting to
    detect 'const decltype(auto)' earlier.  If I'm going to use TYPE_QUALS,
    it needs to happen before we mark the object as const due to constexpr,
    that is, before grokdeclarator's

      /* A `constexpr' specifier used in an object declaration declares
         the object as `const'.  */
      if (constexpr_p && innermost_code != cdk_function)
        ...

    Constrained decltype(auto) was a little problem, hence the TYPENAME
    check.  But in a typename context you can't use decltype(auto) anyway,
    I think.

            PR c++/102229

    gcc/cp/ChangeLog:

            * decl.c (check_decltype_auto): New.
            (grokdeclarator): Call it.
            * pt.c (do_auto_deduction): Don't check decltype(auto) here.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1y/decltype-auto5.C: New test.

  parent reply	other threads:[~2021-12-15 22:48 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-07 13:33 [Bug c++/102229] New: " netcan1996 at gmail dot com
2021-09-07 14:36 ` [Bug c++/102229] " marxin at gcc dot gnu.org
2021-09-07 14:37 ` [Bug c++/102229] [11/12 Regression] " rguenth at gcc dot gnu.org
2021-09-07 14:43 ` mpolacek at gcc dot gnu.org
2021-09-07 15:17 ` mpolacek at gcc dot gnu.org
2021-09-07 19:43 ` jason at gcc dot gnu.org
2021-09-07 20:06 ` mpolacek at gcc dot gnu.org
2021-09-09 13:56 ` netcan1996 at gmail dot com
2021-09-09 15:08 ` jason at gcc dot gnu.org
2021-12-09 13:58 ` mpolacek at gcc dot gnu.org
2021-12-09 18:34 ` mpolacek at gcc dot gnu.org
2021-12-15 22:48 ` cvs-commit at gcc dot gnu.org [this message]
2021-12-15 22:52 ` [Bug c++/102229] [11 " mpolacek at gcc dot gnu.org
2022-01-03 23:45 ` cvs-commit at gcc dot gnu.org
2022-01-03 23:45 ` mpolacek 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-102229-4-RBINsr4CUC@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).