diff options
author | Patrick Palka <ppalka@redhat.com> | 2023-04-20 15:00:06 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2023-04-20 15:00:06 -0400 |
commit | 76fa66ea397cb255ab1d68a90ff6b878236e9620 (patch) | |
tree | 795c8642211cb1ac46c5fa5fdd5e421ea710fd3a /gcc/cp/constraint.cc | |
parent | d180a5524ccdab8ef839ee55efecf60ce5b0240b (diff) | |
download | gcc-76fa66ea397cb255ab1d68a90ff6b878236e9620.zip gcc-76fa66ea397cb255ab1d68a90ff6b878236e9620.tar.gz gcc-76fa66ea397cb255ab1d68a90ff6b878236e9620.tar.bz2 |
c++: use TREE_VEC for trailing args of variadic built-in traits
This patch makes us use TREE_VEC instead of TREE_LIST to represent the
trailing arguments of a variadic built-in trait. These built-ins are
typically passed a simple pack expansion as the second argument, e.g.
__is_constructible(T, Ts...)
and the main benefit of this representation change is that substituting
into this argument list is now basically free since tsubst_template_args
makes sure we reuse the TREE_VEC of the corresponding ARGUMENT_PACK when
expanding such a pack expansion. In the previous TREE_LIST representation
we would need need to convert the expanded pack expansion into a TREE_LIST
(via tsubst_tree_list).
Note that an empty set of trailing arguments is now represented as an
empty TREE_VEC instead of NULL_TREE, so now TRAIT_TYPE/EXPR_TYPE2 will
be empty only for unary traits.
gcc/cp/ChangeLog:
* constraint.cc (diagnose_trait_expr): Convert a TREE_VEC
of arguments into a TREE_LIST for sake of pretty printing.
* cxx-pretty-print.cc (pp_cxx_trait): Handle TREE_VEC
instead of TREE_LIST of trailing variadic trait arguments.
* method.cc (constructible_expr): Likewise.
(is_xible_helper): Likewise.
* parser.cc (cp_parser_trait): Represent trailing variadic trait
arguments as a TREE_VEC instead of TREE_LIST.
* pt.cc (value_dependent_expression_p): Handle TREE_VEC
instead of TREE_LIST of trailing variadic trait arguments.
* semantics.cc (finish_type_pack_element): Likewise.
(check_trait_type): Likewise.
Diffstat (limited to 'gcc/cp/constraint.cc')
-rw-r--r-- | gcc/cp/constraint.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 273d15a..675299a 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3675,6 +3675,16 @@ diagnose_trait_expr (tree expr, tree args) tree t1 = TRAIT_EXPR_TYPE1 (expr); tree t2 = TRAIT_EXPR_TYPE2 (expr); + if (t2 && TREE_CODE (t2) == TREE_VEC) + { + /* Convert the TREE_VEC of arguments into a TREE_LIST, since we can't + directly print a TREE_VEC but we can a TREE_LIST via the E format + specifier. */ + tree list = NULL_TREE; + for (tree t : tree_vec_range (t2)) + list = tree_cons (NULL_TREE, t, list); + t2 = nreverse (list); + } switch (TRAIT_EXPR_KIND (expr)) { case CPTK_HAS_NOTHROW_ASSIGN: |