Re: [PATCH] c++, v4: Implement C++23 P2647R1 - Permitting static constexpr variables in constexpr functions

2022-11-18 Thread Jason Merrill via Gcc-patches
On 11/18/22 11:34, Jakub Jelinek wrote: On Fri, Nov 18, 2022 at 11:24:45AM -0500, Jason Merrill wrote: Right, that's the C++17 implicit constexpr for lambdas, finish_function: /* Lambda closure members are implicitly constexpr if possible. */ if (cxx_dialect >= cxx17 && LAMBDA_

Re: [PATCH] c++, v4: Implement C++23 P2647R1 - Permitting static constexpr variables in constexpr functions

2022-11-18 Thread Jakub Jelinek via Gcc-patches
On Fri, Nov 18, 2022 at 11:24:45AM -0500, Jason Merrill wrote: > > Right, that's the C++17 implicit constexpr for lambdas, finish_function: > > > >/* Lambda closure members are implicitly constexpr if possible. */ > >if (cxx_dialect >= cxx17 > >&& LAMBDA_TYPE_P (CP_DECL_CONTEXT (f

Re: [PATCH] c++, v4: Implement C++23 P2647R1 - Permitting static constexpr variables in constexpr functions

2022-11-18 Thread Jason Merrill via Gcc-patches
On 11/18/22 10:03, Marek Polacek wrote: On Fri, Nov 18, 2022 at 08:48:32AM +0100, Jakub Jelinek wrote: On Thu, Nov 17, 2022 at 07:15:05PM -0500, Marek Polacek wrote: --- gcc/cp/decl.cc.jj 2022-11-16 14:44:43.692339668 +0100 +++ gcc/cp/decl.cc 2022-11-17 20:53:44.102011594 +0100 @@ -5600,

Re: [PATCH] c++, v4: Implement C++23 P2647R1 - Permitting static constexpr variables in constexpr functions

2022-11-18 Thread Jakub Jelinek via Gcc-patches
On Fri, Nov 18, 2022 at 10:03:18AM -0500, Marek Polacek wrote: > > the lambda operator() when still a template as constexpr and then > > cp_finish_decl -> diagnose_static_in_constexpr pedwarns on it. > > For the above perhaps we could figure out there is a static int k; in the > > operator() and do

Re: [PATCH] c++, v4: Implement C++23 P2647R1 - Permitting static constexpr variables in constexpr functions

2022-11-18 Thread Marek Polacek via Gcc-patches
On Fri, Nov 18, 2022 at 08:48:32AM +0100, Jakub Jelinek wrote: > On Thu, Nov 17, 2022 at 07:15:05PM -0500, Marek Polacek wrote: > > > --- gcc/cp/decl.cc.jj 2022-11-16 14:44:43.692339668 +0100 > > > +++ gcc/cp/decl.cc2022-11-17 20:53:44.102011594 +0100 > > > @@ -5600,6 +5600,57 @@ grokty

Re: [PATCH] c++, v4: Implement C++23 P2647R1 - Permitting static constexpr variables in constexpr functions

2022-11-17 Thread Jakub Jelinek via Gcc-patches
On Thu, Nov 17, 2022 at 07:15:05PM -0500, Marek Polacek wrote: > > --- gcc/cp/decl.cc.jj 2022-11-16 14:44:43.692339668 +0100 > > +++ gcc/cp/decl.cc 2022-11-17 20:53:44.102011594 +0100 > > @@ -5600,6 +5600,57 @@ groktypename (cp_decl_specifier_seq *typ > >return type; > > } > > > > +/*

Re: [PATCH] c++, v4: Implement C++23 P2647R1 - Permitting static constexpr variables in constexpr functions

2022-11-17 Thread Jason Merrill via Gcc-patches
On 11/17/22 15:42, Jakub Jelinek wrote: On Thu, Nov 17, 2022 at 07:42:40PM +0100, Jakub Jelinek via Gcc-patches wrote: I thought for older C++ this is to catch void foo () { constexpr int a = ({ static constexpr int b = 2; b; }); } and for C++23 the only 3 spots that diagnose those. But perha

Re: [PATCH] c++, v4: Implement C++23 P2647R1 - Permitting static constexpr variables in constexpr functions

2022-11-17 Thread Marek Polacek via Gcc-patches
On Thu, Nov 17, 2022 at 09:42:17PM +0100, Jakub Jelinek wrote: > On Thu, Nov 17, 2022 at 07:42:40PM +0100, Jakub Jelinek via Gcc-patches wrote: > > I thought for older C++ this is to catch > > void > > foo () > > { > > constexpr int a = ({ static constexpr int b = 2; b; }); > > } > > and for C++2

[PATCH] c++, v4: Implement C++23 P2647R1 - Permitting static constexpr variables in constexpr functions

2022-11-17 Thread Jakub Jelinek via Gcc-patches
On Thu, Nov 17, 2022 at 07:42:40PM +0100, Jakub Jelinek via Gcc-patches wrote: > I thought for older C++ this is to catch > void > foo () > { > constexpr int a = ({ static constexpr int b = 2; b; }); > } > and for C++23 the only 3 spots that diagnose those. > But perhaps for C++20 or older we can