Commits

Anonymous committed 097041d

Serializer Now uses the correct exit block when processing the exit branch of BLOCKS followed by CONTINUE or BREAK without body

Comments (0)

Files changed (1)

lib/axtor/pass/Serializer.cpp

 								(itNode + 2) == node->end() &&
 								(*(itNode + 1))->getEntryBlock() == 0
 						) {
-							nextExitBlock = exitBlock;
+							ast::ControlNode * nextNode = *(itNode + 1);
+							// TODO clean this up
+							switch (nextNode->getType())
+							{
+							case ast::ControlNode::CONTINUE:
+								assert(loopHeader && "can not CONTINUE w/o loop header");
+								nextExitBlock = loopHeader; break;
+
+							case ast::ControlNode::BREAK:
+								assert(loopExit && "can not BREAK w/o loop exit");
+								nextExitBlock = loopExit; break;
+
+							default:
+								nextExitBlock = exitBlock; break;
+							}
 
 						// inner node case
 						} else {