[Bug c++/102229] [11 Regression] 'decltype(auto)' cannot be cv-qualified

2022-01-03 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102229

Marek Polacek  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #13 from Marek Polacek  ---
Fixed.

[Bug c++/102229] [11 Regression] 'decltype(auto)' cannot be cv-qualified

2022-01-03 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102229

--- Comment #12 from CVS Commits  ---
The releases/gcc-11 branch has been updated by Marek Polacek
:

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

commit r11-9430-g24ee44c37a28eae80430a1ad86ffb0923446db2d
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 != 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] 'decltype(auto)' cannot be cv-qualified

2021-12-15 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102229

Marek Polacek  changed:

   What|Removed |Added

Summary|[11/12 Regression]  |[11 Regression]
   |'decltype(auto)' cannot be  |'decltype(auto)' cannot be
   |cv-qualified|cv-qualified

--- Comment #11 from Marek Polacek  ---
Fixed on trunk so far.