public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marek Polacek <polacek@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: gcc-patches@gcc.gnu.org, jwakely@redhat.com
Subject: Re: [PATCH RFC] c++: streamline process for adding new builtin trait
Date: Thu, 29 Sep 2022 13:55:57 -0400	[thread overview]
Message-ID: <YzXcLciX1RpvGP8r@redhat.com> (raw)
In-Reply-To: <20220929150504.829703-1-ppalka@redhat.com>

On Thu, Sep 29, 2022 at 11:05:04AM -0400, Patrick Palka via Gcc-patches wrote:
> Adding a new builtin trait currently involves some boilerplate (as can
> be seen in r13-2956-g9ca147154074a0) of defining corresponding RID_ and
> CPTK_ enumerators and adding them to various switch statements across
> many files.  The exact switch statements we need to change is determined
> by whether the proposed trait yields a type or an expression.
> 
> This RFC patch attempts to streamline this process via a centralized
> cp-trait.def file for declaring the important parts about a builtin trait
> (whether it yields a type or an expression, its code, its spelling and
> its arity) and using this file to automate away the switch statement
> addition boilerplate.  It also converts 9 traits to use this approach
> by way of example (we can convert all the traits once the design is
> settled).
> 
> After this change, the process of adding a new builtin trait is just
> (modulo tests): declare it in cp-trait.def, define its behavior in
> finish_trait_type/expr, and handle it in diagnose_trait_expr if it's
> an expression-yielding trait (this last step is unfortunate but since
> the switch has no default case, we'll at least get a diagnostic if we
> forget to do it).
> 
> Does this look like a good approach?

I think it'd be fantastic to have this.  It's been very easy to forget
to update pp_cxx_trait, or names_builtin_p.  cp-trait.def just needs to
describe what the arguments mean.
 
Marek


  parent reply	other threads:[~2022-09-29 17:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-29 15:05 Patrick Palka
2022-09-29 15:09 ` Patrick Palka
2022-09-29 17:55 ` Marek Polacek [this message]
2022-09-29 18:49   ` Patrick Palka
2022-09-29 22:35 ` Jason Merrill
2022-09-30 15:14   ` Patrick Palka
2022-09-30 19:51     ` Jason Merrill
2022-10-03 12:48       ` Patrick Palka
2022-10-03 15:03         ` Jason Merrill

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=YzXcLciX1RpvGP8r@redhat.com \
    --to=polacek@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    --cc=ppalka@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).