| ... | @@ -9714,18 +9714,18 @@ fn funcCommon( | ... | @@ -9714,18 +9714,18 @@ fn funcCommon( |
| 9714 | { | 9714 | { |
| 9715 | return sema.fail(block, param_src, "non-pointer parameter declared noalias", .{}); | 9715 | return sema.fail(block, param_src, "non-pointer parameter declared noalias", .{}); |
| 9716 | } | 9716 | } |
| 9717 | | 9717 | switch (cc_resolved) { |
| 9718 | if (cc_resolved == .Interrupt) switch (target.cpu.arch) { | 9718 | .Interrupt => if (target.cpu.arch.isX86()) { |
| 9719 | .x86, .x86_64 => { | | |
| 9720 | const err_code_size = target.ptrBitWidth(); | 9719 | const err_code_size = target.ptrBitWidth(); |
| 9721 | switch (i) { | 9720 | switch (i) { |
| 9722 | 0 => if (param_ty.zigTypeTag(mod) != .Pointer) return sema.fail(block, param_src, "parameter must be a pointer type", .{}), | 9721 | 0 => if (param_ty.zigTypeTag(mod) != .Pointer) return sema.fail(block, param_src, "first parameter of function with 'Interrupt' calling convention must be a pointer type", .{}), |
| 9723 | 1 => if (param_ty.bitSize(mod) != err_code_size) return sema.fail(block, param_src, "parameter must be a {d}-bit integer", .{err_code_size}), | 9722 | 1 => if (param_ty.bitSize(mod) != err_code_size) return sema.fail(block, param_src, "second parameter of function with 'Interrupt' calling convention must be a {d}-bit integer", .{err_code_size}), |
| 9724 | else => return sema.fail(block, param_src, "Interrupt calling convention supports up to 2 parameters, found {d}", .{i + 1}), | 9723 | else => return sema.fail(block, param_src, "'Interrupt' calling convention supports up to 2 parameters, found {d}", .{i + 1}), |
| 9725 | } | 9724 | } |
| 9726 | }, | 9725 | } else return sema.fail(block, param_src, "parameters are not allowed with 'Interrupt' calling convention", .{}), |
| 9727 | else => return sema.fail(block, param_src, "parameters are not allowed with Interrupt calling convention", .{}), | 9726 | .Signal => return sema.fail(block, param_src, "parameters are not allowed with 'Signal' calling convention", .{}), |
| 9728 | }; | 9727 | else => {}, |
| | 9728 | } |
| 9729 | } | 9729 | } |
| 9730 | | 9730 | |
| 9731 | var ret_ty_requires_comptime = false; | 9731 | var ret_ty_requires_comptime = false; |
| ... | @@ -10031,6 +10031,16 @@ fn finishFunc( | ... | @@ -10031,6 +10031,16 @@ fn finishFunc( |
| 10031 | return sema.failWithOwnedErrorMsg(block, msg); | 10031 | return sema.failWithOwnedErrorMsg(block, msg); |
| 10032 | } | 10032 | } |
| 10033 | | 10033 | |
| | 10034 | switch (cc_resolved) { |
| | 10035 | .Interrupt, .Signal => if (return_type.zigTypeTag(mod) != .Void and return_type.zigTypeTag(mod) != .NoReturn) { |
| | 10036 | return sema.fail(block, ret_ty_src, "function with calling convention '{s}' must return 'void' or 'noreturn'", .{@tagName(cc_resolved)}); |
| | 10037 | }, |
| | 10038 | .Inline => if (is_noinline) { |
| | 10039 | return sema.fail(block, cc_src, "'noinline' function cannot have callconv 'Inline'", .{}); |
| | 10040 | }, |
| | 10041 | else => {}, |
| | 10042 | } |
| | 10043 | |
| 10034 | const arch = target.cpu.arch; | 10044 | const arch = target.cpu.arch; |
| 10035 | if (@as(?[]const u8, switch (cc_resolved) { | 10045 | if (@as(?[]const u8, switch (cc_resolved) { |
| 10036 | .Unspecified, .C, .Naked, .Async, .Inline => null, | 10046 | .Unspecified, .C, .Naked, .Async, .Inline => null, |
| ... | @@ -10074,20 +10084,7 @@ fn finishFunc( | ... | @@ -10074,20 +10084,7 @@ fn finishFunc( |
| 10074 | }); | 10084 | }); |
| 10075 | } | 10085 | } |
| 10076 | | 10086 | |
| 10077 | if (cc_resolved == .Interrupt and return_type.zigTypeTag(mod) != .Void) { | | |
| 10078 | return sema.fail( | | |
| 10079 | block, | | |
| 10080 | cc_src, | | |
| 10081 | "non-void return type '{}' not allowed in function with calling convention 'Interrupt'", | | |
| 10082 | .{return_type.fmt(mod)}, | | |
| 10083 | ); | | |
| 10084 | } | | |
| 10085 | | | |
| 10086 | if (cc_resolved == .Inline and is_noinline) { | | |
| 10087 | return sema.fail(block, cc_src, "'noinline' function cannot have callconv 'Inline'", .{}); | | |
| 10088 | } | | |
| 10089 | if (is_generic and sema.no_partial_func_ty) return error.GenericPoison; | 10087 | if (is_generic and sema.no_partial_func_ty) return error.GenericPoison; |
| 10090 | | | |
| 10091 | if (!final_is_generic and sema.wantErrorReturnTracing(return_type)) { | 10088 | if (!final_is_generic and sema.wantErrorReturnTracing(return_type)) { |
| 10092 | // Make sure that StackTrace's fields are resolved so that the backend can | 10089 | // Make sure that StackTrace's fields are resolved so that the backend can |
| 10093 | // lower this fn type. | 10090 | // lower this fn type. |