c++: make finish_non_static_data_member SFINAE enabled [PR105351]
Here since finish_non_static_data_member isn't SFINAE enabled, we
incorrectly emit an error when considering the first overload rather
than silently discarding it:
sfinae33.C: In substitution of ‘template<class T> A<T::value> f() [with T = B]’:
sfinae33.C:11:7: required from here
sfinae33.C:5:31: error: invalid use of non-static data member ‘B::value’
5 | template<class T> A<T::value> f();
| ^
This patch makes the function SFINAE enabled in the usual way: give it a
complain parameter, check it before emitting an error, and pass it through
appropriately.
PR c++/105351
gcc/cp/ChangeLog:
* cp-tree.h (finish_non_static_data_member): Add defaulted
complain parameter.
* pt.cc (tsubst_copy_and_build): Pass complain to
finish_non_static_data_member.
* semantics.cc (finish_non_static_data_member): Respect complain
parameter.
(finish_qualified_id_expr): Pass complain to
finish_non_static_data_member.
gcc/testsuite/ChangeLog:
* g++.dg/template/sfinae33.C: New test.