c++: memfn pointer as NTTP argument considered unused [PR119233]
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>
This commit is contained in:
parent
d1fd9da39a
commit
51b1c0a2dd
2 changed files with 34 additions and 0 deletions
|
@ -22491,6 +22491,12 @@ mark_template_arguments_used (tree tmpl, tree args)
|
|||
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))
|
||||
|
|
28
gcc/testsuite/g++.dg/template/fn-ptr5.C
Normal file
28
gcc/testsuite/g++.dg/template/fn-ptr5.C
Normal file
|
@ -0,0 +1,28 @@
|
|||
// 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>();
|
||||
}
|
Loading…
Add table
Reference in a new issue