c++: Missing SFINAE with inaccessible static data member [PR90880]
This is a missing SFINAE issue when verifying the accessibility of a
static data member.
The cause is that check_accessibility_of_qualified_id unconditionally
passes tf_warning_or_error to perform_or_defer_access_check, even when
called from tsubst_qualified_id(..., complain=tf_none).
This patch fixes this by plumbing 'complain' from tsubst_qualified_id
through check_accessibility_of_qualified_id to reach
perform_or_defer_access_check, and by giving
check_accessibility_of_qualified_id the appropriate return value.
gcc/cp/ChangeLog:
PR c++/90880
* cp-tree.h (check_accessibility_of_qualified_id): Add
tsubst_flags_t parameter and change return type to bool.
* parser.c (cp_parser_lookup_name): Pass tf_warning_to_error to
check_accessibility_of_qualified_id.
* pt.c (tsubst_qualified_id): Return error_mark_node if
check_accessibility_of_qualified_id returns false.
* semantics.c (check_accessibility_of_qualified_id): Add
complain parameter. Pass complain instead of
tf_warning_or_error to perform_or_defer_access_check. Return
true unless perform_or_defer_access_check returns false.
gcc/testsuite/ChangeLog:
PR c++/90880
* g++.dg/template/sfinae29.C: New test.