summaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
Diffstat (limited to 'types.c')
-rw-r--r--types.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/types.c b/types.c
index 9d36e78..f202bca 100644
--- a/types.c
+++ b/types.c
@@ -3375,6 +3375,21 @@ static Status types_stmt(Typer *tr, Statement *s) {
return false;
}
} break;
+ case STMT_BREAK:
+ case STMT_CONT: {
+ /* make sure we are actually in a loop */
+ Block *block;
+ for (block = tr->block; block; block = block->parent) {
+ if (block->flags & BLOCK_IS_LOOP) {
+ s->referring_to = block;
+ break;
+ }
+ }
+ if (!block) {
+ err_print(s->where, "%s not in loop.", s->kind == STMT_BREAK ? "break" : "continue");
+ return false;
+ }
+ } break;
}
s->flags |= STMT_TYPED;
return true;