Disallow instructions as a switch expression

This commit is contained in:
Alex Beregszaszi
2017-05-26 03:20:34 +01:00
parent d745dd6542
commit c64bd33784
2 changed files with 3 additions and 1 deletions
+2
View File
@@ -72,6 +72,8 @@ assembly::Statement Parser::parseStatement()
assembly::Switch _switch = createWithLocation<assembly::Switch>();
m_scanner->next();
_switch.expression = make_shared<Statement>(parseExpression());
if (_switch.expression->type() == typeid(assembly::Instruction))
fatalParserError("Instructions are not supported as expressions for switch.");
while (m_scanner->currentToken() == Token::Case)
_switch.cases.emplace_back(parseCase());
if (m_scanner->currentToken() == Token::Default)