From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A8F8D3858D35; Wed, 15 Dec 2021 22:48:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A8F8D3858D35 From: "cvs-commit at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Dec 2021 22:48:07 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102229 --- Comment #10 from CVS Commits --- The trunk branch has been updated by Marek Polacek : https://gcc.gnu.org/g:06d5dcef72542baf49ac245cfde2ad7ecef0916b commit r12-6008-g06d5dcef72542baf49ac245cfde2ad7ecef0916b Author: Marek Polacek 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 !=3D 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.=