[clang-tools-extra] [llvm] [clang] [clang] Fix false positive -Wmissing-field-initializer for anonymous unions (PR #70829)
Mariya Podchishchaeva via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 23 06:16:15 PST 2023
================
@@ -727,6 +729,44 @@ void InitListChecker::FillInEmptyInitForField(unsigned Init, FieldDecl *Field,
if (hadError || VerifyOnly) {
// Do nothing
} else if (Init < NumInits) {
----------------
Fznamznon wrote:
It seems `Init < NumInits` is always true for non-`VerifyOnly` mode only for structs. So, removing lines `684-685, 704-707, 772-778` breaks a number of tests with unions. The assertion on line 676 confirms:
```
if (Init >= NumInits || !ILE->getInit(Init)) {
if (const RecordType *RType = ILE->getType()->getAs<RecordType>())
if (!RType->getDecl()->isUnion())
assert((Init < NumInits || VerifyOnly) &&
"This ILE should have been expanded");
```
I can still put warning emission out of `Init < NumInits` check though if that seems more correct.
https://github.com/llvm/llvm-project/pull/70829
More information about the cfe-commits
mailing list