-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clang] Fix wrong warning about missing init for flexible array members #66341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
9108897 shoudn't have removed an additional check that field has incomplete array type. Fixes llvm#66300
@llvm/pr-subscribers-clang Changes9108897 shouldn't have removed an additional check that field has incomplete array type.Fixes #66300Full diff: https://github.com/llvm/llvm-project/pull/66341.diff 2 Files Affected:
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 93f05e2e47285e4..cb57a2d1a555caa 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -2395,7 +2395,8 @@ void InitListChecker::CheckStructUnionTypes( if (HasDesignatedInit && InitializedFields.count(*it)) continue; - if (!it->isUnnamedBitfield() && !it->hasInClassInitializer()) { + if (!it->isUnnamedBitfield() && !it->hasInClassInitializer() && + !it->getType()->isIncompleteArrayType()) { SemaRef.Diag(IList->getSourceRange().getEnd(), diag::warn_missing_field_initializers) << *it; diff --git a/clang/test/Sema/missing-field-initializers.c b/clang/test/Sema/missing-field-initializers.c index 90e0e2a345b08c6..39b2b55300184cc 100644 --- a/clang/test/Sema/missing-field-initializers.c +++ b/clang/test/Sema/missing-field-initializers.c @@ -50,3 +50,11 @@ struct { int:5; int a; int:5; int b; int:5; } noNamedImplicit[] = { { 1, 2 }, { 1 } // expected-warning {{missing field 'b' initializer}} }; + +// GH66300 +struct S { + int f0; + int f1[]; +}; + +struct S s = {1, {1, 2}}; // No warning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM !
(double checking: this does not need a release note because it fixes something that was changed post 17 branch. Correct?)
Exactly. There is a release note for guilty change. |
Co-authored-by: Aaron Ballman <[email protected]>
Thank you for the quick fix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…rs (llvm#66341) 9108897 shouldn't have removed an additional check that field has incomplete array type. Fixes llvm#66300 Co-authored-by: Aaron Ballman <[email protected]>
9108897 shouldn't have removed an additional check that field has incomplete array type.
Fixes #66300