analyzer: fix -Wanalyzer-deref-before-check false positive seen in loop header macro [PR109251]
Backported from commit
r14-9586-g9093f275e0a343 (moving tests from
c-c++-common to gcc.dg)
gcc/analyzer/ChangeLog:
PR analyzer/109251
* sm-malloc.cc (deref_before_check::emit): Reject cases where the
check is in a loop header within a macro expansion.
(deref_before_check::loop_header_p): New.
gcc/testsuite/ChangeLog:
PR analyzer/109251
* gcc.dg/analyzer/deref-before-check-pr109251-1.c: New test.
* gcc.dg/analyzer/deref-before-check-pr109251-2.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>