analyzer: fix infinite recursion ICE on unions [PR96723]
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 20 Aug 2020 14:00:49 +0000 (10:00 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Thu, 20 Aug 2020 21:01:38 +0000 (17:01 -0400)
commit00cb0f5840795698557731c6e549a5ce99573223
tree90b910cf566a9f1a84fffb3dadb2ecaa11674d16
parent1531d8df6ebe3ce3cd1d59a044eafd4e292f9433
analyzer: fix infinite recursion ICE on unions [PR96723]

Attempts to store sm-state into a union in C++ triggered an infinite
recursion when trying to generate a representative tree, due to
erroneously trying to use the dtor of the union as a field.

Fix it by filtering out non-FIELD_DECLs when walking TYPE_FIELDs
in region::get_subregions_for_binding.

gcc/analyzer/ChangeLog:
PR analyzer/96723
* region-model-manager.cc
(region_model_manager::get_field_region): Assert that field is a
FIELD_DECL.
* region.cc (region::get_subregions_for_binding): In
union-handling, filter the TYPE_FIELDS traversal to just FIELD_DECLs.

gcc/testsuite/ChangeLog:
PR analyzer/96723
* g++.dg/analyzer/pr96723.C: New test.
gcc/analyzer/region-model-manager.cc
gcc/analyzer/region.cc
gcc/testsuite/g++.dg/analyzer/pr96723.C [new file with mode: 0644]