summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-check-decl.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-01-25 17:47:40 -0800
committerGitHub <noreply@github.com>2024-01-25 17:47:40 -0800
commit013bcf28da22fd569154bd9f98368e670fbeb873 (patch)
tree1fde8373912f2576744b7a797878d373cc51e531 /source/slang/slang-check-decl.cpp
parent64804ce0bec66a428f8784b5deb139535909c242 (diff)
Fixes for `module` and `include`. (#3519)
* Fix type checking of enum cases. * Allow decl to have same name as module. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
-rw-r--r--source/slang/slang-check-decl.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 0df9619b6..fe4a7d64c 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -528,6 +528,7 @@ namespace Slang
}
else if( auto enumCaseDeclRef = declRef.as<EnumCaseDecl>() )
{
+ sema->ensureDecl(declRef.declRefBase, DeclCheckState::Checked);
QualType qualType;
qualType.type = getType(astBuilder, enumCaseDeclRef);
qualType.isLeftValue = false;
@@ -5117,6 +5118,8 @@ namespace Slang
// TODO: Do we need/want to support generic cases some day?
auto parentEnumDecl = as<EnumDecl>(decl->parentDecl);
SLANG_ASSERT(parentEnumDecl);
+
+ decl->type.type = DeclRefType::create(m_astBuilder, makeDeclRef(parentEnumDecl));
// The tag type should have already been set by
// the surrounding `enum` declaration.
@@ -5852,6 +5855,13 @@ namespace Slang
}
}
+ if (as<ModuleDeclarationDecl>(oldDecl) || as<ModuleDeclarationDecl>(newDecl))
+ {
+ // It is allowed to have a decl whose name is the same as the module.
+ return SLANG_OK;
+ }
+
+
// For all other flavors of declaration, we do not
// allow duplicate declarations with the same name.
//