fix var args allocating wrong amount of memory in compiler

master
Andrew Kelley 2017-01-31 16:04:26 -05:00
parent 88a253c64d
commit d13cec6894
3 changed files with 7 additions and 7 deletions

View File

@ -898,7 +898,7 @@ static TypeTableEntry *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
return fn_type;
}
void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node) {
void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_count_alloc) {
assert(proto_node->type == NodeTypeFnProto);
AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;
@ -906,7 +906,7 @@ void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node) {
fn_type_id->is_naked = fn_proto->is_nakedcc;
fn_type_id->is_cold = fn_proto->is_coldcc;
fn_type_id->param_count = fn_proto->params.length;
fn_type_id->param_info = allocate_nonzero<FnTypeParamInfo>(fn_type_id->param_count);
fn_type_id->param_info = allocate_nonzero<FnTypeParamInfo>(param_count_alloc);
fn_type_id->next_param_index = 0;
fn_type_id->is_var_args = fn_proto->is_var_args;
}
@ -916,7 +916,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;
FnTypeId fn_type_id = {0};
init_fn_type_id(&fn_type_id, proto_node);
init_fn_type_id(&fn_type_id, proto_node, proto_node->data.fn_proto.params.length);
for (; fn_type_id.next_param_index < fn_type_id.param_count; fn_type_id.next_param_index += 1) {
AstNode *param_node = fn_proto->params.at(fn_type_id.next_param_index);

View File

@ -70,7 +70,7 @@ VariableTableEntry *add_variable(CodeGen *g, AstNode *source_node, Scope *parent
TypeTableEntry *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node);
FnTableEntry *create_fn(AstNode *proto_node);
FnTableEntry *create_fn_raw(FnInline inline_value, bool internal_linkage);
void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node);
void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_count_alloc);
AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index);
FnTableEntry *scope_get_fn_if_root(Scope *scope);
bool type_requires_comptime(TypeTableEntry *type_entry);

View File

@ -7866,7 +7866,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
impl_fn->fndef_scope = create_fndef_scope(impl_fn->fn_def_node, parent_scope, impl_fn);
impl_fn->child_scope = &impl_fn->fndef_scope->base;
FnTypeId inst_fn_type_id = {0};
init_fn_type_id(&inst_fn_type_id, fn_proto_node);
init_fn_type_id(&inst_fn_type_id, fn_proto_node, call_param_count);
inst_fn_type_id.param_count = 0;
inst_fn_type_id.is_var_args = false;
@ -7875,7 +7875,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
GenericFnTypeId *generic_id = allocate<GenericFnTypeId>(1);
generic_id->fn_entry = fn_entry;
generic_id->param_count = 0;
generic_id->params = allocate<ConstExprValue>(src_param_count);
generic_id->params = allocate<ConstExprValue>(call_param_count);
size_t next_proto_i = 0;
if (first_arg_ptr) {
@ -11483,7 +11483,7 @@ static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruc
assert(proto_node->type == NodeTypeFnProto);
FnTypeId fn_type_id = {0};
init_fn_type_id(&fn_type_id, proto_node);
init_fn_type_id(&fn_type_id, proto_node, proto_node->data.fn_proto.params.length);
bool depends_on_compile_var = false;