Skip to content

Commit 69b74fc

Browse files
committed
stage2 astgen: make asm outputs count as referencing vars
This is temporary and putting this as a seperate commit so that it can easily be reverted as andrewrk suggested.
1 parent fc7944e commit 69b74fc

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/AstGen.zig

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6424,6 +6424,33 @@ fn asmExpr(
64246424
// issues and decide how to handle outputs. Do we want this to be identifiers?
64256425
// Or maybe we want to force this to be expressions with a pointer type.
64266426
// Until that is figured out this is only hooked up for referencing Decls.
6427+
// TODO we have put this as an identifier lookup just so that we don't get
6428+
// unused vars for outputs. We need to check if this is correct in the future ^^
6429+
// so we just put in this simple lookup. This is a workaround.
6430+
{
6431+
var s = scope;
6432+
while (true) switch (s.tag) {
6433+
.local_val => {
6434+
const local_val = s.cast(Scope.LocalVal).?;
6435+
if (local_val.name == str_index) {
6436+
local_val.used = true;
6437+
break;
6438+
}
6439+
s = local_val.parent;
6440+
},
6441+
.local_ptr => {
6442+
const local_ptr = s.cast(Scope.LocalPtr).?;
6443+
if (local_ptr.name == str_index) {
6444+
local_ptr.used = true;
6445+
break;
6446+
}
6447+
s = local_ptr.parent;
6448+
},
6449+
.gen_zir => s = s.cast(GenZir).?.parent,
6450+
.defer_normal, .defer_error => s = s.cast(Scope.Defer).?.parent,
6451+
.namespace, .top => break,
6452+
};
6453+
}
64276454
const operand = try gz.addStrTok(.decl_ref, str_index, ident_token);
64286455
outputs[i] = .{
64296456
.name = name,

0 commit comments

Comments
 (0)