aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-08-31 16:54:20 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-08-31 16:54:20 -0400
commitc42e809f132d91fca1f96da2ecff7d78e1085c3f (patch)
treecebe89ba65d63fa5518a08977725553a0b374b8c /src/ir.cpp
parent67b6dd28ec70937a29176719b56457ee17b1c136 (diff)
downloadzig-c42e809f132d91fca1f96da2ecff7d78e1085c3f.tar.gz
zig-c42e809f132d91fca1f96da2ecff7d78e1085c3f.zip
setEvalBranchQuota must be called from top of comptime stack
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index f8b6c4cdf7..74a48f6f50 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -7604,13 +7604,13 @@ static bool ir_emit_backward_branch(IrAnalyze *ira, IrInstruction *source_instru
size_t *bbc = ira->new_irb.exec->backward_branch_count;
size_t quota = ira->new_irb.exec->backward_branch_quota;
- if (ira->new_irb.exec->reported_quota_exceeded) {
+ // If we're already over quota, we've already given an error message for this.
+ if (*bbc > quota) {
return false;
}
*bbc += 1;
if (*bbc > quota) {
- ira->new_irb.exec->reported_quota_exceeded = true;
ir_add_error(ira, source_instruction, buf_sprintf("evaluation exceeded %" ZIG_PRI_usize " backwards branches", quota));
return false;
}
@@ -13285,6 +13285,12 @@ static TypeTableEntry *ir_analyze_instruction_type_id(IrAnalyze *ira,
static TypeTableEntry *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ira,
IrInstructionSetEvalBranchQuota *instruction)
{
+ if (ira->new_irb.exec->parent_exec != nullptr) {
+ ir_add_error(ira, &instruction->base,
+ buf_sprintf("@setEvalBranchQuota must be called from the top of the comptime stack"));
+ return ira->codegen->builtin_types.entry_invalid;
+ }
+
uint64_t new_quota;
if (!ir_resolve_usize(ira, instruction->new_quota->other, &new_quota))
return ira->codegen->builtin_types.entry_invalid;