This is the mail archive of the
mailing list for the GCC project.
Re: [C++ PATCH] Implement P0595R1 - so far as __builtin_is_constant_evaluated rather than std::is_constant_evaluated magic builtin
- From: Jason Merrill <jason at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, Nathan Sidwell <nathan at acm dot org>, Jonathan Wakely <jwakely at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 6 Aug 2018 23:49:33 +1000
- Subject: Re: [C++ PATCH] Implement P0595R1 - so far as __builtin_is_constant_evaluated rather than std::is_constant_evaluated magic builtin
- References: <20180722193121.GC7166@tucnak> <CAFiYyc3-syZD8J=pgvg8mF0VQiB56wxu=2CO5=eKp4Hm3bfAJg@mail.gmail.com> <20180723102812.GH7166@tucnak> <CAFiYyc3nHOGt4QpNP393uNRBdcnjp_OhQyzdTbK=CDBBAFhXww@mail.gmail.com> <CADzB+2nB-bJmYuv5RfejWCMDFBa3LPnTZZ-w6FdY10CONSX6Yw@mail.gmail.com> <20180801090751.GJ17988@tucnak>
On Wed, Aug 1, 2018 at 7:07 PM, Jakub Jelinek <firstname.lastname@example.org> wrote:
> On Wed, Aug 01, 2018 at 12:35:09AM +1000, Jason Merrill wrote:
>> On Mon, Jul 23, 2018 at 8:50 PM, Richard Biener
>> <email@example.com> wrote:
>> > On Mon, Jul 23, 2018 at 12:28 PM Jakub Jelinek <firstname.lastname@example.org> wrote:
>> >> On Mon, Jul 23, 2018 at 12:17:42PM +0200, Richard Biener wrote:
>> >> > > Bootstrapped/regtested on x86_64-linux.
>> >> >
>> >> > Thanks for working on this. I wonder if we can completely hide this
>> >> > from the middle-end, without requiring defining of c_dialect_cxx.
>> >> > There is the BUILT_IN_FRONTEND class so you could somewhere
>> >> > manually inject a decl in that class for C++?
>> >> But then I couldn't handle folding of the builtin in the middle-end to false,
>> >> which is what I need (because in the FE it needs to be either folded to
>> >> true, or its folding deferred until later).
>> >> Or maybe in the C++ gimplification langhook?
>> > Yes, I was thinking the C++ langhook or its fully_fold routine.
>> fully_fold is too soon (until constexpr evaluation uses the
>> pre-genericize form), but the gimplification hook should work.
>> >> Seems we have a single BUILT_IN_FRONTEND builtin in the whole compiler,
>> >> __integer_pack, but it doesn't act as a normal builtin, given it is a
>> >> templatish magic.
>> > Yeah, I think at some point we considered removing BUILT_IN_FRONTEND ...
>> > Nowadays internal-use builtins can easily be internal-functions but of couse
>> > this one will eventually be used from libstdc++.
>> Immediately, I'd think.
> Here is an updated patch that uses BUILT_IN_FRONTEND for this rather than
> BUILT_IN_NORMAL builtin.
> Bootstrapped/regtested on x86_64-linux and i686-linux.
> 2018-08-01 Jakub Jelinek <email@example.com>
> P0595R1 - is_constant_evaluated
> * cp-tree.h (enum cp_built_in_function): New.
> (maybe_constant_init): Add const_evaluated argument.
We should document that this new parameter (here and in
cxx_eval_outermost_constant_expr) means "required to be
constant-evaluated" as per P0595 even though allow_non_constant is
true. And the parameter names should make its magical nature more
obvious; perhaps "pretend_const_required". OK with those changes.