diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index 06c5f005b5..75cf421af0 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -11384,6 +11384,12 @@ RefPtr generateIRForTranslationUnit( if (compileRequest->getLinkage()->m_optionSet.shouldRunNonEssentialValidation()) { + // We don't allow recursive types. + checkForRecursiveTypes(module, compileRequest->getSink()); + + if (compileRequest->getSink()->getErrorCount() != 0) + return module; + // Propagate `constexpr`-ness through the dataflow graph (and the // call graph) based on constraints imposed by different instructions. propagateConstExpr(module, compileRequest->getSink()); @@ -11395,10 +11401,6 @@ RefPtr generateIRForTranslationUnit( // instructions remain. checkForMissingReturns(module, compileRequest->getSink()); - - // We don't allow recursive types. - checkForRecursiveTypes(module, compileRequest->getSink()); - // Check for invalid differentiable function body. checkAutoDiffUsages(module, compileRequest->getSink()); diff --git a/tests/diagnostics/recursive-type.slang b/tests/diagnostics/recursive-type.slang new file mode 100644 index 0000000000..90f49aa86d --- /dev/null +++ b/tests/diagnostics/recursive-type.slang @@ -0,0 +1,14 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):-target spirv + +// CHECK: error 41001: + +struct Outer { + Outer next; // non-pointer + int y; +}; +RWStructuredBuffer Buf; + +[numthreads(1,1,1)] +void csmain() { + Buf[0].y = 0; +} \ No newline at end of file