| author | |
| committer | |
| log | f0dcdd7931f1eb4f3b6a0a87c914baf770f6df03 |
| tree | 2182e84263410cd093d51c5df6393848f3724b22 |
| parent | 069c83d58cebba88275ee76ba01fabcd8e964573 |
4 files changed, 23 insertions(+), 17 deletions(-)
src/Module.zig+8-3| ... | @@ -4220,7 +4220,13 @@ fn markOutdatedDecl(mod: *Module, decl: *Decl) !void { | ... | @@ -4220,7 +4220,13 @@ fn markOutdatedDecl(mod: *Module, decl: *Decl) !void { |
| 4220 | decl.analysis = .outdated; | 4220 | decl.analysis = .outdated; |
| 4221 | } | 4221 | } |
| 4222 | 4222 | ||
| 4223 | pub fn allocateNewDecl(mod: *Module, name: [:0]const u8, namespace: *Namespace, src_node: Ast.Node.Index, src_scope: ?*CaptureScope) !*Decl { | 4223 | pub 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 { | ||
| 4224 | // If we have emit-h then we must allocate a bigger structure to store the emit-h state. | 4230 | // If we have emit-h then we must allocate a bigger structure to store the emit-h state. |
| 4225 | const new_decl: *Decl = if (mod.emit_h != null) blk: { | 4231 | const new_decl: *Decl = if (mod.emit_h != null) blk: { |
| 4226 | const parent_struct = try mod.gpa.create(DeclPlusEmitH); | 4232 | const parent_struct = try mod.gpa.create(DeclPlusEmitH); |
| ... | @@ -4242,7 +4248,7 @@ pub fn allocateNewDecl(mod: *Module, name: [:0]const u8, namespace: *Namespace, | ... | @@ -4242,7 +4248,7 @@ pub fn allocateNewDecl(mod: *Module, name: [:0]const u8, namespace: *Namespace, |
| 4242 | .val = undefined, | 4248 | .val = undefined, |
| 4243 | .align_val = undefined, | 4249 | .align_val = undefined, |
| 4244 | .linksection_val = undefined, | 4250 | .linksection_val = undefined, |
| 4245 | .@"addrspace" = undefined, | 4251 | .@"addrspace" = .generic, |
| 4246 | .analysis = .unreferenced, | 4252 | .analysis = .unreferenced, |
| 4247 | .deletion_flag = false, | 4253 | .deletion_flag = false, |
| 4248 | .zir_decl_index = 0, | 4254 | .zir_decl_index = 0, |
| ... | @@ -4346,7 +4352,6 @@ pub fn createAnonymousDeclFromDeclNamed( | ... | @@ -4346,7 +4352,6 @@ pub fn createAnonymousDeclFromDeclNamed( |
| 4346 | new_decl.val = typed_value.val; | 4352 | new_decl.val = typed_value.val; |
| 4347 | new_decl.align_val = Value.initTag(.null_value); | 4353 | new_decl.align_val = Value.initTag(.null_value); |
| 4348 | new_decl.linksection_val = Value.initTag(.null_value); | 4354 | new_decl.linksection_val = Value.initTag(.null_value); |
| 4349 | new_decl.@"addrspace" = .generic; // default global addrspace | ||
| 4350 | new_decl.has_tv = true; | 4355 | new_decl.has_tv = true; |
| 4351 | new_decl.analysis = .complete; | 4356 | new_decl.analysis = .complete; |
| 4352 | new_decl.generation = mod.generation; | 4357 | new_decl.generation = mod.generation; |
test/behavior/basic.zig+13| ... | @@ -2,6 +2,7 @@ const std = @import("std"); | ... | @@ -2,6 +2,7 @@ const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const mem = std.mem; | 3 | const mem = std.mem; |
| 4 | const expect = std.testing.expect; | 4 | const expect = std.testing.expect; |
| 5 | const expectEqualStrings = std.testing.expectEqualStrings; | ||
| 5 | 6 | ||
| 6 | // normal comment | 7 | // normal comment |
| 7 | 8 | ||
| ... | @@ -446,3 +447,15 @@ test "self reference through fn ptr field" { | ... | @@ -446,3 +447,15 @@ test "self reference through fn ptr field" { |
| 446 | a.f = S.foo; | 447 | a.f = S.foo; |
| 447 | try expect(a.f(a) == 12); | 448 | try expect(a.f(a) == 12); |
| 448 | } | 449 | } |
| 450 | |||
| 451 | test "global variable initialized to global variable array element" { | ||
| 452 | try expect(global_ptr == &gdt[0]); | ||
| 453 | } | ||
| 454 | const GDTEntry = struct { | ||
| 455 | field: i32, | ||
| 456 | }; | ||
| 457 | var gdt = [_]GDTEntry{ | ||
| 458 | GDTEntry{ .field = 1 }, | ||
| 459 | GDTEntry{ .field = 2 }, | ||
| 460 | }; | ||
| 461 | var global_ptr = &gdt[0]; |
test/behavior/misc.zig-12| ... | @@ -100,18 +100,6 @@ test "string concatenation" { | ... | @@ -100,18 +100,6 @@ test "string concatenation" { |
| 100 | try expect(b[len] == 0); | 100 | try expect(b[len] == 0); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | test "global variable initialized to global variable array element" { | ||
| 104 | try expect(global_ptr == &gdt[0]); | ||
| 105 | } | ||
| 106 | const GDTEntry = struct { | ||
| 107 | field: i32, | ||
| 108 | }; | ||
| 109 | var gdt = [_]GDTEntry{ | ||
| 110 | GDTEntry{ .field = 1 }, | ||
| 111 | GDTEntry{ .field = 2 }, | ||
| 112 | }; | ||
| 113 | var global_ptr = &gdt[0]; | ||
| 114 | |||
| 115 | // can't really run this test but we can make sure it has no compile error | 103 | // can't really run this test but we can make sure it has no compile error |
| 116 | // and generates code | 104 | // and generates code |
| 117 | const vram = @intToPtr([*]volatile u8, 0x20000000)[0..0x8000]; | 105 | const vram = @intToPtr([*]volatile u8, 0x20000000)[0..0x8000]; |
test/behavior/saturating_arithmetic.zig+2-2| ... | @@ -62,7 +62,7 @@ test "saturating subtraction" { | ... | @@ -62,7 +62,7 @@ test "saturating subtraction" { |
| 62 | 62 | ||
| 63 | test "saturating multiplication" { | 63 | test "saturating multiplication" { |
| 64 | // TODO: once #9660 has been solved, remove this line | 64 | // 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; |
| 66 | 66 | ||
| 67 | const S = struct { | 67 | const S = struct { |
| 68 | fn doTheTest() !void { | 68 | fn doTheTest() !void { |
| ... | @@ -99,7 +99,7 @@ test "saturating shift-left" { | ... | @@ -99,7 +99,7 @@ test "saturating shift-left" { |
| 99 | try testSatShl(i8, 127, 1, 127); | 99 | try testSatShl(i8, 127, 1, 127); |
| 100 | try testSatShl(i8, -128, 1, -128); | 100 | try testSatShl(i8, -128, 1, -128); |
| 101 | // TODO: remove this check once #9668 is completed | 101 | // TODO: remove this check once #9668 is completed |
| 102 | if (builtin.stage2_arch != .wasm32) { | 102 | if (builtin.cpu.arch != .wasm32) { |
| 103 | // skip testing ints > 64 bits on wasm due to miscompilation / wasmtime ci error | 103 | // skip testing ints > 64 bits on wasm due to miscompilation / wasmtime ci error |
| 104 | try testSatShl(i128, maxInt(i128), 64, maxInt(i128)); | 104 | try testSatShl(i128, maxInt(i128), 64, maxInt(i128)); |
| 105 | try testSatShl(u128, maxInt(u128), 64, maxInt(u128)); | 105 | try testSatShl(u128, maxInt(u128), 64, maxInt(u128)); |