aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-11-27 18:47:49 +0200
committerVeikka Tuominen <git@vexu.eu>2022-11-30 15:14:33 +0200
commit4def9c4a9b384a5980086825bcb849a88438912b (patch)
treebf8269d98e362096dfe313c300b3542d80c6993a /src/codegen
parent6310186d52ae4e7bccf40326a98916695192b543 (diff)
downloadzig-4def9c4a9b384a5980086825bcb849a88438912b.tar.gz
zig-4def9c4a9b384a5980086825bcb849a88438912b.zip
cbe: operand of address of operator must be an lvalue
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/c.zig10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index 85f822d514..97b37309b2 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -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");