aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorParker Liu <flyfish30@users.noreply.github.com>2025-04-01 01:22:03 +0800
committerGitHub <noreply@github.com>2025-03-31 20:22:03 +0300
commit0bdc0bb534ed6d3cc787b5bca44173d2b49480da (patch)
tree0344b4b07edca28ee5d306c04d46e7b442984684 /lib
parent0753af792a41645b6cac51d7bd29b2c526c3b81b (diff)
downloadzig-0bdc0bb534ed6d3cc787b5bca44173d2b49480da.tar.gz
zig-0bdc0bb534ed6d3cc787b5bca44173d2b49480da.zip
translate-c: fix referencing extern locals from nested blocks
Diffstat (limited to 'lib')
-rw-r--r--lib/compiler/aro_translate_c.zig6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/compiler/aro_translate_c.zig b/lib/compiler/aro_translate_c.zig
index ffb133dad5..5abc244c97 100644
--- a/lib/compiler/aro_translate_c.zig
+++ b/lib/compiler/aro_translate_c.zig
@@ -1620,7 +1620,11 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
.root => null,
.block => ret: {
const block = @as(*Block, @fieldParentPtr("base", scope));
- break :ret block.getLocalExternAlias(name);
+ const alias_name = block.getLocalExternAlias(name);
+ if (alias_name) |_alias_name| {
+ break :ret _alias_name;
+ }
+ break :ret scope.parent.?.getLocalExternAlias(name);
},
.loop, .do_loop, .condition => scope.parent.?.getLocalExternAlias(name),
};