authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-10-22 15:53:59-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-10-22 15:53:59-07:00
logf0dcdd7931f1eb4f3b6a0a87c914baf770f6df03
tree2182e84263410cd093d51c5df6393848f3724b22
parent069c83d58cebba88275ee76ba01fabcd8e964573

stage2: fix Decl addrspace being undefined


4 files changed, 23 insertions(+), 17 deletions(-)

src/Module.zig+8-3
......@@ -4220,7 +4220,13 @@ fn markOutdatedDecl(mod: *Module, decl: *Decl) !void {
42204220 decl.analysis = .outdated;
42214221}
42224222
4223pub fn allocateNewDecl(mod: *Module, name: [:0]const u8, namespace: *Namespace, src_node: Ast.Node.Index, src_scope: ?*CaptureScope) !*Decl {
4223pub fn allocateNewDecl(
4224 mod: *Module,
4225 name: [:0]const u8,
4226 namespace: *Namespace,
4227 src_node: Ast.Node.Index,
4228 src_scope: ?*CaptureScope,
4229) !*Decl {
42244230 // If we have emit-h then we must allocate a bigger structure to store the emit-h state.
42254231 const new_decl: *Decl = if (mod.emit_h != null) blk: {
42264232 const parent_struct = try mod.gpa.create(DeclPlusEmitH);
......@@ -4242,7 +4248,7 @@ pub fn allocateNewDecl(mod: *Module, name: [:0]const u8, namespace: *Namespace,
42424248 .val = undefined,
42434249 .align_val = undefined,
42444250 .linksection_val = undefined,
4245 .@"addrspace" = undefined,
4251 .@"addrspace" = .generic,
42464252 .analysis = .unreferenced,
42474253 .deletion_flag = false,
42484254 .zir_decl_index = 0,
......@@ -4346,7 +4352,6 @@ pub fn createAnonymousDeclFromDeclNamed(
43464352 new_decl.val = typed_value.val;
43474353 new_decl.align_val = Value.initTag(.null_value);
43484354 new_decl.linksection_val = Value.initTag(.null_value);
4349 new_decl.@"addrspace" = .generic; // default global addrspace
43504355 new_decl.has_tv = true;
43514356 new_decl.analysis = .complete;
43524357 new_decl.generation = mod.generation;
test/behavior/basic.zig+13
......@@ -2,6 +2,7 @@ const std = @import("std");
22const builtin = @import("builtin");
33const mem = std.mem;
44const expect = std.testing.expect;
5const expectEqualStrings = std.testing.expectEqualStrings;
56
67// normal comment
78
......@@ -446,3 +447,15 @@ test "self reference through fn ptr field" {
446447 a.f = S.foo;
447448 try expect(a.f(a) == 12);
448449}
450
451test "global variable initialized to global variable array element" {
452 try expect(global_ptr == &gdt[0]);
453}
454const GDTEntry = struct {
455 field: i32,
456};
457var gdt = [_]GDTEntry{
458 GDTEntry{ .field = 1 },
459 GDTEntry{ .field = 2 },
460};
461var global_ptr = &gdt[0];
test/behavior/misc.zig-12
......@@ -100,18 +100,6 @@ test "string concatenation" {
100100 try expect(b[len] == 0);
101101}
102102
103test "global variable initialized to global variable array element" {
104 try expect(global_ptr == &gdt[0]);
105}
106const GDTEntry = struct {
107 field: i32,
108};
109var gdt = [_]GDTEntry{
110 GDTEntry{ .field = 1 },
111 GDTEntry{ .field = 2 },
112};
113var global_ptr = &gdt[0];
114
115103// can't really run this test but we can make sure it has no compile error
116104// and generates code
117105const vram = @intToPtr([*]volatile u8, 0x20000000)[0..0x8000];
test/behavior/saturating_arithmetic.zig+2-2
......@@ -62,7 +62,7 @@ test "saturating subtraction" {
6262
6363test "saturating multiplication" {
6464 // TODO: once #9660 has been solved, remove this line
65 if (builtin.stage2_arch == .wasm32) return error.SkipZigTest;
65 if (builtin.cpu.arch == .wasm32) return error.SkipZigTest;
6666
6767 const S = struct {
6868 fn doTheTest() !void {
......@@ -99,7 +99,7 @@ test "saturating shift-left" {
9999 try testSatShl(i8, 127, 1, 127);
100100 try testSatShl(i8, -128, 1, -128);
101101 // TODO: remove this check once #9668 is completed
102 if (builtin.stage2_arch != .wasm32) {
102 if (builtin.cpu.arch != .wasm32) {
103103 // skip testing ints > 64 bits on wasm due to miscompilation / wasmtime ci error
104104 try testSatShl(i128, maxInt(i128), 64, maxInt(i128));
105105 try testSatShl(u128, maxInt(u128), 64, maxInt(u128));