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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 29 09:50:22 PDT 2026


================
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fblocks -fsyntax-only -verify %s
+
+ at interface MyClass {
+    // expected-warning at -1 {{class 'MyClass' defined without specifying a base class}}
+    // expected-note at -2 {{add a super class to fix this problem}}
+    __block int _myIvar;
----------------
AaronBallman wrote:

Thanks! I think this means that the diagnostic message we're emitting should be improved so it's not specific to local variables.

I'm not super familiar with Objective-C so some of this may not apply. @ahatanak would know better than me. But ideally, I think we should make sure we have test coverage for other edge cases like a static data member in C++, (non-type) template parameters, parameters, etc. And if this is more about linkage than about scope, things like global variables in an unnamed namespace, local static variables, etc.

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


More information about the cfe-commits mailing list