| author | |
| committer | |
| log | a380b803ac8b4eefcde4d3d552cdcbc8010aa798 |
| tree | de6309db31e1614467295bfd82c3bc27928bd27b |
| parent | ae600d2f7f89989c297c036f189b7bedfde910af |
3 files changed, 15 insertions(+), 2 deletions(-)
src/analyze.cpp+2-1| ... | @@ -2219,7 +2219,8 @@ static TypeTableEntry *analyze_container_init_expr(CodeGen *g, ImportTableEntry | ... | @@ -2219,7 +2219,8 @@ static TypeTableEntry *analyze_container_init_expr(CodeGen *g, ImportTableEntry |
| 2219 | return container_type; | 2219 | return container_type; |
| 2220 | } else if (container_type->id == TypeTableEntryIdStruct && | 2220 | } else if (container_type->id == TypeTableEntryIdStruct && |
| 2221 | !container_type->data.structure.is_unknown_size_array && | 2221 | !container_type->data.structure.is_unknown_size_array && |
| 2222 | kind == ContainerInitKindStruct) | 2222 | (kind == ContainerInitKindStruct || (kind == ContainerInitKindArray && |
| 2223 | container_init_expr->entries.length == 0))) | ||
| 2223 | { | 2224 | { |
| 2224 | StructValExprCodeGen *codegen = &container_init_expr->resolved_struct_val_expr; | 2225 | StructValExprCodeGen *codegen = &container_init_expr->resolved_struct_val_expr; |
| 2225 | codegen->type_entry = container_type; | 2226 | codegen->type_entry = container_type; |
src/codegen.cpp+3-1| ... | @@ -801,14 +801,16 @@ static LLVMValueRef gen_fn_call_expr(CodeGen *g, AstNode *node) { | ... | @@ -801,14 +801,16 @@ static LLVMValueRef gen_fn_call_expr(CodeGen *g, AstNode *node) { |
| 801 | gen_param_values[gen_param_index] = node->data.fn_call_expr.tmp_ptr; | 801 | gen_param_values[gen_param_index] = node->data.fn_call_expr.tmp_ptr; |
| 802 | gen_param_index += 1; | 802 | gen_param_index += 1; |
| 803 | } | 803 | } |
| 804 | if (struct_type) { | 804 | if (struct_type && type_has_bits(struct_type)) { |
| 805 | gen_param_values[gen_param_index] = gen_expr(g, first_param_expr); | 805 | gen_param_values[gen_param_index] = gen_expr(g, first_param_expr); |
| 806 | assert(gen_param_values[gen_param_index]); | ||
| 806 | gen_param_index += 1; | 807 | gen_param_index += 1; |
| 807 | } | 808 | } |
| 808 | 809 | ||
| 809 | for (int i = 0; i < fn_call_param_count; i += 1) { | 810 | for (int i = 0; i < fn_call_param_count; i += 1) { |
| 810 | AstNode *expr_node = node->data.fn_call_expr.params.at(i); | 811 | AstNode *expr_node = node->data.fn_call_expr.params.at(i); |
| 811 | LLVMValueRef param_value = gen_expr(g, expr_node); | 812 | LLVMValueRef param_value = gen_expr(g, expr_node); |
| 813 | assert(param_value); | ||
| 812 | TypeTableEntry *param_type = get_expr_type(expr_node); | 814 | TypeTableEntry *param_type = get_expr_type(expr_node); |
| 813 | if (is_var_args || type_has_bits(param_type)) { | 815 | if (is_var_args || type_has_bits(param_type)) { |
| 814 | gen_param_values[gen_param_index] = param_value; | 816 | gen_param_values[gen_param_index] = param_value; |
test/self_hosted.zig+10| ... | @@ -1285,3 +1285,13 @@ fn mangle_string(s: []u8) { | ... | @@ -1285,3 +1285,13 @@ fn mangle_string(s: []u8) { |
| 1285 | *c += 1; | 1285 | *c += 1; |
| 1286 | } | 1286 | } |
| 1287 | } | 1287 | } |
| 1288 | |||
| 1289 | #attribute("test") | ||
| 1290 | fn empty_struct_method_call() { | ||
| 1291 | const es = EmptyStruct{}; | ||
| 1292 | assert(es.method() == 1234); | ||
| 1293 | } | ||
| 1294 | struct EmptyStruct { | ||
| 1295 | #static_eval_enable(false) | ||
| 1296 | fn method(es: EmptyStruct) -> i32 { 1234 } | ||
| 1297 | } |