[libc-commits] [libcxx] [clang-tools-extra] [flang] [clang] [llvm] [libc] [compiler-rt] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

John McCall via libc-commits libc-commits at lists.llvm.org
Mon Dec 18 13:57:14 PST 2023


================
@@ -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()) {
----------------
rjmccall wrote:

We need to figure out this thing about `getOuterLexicalRecordContext()` before we can go forward here.  It sounds like you might be concerned about the established behavior of some existing attribute that isn't the `-fbounds-safety` `__counted_by`, but which people are trying to merge with `__counted_by` on general principle?

https://github.com/llvm/llvm-project/pull/73730


More information about the libc-commits mailing list