This is just the member function pointer version of PR c++/105848,
in which our non-dependent call pruning may cause us to not mark an
otherwise unused function pointer template argument as used.
PR c++/119233
gcc/cp/ChangeLog:
* pt.cc (mark_template_arguments_used): Also handle member
function pointers.
gcc/testsuite/ChangeLog:
* g++.dg/template/fn-ptr5.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
gcc_checking_assert (ok || seen_error ());
}
}
+ /* A member function pointer. */
+ else if (TREE_CODE (arg) == PTRMEM_CST)
+ {
+ bool ok = mark_used (PTRMEM_CST_MEMBER (arg), tf_none);
+ gcc_checking_assert (ok || seen_error ());
+ }
/* A class NTTP argument. */
else if (VAR_P (arg)
&& DECL_NTTP_OBJECT_P (arg))
--- /dev/null
+// PR c++/119233
+// A version of fn-ptr3a.C using member instead of non-member function
+// pointers.
+
+struct B {
+ template<class T>
+ void f(T) { T::fail; } // { dg-error "fail" }
+};
+
+template<void (B::*P)(int)>
+struct A {
+ // P not called
+};
+
+template<void (B::*P)(char)>
+void wrap() {
+ // P not called
+}
+
+template<int>
+void g() {
+ A<&B::f> a; // { dg-message "required from" }
+ wrap<&B::f>(); // { dg-message "required from" }
+}
+
+int main() {
+ g<0>();
+}