testsuite: Accept pmf-vbit-in-delta extra warning

cp_build_binary_op, that issues -Waddress warnings, issues an extra
warning on arm targets, that g++.dg/warn/Waddress-5.C does not expect
when comparing a pointer-to-member-function literal with null.

The reason for the extra warning is that, on arm targets,
TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_delta, which
causes a different path to be taken, that extracts the
pointer-to-function and the delta fields (minus the vbit) and compares
each one with zero.  It's when comparing this pointer-to-function with
zero, in a recursive cp_build_binary_op, that another warning is
issued.

I suppose there should be a way to skip the warning in this recursive
call, without disabling other warnings that might be issued there, but
this patch only arranges for the test to tolerate the extra warning.


for  gcc/testsuite/ChangeLog

	* g++.dg/warn/Waddress-5.C: Tolerate extra -Waddress warning.
This commit is contained in:
Alexandre Oliva 2023-02-22 14:35:20 -03:00 committed by Alexandre Oliva
parent d70f49e982
commit 1a45573d3d

View file

@ -23,7 +23,11 @@ void T (bool);
void warn_memptr_if ()
{
// Exercise warnings for addresses of nonstatic member functions.
if (&A::f == 0) // { dg-warning "the address '&A::f'" }
// On targets with TARGET_PTRMEMFUNC_VBIT_LOCATION ==
// ptrmemfunc_vbit_in_delta, cp_build_binary_op recurses to compare
// the pfn from the ptrmemfunc with null, so we get two warnings.
// This matches both. ??? Should we disable one of them?
if (&A::f == 0) // { dg-warning "A::f" }
T (0);
if (&A::vf) // { dg-warning "-Waddress" }