authorgravatar for jacoblevgw@gmail.comJacob G-W <jacoblevgw@gmail.com> 2021-06-09 16:59:20-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-21 17:03:03-07:00
logf8b8f50b633babb9d8e8a17a70a214057274f2a0
tree89c7540d4c7e632a929e691bfffbc82bc10217c0
parent796b420092d194e3152586cf9419fddf4167ea36

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 files changed, 27 insertions(+), 0 deletions(-)

src/AstGen.zig+27
...@@ -6472,6 +6472,33 @@ fn asmExpr(...@@ -6472,6 +6472,33 @@ fn asmExpr(
6472 // issues and decide how to handle outputs. Do we want this to be identifiers?6472 // issues and decide how to handle outputs. Do we want this to be identifiers?
6473 // Or maybe we want to force this to be expressions with a pointer type.6473 // Or maybe we want to force this to be expressions with a pointer type.
6474 // Until that is figured out this is only hooked up for referencing Decls.6474 // Until that is figured out this is only hooked up for referencing Decls.
6475 // TODO we have put this as an identifier lookup just so that we don't get
6476 // unused vars for outputs. We need to check if this is correct in the future ^^
6477 // so we just put in this simple lookup. This is a workaround.
6478 {
6479 var s = scope;
6480 while (true) switch (s.tag) {
6481 .local_val => {
6482 const local_val = s.cast(Scope.LocalVal).?;
6483 if (local_val.name == str_index) {
6484 local_val.used = true;
6485 break;
6486 }
6487 s = local_val.parent;
6488 },
6489 .local_ptr => {
6490 const local_ptr = s.cast(Scope.LocalPtr).?;
6491 if (local_ptr.name == str_index) {
6492 local_ptr.used = true;
6493 break;
6494 }
6495 s = local_ptr.parent;
6496 },
6497 .gen_zir => s = s.cast(GenZir).?.parent,
6498 .defer_normal, .defer_error => s = s.cast(Scope.Defer).?.parent,
6499 .namespace, .top => break,
6500 };
6501 }
6475 const operand = try gz.addStrTok(.decl_ref, str_index, ident_token);6502 const operand = try gz.addStrTok(.decl_ref, str_index, ident_token);
6476 outputs[i] = .{6503 outputs[i] = .{
6477 .name = name,6504 .name = name,