[clang] [clang] Fix static local variables in consteval functions (PR #156933)
John McCall via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 12 07:41:43 PDT 2025
================
@@ -432,7 +443,8 @@ void CodeGenFunction::EmitStaticVarDecl(const VarDecl &D,
bool isCudaSharedVar = getLangOpts().CUDA && getLangOpts().CUDAIsDevice &&
D.hasAttr<CUDASharedAttr>();
// If this value has an initializer, emit it.
- if (D.getInit() && !isCudaSharedVar) {
+ if (D.getInit() && !isCudaSharedVar &&
+ !(D.isUsableInConstantExpressions(getContext()) && D.isStaticLocal())) {
----------------
rjmccall wrote:
Ah, right, sometimes we emit constant local variables as globals. Um... well, actually, there's no reason we couldn't be lazy about those as well if they're not ODR-used. There's no harm in that.
https://github.com/llvm/llvm-project/pull/156933
More information about the cfe-commits
mailing list