diff options
author | Marek Polacek <polacek@redhat.com> | 2022-05-11 14:38:49 -0400 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2022-05-26 17:11:07 -0400 |
commit | 6f56efa94e845db0d5c934ca202295019bf334c1 (patch) | |
tree | b23418750a1e6000006263be1144f8c877d9b716 /gcc/ada | |
parent | 3397563ad6c8fc5d9675faf507e52dd2ed284202 (diff) | |
download | gcc-6f56efa94e845db0d5c934ca202295019bf334c1.zip gcc-6f56efa94e845db0d5c934ca202295019bf334c1.tar.gz gcc-6f56efa94e845db0d5c934ca202295019bf334c1.tar.bz2 |
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.
Diffstat (limited to 'gcc/ada')
0 files changed, 0 insertions, 0 deletions