================
@@ -6513,6 +6513,14 @@ static bool canPerformArrayCopy(const InitializedEntity
&Entity) {
static const FieldDecl *getConstField(const RecordDecl *RD) {
assert(!isa<CXXRecordDecl>(RD) && "Only expect to call this in C mode");
for (const FieldDecl *FD : RD->fields()) {
+ // If the field is a flexible array member, we don't want to consider it
+ // as a const field because there's no way to initialize the FAM anyway.
+ if (Decl::isFlexibleArrayMemberLike(
+ FD->getASTContext(), FD, FD->getType(),
+ LangOptions::StrictFlexArraysLevelKind::ZeroOrIncomplete,
----------------
bwendling wrote:
Would it be better to use `getLangOpts().getStrictFlexArraysLevel()` instead of
hard-coding `ZeroOrIncomplete`? If `-fstrict-flex-arrays=<n>` is set, then we
may not expect there to be storage available in the flex array.
https://github.com/llvm/llvm-project/pull/140578
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits