aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-04-06 21:00:49 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-04-06 21:00:49 -0400
commita3de550d3bf020fd68e1331d3cb8b7b422894f96 (patch)
treef6d5a2a173bc3dd6c42fc0581cc1ec9d06fa3cea /src/ir.cpp
parent273cebdf4dde46f00eb177b9aa05d8dd1c0606a7 (diff)
downloadzig-a3de550d3bf020fd68e1331d3cb8b7b422894f96.tar.gz
zig-a3de550d3bf020fd68e1331d3cb8b7b422894f96.zip
fix var args having wrong index when runtime param before it
closes #312
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 79f4a27914..c7c9c6490c 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -8346,7 +8346,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
}
bool found_first_var_arg = false;
- size_t first_var_arg = inst_fn_type_id.param_count;
+ size_t first_var_arg;
FnTableEntry *parent_fn_entry = exec_fn_entry(ira->new_irb.exec);
assert(parent_fn_entry);
@@ -8394,6 +8394,10 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(next_proto_i);
Buf *param_name = param_decl_node->data.param_decl.name;
+ if (!found_first_var_arg) {
+ first_var_arg = inst_fn_type_id.param_count;
+ }
+
ConstExprValue *var_args_val = create_const_arg_tuple(ira->codegen,
first_var_arg, inst_fn_type_id.param_count);
VariableTableEntry *var = add_variable(ira->codegen, param_decl_node,