public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Nathaniel Shead <nathanieloshead@gmail.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 1/3] c++: Track lifetimes in constant evaluation [PR70331, PR96630, PR98675]
Date: Tue, 28 Mar 2023 23:04:03 +1100	[thread overview]
Message-ID: <CACEF2k6978xrCKS8fsWXmJ+WACBJUkh_HoUcT_411dEz+-k6tQ@mail.gmail.com> (raw)
In-Reply-To: <ZCLUhEC54x32U9Vk@tucnak>

On Tue, Mar 28, 2023 at 10:50 PM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Tue, Mar 28, 2023 at 10:32:28PM +1100, Nathaniel Shead via Gcc-patches wrote:
> >       * tree-core.h (struct tree_decl_common): New flag to check if
> >         value lifetime has expired.
> >       * tree.h (DECL_EXPIRED): Access the new flag.
> >       * print-tree.cc (print_node): Print the new flag.
> > --- a/gcc/tree-core.h
> > +++ b/gcc/tree-core.h
> > @@ -1834,7 +1834,10 @@ struct GTY(()) tree_decl_common {
> >    /* In FIELD_DECL, this is DECL_NOT_FLEXARRAY.  */
> >    unsigned int decl_not_flexarray : 1;
> >
> > -  /* 13 bits unused.  */
> > +  /* In VAR_DECL, PARM_DECL, or RESULT_DECL, this is DECL_EXPIRED.  */
> > +  unsigned int decl_expired_flag : 1;
> > +
> > +  /* 12 bits unused.  */
> >
> >    /* UID for points-to sets, stable over copying from inlining.  */
> >    unsigned int pt_uid;
> > --- a/gcc/tree.h
> > +++ b/gcc/tree.h
> > @@ -2697,6 +2697,12 @@ extern tree vector_element_bits_tree (const_tree);
> >     ??? Need to figure out some way to check this isn't a PARM_DECL.  */
> >  #define DECL_INITIAL(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.initial)
> >
> > +/* Used in a VAR_DECL, PARM_DECL, or RESULT_DECL to indicate whether
> > +   this declaration is currently in lifetime for constant evaluation
> > +   purposes.  */
> > +#define DECL_EXPIRED(NODE) \
> > +  (DECL_COMMON_CHECK(NODE)->decl_common.decl_expired_flag)
> > +
> >  /* Holds the size of the datum, in bits, as a tree expression.
> >     Need not be constant and may be null.  May be less than TYPE_SIZE
> >     for a C++ FIELD_DECL representing a base class subobject with its
>
> While it is true that tree_decl_common has some spare bits, this support
> is for an implementation detail of the C++ FE and as such, I think it is
> highly preferred to use some bit in the lang specific data structures
> rather than wasting bits that we could need later on for things that will
> be needed in the middle-end.
> struct lang_decl_base I think also has 12 spare bits...
>
> Rest I'll defer to C++ maintainers (also whether this is appropriate now
> or should be deferred for GCC 14 stage1).
>
>         Jakub
>

Thanks, I didn't notice that there were lang specific data structures;
I'll take a look at using that instead.

From my point of view I was expecting this would be too late for GCC13
(especially since it should only affect already invalid code, and the
risk of false positives), but I'm happy either way.

  reply	other threads:[~2023-03-28 12:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-28 11:32 [PATCH 0/3] Track lifetimes in constant evaluation [PR70331,...] Nathaniel Shead
2023-03-28 11:32 ` [PATCH 1/3] c++: Track lifetimes in constant evaluation [PR70331,PR96630,PR98675] Nathaniel Shead
2023-03-28 11:50   ` [PATCH 1/3] c++: Track lifetimes in constant evaluation [PR70331, PR96630, PR98675] Jakub Jelinek
2023-03-28 12:04     ` Nathaniel Shead [this message]
2023-03-28 11:32 ` [PATCH 2/3] c++: Improve constexpr error for dangling local variables Nathaniel Shead
2023-03-28 11:32 ` [PATCH 3/3] c++: Improve location information in constexpr evaluation Nathaniel Shead

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACEF2k6978xrCKS8fsWXmJ+WACBJUkh_HoUcT_411dEz+-k6tQ@mail.gmail.com \
    --to=nathanieloshead@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).