From 447d73f8c2245d061b0e84890fb994a77816a736 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 17 Jul 2025 23:53:43 +0000 Subject: Fix GLSL global const diagnostic regression (#7808) * Initial plan * Fix GLSL global const diagnostic regression - add test exclusion for GLSL module Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --- source/slang/slang-check-decl.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index 46876131a..1dc230dae 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -240,13 +240,19 @@ struct SemanticsDeclModifiersVisitor : public SemanticsDeclVisitorBase, // In HLSL, const global variables without static are uniform parameters // that cannot have default values // Exception: specialization constants are allowed to have initializers + // Exception: In GLSL mode, global const variables are real constants, not uniform + // parameters if (isGlobalDecl(decl) && (hasConst || hasUniform) && !hasStatic && !hasSpecializationConstant && decl->initExpr) { - getSink()->diagnose( - decl, - Diagnostics::constGlobalVarWithInitRequiresStatic, - decl->getName()); + auto moduleDecl = getModuleDecl(decl); + if (!moduleDecl || !moduleDecl->hasModifier()) + { + getSink()->diagnose( + decl, + Diagnostics::constGlobalVarWithInitRequiresStatic, + decl->getName()); + } } } -- cgit v1.2.3