cbe: operand of address of operator must be an lvalue

This commit is contained in:
Veikka Tuominen
2022-11-27 18:47:49 +02:00
parent 6310186d52
commit 4def9c4a9b
2 changed files with 9 additions and 3 deletions

View File

@@ -3788,10 +3788,18 @@ fn airBitcast(f: *Function, inst: Air.Inst.Index) !CValue {
const local = try f.allocLocal(inst_ty, .Mut);
try writer.writeAll(";\n");
const operand_lval = if (operand == .constant) blk: {
const operand_local = try f.allocLocal(f.air.typeOf(ty_op.operand), .Const);
try writer.writeAll(" = ");
try f.writeCValue(writer, operand, .Initializer);
try writer.writeAll(";\n");
break :blk operand_local;
} else operand;
try writer.writeAll("memcpy(&");
try f.writeCValue(writer, local, .Other);
try writer.writeAll(", &");
try f.writeCValue(writer, operand, .Other);
try f.writeCValue(writer, operand_lval, .Other);
try writer.writeAll(", sizeof(");
try f.renderTypecast(writer, inst_ty);
try writer.writeAll("));\n");

View File

@@ -798,7 +798,6 @@ test "comptime fixed-width float non-zero divided by zero produces signed Inf" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
inline for (.{ f16, f32, f64, f80, f128 }) |F| {
const pos = @as(F, 1) / @as(F, 0);
@@ -897,7 +896,6 @@ test "nan negation f80" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
const nan_comptime = comptime math.nan(f80);
const neg_nan_comptime = -nan_comptime;