if (DECL_CLONED_FUNCTION_P (fn))
fn = DECL_CLONED_FUNCTION (fn);
+
+ tree orig_fn = NULL_TREE;
+ /* For a member friend template we can get a TEMPLATE_DECL. Let's use
+ its FUNCTION_DECL for the rest of this function -- push_access_scope
+ doesn't accept TEMPLATE_DECLs. */
+ if (DECL_FUNCTION_TEMPLATE_P (fn))
+ {
+ orig_fn = fn;
+ fn = DECL_TEMPLATE_RESULT (fn);
+ }
+
fntype = TREE_TYPE (fn);
spec = TYPE_RAISES_EXCEPTIONS (fntype);
push_deferring_access_checks (dk_no_deferred);
input_location = DECL_SOURCE_LOCATION (fn);
- /* A new stack interferes with pop_access_scope. */
- {
- /* Set up the list of local specializations. */
- local_specialization_stack lss (lss_copy);
-
- tree save_ccp = current_class_ptr;
- tree save_ccr = current_class_ref;
- /* If needed, set current_class_ptr for the benefit of
- tsubst_copy/PARM_DECL. */
- tree tdecl = DECL_TEMPLATE_RESULT (DECL_TI_TEMPLATE (fn));
- if (DECL_NONSTATIC_MEMBER_FUNCTION_P (tdecl))
- {
- tree this_parm = DECL_ARGUMENTS (tdecl);
- current_class_ptr = NULL_TREE;
- current_class_ref = cp_build_fold_indirect_ref (this_parm);
- current_class_ptr = this_parm;
- }
+ tree save_ccp = current_class_ptr;
+ tree save_ccr = current_class_ref;
+ /* If needed, set current_class_ptr for the benefit of
+ tsubst_copy/PARM_DECL. */
+ tree tdecl = DECL_TEMPLATE_RESULT (DECL_TI_TEMPLATE (fn));
+ if (DECL_NONSTATIC_MEMBER_FUNCTION_P (tdecl))
+ {
+ tree this_parm = DECL_ARGUMENTS (tdecl);
+ current_class_ptr = NULL_TREE;
+ current_class_ref = cp_build_fold_indirect_ref (this_parm);
+ current_class_ptr = this_parm;
+ }
- /* Create substitution entries for the parameters. */
- register_parameter_specializations (tdecl, fn);
+ /* If this function is represented by a TEMPLATE_DECL, then
+ the deferred noexcept-specification might still contain
+ dependent types, even after substitution. And we need the
+ dependency check functions to work in build_noexcept_spec. */
+ if (orig_fn)
+ ++processing_template_decl;
- /* Do deferred instantiation of the noexcept-specifier. */
- noex = tsubst_copy_and_build (DEFERRED_NOEXCEPT_PATTERN (noex),
- DEFERRED_NOEXCEPT_ARGS (noex),
- tf_warning_or_error, fn,
- /*function_p=*/false,
- /*i_c_e_p=*/true);
- current_class_ptr = save_ccp;
- current_class_ref = save_ccr;
- spec = build_noexcept_spec (noex, tf_warning_or_error);
- }
+ /* Do deferred instantiation of the noexcept-specifier. */
+ noex = tsubst_copy_and_build (DEFERRED_NOEXCEPT_PATTERN (noex),
+ DEFERRED_NOEXCEPT_ARGS (noex),
+ tf_warning_or_error, fn,
+ /*function_p=*/false,
+ /*i_c_e_p=*/true);
+
+ current_class_ptr = save_ccp;
+ current_class_ref = save_ccr;
+
+ /* Build up the noexcept-specification. */
+ spec = build_noexcept_spec (noex, tf_warning_or_error);
+
+ if (orig_fn)
+ --processing_template_decl;
pop_deferring_access_checks ();
pop_access_scope (fn);
}
TREE_TYPE (fn) = build_exception_variant (fntype, spec);
+ if (orig_fn)
+ TREE_TYPE (orig_fn) = TREE_TYPE (fn);
}
FOR_EACH_CLONE (clone, fn)
--- /dev/null
+// PR c++/89612
+// { dg-do compile { target c++17 } }
+
+template <typename a> using b = typename a ::c;
+template <typename> bool d;
+template <typename, typename> struct e {
+ template <typename f, typename g> e(f, g) {}
+ template <typename h, typename i, typename j>
+ friend auto k(h &&, const j &, i &&) noexcept(d<b<h>, h> &&d<b<i>, i>);
+};
+template <typename l, typename m> e(l, m)->e<l, m>;
+template <typename l, typename m, typename j>
+auto k(l &&, const j &, m &&) noexcept(d<b<l>, l> &&d<b<m>, m>);
+int main() {
+ e(0, [] {});
+}