Also allow #no_bounds_check on an expression #499

This commit is contained in:
gingerBill
2019-12-15 11:41:21 +00:00
parent 58d4d424c6
commit 4ba579bc25
7 changed files with 105 additions and 56 deletions

View File

@@ -1727,7 +1727,7 @@ Ast *parse_operand(AstFile *f, bool lhs) {
syntax_error(operand, "#no_deferred can only be applied to procedure calls");
operand = ast_bad_expr(f, token, f->curr_token);
}
operand->stmt_state_flags |= StmtStateFlag_no_deferred;
operand->state_flags |= StateFlag_no_deferred;
} */ else if (name.string == "file") {
return ast_basic_directive(f, token, name.string);
} else if (name.string == "line") { return ast_basic_directive(f, token, name.string);
@@ -1757,6 +1757,20 @@ Ast *parse_operand(AstFile *f, bool lhs) {
break;
}
return original_type;
} else if (name.string == "bounds_check") {
Ast *operand = parse_expr(f, lhs);
operand->state_flags |= StateFlag_bounds_check;
if ((operand->state_flags & StateFlag_no_bounds_check) != 0) {
syntax_error(token, "#bounds_check and #no_bounds_check cannot be applied together");
}
return operand;
} else if (name.string == "no_bounds_check") {
Ast *operand = parse_expr(f, lhs);
operand->state_flags |= StateFlag_no_bounds_check;
if ((operand->state_flags & StateFlag_bounds_check) != 0) {
syntax_error(token, "#bounds_check and #no_bounds_check cannot be applied together");
}
return operand;
} else {
operand = ast_tag_expr(f, token, name, parse_expr(f, false));
}
@@ -4025,15 +4039,15 @@ Ast *parse_stmt(AstFile *f) {
if (tag == "bounds_check") {
s = parse_stmt(f);
s->stmt_state_flags |= StmtStateFlag_bounds_check;
if ((s->stmt_state_flags & StmtStateFlag_no_bounds_check) != 0) {
s->state_flags |= StateFlag_bounds_check;
if ((s->state_flags & StateFlag_no_bounds_check) != 0) {
syntax_error(token, "#bounds_check and #no_bounds_check cannot be applied together");
}
return s;
} else if (tag == "no_bounds_check") {
s = parse_stmt(f);
s->stmt_state_flags |= StmtStateFlag_no_bounds_check;
if ((s->stmt_state_flags & StmtStateFlag_bounds_check) != 0) {
s->state_flags |= StateFlag_no_bounds_check;
if ((s->state_flags & StateFlag_bounds_check) != 0) {
syntax_error(token, "#bounds_check and #no_bounds_check cannot be applied together");
}
return s;