gcc_checking_assert (DECL_TEMPLATE_RESULT (tmpl) == decl);
- /* Push template declarations for global functions and types. Note
- that we do not try to push a global template friend declared in a
- template class; such a thing may well depend on the template
- parameters of the class. */
- if (new_template_p && !ctx
- && !(is_friend && template_class_depth (current_class_type) > 0))
- {
- tmpl = pushdecl_namespace_level (tmpl, is_friend);
- if (tmpl == error_mark_node)
- return error_mark_node;
- /* Hide template friend classes that haven't been declared yet. */
- if (is_friend && TREE_CODE (decl) == TYPE_DECL)
+ if (new_template_p)
+ {
+ /* Push template declarations for global functions and types.
+ Note that we do not try to push a global template friend
+ declared in a template class; such a thing may well depend on
+ the template parameters of the class and we'll push it when
+ instantiating the befriending class. */
+ if (!ctx
+ && !(is_friend && template_class_depth (current_class_type) > 0))
{
- DECL_ANTICIPATED (tmpl) = 1;
- DECL_FRIEND_P (tmpl) = 1;
+ tmpl = pushdecl_namespace_level (tmpl, is_friend);
+ if (tmpl == error_mark_node)
+ return error_mark_node;
+
+ /* Hide template friend classes that haven't been declared yet. */
+ if (is_friend && TREE_CODE (decl) == TYPE_DECL)
+ {
+ DECL_ANTICIPATED (tmpl) = 1;
+ DECL_FRIEND_P (tmpl) = 1;
+ }
}
}
+ else
+ /* The type may have been completed, or (erroneously) changed. */
+ TREE_TYPE (tmpl) = TREE_TYPE (decl);
if (is_primary)
{