analyzer: fix ICE getting void return value (PR 93379)
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 31 Jan 2020 17:05:03 +0000 (12:05 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Fri, 31 Jan 2020 19:29:09 +0000 (14:29 -0500)
commitf1c807e887d43551bca0acc16a438d880cfaf7c9
tree78125ffde4cfce1245e23917660489a9d1561df7
parent455f58ec50465aed9d92dc31d68708a05e499388
analyzer: fix ICE getting void return value (PR 93379)

PR analyzer/93379 reports an ICE within
region_model::update_for_return_superedge when writing the
returned svalue_id to the lhs of the call_stmt

The root cause is that this analyzer code assumed that for any call
with a non-NULL gimple_call_lhs, the called fndecl would have non-void
return type, and thus that a non-null svalue_id would be returned from
region_model::pop_frame.  This isn't the case e.g. for a call with
conflicting types where the callee returns void but the caller assumes
int.

This patch fixes the ICE by moving the check for null result so that
it also guards setting the lhs.

gcc/analyzer/ChangeLog:
PR analyzer/93379
* region-model.cc (region_model::update_for_return_superedge):
Move check for null result so that it also guards setting the
lhs.

gcc/testsuite/ChangeLog:
PR analyzer/93379
* gcc.dg/analyzer/torture/pr93379-2.c: New test.
* gcc.dg/analyzer/torture/pr93379.c: New test.
gcc/analyzer/ChangeLog
gcc/analyzer/region-model.cc
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/analyzer/torture/pr93379-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/analyzer/torture/pr93379.c [new file with mode: 0644]