| author | |
| committer | |
| log | a6bf37f8ca5a2eabc7cacb22696d2a2c622a993d |
| tree | 615f02861d70bc18bb210e3435d685f6e6c808ec |
| parent | c7f70893923cd0a9d3be79b352e2674a87ad8127 |
| parent | 52f4e934a963a5497bd5dd9834e6c419cd171ae4 |
| signature |
3 files changed, 11 insertions(+), 1 deletions(-)
src/analyze.cpp+3| ... | ... | @@ -1224,6 +1224,9 @@ ZigType *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) { |
| 1224 | 1224 | |
| 1225 | 1225 | fn_type->data.fn.gen_param_count = gen_param_types.length; |
| 1226 | 1226 | |
| 1227 | for (size_t i = 0; i < gen_param_types.length; i += 1) { | |
| 1228 | assert(gen_param_types.items[i] != nullptr); | |
| 1229 | } | |
| 1227 | 1230 | fn_type->data.fn.raw_type_ref = LLVMFunctionType(gen_return_type->type_ref, |
| 1228 | 1231 | gen_param_types.items, (unsigned int)gen_param_types.length, fn_type_id->is_var_args); |
| 1229 | 1232 | fn_type->type_ref = LLVMPointerType(fn_type->data.fn.raw_type_ref, 0); |
src/ir.cpp+7-1| ... | ... | @@ -19643,7 +19643,7 @@ static ZigType *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstructionFnP |
| 19643 | 19643 | return ira->codegen->builtin_types.entry_invalid; |
| 19644 | 19644 | if (type_requires_comptime(param_type)) { |
| 19645 | 19645 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { |
| 19646 | ir_add_error(ira, &instruction->base, | |
| 19646 | ir_add_error(ira, param_type_value, | |
| 19647 | 19647 | buf_sprintf("parameter of type '%s' not allowed in function with calling convention '%s'", |
| 19648 | 19648 | buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc))); |
| 19649 | 19649 | return ira->codegen->builtin_types.entry_invalid; |
| ... | ... | @@ -19654,6 +19654,12 @@ static ZigType *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstructionFnP |
| 19654 | 19654 | out_val->data.x_type = get_generic_fn_type(ira->codegen, &fn_type_id); |
| 19655 | 19655 | return ira->codegen->builtin_types.entry_type; |
| 19656 | 19656 | } |
| 19657 | if (!type_has_bits(param_type) && !calling_convention_allows_zig_types(fn_type_id.cc)) { | |
| 19658 | ir_add_error(ira, param_type_value, | |
| 19659 | buf_sprintf("parameter of type '%s' has 0 bits; not allowed in function with calling convention '%s'", | |
| 19660 | buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc))); | |
| 19661 | return ira->codegen->builtin_types.entry_invalid; | |
| 19662 | } | |
| 19657 | 19663 | param_info->type = param_type; |
| 19658 | 19664 | } |
| 19659 | 19665 |
test/compile_errors.zig+1| ... | ... | @@ -1291,6 +1291,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 1291 | 1291 | \\ |
| 1292 | 1292 | \\extern fn bar(x: *void) void { } |
| 1293 | 1293 | , |
| 1294 | ".tmp_source.zig:1:30: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'ccc'", | |
| 1294 | 1295 | ".tmp_source.zig:7:18: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'ccc'", |
| 1295 | 1296 | ); |
| 1296 | 1297 |