aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-01-03 12:57:01 -0800
committerGitHub <noreply@github.com>2024-01-03 12:57:01 -0800
commita9337bef2d54201ab304bb3428479339ecaacbac (patch)
treee253679e591e86d84a29139b7d7987eab3c3718f /src/Sema.zig
parent9a56228c2b90d94d01bb76784c77fdec5710cf0a (diff)
parent047d6d996e540eaa50ec24b0751d147bfe2cacdb (diff)
downloadzig-a9337bef2d54201ab304bb3428479339ecaacbac.tar.gz
zig-a9337bef2d54201ab304bb3428479339ecaacbac.zip
Merge pull request #18431 from jacobly0/cbe-extern
cbe: fix non-msvc externs and exports
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index c6648b3d90..a2ed81161b 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -24760,7 +24760,9 @@ fn zirVarExtended(
.decl = sema.owner_decl_index,
.lib_name = try mod.intern_pool.getOrPutStringOpt(sema.gpa, lib_name),
.is_extern = small.is_extern,
+ .is_const = small.is_const,
.is_threadlocal = small.is_threadlocal,
+ .is_weak_linkage = false,
} })));
}
@@ -25264,6 +25266,7 @@ fn zirBuiltinExtern(
if (options.linkage == .Weak and !ty.ptrAllowsZero(mod)) {
ty = try mod.optionalType(ty.toIntern());
}
+ const ptr_info = ty.ptrInfo(mod);
// TODO check duplicate extern
@@ -25274,11 +25277,12 @@ fn zirBuiltinExtern(
{
const new_var = try mod.intern(.{ .variable = .{
- .ty = ty.toIntern(),
+ .ty = ptr_info.child,
.init = .none,
.decl = sema.owner_decl_index,
+ .lib_name = options.library_name,
.is_extern = true,
- .is_const = true,
+ .is_const = ptr_info.flags.is_const,
.is_threadlocal = options.is_thread_local,
.is_weak_linkage = options.linkage == .Weak,
} });
@@ -25286,7 +25290,7 @@ fn zirBuiltinExtern(
new_decl.src_line = sema.owner_decl.src_line;
// We only access this decl through the decl_ref with the correct type created
// below, so this type doesn't matter
- new_decl.ty = ty;
+ new_decl.ty = Type.fromInterned(ptr_info.child);
new_decl.val = Value.fromInterned(new_var);
new_decl.alignment = .none;
new_decl.@"linksection" = .none;