gcc/cp/ChangeLog:
* cp-tree.h (PLACEHOLDER_TYPE_CONSTRAINTS_INFO): Use
TEMPLATE_TYPE_PARM_CHECK.
(TPARMS_PRIMARY_TEMPLATE): Use TREE_VEC_CHECK.
(TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL): Use
TEMPLATE_TEMPLATE_PARM_CHECK.
* cxx-pretty-print.cc (cxx_pretty_printer::simple_type_specifier):
Only use PLACEHOLDER_TYPE_CONSTRAINTS on TEMPLATE_TYPE_PARM.
* error.cc (dump_type) <case TEMPLATE_TYPE_PARM>: Use separate
variable for CLASS_PLACEHOLDER_TEMPLATE result.
* pt.cc (outer_template_args): Use strip_innermost_template_args.
(any_type_dependent_arguments_p): Return false if
!processing_template_decl. Use range-based for.
(any_dependent_template_arguments_p): Likewise.
---
gcc/cp/cp-tree.h | 6 +++---
gcc/cp/cxx-pretty-print.cc | 5 +++--
gcc/cp/error.cc | 4 ++--
gcc/cp/pt.cc | 30 ++++++++++++------------------
4 files changed, 20 insertions(+), 25 deletions(-)
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index c9c4cd6f32f..a02461481a2 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -1636,7 +1636,7 @@ check_constraint_info (tree t)
holds the set of template parameters that were in-scope when this 'auto'
was formed. */
#define PLACEHOLDER_TYPE_CONSTRAINTS_INFO(NODE) \
- DECL_SIZE_UNIT (TYPE_NAME (NODE))
+ DECL_SIZE_UNIT (TYPE_NAME (TEMPLATE_TYPE_PARM_CHECK (NODE)))
/* The constraints on the 'auto' placeholder type NODE. */
#define PLACEHOLDER_TYPE_CONSTRAINTS(NODE) \
@@ -5084,7 +5084,7 @@ get_vec_init_expr (tree t)
templates are primary, too. */
/* Returns the primary template corresponding to these parameters. */
-#define TPARMS_PRIMARY_TEMPLATE(NODE) (TREE_TYPE (NODE))
+#define TPARMS_PRIMARY_TEMPLATE(NODE) (TREE_TYPE (TREE_VEC_CHECK (NODE)))
#define DECL_PRIMARY_TEMPLATE(NODE) \
(TPARMS_PRIMARY_TEMPLATE (DECL_INNERMOST_TEMPLATE_PARMS (NODE)))
@@ -6098,7 +6098,7 @@ const unsigned int STF_STRIP_DEPENDENT = 1U << 1;
#define TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL(NODE) \
((TREE_CODE (NODE) == BOUND_TEMPLATE_TEMPLATE_PARM) \
? TYPE_TI_TEMPLATE (NODE) \
- : TYPE_NAME (NODE))
+ : TYPE_NAME (TEMPLATE_TEMPLATE_PARM_CHECK (NODE)))
/* in lex.cc */
diff --git a/gcc/cp/cxx-pretty-print.cc b/gcc/cp/cxx-pretty-print.cc
index 4cda27f2b30..950295effc6 100644
--- a/gcc/cp/cxx-pretty-print.cc
+++ b/gcc/cp/cxx-pretty-print.cc
@@ -1364,8 +1364,9 @@ cxx_pretty_printer::simple_type_specifier (tree t)
case TEMPLATE_PARM_INDEX:
case BOUND_TEMPLATE_TEMPLATE_PARM:
pp_cxx_unqualified_id (this, t);
- if (tree c = PLACEHOLDER_TYPE_CONSTRAINTS (t))
- pp_cxx_constrained_type_spec (this, c);
+ if (TREE_CODE (t) == TEMPLATE_TYPE_PARM)
+ if (tree c = PLACEHOLDER_TYPE_CONSTRAINTS (t))
+ pp_cxx_constrained_type_spec (this, c);
break;
case TYPENAME_TYPE:
diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc
index a5d888926a6..1cfa4f1a240 100644
--- a/gcc/cp/error.cc
+++ b/gcc/cp/error.cc
@@ -639,8 +639,8 @@ dump_type (cxx_pretty_printer *pp, tree t, int flags)
pp_cxx_cv_qualifier_seq (pp, t);
if (template_placeholder_p (t))
{
- t = TREE_TYPE (CLASS_PLACEHOLDER_TEMPLATE (t));
- pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t));
+ tree tmpl = TREE_TYPE (CLASS_PLACEHOLDER_TEMPLATE (t));
+ pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (tmpl));
pp_string (pp, "<...auto...>");
}
else if (TYPE_IDENTIFIER (t))
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 3f1cf139bbd..e62cca38195 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -4982,9 +4982,7 @@ outer_template_args (tree tmpl)
return args;
if (TMPL_ARGS_DEPTH (args) == 1)
return NULL_TREE;
- args = copy_node (args);
- --TREE_VEC_LENGTH (args);
- return args;
+ return strip_innermost_template_args (args, 1);
}
/* Update the declared TYPE by doing any lookups which were thought to be
@@ -28635,14 +28633,13 @@ type_dependent_expression_p_push (tree expr)
bool
any_type_dependent_arguments_p (const vec<tree, va_gc> *args)
{
- unsigned int i;
- tree arg;
+ if (!processing_template_decl || !args)
+ return false;
+
+ for (tree arg : *args)
+ if (type_dependent_expression_p (arg))
+ return true;
- FOR_EACH_VEC_SAFE_ELT (args, i, arg)
- {
- if (type_dependent_expression_p (arg))
- return true;
- }
return false;
}
@@ -28805,19 +28802,16 @@ any_template_arguments_need_structural_equality_p (tree args)
bool
any_dependent_template_arguments_p (const_tree args)
{
- int i;
- int j;
-
- if (!args)
- return false;
if (args == error_mark_node)
return true;
+ if (!processing_template_decl || !args)
+ return false;
- for (i = 0; i < TMPL_ARGS_DEPTH (args); ++i)
+ for (int i = 0, depth = TMPL_ARGS_DEPTH (args); i < depth; ++i)
{
const_tree level = TMPL_ARGS_LEVEL (args, i + 1);
- for (j = 0; j < TREE_VEC_LENGTH (level); ++j)
- if (dependent_template_arg_p (TREE_VEC_ELT (level, j)))
+ for (tree arg : tree_vec_range (CONST_CAST_TREE (level)))
+ if (dependent_template_arg_p (arg))
return true;
}