[clang] [Clang] support storage-class specifiers in C23 compound literals (PR #212559)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 29 09:56:41 PDT 2026


================
@@ -1360,8 +1360,10 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
       else
         Ty = VD->getType();
 
-      if (Ty->isVariablyModifiedType())
+      if (Ty->isVariablyModifiedType()) {
+        RunCleanupsScope Scope(*this);
----------------
AaronBallman wrote:

> That said, "destroying" a compound literal doesn't really do anything at the moment; outside of ObjC ARC, C doesn't have destructors, and we don't emit lifetime intrinsics (#68746) .

C does now have `_Defer` though for running cleanups at the appropriate time, we have lifetime analysis in C, and we have `__attribute__((cleanup))` (though that's on a declaration of a variable and shouldn't matter here). Given that a common idiom in C is to take the address of the compound literal (because it's an lvalue, unlike in C++), I think we have to be careful about getting cleanups correct.

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


More information about the cfe-commits mailing list