summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-validate.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-04-12 14:40:30 -0700
committerGitHub <noreply@github.com>2024-04-12 14:40:30 -0700
commitb937207dccd05f700855e9aeb3f7c375b595b827 (patch)
tree19146073437f9f02c7784f974519cce02ca7a6db /source/slang/slang-ir-validate.cpp
parent565a871ad899c01dc6a1b4bdb1b9d2bc4281758f (diff)
Fix IR lowering bug of do-while loops. (#3941)
Diffstat (limited to 'source/slang/slang-ir-validate.cpp')
-rw-r--r--source/slang/slang-ir-validate.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/source/slang/slang-ir-validate.cpp b/source/slang/slang-ir-validate.cpp
index 2868c9929..a4a2921fe 100644
--- a/source/slang/slang-ir-validate.cpp
+++ b/source/slang/slang-ir-validate.cpp
@@ -66,6 +66,7 @@ namespace Slang
State state = kState_Initial;
IRInst* prevChild = nullptr;
+ bool hasSeenTerminatorInst = false;
for(auto child : parent->getDecorationsAndChildren() )
{
// We need to check the integrity of the parent/next/prev links of
@@ -105,7 +106,11 @@ namespace Slang
validate(context, !as<IRTerminatorInst>(child), child, "terminator must be last instruction in a block");
}
-
+ if (as<IRTerminatorInst>(child))
+ {
+ validate(context, !hasSeenTerminatorInst, child, "block must not contain more than one terminator");
+ hasSeenTerminatorInst = true;
+ }
prevChild = child;
}
}