return late_return_type;
}
- if (tree *auto_node = find_type_usage (&type, is_auto))
- {
- tree idx = get_template_parm_index (*auto_node);
- if (TEMPLATE_PARM_LEVEL (idx) <= processing_template_decl)
- {
- /* In an abbreviated function template we didn't know we were dealing
- with a function template when we saw the auto return type, so update
- it to have the correct level. */
- tree new_auto = make_auto_1 (TYPE_IDENTIFIER (*auto_node), false);
- PLACEHOLDER_TYPE_CONSTRAINTS (new_auto)
- = PLACEHOLDER_TYPE_CONSTRAINTS (*auto_node);
- TYPE_CANONICAL (new_auto) = canonical_type_parameter (new_auto);
- new_auto = cp_build_qualified_type (new_auto, TYPE_QUALS (*auto_node));
- *auto_node = new_auto;
- }
- }
+ if (tree auto_node = find_type_usage (type, is_auto))
+ if (TEMPLATE_TYPE_LEVEL (auto_node) <= processing_template_decl)
+ {
+ /* In an abbreviated function template we didn't know we were dealing
+ with a function template when we saw the auto return type, so rebuild
+ the return type using an auto with the correct level. */
+ tree new_auto = make_auto_1 (TYPE_IDENTIFIER (auto_node), false);
+ tree auto_vec = make_tree_vec (1);
+ TREE_VEC_ELT (auto_vec, 0) = new_auto;
+ tree targs = add_outermost_template_args (current_template_args (),
+ auto_vec);
+ /* FIXME: We should also rebuild the constraint to refer to the new
+ auto. */
+ PLACEHOLDER_TYPE_CONSTRAINTS (new_auto)
+ = PLACEHOLDER_TYPE_CONSTRAINTS (auto_node);
+ TYPE_CANONICAL (new_auto) = canonical_type_parameter (new_auto);
+ return tsubst (type, targs, tf_none, NULL_TREE);
+ }
return type;
}
else
return NULL_TREE;
}
- else if (tree *tp = find_type_usage (&type, is_auto))
- return *tp;
else
- return NULL_TREE;
+ return find_type_usage (type, is_auto);
}
/* Report ill-formed occurrences of auto types in ARGUMENTS. If
#ifndef GCC_CP_TYPE_UTILS_H
#define GCC_CP_TYPE_UTILS_H
-/* Returns a pointer to the first tree within *TP that is directly matched by
- PRED. *TP may be a type or PARM_DECL and is incrementally decomposed toward
- its type-specifier until a match is found. NULL is returned if PRED does not
- match any part of *TP.
+/* Returns the first tree within T that is directly matched by PRED. T may be a
+ type or PARM_DECL and is incrementally decomposed toward its type-specifier
+ until a match is found. NULL is returned if PRED does not match any
+ part of T.
- This is primarily intended for detecting whether *TP uses `auto' or a concept
+ This is primarily intended for detecting whether T uses `auto' or a concept
identifier. Since either of these can only appear as a type-specifier for
the declaration in question, only top-level qualifications are traversed;
find_type_usage does not look through the whole type. */
-inline tree *
-find_type_usage (tree *tp, bool (*pred) (const_tree))
+inline tree
+find_type_usage (tree t, bool (*pred) (const_tree))
{
- tree t = *tp;
if (pred (t))
- return tp;
+ return t;
enum tree_code code = TREE_CODE (t);
|| code == PARM_DECL || code == OFFSET_TYPE
|| code == FUNCTION_TYPE || code == METHOD_TYPE
|| code == ARRAY_TYPE)
- return find_type_usage (&TREE_TYPE (t), pred);
+ return find_type_usage (TREE_TYPE (t), pred);
if (TYPE_PTRMEMFUNC_P (t))
return find_type_usage
- (&TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (t)), pred);
+ (TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (t)), pred);
- return NULL;
+ return NULL_TREE;
}
#endif // GCC_CP_TYPE_UTILS_H