Zir: add missing extra index for linksection_or_addspace

Closes #18052
Closes #18104

Signed-off-by: Tw <tw19881113@gmail.com>
This commit is contained in:
Tw 2023-11-25 19:39:37 +08:00 committed by GitHub
parent 648f592db1
commit 2fefc0b5c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 2 deletions

View File

@ -3416,8 +3416,9 @@ pub const DeclIterator = struct {
it.extra_index += 5; // src_hash(4) + line(1)
const name = it.zir.nullTerminatedString(it.zir.extra[it.extra_index]);
it.extra_index += 3; // name(1) + value(1) + doc_comment(1)
it.extra_index += @as(u1, @truncate(flags >> 2));
it.extra_index += @as(u1, @truncate(flags >> 3));
it.extra_index += @as(u1, @truncate(flags >> 2)); // align
it.extra_index += @as(u1, @truncate(flags >> 3)); // link_section
it.extra_index += @as(u1, @truncate(flags >> 3)); // address_space
return Item{
.sub_index = sub_index,

View File

@ -228,6 +228,7 @@ test {
_ = @import("behavior/type.zig");
_ = @import("behavior/type_info.zig");
_ = @import("behavior/type_info_only_pub_decls.zig");
_ = @import("behavior/type_info_mul_linksection_addrspace_decls.zig");
_ = @import("behavior/typename.zig");
_ = @import("behavior/undefined.zig");
_ = @import("behavior/underscore.zig");

View File

@ -0,0 +1,12 @@
const std = @import("std");
const expect = std.testing.expect;
pub const a linksection("sec_a") = 0;
pub const b linksection("sec_b") = 0;
pub const c addrspace("space_c") = 0;
pub const d addrspace("space_d") = 0;
test {
const decls = @typeInfo(@This()).Struct.decls;
try expect(decls.len == 4);
}