[clang] [Clang] Fix assertion when __block is used on global variables in C mode (PR #194856)

via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 29 18:02:26 PDT 2026


================
@@ -1711,6 +1711,12 @@ void SemaObjC::handleBlocksAttr(Decl *D, const ParsedAttr &AL) {
     return;
   }
 
+  VarDecl *VD = dyn_cast<VarDecl>(D);
+  if (VD && !VD->hasLocalStorage()) {
+    Diag(AL.getLoc(), diag::err_block_on_nonlocal) << AL;
----------------
TPPPP72 wrote:

In fact, such check already exist, but they still cause crashes.
https://github.com/llvm/llvm-project/blob/0abb4569da0328441f14edb14be59da08c46ccac/clang/lib/Sema/SemaDecl.cpp#L9165-L9169

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


More information about the cfe-commits mailing list