analyzer: fix ICE on globals with unknown size [PR93388]
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 13 Oct 2020 22:49:11 +0000 (18:49 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 14 Oct 2020 20:38:25 +0000 (16:38 -0400)
commit61a43de58cb6de7212a622060500ad0a0fd94fae
treeb4e27b67acbfab4227c1a16fd00460db4c98910d
parent12b267cc606a48a2fef809189c35573c4a51d3a5
analyzer: fix ICE on globals with unknown size [PR93388]

This patch fixes an ICE seen when attempting to build various existing
tests in our testsuite with -fanalyzer, including
gcc.c-torture/compile/980816-1.c.

gcc/analyzer/ChangeLog:
PR analyzer/93388
* region-model.cc (region_model::get_initial_value_for_global):
Fall back to returning an initial_svalue if
decl_region::get_svalue_for_initializer fails.
* region.cc (decl_region::get_svalue_for_initializer): Don't
attempt to create a compound_svalue if the region has an unknown
size.

gcc/testsuite/ChangeLog:
PR analyzer/93388
* gcc.dg/analyzer/data-model-21.c: New test.
gcc/analyzer/region-model.cc
gcc/analyzer/region.cc
gcc/testsuite/gcc.dg/analyzer/data-model-21.c [new file with mode: 0644]