authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-10 22:45:20-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-10 22:45:20-04:00
loga6bf37f8ca5a2eabc7cacb22696d2a2c622a993d
tree615f02861d70bc18bb210e3435d685f6e6c808ec
parentc7f70893923cd0a9d3be79b352e2674a87ad8127
parent52f4e934a963a5497bd5dd9834e6c419cd171ae4
signaturelock-open Commit is signed but in an unrecognized format.

Merge remote-tracking branch 'origin/master' into llvm7


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,6 +1224,9 @@ ZigType *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
12241224
1225 fn_type->data.fn.gen_param_count = gen_param_types.length;1225 fn_type->data.fn.gen_param_count = gen_param_types.length;
12261226
1227 for (size_t i = 0; i < gen_param_types.length; i += 1) {
1228 assert(gen_param_types.items[i] != nullptr);
1229 }
1227 fn_type->data.fn.raw_type_ref = LLVMFunctionType(gen_return_type->type_ref,1230 fn_type->data.fn.raw_type_ref = LLVMFunctionType(gen_return_type->type_ref,
1228 gen_param_types.items, (unsigned int)gen_param_types.length, fn_type_id->is_var_args);1231 gen_param_types.items, (unsigned int)gen_param_types.length, fn_type_id->is_var_args);
1229 fn_type->type_ref = LLVMPointerType(fn_type->data.fn.raw_type_ref, 0);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,7 +19643,7 @@ static ZigType *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstructionFnP
19643 return ira->codegen->builtin_types.entry_invalid;19643 return ira->codegen->builtin_types.entry_invalid;
19644 if (type_requires_comptime(param_type)) {19644 if (type_requires_comptime(param_type)) {
19645 if (!calling_convention_allows_zig_types(fn_type_id.cc)) {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 buf_sprintf("parameter of type '%s' not allowed in function with calling convention '%s'",19647 buf_sprintf("parameter of type '%s' not allowed in function with calling convention '%s'",
19648 buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc)));19648 buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc)));
19649 return ira->codegen->builtin_types.entry_invalid;19649 return ira->codegen->builtin_types.entry_invalid;
...@@ -19654,6 +19654,12 @@ static ZigType *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstructionFnP...@@ -19654,6 +19654,12 @@ static ZigType *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstructionFnP
19654 out_val->data.x_type = get_generic_fn_type(ira->codegen, &fn_type_id);19654 out_val->data.x_type = get_generic_fn_type(ira->codegen, &fn_type_id);
19655 return ira->codegen->builtin_types.entry_type;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 param_info->type = param_type;19663 param_info->type = param_type;
19658 }19664 }
1965919665
test/compile_errors.zig+1
...@@ -1291,6 +1291,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1291,6 +1291,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1291 \\1291 \\
1292 \\extern fn bar(x: *void) void { }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 ".tmp_source.zig:7:18: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'ccc'",1295 ".tmp_source.zig:7:18: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'ccc'",
1295 );1296 );
12961297