| ... | @@ -26067,7 +26067,8 @@ fn coerceVarArgParam( | ... | @@ -26067,7 +26067,8 @@ fn coerceVarArgParam( |
| 26067 | ) !Air.Inst.Ref { | 26067 | ) !Air.Inst.Ref { |
| 26068 | if (block.is_typeof) return inst; | 26068 | if (block.is_typeof) return inst; |
| 26069 | | 26069 | |
| 26070 | const coerced = switch (sema.typeOf(inst).zigTypeTag()) { | 26070 | const uncasted_ty = sema.typeOf(inst); |
| | 26071 | const coerced = switch (uncasted_ty.zigTypeTag()) { |
| 26071 | // TODO consider casting to c_int/f64 if they fit | 26072 | // TODO consider casting to c_int/f64 if they fit |
| 26072 | .ComptimeInt, .ComptimeFloat => return sema.fail( | 26073 | .ComptimeInt, .ComptimeFloat => return sema.fail( |
| 26073 | block, | 26074 | block, |
| ... | @@ -26081,6 +26082,17 @@ fn coerceVarArgParam( | ... | @@ -26081,6 +26082,17 @@ fn coerceVarArgParam( |
| 26081 | break :blk try sema.analyzeDeclRef(fn_decl); | 26082 | break :blk try sema.analyzeDeclRef(fn_decl); |
| 26082 | }, | 26083 | }, |
| 26083 | .Array => return sema.fail(block, inst_src, "arrays must be passed by reference to variadic function", .{}), | 26084 | .Array => return sema.fail(block, inst_src, "arrays must be passed by reference to variadic function", .{}), |
| | 26085 | .Float => float: { |
| | 26086 | const target = sema.mod.getTarget(); |
| | 26087 | const double_bits = @import("type.zig").CType.sizeInBits(.double, target); |
| | 26088 | const inst_bits = uncasted_ty.floatBits(sema.mod.getTarget()); |
| | 26089 | if (inst_bits >= double_bits) break :float inst; |
| | 26090 | switch (double_bits) { |
| | 26091 | 32 => break :float try sema.coerce(block, Type.f32, inst, inst_src), |
| | 26092 | 64 => break :float try sema.coerce(block, Type.f64, inst, inst_src), |
| | 26093 | else => unreachable, |
| | 26094 | } |
| | 26095 | }, |
| 26084 | else => inst, | 26096 | else => inst, |
| 26085 | }; | 26097 | }; |
| 26086 | | 26098 | |