diff options
| author | Copilot <198982749+Copilot@users.noreply.github.com> | 2025-07-17 23:53:43 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-17 23:53:43 +0000 |
| commit | 447d73f8c2245d061b0e84890fb994a77816a736 (patch) | |
| tree | 1361e7d1a28c225f46a7e2c5ad86a7ffcea0897b /source | |
| parent | 094d1ba7cd1eb5f09be05b2e57b5fbd3041cca38 (diff) | |
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>
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-check-decl.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
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<GLSLModuleModifier>()) + { + getSink()->diagnose( + decl, + Diagnostics::constGlobalVarWithInitRequiresStatic, + decl->getName()); + } } } |
