diff options
author | David Malcolm <dmalcolm@redhat.com> | 2022-02-10 19:01:30 -0500 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2022-02-11 08:46:05 -0500 |
commit | cc68ad87014a331399ccb2528db3bf47fabe6f72 (patch) | |
tree | 8020fd5971b9177d75c2b8fada0c03f6b8e927eb /gcc/testsuite | |
parent | ae117af43944101ca47b99b743c85a3c528b4b4f (diff) | |
download | gcc-cc68ad87014a331399ccb2528db3bf47fabe6f72.zip gcc-cc68ad87014a331399ccb2528db3bf47fabe6f72.tar.gz gcc-cc68ad87014a331399ccb2528db3bf47fabe6f72.tar.bz2 |
analyzer: ignore uninitialized uses of empty types [PR104274]
PR analyzer/104274 reports a false positive from
-Wanalyzer-use-of-uninitialized-value on hppa when passing
an empty struct as a function parameter.
pa_pass_by_reference returns true for empty structs, so the
call is turned into:
struct empty arg.0;
arg.0 = arg
called_function (arg.0);
by gimplify_parameters.
However, gimplify_modify_expr discards assignments statments
of empty types, so that we end up with:
struct empty arg.0;
called_function (arg.0);
which the analyzer considers to be a use of uninitialized "arg.0";
Given that gimplify_modify_expr will discard any assignments to
such types, it seems simplest for -Wanalyzer-use-of-uninitialized-value
to ignore values of empty types.
gcc/analyzer/ChangeLog:
PR analyzer/104274
* region-model.cc (region_model::check_for_poison): Ignore
uninitialized uses of empty types.
gcc/testsuite/ChangeLog:
PR analyzer/104274
* gcc.dg/analyzer/torture/empty-struct-1.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/gcc.dg/analyzer/torture/empty-struct-1.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/empty-struct-1.c b/gcc/testsuite/gcc.dg/analyzer/torture/empty-struct-1.c new file mode 100644 index 0000000..1f1c07a --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/torture/empty-struct-1.c @@ -0,0 +1,18 @@ +struct empty {}; + +struct empty g; + +extern void sink (struct empty e); + +void test_1 (struct empty a) +{ + sink (a); /* { dg-bogus "uninit" } */ +} +void test_2 () +{ + struct empty a, b; + b = a; + g = b; + sink (b); /* { dg-bogus "uninit" } */ + /* ...as there's nothing to initialize. */ +} |