analyzer: fix ICE when DECL_INITIAL is error_mark_node [PR98580]
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 7 Jan 2021 20:45:29 +0000 (15:45 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Thu, 7 Jan 2021 20:45:29 +0000 (15:45 -0500)
commit0677759f753d321bde52d7343227f842b7e759d2
treea5bc16fb608f00a04d1ce29219a08454ba454340
parentb87ec922c4090fcacf802c73b6bfd59a8632f8a5
analyzer: fix ICE when DECL_INITIAL is error_mark_node [PR98580]

lto-streamer-out.c's get_symbol_initial_value can return error_mark_node
rather than DECL_INITIAL as an optimization to avoid extra sections for
simple scalar values.

Add a check to the analyzer to handle such cases gracefully.

gcc/analyzer/ChangeLog:
PR analyzer/98580
* region.cc (decl_region::get_svalue_for_initializer): Gracefully
handle when LTO writes out DECL_INITIAL as error_mark_node.

gcc/testsuite/ChangeLog:
PR analyzer/98580
* gcc.dg/analyzer/pr98580-a.c: New test.
* gcc.dg/analyzer/pr98580-b.c: New test.
gcc/analyzer/region.cc
gcc/testsuite/gcc.dg/analyzer/pr98580-a.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/analyzer/pr98580-b.c [new file with mode: 0644]