static tree alias_ctad_tweaks (tree, tree);
static tree inherited_ctad_tweaks (tree, tree, tsubst_flags_t);
static tree deduction_guides_for (tree, bool&, tsubst_flags_t);
+static void mark_template_arguments_used_1 (tree);
/* Make the current scope suitable for access checking when we are
processing T. T can be FUNCTION_DECL for instantiated function
/* We already marked outer arguments when specializing the context. */
args = INNERMOST_TEMPLATE_ARGS (args);
+ mark_template_arguments_used_1 (args);
+}
+
+/* Main recursive part of the above. */
+
+static void
+mark_template_arguments_used_1 (tree args)
+{
for (tree arg : tree_vec_range (args))
{
/* A (pointer/reference to) function or variable NTTP argument. */
cp_walk_tree_without_duplicates (&DECL_INITIAL (arg),
mark_used_r, nullptr);
}
+ else if (TREE_CODE (arg) == NONTYPE_ARGUMENT_PACK)
+ mark_template_arguments_used_1 (ARGUMENT_PACK_ARGS (arg));
}
}
--- /dev/null
+// PR c++/126280
+// A version of fn-ptr3a.C where the template parameter is a pack.
+// { dg-do compile { target c++11 } }
+
+template<class T>
+void f(T) { T::fail; } // { dg-error "fail" }
+
+template<void (*...P)(int)>
+struct A {
+ // P not called
+};
+
+template<void (&...P)(char)>
+void wrap() {
+ // P not called
+}
+
+template<int>
+void g() {
+ A<f> a; // { dg-message "required from" }
+ wrap<f>(); // { dg-message "required from" }
+}
+
+int main() {
+ g<0>();
+}