aboutsummaryrefslogtreecommitdiff
path: root/gcc/analyzer
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2022-08-09 19:58:54 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2022-08-09 19:58:54 -0400
commitbddd8d86e3036e480158ba9219ee3f290ba652ce (patch)
treebf8679b09610d267849816bbd0ee8cf3ad4d9a90 /gcc/analyzer
parenta56c1641e9d25e46059168e811b4a2f185f07b6b (diff)
downloadgcc-bddd8d86e3036e480158ba9219ee3f290ba652ce.zip
gcc-bddd8d86e3036e480158ba9219ee3f290ba652ce.tar.gz
gcc-bddd8d86e3036e480158ba9219ee3f290ba652ce.tar.bz2
analyzer: fix missing -Wanalyzer-use-of-uninitialized-value on special-cased functions [PR106573]
We were missing checks for uninitialized params on calls to functions that the analyzer has hardcoded knowledge of - both for those that are handled just by state machines, and for those that are handled in region-model-impl-calls.cc (for those arguments for which the svalue wasn't accessed in handling the call). Fixed thusly. gcc/analyzer/ChangeLog: PR analyzer/106573 * region-model.cc (region_model::on_call_pre): Ensure that we call get_arg_svalue on all arguments. gcc/testsuite/ChangeLog: PR analyzer/106573 * gcc.dg/analyzer/error-uninit.c: New test. * gcc.dg/analyzer/fd-uninit-1.c: New test. * gcc.dg/analyzer/file-uninit-1.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/analyzer')
-rw-r--r--gcc/analyzer/region-model.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index a140f4d..8393c7d 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -1355,6 +1355,14 @@ region_model::on_call_pre (const gcall *call, region_model_context *ctxt,
&& gimple_call_internal_fn (call) == IFN_DEFERRED_INIT)
return false;
+ /* Get svalues for all of the arguments at the callsite, to ensure that we
+ complain about any uninitialized arguments. This might lead to
+ duplicates if any of the handling below also looks up the svalues,
+ but the deduplication code should deal with that. */
+ if (ctxt)
+ for (unsigned arg_idx = 0; arg_idx < cd.num_args (); arg_idx++)
+ cd.get_arg_svalue (arg_idx);
+
/* Some of the cases below update the lhs of the call based on the
return value, but not all. Provide a default value, which may
get overwritten below. */