diff options
author | Jason Merrill <jason@redhat.com> | 2019-11-27 17:05:53 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2019-11-27 17:05:53 -0500 |
commit | 1a291106384cabc73da0bc0f457b1cd3a4015970 (patch) | |
tree | 3f4b4913ffbd60d6a8230235c945963f61958534 /gcc/cp/constraint.cc | |
parent | 1f41df916c2d6d7598cb5e67cdaebdc86910e902 (diff) | |
download | gcc-1a291106384cabc73da0bc0f457b1cd3a4015970.zip gcc-1a291106384cabc73da0bc0f457b1cd3a4015970.tar.gz gcc-1a291106384cabc73da0bc0f457b1cd3a4015970.tar.bz2 |
Implement P1814R0, CTAD for alias templates.
This patch implements C++20 class template argument deduction for alias
templates, which works by a moderately arcane transformation of the
deduction guides for the underlying class template. When implementing it,
it seemed that I could simplify the rules in the draft a bit and get
essentially the same effect; I'll be emailing the committee to that effect
soon.
gcc/cp/
* pt.c (rewrite_tparm_list): Factor out of build_deduction_guide.
(maybe_aggr_guide): Check for copy-init here.
(alias_ctad_tweaks, deduction_guides_for): New.
(ctor_deduction_guides_for): Factor out of do_class_deduction.
(ctad_template_p): New.
* parser.c (cp_parser_simple_type_specifier): Use it.
* constraint.cc (append_constraint): New.
gcc/c-family/
* c-cppbuiltin.c (c_cpp_builtins): Update __cpp_deduction_guides.
From-SVN: r278786
Diffstat (limited to 'gcc/cp/constraint.cc')
-rw-r--r-- | gcc/cp/constraint.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 0d1c27a..533277a 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -1116,6 +1116,25 @@ build_constraints (tree tr, tree dr) return (tree)ci; } +/* Add constraint RHS to the end of CONSTRAINT_INFO ci. */ + +tree +append_constraint (tree ci, tree rhs) +{ + tree tr = ci ? CI_TEMPLATE_REQS (ci) : NULL_TREE; + tree dr = ci ? CI_DECLARATOR_REQS (ci) : NULL_TREE; + dr = combine_constraint_expressions (dr, rhs); + if (ci) + { + CI_DECLARATOR_REQS (ci) = dr; + tree ac = combine_constraint_expressions (tr, dr); + CI_ASSOCIATED_CONSTRAINTS (ci) = ac; + } + else + ci = build_constraints (tr, dr); + return ci; +} + /* A mapping from declarations to constraint information. */ static GTY ((cache)) decl_tree_cache_map *decl_constraints; |