Skip to content

Commit 2bec21e

Browse files
Fix crash on recursive types. (#5796)
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
1 parent 2e7774a commit 2bec21e

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

source/slang/slang-lower-to-ir.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -11384,6 +11384,12 @@ RefPtr<IRModule> generateIRForTranslationUnit(
1138411384

1138511385
if (compileRequest->getLinkage()->m_optionSet.shouldRunNonEssentialValidation())
1138611386
{
11387+
// We don't allow recursive types.
11388+
checkForRecursiveTypes(module, compileRequest->getSink());
11389+
11390+
if (compileRequest->getSink()->getErrorCount() != 0)
11391+
return module;
11392+
1138711393
// Propagate `constexpr`-ness through the dataflow graph (and the
1138811394
// call graph) based on constraints imposed by different instructions.
1138911395
propagateConstExpr(module, compileRequest->getSink());
@@ -11395,10 +11401,6 @@ RefPtr<IRModule> generateIRForTranslationUnit(
1139511401
// instructions remain.
1139611402

1139711403
checkForMissingReturns(module, compileRequest->getSink());
11398-
11399-
// We don't allow recursive types.
11400-
checkForRecursiveTypes(module, compileRequest->getSink());
11401-
1140211404
// Check for invalid differentiable function body.
1140311405
checkAutoDiffUsages(module, compileRequest->getSink());
1140411406

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):-target spirv
2+
3+
// CHECK: error 41001:
4+
5+
struct Outer {
6+
Outer next; // non-pointer
7+
int y;
8+
};
9+
RWStructuredBuffer<Outer> Buf;
10+
11+
[numthreads(1,1,1)]
12+
void csmain() {
13+
Buf[0].y = 0;
14+
}

0 commit comments

Comments
 (0)