summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-check-expr.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-11-02 20:35:44 -0700
committerGitHub <noreply@github.com>2024-11-02 20:35:44 -0700
commit5f4980a16e0df12b9d91c2fca12d6c57473ab6c9 (patch)
tree598ebcdd34ee39b11533bf00c0e85faa7aa61a10 /source/slang/slang-check-expr.cpp
parentf4d5aa73fb72a483f04bb6b014e80192331504ea (diff)
Allow enum cases to be used in attribute arguments. (#5478)
Diffstat (limited to 'source/slang/slang-check-expr.cpp')
-rw-r--r--source/slang/slang-check-expr.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp
index 8c170698b..47eb6be45 100644
--- a/source/slang/slang-check-expr.cpp
+++ b/source/slang/slang-check-expr.cpp
@@ -2038,6 +2038,12 @@ IntVal* SemanticsVisitor::tryConstantFoldExpr(
}
else if (auto enumRef = declRef.as<EnumCaseDecl>())
{
+ auto enumTypeDecl = enumRef.getParent().getDecl();
+ if (enumTypeDecl && !enumTypeDecl->checkState.isBeingChecked())
+ {
+ ensureDecl(enumRef.getParent(), DeclCheckState::DefinitionChecked);
+ }
+
// The cases in an `enum` declaration can also be used as constant expressions,
if (auto tagExpr = getTagExpr(m_astBuilder, enumRef))
{