aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-uninit.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2020-09-16 13:23:31 -0600
committerMartin Sebor <msebor@redhat.com>2020-09-16 13:23:31 -0600
commit8b75204b27cb2a296ac329d48918992b4053c61e (patch)
treed18e80f2199b59b8790a01df3e62b8a058e875ad /gcc/tree-ssa-uninit.c
parent8155316c6fc23045e8e056e91449a6e9863c357f (diff)
downloadgcc-8b75204b27cb2a296ac329d48918992b4053c61e.zip
gcc-8b75204b27cb2a296ac329d48918992b4053c61e.tar.gz
gcc-8b75204b27cb2a296ac329d48918992b4053c61e.tar.bz2
Work harder to avoid -Wuninitialized for objects of empty structs (PR middle-end/96295).
Resolves: PR middle-end/96295 - -Wmaybe-uninitialized warning for range operator with reference to an empty struct gcc/ChangeLog: PR middle-end/96295 * tree-ssa-uninit.c (maybe_warn_operand): Work harder to avoid warning for objects of empty structs gcc/testsuite/ChangeLog: PR middle-end/96295 * g++.dg/warn/Wuninitialized-11.C: New test.
Diffstat (limited to 'gcc/tree-ssa-uninit.c')
-rw-r--r--gcc/tree-ssa-uninit.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c
index 7eddca3..c7f994b 100644
--- a/gcc/tree-ssa-uninit.c
+++ b/gcc/tree-ssa-uninit.c
@@ -401,6 +401,8 @@ maybe_warn_operand (ao_ref &ref, gimple *stmt, tree lhs, tree rhs,
The first_field() test is important for C++ where the predicate
alone isn't always sufficient. */
tree rhstype = TREE_TYPE (rhs);
+ if (POINTER_TYPE_P (rhstype))
+ rhstype = TREE_TYPE (rhstype);
if (TYPE_EMPTY_P (rhstype)
|| (RECORD_OR_UNION_TYPE_P (rhstype)
&& (!first_field (rhstype)