aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/typeck2.cc
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2023-07-19 13:31:52 -0400
committerMarek Polacek <polacek@redhat.com>2023-07-19 16:31:30 -0400
commitb1ae46bdd19fc2aaea41bc894168bdaf4799be80 (patch)
treed803cf6f2b5017292a2ef54998ce1ac70d97f3ca /gcc/cp/typeck2.cc
parent74477d25a2c9e6790f3bc1e8b908fc32013614ca (diff)
downloadgcc-b1ae46bdd19fc2aaea41bc894168bdaf4799be80.zip
gcc-b1ae46bdd19fc2aaea41bc894168bdaf4799be80.tar.gz
gcc-b1ae46bdd19fc2aaea41bc894168bdaf4799be80.tar.bz2
c++: -Wmissing-field-initializers and empty class [PR110064]
Let's suppress -Wmissing-field-initializers for empty classes. Here I don't think I need the usual COMPLETE_TYPE_P/dependent_type_p checks. PR c++/110064 gcc/cp/ChangeLog: * typeck2.cc (process_init_constructor_record): Don't emit -Wmissing-field-initializers for empty classes. gcc/testsuite/ChangeLog: * g++.dg/warn/Wmissing-field-initializers-3.C: New test.
Diffstat (limited to 'gcc/cp/typeck2.cc')
-rw-r--r--gcc/cp/typeck2.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc
index 1c204c86..582a73b 100644
--- a/gcc/cp/typeck2.cc
+++ b/gcc/cp/typeck2.cc
@@ -1874,7 +1874,8 @@ process_init_constructor_record (tree type, tree init, int nested, int flags,
to zero. */
if ((complain & tf_warning)
&& !cp_unevaluated_operand
- && !EMPTY_CONSTRUCTOR_P (init))
+ && !EMPTY_CONSTRUCTOR_P (init)
+ && !is_really_empty_class (fldtype, /*ignore_vptr*/false))
warning (OPT_Wmissing_field_initializers,
"missing initializer for member %qD", field);