================
@@ -8547,15 +8547,25 @@ static const RecordDecl 
*GetEnclosingNamedOrTopAnonRecord(const FieldDecl *FD) {
   return RD;
 }
 
-static bool
-CheckCountExpr(Sema &S, FieldDecl *FD, Expr *E,
-               llvm::SmallVectorImpl<TypeCoupledDeclRefInfo> &Decls) {
+static bool CheckCountedByAttrOnField(
+    Sema &S, FieldDecl *FD, Expr *E,
+    llvm::SmallVectorImpl<TypeCoupledDeclRefInfo> &Decls) {
   if (FD->getParent()->isUnion()) {
     S.Diag(FD->getBeginLoc(), diag::err_counted_by_attr_in_union)
         << FD->getSourceRange();
     return true;
   }
 
+  const auto FieldTy = FD->getType();
+  if (FieldTy->isPointerType() &&
+      FieldTy->getPointeeType()->isIncompleteType()) {
----------------
rapidsna wrote:

`isIncompleteType()` won't be sufficient. We should also prevent a pointer to 
sizeless type, function type, and struct with flexible array member, etc.

https://github.com/llvm/llvm-project/pull/87596
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to