microsoft / microsoft/DirectXShaderCompiler
C++11 enums don’t work as integer constants as expected
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Is your feature request related to a problem? Please describe.
Thanks to HLSL2021 I can share enumeration declarations between C++ and HLSL202x.
Bug Report: However whenever I declare the enum class HLSL does not complain until I actually try to use the scoped enum. Seems that enum class passes through your tokenizer unharmed, but then the rest of the logic is gone.
Describe the solution you'd like
For the compiler to support scope enum lookup enum_t:: without errors.
Describe alternatives you've considered
Not using scoped enums but a lot of my C++ code I want to expose to HLSL already does, so not fun.
Additional context
Here's a repro:
https://godbolt.org/z/1TdYh9E1a
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 by reproducing the scoped-enum lookup failure with the linked Godbolt example and trace how the DirectX Shader Compiler parses and resolves enum class references. Confirm that enum_t:: uses compile without errors while preserving the shared C++/HLSL declarations; the payload does not name a source file or test to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100