aboutsummaryrefslogtreecommitdiff
path: root/src/AstGen.zig
diff options
context:
space:
mode:
authorJacob G-W <jacoblevgw@gmail.com>2021-06-09 16:59:20 -0400
committerAndrew Kelley <andrew@ziglang.org>2021-06-21 17:03:03 -0700
commitf8b8f50b633babb9d8e8a17a70a214057274f2a0 (patch)
tree89c7540d4c7e632a929e691bfffbc82bc10217c0 /src/AstGen.zig
parent796b420092d194e3152586cf9419fddf4167ea36 (diff)
downloadzig-f8b8f50b633babb9d8e8a17a70a214057274f2a0.tar.gz
zig-f8b8f50b633babb9d8e8a17a70a214057274f2a0.zip
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.
Diffstat (limited to 'src/AstGen.zig')
-rw-r--r--src/AstGen.zig27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig
index 718d577324..12b3d3a1c3 100644
--- a/src/AstGen.zig
+++ b/src/AstGen.zig
@@ -6472,6 +6472,33 @@ fn asmExpr(
// issues and decide how to handle outputs. Do we want this to be identifiers?
// Or maybe we want to force this to be expressions with a pointer type.
// Until that is figured out this is only hooked up for referencing Decls.
+ // TODO we have put this as an identifier lookup just so that we don't get
+ // unused vars for outputs. We need to check if this is correct in the future ^^
+ // so we just put in this simple lookup. This is a workaround.
+ {
+ var s = scope;
+ while (true) switch (s.tag) {
+ .local_val => {
+ const local_val = s.cast(Scope.LocalVal).?;
+ if (local_val.name == str_index) {
+ local_val.used = true;
+ break;
+ }
+ s = local_val.parent;
+ },
+ .local_ptr => {
+ const local_ptr = s.cast(Scope.LocalPtr).?;
+ if (local_ptr.name == str_index) {
+ local_ptr.used = true;
+ break;
+ }
+ s = local_ptr.parent;
+ },
+ .gen_zir => s = s.cast(GenZir).?.parent,
+ .defer_normal, .defer_error => s = s.cast(Scope.Defer).?.parent,
+ .namespace, .top => break,
+ };
+ }
const operand = try gz.addStrTok(.decl_ref, str_index, ident_token);
outputs[i] = .{
.name = name,