| ... | @@ -9700,18 +9700,18 @@ fn funcCommon( | ... | @@ -9700,18 +9700,18 @@ fn funcCommon( |
| 9700 | { | 9700 | { |
| 9701 | return sema.fail(block, param_src, "non-pointer parameter declared noalias", .{}); | 9701 | return sema.fail(block, param_src, "non-pointer parameter declared noalias", .{}); |
| 9702 | } | 9702 | } |
| 9703 | | 9703 | switch (cc_resolved) { |
| 9704 | if (cc_resolved == .Interrupt) switch (target.cpu.arch) { | 9704 | .Interrupt => if (target.cpu.arch.isX86()) { |
| 9705 | .x86, .x86_64 => { | | |
| 9706 | const err_code_size = target.ptrBitWidth(); | 9705 | const err_code_size = target.ptrBitWidth(); |
| 9707 | switch (i) { | 9706 | switch (i) { |
| 9708 | 0 => if (param_ty.zigTypeTag(mod) != .Pointer) return sema.fail(block, param_src, "parameter must be a pointer type", .{}), | 9707 | 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", .{}), |
| 9709 | 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}), | 9708 | 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}), |
| 9710 | else => return sema.fail(block, param_src, "Interrupt calling convention supports up to 2 parameters, found {d}", .{i + 1}), | 9709 | else => return sema.fail(block, param_src, "'Interrupt' calling convention supports up to 2 parameters, found {d}", .{i + 1}), |
| 9711 | } | 9710 | } |
| 9712 | }, | 9711 | } else return sema.fail(block, param_src, "parameters are not allowed with 'Interrupt' calling convention", .{}), |
| 9713 | else => return sema.fail(block, param_src, "parameters are not allowed with Interrupt calling convention", .{}), | 9712 | .Signal => return sema.fail(block, param_src, "parameters are not allowed with 'Signal' calling convention", .{}), |
| 9714 | }; | 9713 | else => {}, |
| | 9714 | } |
| 9715 | } | 9715 | } |
| 9716 | | 9716 | |
| 9717 | var ret_ty_requires_comptime = false; | 9717 | var ret_ty_requires_comptime = false; |
| ... | @@ -10017,6 +10017,16 @@ fn finishFunc( | ... | @@ -10017,6 +10017,16 @@ fn finishFunc( |
| 10017 | return sema.failWithOwnedErrorMsg(block, msg); | 10017 | return sema.failWithOwnedErrorMsg(block, msg); |
| 10018 | } | 10018 | } |
| 10019 | | 10019 | |
| | 10020 | switch (cc_resolved) { |
| | 10021 | .Interrupt, .Signal => if (return_type.zigTypeTag(mod) != .Void and return_type.zigTypeTag(mod) != .NoReturn) { |
| | 10022 | return sema.fail(block, ret_ty_src, "function with calling convention '{s}' must return 'void' or 'noreturn'", .{@tagName(cc_resolved)}); |
| | 10023 | }, |
| | 10024 | .Inline => if (is_noinline) { |
| | 10025 | return sema.fail(block, cc_src, "'noinline' function cannot have callconv 'Inline'", .{}); |
| | 10026 | }, |
| | 10027 | else => {}, |
| | 10028 | } |
| | 10029 | |
| 10020 | const arch = target.cpu.arch; | 10030 | const arch = target.cpu.arch; |
| 10021 | if (@as(?[]const u8, switch (cc_resolved) { | 10031 | if (@as(?[]const u8, switch (cc_resolved) { |
| 10022 | .Unspecified, .C, .Naked, .Async, .Inline => null, | 10032 | .Unspecified, .C, .Naked, .Async, .Inline => null, |
| ... | @@ -10060,20 +10070,7 @@ fn finishFunc( | ... | @@ -10060,20 +10070,7 @@ fn finishFunc( |
| 10060 | }); | 10070 | }); |
| 10061 | } | 10071 | } |
| 10062 | | 10072 | |
| 10063 | if (cc_resolved == .Interrupt and return_type.zigTypeTag(mod) != .Void) { | | |
| 10064 | return sema.fail( | | |
| 10065 | block, | | |
| 10066 | cc_src, | | |
| 10067 | "non-void return type '{}' not allowed in function with calling convention 'Interrupt'", | | |
| 10068 | .{return_type.fmt(mod)}, | | |
| 10069 | ); | | |
| 10070 | } | | |
| 10071 | | | |
| 10072 | if (cc_resolved == .Inline and is_noinline) { | | |
| 10073 | return sema.fail(block, cc_src, "'noinline' function cannot have callconv 'Inline'", .{}); | | |
| 10074 | } | | |
| 10075 | if (is_generic and sema.no_partial_func_ty) return error.GenericPoison; | 10073 | if (is_generic and sema.no_partial_func_ty) return error.GenericPoison; |
| 10076 | | | |
| 10077 | if (!final_is_generic and sema.wantErrorReturnTracing(return_type)) { | 10074 | if (!final_is_generic and sema.wantErrorReturnTracing(return_type)) { |
| 10078 | // Make sure that StackTrace's fields are resolved so that the backend can | 10075 | // Make sure that StackTrace's fields are resolved so that the backend can |
| 10079 | // lower this fn type. | 10076 | // lower this fn type. |
| ... | @@ -22707,7 +22704,16 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -22707,7 +22704,16 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 22707 | .storage = .{ .elems = new_elems }, | 22704 | .storage = .{ .elems = new_elems }, |
| 22708 | } })); | 22705 | } })); |
| 22709 | } | 22706 | } |
| | 22707 | if (try sema.typeRequiresComptime(ptr_ty)) { |
| | 22708 | return sema.failWithOwnedErrorMsg(block, msg: { |
| | 22709 | const msg = try sema.errMsg(block, src, "pointer to comptime-only type '{}' must be comptime-known, but operand is runtime-known", .{ptr_ty.fmt(mod)}); |
| | 22710 | errdefer msg.destroy(sema.gpa); |
| 22710 | | 22711 | |
| | 22712 | const src_decl = mod.declPtr(block.src_decl); |
| | 22713 | try sema.explainWhyTypeIsComptime(msg, src_decl.toSrcLoc(src, mod), ptr_ty); |
| | 22714 | break :msg msg; |
| | 22715 | }); |
| | 22716 | } |
| 22711 | try sema.requireRuntimeBlock(block, src, operand_src); | 22717 | try sema.requireRuntimeBlock(block, src, operand_src); |
| 22712 | if (!is_vector) { | 22718 | if (!is_vector) { |
| 22713 | if (block.wantSafety() and (try sema.typeHasRuntimeBits(elem_ty) or elem_ty.zigTypeTag(mod) == .Fn)) { | 22719 | if (block.wantSafety() and (try sema.typeHasRuntimeBits(elem_ty) or elem_ty.zigTypeTag(mod) == .Fn)) { |