[clang] [CUDA] Fix diagnosing of static variable initializers in device functions (PR #233925)
Mariya Podchishchaeva via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 21 04:27:30 PDT 2026
================
@@ -774,7 +774,7 @@ void SemaCUDA::checkAllowedInitializer(VarDecl *VD) {
IsSharedVar ? diag::err_shared_var_init : diag::err_dynamic_var_init)
<< Init->getSourceRange();
VD->setInvalidDecl();
- } else {
+ } else if (IdentifyTarget(VD) == CVT_Host) {
----------------
Fznamznon wrote:
Thank you, good catch. I preserved the check and added a test.
I also added some tests for template contexts, but it seems a missing error there is preexisting problem and not a regression of the patch https://godbolt.org/z/MbGn95Ydn
https://github.com/llvm/llvm-project/pull/233925
More information about the cfe-commits
mailing list