c++: -Wuninitialized for mem-inits and empty classes [PR19808]
commit4b1d3d8d732bea86c7b2aba46c2a437461020824
authorMarek Polacek <polacek@redhat.com>
Fri, 19 Nov 2021 19:22:10 +0000 (19 14:22 -0500)
committerMarek Polacek <polacek@redhat.com>
Tue, 23 Nov 2021 20:02:08 +0000 (23 15:02 -0500)
tree4c71c291334d11e645f9a42f24b90b7d572c36a1
parent7b7318faf7987ae17806a8c84fbaccaf255e7cbf
c++: -Wuninitialized for mem-inits and empty classes [PR19808]

This fixes a bogus -Wuninitialized warning: there's nothing to initialize
in empty classes, so don't add them into our uninitialized set.

PR c++/19808

gcc/cp/ChangeLog:

* init.c (emit_mem_initializers): Don't add is_really_empty_class
members into uninitialized.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wuninitialized-28.C: Make a class nonempty.
* g++.dg/warn/Wuninitialized-29.C: Likewise.
* g++.dg/warn/Wuninitialized-31.C: New test.
gcc/cp/init.c
gcc/testsuite/g++.dg/warn/Wuninitialized-28.C
gcc/testsuite/g++.dg/warn/Wuninitialized-29.C
gcc/testsuite/g++.dg/warn/Wuninitialized-31.C [new file with mode: 0644]