commit a6bf37f8ca5a2eabc7cacb22696d2a2c622a993d (tree)
parent c7f70893923cd0a9d3be79b352e2674a87ad8127
Author: Andrew Kelley <superjoe30@gmail.com>
Date: Mon, 10 Sep 2018 22:45:20 -0400
Merge remote-tracking branch 'origin/master' into llvm7
Diffstat:
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/analyze.cpp b/src/analyze.cpp
@@ -1224,6 +1224,9 @@ ZigType *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
fn_type->data.fn.gen_param_count = gen_param_types.length;
+ for (size_t i = 0; i < gen_param_types.length; i += 1) {
+ assert(gen_param_types.items[i] != nullptr);
+ }
fn_type->data.fn.raw_type_ref = LLVMFunctionType(gen_return_type->type_ref,
gen_param_types.items, (unsigned int)gen_param_types.length, fn_type_id->is_var_args);
fn_type->type_ref = LLVMPointerType(fn_type->data.fn.raw_type_ref, 0);
diff --git a/src/ir.cpp b/src/ir.cpp
@@ -19643,7 +19643,7 @@ static ZigType *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstructionFnP
return ira->codegen->builtin_types.entry_invalid;
if (type_requires_comptime(param_type)) {
if (!calling_convention_allows_zig_types(fn_type_id.cc)) {
- ir_add_error(ira, &instruction->base,
+ ir_add_error(ira, param_type_value,
buf_sprintf("parameter of type '%s' not allowed in function with calling convention '%s'",
buf_ptr(¶m_type->name), calling_convention_name(fn_type_id.cc)));
return ira->codegen->builtin_types.entry_invalid;
@@ -19654,6 +19654,12 @@ static ZigType *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstructionFnP
out_val->data.x_type = get_generic_fn_type(ira->codegen, &fn_type_id);
return ira->codegen->builtin_types.entry_type;
}
+ if (!type_has_bits(param_type) && !calling_convention_allows_zig_types(fn_type_id.cc)) {
+ ir_add_error(ira, param_type_value,
+ buf_sprintf("parameter of type '%s' has 0 bits; not allowed in function with calling convention '%s'",
+ buf_ptr(¶m_type->name), calling_convention_name(fn_type_id.cc)));
+ return ira->codegen->builtin_types.entry_invalid;
+ }
param_info->type = param_type;
}
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
@@ -1291,6 +1291,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\
\\extern fn bar(x: *void) void { }
,
+ ".tmp_source.zig:1:30: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'ccc'",
".tmp_source.zig:7:18: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'ccc'",
);