<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/tests/diagnostics/global-const-uniform-with-init.slang, branch master</title>
<subtitle>Making it easier to work with shaders</subtitle>
<id>https://git.yummers.dev/slang.git/atom?h=master</id>
<link rel='self' href='https://git.yummers.dev/slang.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/'/>
<updated>2025-07-16T06:36:18+00:00</updated>
<entry>
<title>Diagnose on initExpr of a global `const` decl (#7711)</title>
<updated>2025-07-16T06:36:18+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2025-07-16T06:36:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=56e91e91e425b77a9d1512cca3d26ce446781935'/>
<id>urn:sha1:56e91e91e425b77a9d1512cca3d26ce446781935</id>
<content type='text'>
* Add diagnostic for const/uniform global variables with initializers

Global const and uniform variables without the static modifier are
treated as uniform parameters in HLSL, which cannot have default values.
This change adds error 31224 to catch this case early and provide clear
guidance to users.

Fixes #7701

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Yong He &lt;csyonghe@users.noreply.github.com&gt;

* Add test case for global const/uniform variable diagnostic

Add test for diagnostic 31224 which catches global const and uniform
variables with initializers that aren't declared static. The test
verifies both error cases and valid cases to ensure the diagnostic
works correctly.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Yong He &lt;csyonghe@users.noreply.github.com&gt;

* Fix failing tests due to new global const diagnostic

Add 'static' keyword to global const variables with initializers
to resolve diagnostic 31224: "global const variable with initializer
must be declared static"

Co-authored-by: Jay Kwak &lt;jkwak-work@users.noreply.github.com&gt;

* Allow specialization constants with initializers without static

- Modified diagnostic logic in slang-check-decl.cpp to allow specialization
  constants (SpecializationConstantAttribute and VkConstantIdAttribute) to
  have initializers without requiring the static keyword
- Updated 8 SPIRV test files to remove unnecessary static keywords from
  specialization constant declarations
- Enhanced diagnostic test case to include specialization constant examples
- All tests passing with the new behavior

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Yong He &lt;csyonghe@users.noreply.github.com&gt;

* format code (#7765)

Co-authored-by: slangbot &lt;186143334+slangbot@users.noreply.github.com&gt;

* Remove static keyword from specialization constants and add comprehensive test cases

- Remove static from specialization constants in test files as they are semantically meaningless
- Update tests to use existing diagnostic 31219 for static specialization constant errors
- Add comprehensive test cases that verify the error occurs when static is used with specialization constants
- Fixes suggested in PR review to make static specialization constants an error

Co-authored-by: ArielG-NV &lt;ArielG-NV@users.noreply.github.com&gt;

* Add error for static specialization constants

Static specialization constants are semantically meaningless and should
produce an error. This change adds logic to trigger diagnostic 31219
when both 'static' and specialization constant attributes are present.

The existing diagnostic 31219 'push or specialization constants cannot
be static' is now correctly triggered for:
- [SpecializationConstant] static const variables
- [vk::constant_id] static const variables

Co-authored-by: ArielG-NV &lt;ArielG-NV@users.noreply.github.com&gt;

* Update source/slang/slang-check-decl.cpp

* Update tests/glsl/compute-shader-layout-id.slang

* Update tests/glsl/compute-shader-layout-id.slang

* Fix test case Claude broke

* Update global-uniform.slang

* Update global-uniform.slang.expected

---------

Co-authored-by: github-actions[bot] &lt;41898282+github-actions[bot]@users.noreply.github.com&gt;
Co-authored-by: Yong He &lt;csyonghe@users.noreply.github.com&gt;
Co-authored-by: ArielG-NV &lt;159081215+ArielG-NV@users.noreply.github.com&gt;
Co-authored-by: Jay Kwak &lt;jkwak-work@users.noreply.github.com&gt;
Co-authored-by: slangbot &lt;ellieh+slangbot@nvidia.com&gt;
Co-authored-by: slangbot &lt;186143334+slangbot@users.noreply.github.com&gt;
Co-authored-by: ArielG-NV &lt;ArielG-NV@users.noreply.github.com&gt;</content>
</entry>
</feed>
