c++: improve -Waddress warnings with *_cast [PR105569]
This patch improves the diagnostic for -Waddress when it warns for
if (dynamic_cast<A*>(&ref))
// ...
where 'ref' is a reference, which cannot be null. In particular, it
changes
warning: comparing the result of pointer addition '(((A*)ref) + ((sizetype)(*(long int*)((& ref)->B::_vptr.B + -24))))' and NULL
to
warning: the compiler can assume that the address of 'ref' will never be NULL
PR c++/105569
gcc/cp/ChangeLog:
* typeck.cc (warn_for_null_address): Improve the warning when
the POINTER_PLUS_EXPR's base is of reference type.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Waddress-9.C: New test.