= TINFO_USED_TEMPLATE_ID (new_template_info);
}
- if (non_templated_friend_p (olddecl))
- /* Don't copy tinfo from a non-templated friend (PR105761). */;
- else
- DECL_TEMPLATE_INFO (newdecl) = DECL_TEMPLATE_INFO (olddecl);
+ /* We don't want to copy template info from a non-templated friend
+ (PR105761), but these shouldn't have DECL_TEMPLATE_INFO now. */
+ gcc_checking_assert (!DECL_TEMPLATE_INFO (olddecl)
+ || !non_templated_friend_p (olddecl));
+ DECL_TEMPLATE_INFO (newdecl) = DECL_TEMPLATE_INFO (olddecl);
}
if (DECL_DECLARES_FUNCTION_P (newdecl))
tree new_friend_template_info = DECL_TEMPLATE_INFO (new_friend);
tree new_friend_result_template_info = NULL_TREE;
bool new_friend_is_defn =
- (DECL_INITIAL (DECL_TEMPLATE_RESULT
- (template_for_substitution (new_friend)))
- != NULL_TREE);
+ (new_friend_template_info
+ && (DECL_INITIAL (DECL_TEMPLATE_RESULT
+ (template_for_substitution (new_friend)))
+ != NULL_TREE));
tree not_tmpl = new_friend;
if (TREE_CODE (new_friend) == TEMPLATE_DECL)
&& !LAMBDA_FUNCTION_P (t))
return t;
+ /* A non-templated friend doesn't get DECL_TEMPLATE_INFO. */
+ if (non_templated_friend_p (t))
+ goto friend_case;
+
/* Calculate the most general template of which R is a
specialization. */
gen_tmpl = most_general_template (DECL_TI_TEMPLATE (t));
tsubst_friend_function, and we want only to create a
new decl (R) with appropriate types so that we can call
determine_specialization. */
+ friend_case:
gen_tmpl = NULL_TREE;
argvec = NULL_TREE;
}
/* If this is an instantiation of a member template, clone it.
If it isn't, that'll be handled by
clone_constructors_and_destructors. */
- if (PRIMARY_TEMPLATE_P (gen_tmpl))
+ if (gen_tmpl && PRIMARY_TEMPLATE_P (gen_tmpl))
clone_cdtor (r, /*update_methods=*/false);
}
else if ((complain & tf_error) != 0