summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-03-10 21:02:36 -0700
committerGitHub <noreply@github.com>2024-03-10 21:02:36 -0700
commit10c4d2e76af284903c7552a05ad757c2a608b803 (patch)
tree444afffb3d81403c653a54a9c5f45e5d9409522a
parent5074ee7c8a7f154273ed26815a8018df27dc03bb (diff)
Fix crash when trying to constant fold non-existent call. (#3728)
-rw-r--r--source/slang/slang-check-expr.cpp2
-rw-r--r--tests/bugs/gh-3727.slang10
2 files changed, 12 insertions, 0 deletions
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp
index 8b6fe76c7..ea6afdc1d 100644
--- a/source/slang/slang-check-expr.cpp
+++ b/source/slang/slang-check-expr.cpp
@@ -1424,6 +1424,8 @@ namespace Slang
if (!funcDeclRefExpr) return nullptr;
auto funcDeclRef = getDeclRef(m_astBuilder, funcDeclRefExpr);
+ if (!funcDeclRef)
+ return nullptr;
auto intrinsicMod = funcDeclRef.getDecl()->findModifier<IntrinsicOpModifier>();
auto implicitCast = funcDeclRef.getDecl()->findModifier<ImplicitConversionModifier>();
if (!intrinsicMod && !implicitCast)
diff --git a/tests/bugs/gh-3727.slang b/tests/bugs/gh-3727.slang
new file mode 100644
index 000000000..89480d146
--- /dev/null
+++ b/tests/bugs/gh-3727.slang
@@ -0,0 +1,10 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage compute -entry main
+
+// CHECK: undefined identifier
+
+[shader("compute")]
+[numthreads(1, 1, 1)]
+void main(uint3 dtid : SV_DispatchThreadID)
+{
+ const uint index = does_not_exist();
+} \ No newline at end of file