-Wdangling-pointer: fix MEM_REF handling [PR109514]
Here we hit the MEM_REF case, with its arg an ADDR_EXPR, but had no handling
for that and wrongly assumed it would be a reference to a local variable.
This patch overhauls the logic for deciding whether the target is something
to warn about so that we only warn if we specifically recognize the target
as non-local. None of the existing tests regress as a result.
PR c++/109514
gcc/ChangeLog:
* gimple-ssa-warn-access.cc (pass_waccess::check_dangling_stores):
Overhaul lhs_ref.ref analysis.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wdangling-pointer-6.C: New test.