analyzer: fix ICE when discarding result of realloc [PR102225]
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 8 Sep 2021 18:37:19 +0000 (14:37 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 8 Sep 2021 18:37:19 +0000 (14:37 -0400)
commite66b9f6779f46433b0e2c093b58403604ed131cc
treeab637db2e7048d40545e4be1964f4334b80eff19
parent716a5836928ee6d8fb884d9a2fbc1b1386ec8994
analyzer: fix ICE when discarding result of realloc [PR102225]

gcc/analyzer/ChangeLog:
PR analyzer/102225
* analyzer.h (compat_types_p): New decl.
* constraint-manager.cc
(constraint_manager::get_or_add_equiv_class): Guard against NULL
type when checking for pointer types.
* region-model-impl-calls.cc (region_model::impl_call_realloc):
Guard against NULL lhs type/region.  Guard against the size value
not being of a compatible type for dynamic extents.
* region-model.cc (compat_types_p): Make non-static.

gcc/testsuite/ChangeLog:
PR analyzer/102225
* gcc.dg/analyzer/realloc-1.c (test_10): New.
* gcc.dg/analyzer/torture/pr102225.c: New test.
gcc/analyzer/analyzer.h
gcc/analyzer/constraint-manager.cc
gcc/analyzer/region-model-impl-calls.cc
gcc/analyzer/region-model.cc
gcc/testsuite/gcc.dg/analyzer/realloc-1.c
gcc/testsuite/gcc.dg/analyzer/torture/pr102225.c [new file with mode: 0644]