authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-31 16:04:26-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-31 16:04:26-05:00
logd13cec6894aa01b6a5dbf6a7cf9b071fa9c68666
tree3bf96fabf7d9df63ee9cc463ebd8c96207f8af23
parent88a253c64dc148a6f09e4e872e3abbcd37fcc18a

fix var args allocating wrong amount of memory in compiler


3 files changed, 7 insertions(+), 7 deletions(-)

src/analyze.cpp+3-3
......@@ -898,7 +898,7 @@ static TypeTableEntry *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
898898 return fn_type;
899899}
900900
901void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node) {
901void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_count_alloc) {
902902 assert(proto_node->type == NodeTypeFnProto);
903903 AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;
904904
......@@ -906,7 +906,7 @@ void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node) {
906906 fn_type_id->is_naked = fn_proto->is_nakedcc;
907907 fn_type_id->is_cold = fn_proto->is_coldcc;
908908 fn_type_id->param_count = fn_proto->params.length;
909 fn_type_id->param_info = allocate_nonzero<FnTypeParamInfo>(fn_type_id->param_count);
909 fn_type_id->param_info = allocate_nonzero<FnTypeParamInfo>(param_count_alloc);
910910 fn_type_id->next_param_index = 0;
911911 fn_type_id->is_var_args = fn_proto->is_var_args;
912912}
......@@ -916,7 +916,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
916916 AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;
917917
918918 FnTypeId fn_type_id = {0};
919 init_fn_type_id(&fn_type_id, proto_node);
919 init_fn_type_id(&fn_type_id, proto_node, proto_node->data.fn_proto.params.length);
920920
921921 for (; fn_type_id.next_param_index < fn_type_id.param_count; fn_type_id.next_param_index += 1) {
922922 AstNode *param_node = fn_proto->params.at(fn_type_id.next_param_index);
src/analyze.hpp+1-1
......@@ -70,7 +70,7 @@ VariableTableEntry *add_variable(CodeGen *g, AstNode *source_node, Scope *parent
7070TypeTableEntry *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node);
7171FnTableEntry *create_fn(AstNode *proto_node);
7272FnTableEntry *create_fn_raw(FnInline inline_value, bool internal_linkage);
73void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node);
73void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_count_alloc);
7474AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index);
7575FnTableEntry *scope_get_fn_if_root(Scope *scope);
7676bool type_requires_comptime(TypeTableEntry *type_entry);
src/ir.cpp+3-3
......@@ -7866,7 +7866,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
78667866 impl_fn->fndef_scope = create_fndef_scope(impl_fn->fn_def_node, parent_scope, impl_fn);
78677867 impl_fn->child_scope = &impl_fn->fndef_scope->base;
78687868 FnTypeId inst_fn_type_id = {0};
7869 init_fn_type_id(&inst_fn_type_id, fn_proto_node);
7869 init_fn_type_id(&inst_fn_type_id, fn_proto_node, call_param_count);
78707870 inst_fn_type_id.param_count = 0;
78717871 inst_fn_type_id.is_var_args = false;
78727872
......@@ -7875,7 +7875,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
78757875 GenericFnTypeId *generic_id = allocate<GenericFnTypeId>(1);
78767876 generic_id->fn_entry = fn_entry;
78777877 generic_id->param_count = 0;
7878 generic_id->params = allocate<ConstExprValue>(src_param_count);
7878 generic_id->params = allocate<ConstExprValue>(call_param_count);
78797879 size_t next_proto_i = 0;
78807880
78817881 if (first_arg_ptr) {
......@@ -11483,7 +11483,7 @@ static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruc
1148311483 assert(proto_node->type == NodeTypeFnProto);
1148411484
1148511485 FnTypeId fn_type_id = {0};
11486 init_fn_type_id(&fn_type_id, proto_node);
11486 init_fn_type_id(&fn_type_id, proto_node, proto_node->data.fn_proto.params.length);
1148711487
1148811488 bool depends_on_compile_var = false;
1148911489