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

--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Marek Polacek
<mpola...@gcc.gnu.org>:

https://gcc.gnu.org/g:24ee44c37a28eae80430a1ad86ffb0923446db2d

commit r11-9430-g24ee44c37a28eae80430a1ad86ffb0923446db2d
Author: Marek Polacek <pola...@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.

    (cherry picked from commit 06d5dcef72542baf49ac245cfde2ad7ecef0916b)
  • [Bug c++/102229] [11 Regression... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to