analyzer: fix infinite recursion false +ves [PR108935]
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 1 Mar 2023 13:54:43 +0000 (08:54 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 1 Mar 2023 13:54:43 +0000 (08:54 -0500)
commit070523b9d4c6cfa69060255893006efaf39bf617
tree519d59ab9ec81597143a2a6fdc764f3854bc17a2
parentf769d22ab685671095525d09ef29eeeed0ae3cee
analyzer: fix infinite recursion false +ves [PR108935]

gcc/analyzer/ChangeLog:
PR analyzer/108935
* infinite-recursion.cc (contains_unknown_p): New.
(sufficiently_different_region_binding_p): New function, splitting
out inner loop from...
(sufficiently_different_p): ...here.  Extend detection of unknown
svalues to also include svalues that contain unknown.  Treat
changes in frames below the entry to the recursion as being
sufficiently different to reject being an infinite recursion.

gcc/testsuite/ChangeLog:
PR analyzer/108935
* gcc.dg/analyzer/infinite-recursion-pr108935-1.c: New test.
* gcc.dg/analyzer/infinite-recursion-pr108935-1a.c: New test.
* gcc.dg/analyzer/infinite-recursion-pr108935-2.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/infinite-recursion.cc
gcc/testsuite/gcc.dg/analyzer/infinite-recursion-pr108935-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/analyzer/infinite-recursion-pr108935-1a.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/analyzer/infinite-recursion-pr108935-2.c [new file with mode: 0644]