================
@@ -6590,8 +6590,34 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, 
SourceLocation LParenLoc,
     return CallExpr::Create(Context, Fn, ArgExprs, Context.DependentTy,
                             VK_PRValue, RParenLoc, CurFPFeatureOverrides());
   }
-  return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
-                               ExecConfig, IsExecConfig);
+
+  Result = BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
+                                 ExecConfig, IsExecConfig);
+
+  if (FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(NDecl);
+      FDecl && FDecl->getBuiltinID() == Builtin::BI__builtin_get_counted_by) {
+    if (const MemberExpr *ME = ArgExprs[0]->getMemberExpr()) {
+      bool IsFlexibleArrayMember = ME->isFlexibleArrayMemberLike(
+          Context, getLangOpts().getStrictFlexArraysLevel());
+
+      if (!ME->HasSideEffects(Context) && IsFlexibleArrayMember &&
----------------
Sirraide wrote:

Oh, also, this should issue a diagnostic (probably honestly just straight-up an 
error) if the expression isn’t a member access of any sort. Or is there a use 
case where this might be applied to something that isn’t even a member 
expression?

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

Reply via email to