diff --git a/gcc/analyzer/ChangeLog b/gcc/analyzer/ChangeLog index 8806a775acb1..fa791f70d34d 100644 --- a/gcc/analyzer/ChangeLog +++ b/gcc/analyzer/ChangeLog @@ -1,3 +1,10 @@ +2020-01-31 David Malcolm + + 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. + 2020-01-31 David Malcolm PR analyzer/93438 diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index f116c0ae7a28..d43aef3a4d79 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -5694,12 +5694,15 @@ region_model::update_for_return_superedge (const return_superedge &return_edge, svalue_id result_sid = pop_frame (true, &stats, ctxt); // TODO: do something with the stats? + if (result_sid.null_p ()) + return; + /* Set the result of the call, within the caller frame. */ const gcall *call_stmt = return_edge.get_call_stmt (); tree lhs = gimple_call_lhs (call_stmt); if (lhs) set_value (get_lvalue (lhs, ctxt), result_sid, ctxt); - else if (!result_sid.null_p ()) + else { /* This could be a leak; try purging again, but this time, don't special-case the result_sid. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f8051b440850..cce52ea69610 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2020-01-31 David Malcolm + + PR analyzer/93379 + * gcc.dg/analyzer/torture/pr93379-2.c: New test. + * gcc.dg/analyzer/torture/pr93379.c: New test. + 2020-01-31 David Malcolm PR analyzer/93438 diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/pr93379-2.c b/gcc/testsuite/gcc.dg/analyzer/torture/pr93379-2.c new file mode 100644 index 000000000000..6e533dbca689 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/torture/pr93379-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Wno-implicit-function-declaration" } */ + +void foo (void) +{ + int i = actually_returns_void (); +} + +void actually_returns_void (void) /* { dg-warning "conflicting types" } */ +{ +} diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/pr93379.c b/gcc/testsuite/gcc.dg/analyzer/torture/pr93379.c new file mode 100644 index 000000000000..01465cf60e10 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/torture/pr93379.c @@ -0,0 +1,2 @@ +/* { dg-do compile } */ +#include "../../torture/pr57330.c"