c++: vtable referring to "unavailable" virtual fn [PR116606]

mark_vtable_entries already has

   /* It's OK for the vtable to refer to deprecated virtual functions.  */
   warning_sentinel w(warn_deprecated_decl);

but that doesn't cover __attribute__((unavailable)).  We can use the
following override to cover both.

	PR c++/116606

gcc/cp/ChangeLog:

	* decl2.cc (mark_vtable_entries): Temporarily override deprecated_state to
	UNAVAILABLE_DEPRECATED_SUPPRESS.  Remove a warning_sentinel.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/attr-unavailable-13.C: New test.
This commit is contained in:
Marek Polacek 2024-09-05 13:01:59 -04:00
parent 7d14839219
commit d9d34f9a91
2 changed files with 10 additions and 1 deletions

View file

@ -2180,7 +2180,8 @@ static void
mark_vtable_entries (tree decl, vec<tree> &consteval_vtables)
{
/* It's OK for the vtable to refer to deprecated virtual functions. */
warning_sentinel w(warn_deprecated_decl);
auto du = make_temp_override (deprecated_state,
UNAVAILABLE_DEPRECATED_SUPPRESS);
bool consteval_seen = false;

View file

@ -0,0 +1,8 @@
// PR c++/116606
// { dg-do compile }
struct C {
__attribute__((unavailable)) virtual void f() {}
};
C c;