mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 07:32:44 +00:00
Address spaces: Forbid addrspace and linksection for local variables
This commit is contained in:
parent
805e1bffbd
commit
cfbe9a6f61
@ -2377,6 +2377,7 @@ fn varDecl(
|
||||
const gpa = astgen.gpa;
|
||||
const tree = astgen.tree;
|
||||
const token_tags = tree.tokens.items(.tag);
|
||||
const main_tokens = tree.nodes.items(.main_token);
|
||||
|
||||
const name_token = var_decl.ast.mut_token + 1;
|
||||
const ident_name_raw = tree.tokenSlice(name_token);
|
||||
@ -2391,6 +2392,14 @@ fn varDecl(
|
||||
return astgen.failNode(node, "variables must be initialized", .{});
|
||||
}
|
||||
|
||||
if (var_decl.ast.addrspace_node != 0) {
|
||||
return astgen.failTok(main_tokens[var_decl.ast.addrspace_node], "cannot set address space of local variable '{s}'", .{ ident_name_raw });
|
||||
}
|
||||
|
||||
if (var_decl.ast.section_node != 0) {
|
||||
return astgen.failTok(main_tokens[var_decl.ast.section_node], "cannot set section of local variable '{s}'", .{ ident_name_raw });
|
||||
}
|
||||
|
||||
const align_inst: Zir.Inst.Ref = if (var_decl.ast.align_node != 0)
|
||||
try expr(gz, scope, align_rl, var_decl.ast.align_node)
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user