From 1f41df916c2d6d7598cb5e67cdaebdc86910e902 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 27 Nov 2019 17:05:47 -0500 Subject: Fix constrained alias template transparency. A constrained alias template can't be treated as equivalent to its underlying template/type for much the same reason that an alias template like void_t can't; we're relying on checking during substitution. * cxx-pretty-print.c (pp_cxx_unqualified_id): Handle alias template-id. * pt.c (complex_alias_template_p): True if constraints. (get_underlying_template, tsubst): Check alias constraints. (push_template_decl_real): Set alias constraints here. * parser.c (cp_parser_alias_declaration): Not here. * constraint.cc (get_constraints): Take const_tree. From-SVN: r278785 --- gcc/cp/constraint.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'gcc/cp/constraint.cc') diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index fadbe7c..0d1c27a 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -1124,7 +1124,7 @@ static GTY ((cache)) decl_tree_cache_map *decl_constraints; constrained, return NULL_TREE. Note that T must be non-null. */ tree -get_constraints (tree t) +get_constraints (const_tree t) { if (!flag_concepts) return NULL_TREE; @@ -1134,7 +1134,7 @@ get_constraints (tree t) gcc_assert (DECL_P (t)); if (TREE_CODE (t) == TEMPLATE_DECL) t = DECL_TEMPLATE_RESULT (t); - tree* found = decl_constraints->get (t); + tree* found = decl_constraints->get (CONST_CAST_TREE (t)); if (found) return *found; else @@ -2966,6 +2966,17 @@ more_constrained (tree d1, tree d2) return winner; } +/* Return whether D1 is at least as constrained as D2. */ + +bool +at_least_as_constrained (tree d1, tree d2) +{ + tree n1 = get_normalized_constraints_from_decl (d1); + tree n2 = get_normalized_constraints_from_decl (d2); + + return subsumes (n1, n2); +} + /*--------------------------------------------------------------------------- Constraint diagnostics ---------------------------------------------------------------------------*/ -- cgit v1.1