summaryrefslogtreecommitdiff
path: root/05/parse.b
diff options
context:
space:
mode:
Diffstat (limited to '05/parse.b')
-rw-r--r--05/parse.b9
1 files changed, 9 insertions, 0 deletions
diff --git a/05/parse.b b/05/parse.b
index 93de88e..15851d9 100644
--- a/05/parse.b
+++ b/05/parse.b
@@ -522,7 +522,11 @@ function parse_statement
token += 16
out += 8
*8out = expressions_end
+ c = expressions_end + 4
expressions_end = parse_expression(token, p, expressions_end)
+ c = types + *4c
+ if *1c > TYPE_UNSIGNED_LONG goto bad_switch_type
+
token = p + 16
out += 8
@@ -542,6 +546,11 @@ function parse_statement
:str_switch_no_lparen
string No ( after switch.
byte 0
+ :bad_switch_type
+ token_error(token, .str_bad_switch_type)
+ :str_bad_switch_type
+ string The expression in a switch statement must have an integer type.
+ byte 0
:stmt_while
write_statement_header(out, STATEMENT_WHILE, token)
token += 16