microsoft / microsoft/DirectXShaderCompiler
Semantics declarations on resources, static variables and cbuffer members should be an error/warning
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
There are many places where DXC currently accepts semantic declarations that don't really make much sense. This includes resource declarations, static variables and members of cbuffers. I wouldn't be surprised if I missed some other cases. This works with any semantic name as far as I can tell.
Steps to Reproduce
https://hlsl.godbolt.org/z/n19xv7zsv
Actual Behavior
All of the semantics do nothing in these cases, but there are no diagnostics emitted. It should probably at minimum be a warning like it is in clang. Regarding cbuffers specifically, it should technically still be valid to have a nested struct inside with semantics on its members because that struct could then be reused for a function entry point parameter or return value, but you cannot directly use a cbuffer that way because it is not considered a struct and thus semantic declarations on its direct (non-nested) members should be rejected.
Environment
- DXC version: 1.6+
- Host Operating System: All
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Godbolt reproduction to identify each accepted semantic declaration on resources, static variables, and direct cbuffer members. Trace the compiler's semantic validation and add diagnostics for invalid placements while preserving semantics on nested structs; finish by adding or running regression coverage for the reported cases.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100