[clang] [CUDA] Treat function-scope statics in device code as device variables (PR #222985)
Ambrose Leeb via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 2 10:50:48 PDT 2026
================
@@ -764,8 +764,26 @@ void SemaCUDA::checkAllowedInitializer(VarDecl *VD) {
if (VD->isInvalidDecl() || !VD->hasInit() || !VD->hasGlobalStorage() ||
IsDependentVar(VD))
return;
+
+ // A function-scope static is a device variable when it is emitted on the
+ // device side, and has the same initialization restrictions.
+ CUDAVariableTarget VT = IdentifyTarget(VD);
----------------
Sirraide wrote:
I checked the implementation of `IdentifyTarget()`, and it should be updated to use `getEnclosingFunction()` rather than attempting to cast the parent `DeclContext` of the `VarDecl` directly
https://github.com/llvm/llvm-project/pull/222985
More information about the cfe-commits
mailing list