diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-01-31 16:04:26 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-01-31 16:04:26 -0500 |
| commit | d13cec6894aa01b6a5dbf6a7cf9b071fa9c68666 (patch) | |
| tree | 3bf96fabf7d9df63ee9cc463ebd8c96207f8af23 /src | |
| parent | 88a253c64dc148a6f09e4e872e3abbcd37fcc18a (diff) | |
| download | zig-d13cec6894aa01b6a5dbf6a7cf9b071fa9c68666.tar.gz zig-d13cec6894aa01b6a5dbf6a7cf9b071fa9c68666.zip | |
fix var args allocating wrong amount of memory in compiler
Diffstat (limited to 'src')
| -rw-r--r-- | src/analyze.cpp | 6 | ||||
| -rw-r--r-- | src/analyze.hpp | 2 | ||||
| -rw-r--r-- | src/ir.cpp | 6 |
3 files changed, 7 insertions, 7 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index f1f294fdd3..25065e9f88 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -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); diff --git a/src/analyze.hpp b/src/analyze.hpp index 2af0010557..c22835f038 100644 --- a/src/analyze.hpp +++ b/src/analyze.hpp @@ -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); diff --git a/src/ir.cpp b/src/ir.cpp index 48782ba907..ed4382d415 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -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; |
