mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
stage2: fix Decl addrspace being undefined
This commit is contained in:
parent
069c83d58c
commit
f0dcdd7931
@ -4220,7 +4220,13 @@ fn markOutdatedDecl(mod: *Module, decl: *Decl) !void {
|
||||
decl.analysis = .outdated;
|
||||
}
|
||||
|
||||
pub fn allocateNewDecl(mod: *Module, name: [:0]const u8, namespace: *Namespace, src_node: Ast.Node.Index, src_scope: ?*CaptureScope) !*Decl {
|
||||
pub fn allocateNewDecl(
|
||||
mod: *Module,
|
||||
name: [:0]const u8,
|
||||
namespace: *Namespace,
|
||||
src_node: Ast.Node.Index,
|
||||
src_scope: ?*CaptureScope,
|
||||
) !*Decl {
|
||||
// If we have emit-h then we must allocate a bigger structure to store the emit-h state.
|
||||
const new_decl: *Decl = if (mod.emit_h != null) blk: {
|
||||
const parent_struct = try mod.gpa.create(DeclPlusEmitH);
|
||||
@ -4242,7 +4248,7 @@ pub fn allocateNewDecl(mod: *Module, name: [:0]const u8, namespace: *Namespace,
|
||||
.val = undefined,
|
||||
.align_val = undefined,
|
||||
.linksection_val = undefined,
|
||||
.@"addrspace" = undefined,
|
||||
.@"addrspace" = .generic,
|
||||
.analysis = .unreferenced,
|
||||
.deletion_flag = false,
|
||||
.zir_decl_index = 0,
|
||||
@ -4346,7 +4352,6 @@ pub fn createAnonymousDeclFromDeclNamed(
|
||||
new_decl.val = typed_value.val;
|
||||
new_decl.align_val = Value.initTag(.null_value);
|
||||
new_decl.linksection_val = Value.initTag(.null_value);
|
||||
new_decl.@"addrspace" = .generic; // default global addrspace
|
||||
new_decl.has_tv = true;
|
||||
new_decl.analysis = .complete;
|
||||
new_decl.generation = mod.generation;
|
||||
|
||||
@ -2,6 +2,7 @@ const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const mem = std.mem;
|
||||
const expect = std.testing.expect;
|
||||
const expectEqualStrings = std.testing.expectEqualStrings;
|
||||
|
||||
// normal comment
|
||||
|
||||
@ -446,3 +447,15 @@ test "self reference through fn ptr field" {
|
||||
a.f = S.foo;
|
||||
try expect(a.f(a) == 12);
|
||||
}
|
||||
|
||||
test "global variable initialized to global variable array element" {
|
||||
try expect(global_ptr == &gdt[0]);
|
||||
}
|
||||
const GDTEntry = struct {
|
||||
field: i32,
|
||||
};
|
||||
var gdt = [_]GDTEntry{
|
||||
GDTEntry{ .field = 1 },
|
||||
GDTEntry{ .field = 2 },
|
||||
};
|
||||
var global_ptr = &gdt[0];
|
||||
|
||||
@ -100,18 +100,6 @@ test "string concatenation" {
|
||||
try expect(b[len] == 0);
|
||||
}
|
||||
|
||||
test "global variable initialized to global variable array element" {
|
||||
try expect(global_ptr == &gdt[0]);
|
||||
}
|
||||
const GDTEntry = struct {
|
||||
field: i32,
|
||||
};
|
||||
var gdt = [_]GDTEntry{
|
||||
GDTEntry{ .field = 1 },
|
||||
GDTEntry{ .field = 2 },
|
||||
};
|
||||
var global_ptr = &gdt[0];
|
||||
|
||||
// can't really run this test but we can make sure it has no compile error
|
||||
// and generates code
|
||||
const vram = @intToPtr([*]volatile u8, 0x20000000)[0..0x8000];
|
||||
|
||||
@ -62,7 +62,7 @@ test "saturating subtraction" {
|
||||
|
||||
test "saturating multiplication" {
|
||||
// TODO: once #9660 has been solved, remove this line
|
||||
if (builtin.stage2_arch == .wasm32) return error.SkipZigTest;
|
||||
if (builtin.cpu.arch == .wasm32) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest() !void {
|
||||
@ -99,7 +99,7 @@ test "saturating shift-left" {
|
||||
try testSatShl(i8, 127, 1, 127);
|
||||
try testSatShl(i8, -128, 1, -128);
|
||||
// TODO: remove this check once #9668 is completed
|
||||
if (builtin.stage2_arch != .wasm32) {
|
||||
if (builtin.cpu.arch != .wasm32) {
|
||||
// skip testing ints > 64 bits on wasm due to miscompilation / wasmtime ci error
|
||||
try testSatShl(i128, maxInt(i128), 64, maxInt(i128));
|
||||
try testSatShl(u128, maxInt(u128), 64, maxInt(u128));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user