push_deferring_access_checks (dk_no_deferred);
input_location = DECL_SOURCE_LOCATION (fn);
- /* 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))
+ if (!DECL_LOCAL_DECL_P (fn))
{
- 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;
+ /* If needed, set current_class_ptr for the benefit of
+ tsubst_copy/PARM_DECL. The exception pattern will
+ refer to the parm of the template, not the
+ instantiation. */
+ 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;
+ }
}
/* If this function is represented by a TEMPLATE_DECL, then
--- /dev/null
+// PR c++/97171
+
+// { dg-require-effective-target lto }
+// { dg-additional-options -flto }
+
+template <typename _UnaryOperation>
+void transform(_UnaryOperation);
+
+template <typename T>
+void Apply ()
+{
+ extern T Maker (void); // block-scope extern with dependent type
+
+ transform (Maker);
+}
+
+template void Apply<int> ();
+++ /dev/null
-// PR c++/97171
-// { dg-additional-options -flto }
-
-template <typename _UnaryOperation>
-void transform(_UnaryOperation);
-
-template <typename T>
-void Apply ()
-{
- extern T Maker (void); // block-scope extern with dependent type
-
- transform (Maker);
-}
-
-template void Apply<int> ();