================ @@ -1155,15 +1159,14 @@ const FieldDecl *CodeGenFunction::FindCountedByField(const FieldDecl *FD) { return nullptr; auto GetNonAnonStructOrUnion = [](const RecordDecl *RD) { - while (RD && !RD->getDeclName()) - if (const auto *R = dyn_cast<RecordDecl>(RD->getDeclContext())) - RD = R; - else + while (RD && RD->isAnonymousStructOrUnion()) { + const auto *R = dyn_cast<RecordDecl>(RD->getDeclContext()); + if (!R) ---------------- bwendling wrote:
I think you could have: ``` int foo(void) { struct { int a, b; } x; ... } ``` Though in the case of a struct with a flexible array member, probably not. Then again, you might be able to do this: ``` int foo(void) { struct { int count; int array[] __counted_by(count); } x = { 3 }; ... } ``` I just didn't want to make any assumptions. I can make this an assert if you'd like. https://github.com/llvm/llvm-project/pull/76348 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits