diff options
author | Patrick Palka <ppalka@redhat.com> | 2022-09-30 11:06:54 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2022-09-30 11:06:54 -0400 |
commit | 1e2c124d71ac051373a30495793883c45bcc5415 (patch) | |
tree | 281e8aa9254d44be03e336282fc885c29eab597c /gcc/dwarf2out.cc | |
parent | 3bb2d70d38027c43b437dee98ee1a7a15843682f (diff) | |
download | gcc-1e2c124d71ac051373a30495793883c45bcc5415.zip gcc-1e2c124d71ac051373a30495793883c45bcc5415.tar.gz gcc-1e2c124d71ac051373a30495793883c45bcc5415.tar.bz2 |
c++: streamline built-in trait addition process
Adding a new built-in trait currently involves manual boilerplate
consisting of defining an rid enumerator for the identifier as well as a
corresponding cp_trait_kind enumerator and handling them in various switch
statements, the exact set of which depends on whether the proposed trait
yields (and thus is recognized as) a type or an expression.
To streamline the process, this patch adds a central cp-trait.def file
that tabulates the essential details about each built-in trait (whether
it yields a type or an expression, its code, its spelling and its arity)
and uses this file to automate away the manual boilerplate. It also
migrates all the existing C++-specific built-in traits to use this
approach.
After this change, adding a new built-in trait just entails declaring
it in cp-trait.def and defining its behavior in finish_trait_expr/type
(and handling it in diagnose_trait_expr, if it's an expression-yielding
trait).
gcc/c-family/ChangeLog:
* c-common.cc (c_common_reswords): Use cp/cp-trait.def to handle
C++ traits.
* c-common.h (enum rid): Likewise.
gcc/cp/ChangeLog:
* constraint.cc (diagnose_trait_expr): Likewise.
* cp-objcp-common.cc (names_builtin_p): Likewise.
* cp-tree.h (enum cp_trait_kind): Likewise.
* cxx-pretty-print.cc (pp_cxx_trait): Likewise.
* parser.cc (cp_keyword_starts_decl_specifier_p): Likewise.
(cp_parser_primary_expression): Likewise.
(cp_parser_trait): Likewise.
(cp_parser_simple_type_specifier): Likewise.
* cp-trait.def: New file.
Diffstat (limited to 'gcc/dwarf2out.cc')
0 files changed, 0 insertions, 0 deletions