[clang] e5d57ce - Revert "[Clang] Fix assertion when __block is used on global variables in C mode" (#190018)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 1 11:57:48 PDT 2026
Author: Arthur Eubanks
Date: 2026-04-01T18:57:42Z
New Revision: e5d57ce707e388219f0341002b8d8c908095bad1
URL: https://github.com/llvm/llvm-project/commit/e5d57ce707e388219f0341002b8d8c908095bad1
DIFF: https://github.com/llvm/llvm-project/commit/e5d57ce707e388219f0341002b8d8c908095bad1.diff
LOG: Revert "[Clang] Fix assertion when __block is used on global variables in C mode" (#190018)
Reverts llvm/llvm-project#183988
Breaks ObjC code, see
https://github.com/llvm/llvm-project/pull/183988#issuecomment-4134934748
Added:
Modified:
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaObjC.cpp
Removed:
clang/test/Sema/gh183974.c
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 98bd0d9fa807a..061ccd2492c49 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -430,7 +430,6 @@ Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed a bug where explicit nullability property attributes were not stored in AST nodes in Objective-C. (#GH179703)
- Fixed a crash when parsing Doxygen ``@param`` commands attached to invalid declarations or non-function entities. (#GH182737)
-- Fixed a assertion when __block is used on global variables in C mode. (#GH183974)
Miscellaneous Bug Fixes
^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/Sema/SemaObjC.cpp b/clang/lib/Sema/SemaObjC.cpp
index dcd1b35e8fbc7..dae30b7e941d1 100644
--- a/clang/lib/Sema/SemaObjC.cpp
+++ b/clang/lib/Sema/SemaObjC.cpp
@@ -1711,12 +1711,6 @@ 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;
- return;
- }
-
D->addAttr(::new (getASTContext()) BlocksAttr(getASTContext(), AL, type));
}
diff --git a/clang/test/Sema/gh183974.c b/clang/test/Sema/gh183974.c
deleted file mode 100644
index 642a622761f69..0000000000000
--- a/clang/test/Sema/gh183974.c
+++ /dev/null
@@ -1,5 +0,0 @@
-// RUN: %clang_cc1 -fblocks -fsyntax-only -verify %s
-
-__block int x; // expected-error {{__block attribute not allowed, only allowed on local variables}}
-
-int x;
More information about the cfe-commits
mailing list