================ @@ -8522,6 +8522,22 @@ bool Sema::CheckCountedByAttr(Scope *S, const FieldDecl *FD) { } } + // We don't support 'counted_by' on flexible array members in substructures. + const DeclContext *DC = FD->getParent(); + while (const auto *RD = dyn_cast<RecordDecl>(DC)) { + if (!RD->isAnonymousStructOrUnion() || + !isa<RecordDecl>(RD->getLexicalParent())) + break; + DC = RD->getLexicalParent(); + } + + if (DC != FD->getDeclContext()->getOuterLexicalRecordContext()) { ---------------- bwendling wrote:
I added this to ensure that we're not dealing with FAMs in sub-structures. I need to work with @rapidsna's work to make sure that what they do is what this attribute will do. It's not really a perfect check, but I removed the code in CodeGen that handles FAMs in substructs. So I think we can table this discussion if this patch goes on. https://github.com/llvm/llvm-project/pull/73730 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits