authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-06 17:48:38-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-06 17:48:38-07:00
log7dd33d431612cd8511eaea8dcabdca44b354e14b
treed1381cfd8da2bfcacc00cbf84e1570bffda3503e
parent9b9ea405ef1d11af377057067118b07a021b990f

stage2: fix compile errors in test harness


4 files changed, 69 insertions(+), 69 deletions(-)

BRANCH_TODO+4-4
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1 * namespace decls table can't reference ZIR memory because it can get modified on updates1 * get stage2 tests passing
2 - change it for astgen worker to compare old and new ZIR, updating existing2 * modify stage2 tests so that only 1 uses _start and the rest use
3 namespaces & decls, and creating a changelist.3 pub fn main
4 * reimplement semaDecl4
5 * use a hash map for instructions because the array is too big5 * use a hash map for instructions because the array is too big
6 - no, actually modify the Zir.Inst.Ref strategy so that each decl gets6 - no, actually modify the Zir.Inst.Ref strategy so that each decl gets
7 their indexes starting at 0 so that we can use an array to store Sema7 their indexes starting at 0 so that we can use an array to store Sema
lib/std/elf.zig+7-7
...@@ -4,13 +4,13 @@...@@ -4,13 +4,13 @@
4// The MIT license requires this copyright notice to be included in all copies4// The MIT license requires this copyright notice to be included in all copies
5// and substantial portions of the software.5// and substantial portions of the software.
6const std = @import("std.zig");6const std = @import("std.zig");
7const builtin = std.builtin;
8const io = std.io;7const io = std.io;
9const os = std.os;8const os = std.os;
10const math = std.math;9const math = std.math;
11const mem = std.mem;10const mem = std.mem;
12const debug = std.debug;11const debug = std.debug;
13const File = std.fs.File;12const File = std.fs.File;
13const native_endian = @import("builtin").target.cpu.arch.endian();
1414
15pub const AT_NULL = 0;15pub const AT_NULL = 0;
16pub const AT_IGNORE = 1;16pub const AT_IGNORE = 1;
...@@ -336,7 +336,7 @@ pub const ET = enum(u16) {...@@ -336,7 +336,7 @@ pub const ET = enum(u16) {
336336
337/// All integers are native endian.337/// All integers are native endian.
338pub const Header = struct {338pub const Header = struct {
339 endian: builtin.Endian,339 endian: std.builtin.Endian,
340 machine: EM,340 machine: EM,
341 is_64: bool,341 is_64: bool,
342 entry: u64,342 entry: u64,
...@@ -380,7 +380,7 @@ pub const Header = struct {...@@ -380,7 +380,7 @@ pub const Header = struct {
380 ELFDATA2MSB => .Big,380 ELFDATA2MSB => .Big,
381 else => return error.InvalidElfEndian,381 else => return error.InvalidElfEndian,
382 };382 };
383 const need_bswap = endian != std.builtin.endian;383 const need_bswap = endian != native_endian;
384384
385 const is_64 = switch (hdr32.e_ident[EI_CLASS]) {385 const is_64 = switch (hdr32.e_ident[EI_CLASS]) {
386 ELFCLASS32 => false,386 ELFCLASS32 => false,
...@@ -426,7 +426,7 @@ pub fn ProgramHeaderIterator(ParseSource: anytype) type {...@@ -426,7 +426,7 @@ pub fn ProgramHeaderIterator(ParseSource: anytype) type {
426 try self.parse_source.reader().readNoEof(mem.asBytes(&phdr));426 try self.parse_source.reader().readNoEof(mem.asBytes(&phdr));
427427
428 // ELF endianness matches native endianness.428 // ELF endianness matches native endianness.
429 if (self.elf_header.endian == std.builtin.endian) return phdr;429 if (self.elf_header.endian == native_endian) return phdr;
430430
431 // Convert fields to native endianness.431 // Convert fields to native endianness.
432 bswapAllFields(Elf64_Phdr, &phdr);432 bswapAllFields(Elf64_Phdr, &phdr);
...@@ -439,7 +439,7 @@ pub fn ProgramHeaderIterator(ParseSource: anytype) type {...@@ -439,7 +439,7 @@ pub fn ProgramHeaderIterator(ParseSource: anytype) type {
439 try self.parse_source.reader().readNoEof(mem.asBytes(&phdr));439 try self.parse_source.reader().readNoEof(mem.asBytes(&phdr));
440440
441 // ELF endianness does NOT match native endianness.441 // ELF endianness does NOT match native endianness.
442 if (self.elf_header.endian != std.builtin.endian) {442 if (self.elf_header.endian != native_endian) {
443 // Convert fields to native endianness.443 // Convert fields to native endianness.
444 bswapAllFields(Elf32_Phdr, &phdr);444 bswapAllFields(Elf32_Phdr, &phdr);
445 }445 }
...@@ -476,7 +476,7 @@ pub fn SectionHeaderIterator(ParseSource: anytype) type {...@@ -476,7 +476,7 @@ pub fn SectionHeaderIterator(ParseSource: anytype) type {
476 try self.parse_source.reader().readNoEof(mem.asBytes(&shdr));476 try self.parse_source.reader().readNoEof(mem.asBytes(&shdr));
477477
478 // ELF endianness matches native endianness.478 // ELF endianness matches native endianness.
479 if (self.elf_header.endian == std.builtin.endian) return shdr;479 if (self.elf_header.endian == native_endian) return shdr;
480480
481 // Convert fields to native endianness.481 // Convert fields to native endianness.
482 return Elf64_Shdr{482 return Elf64_Shdr{
...@@ -499,7 +499,7 @@ pub fn SectionHeaderIterator(ParseSource: anytype) type {...@@ -499,7 +499,7 @@ pub fn SectionHeaderIterator(ParseSource: anytype) type {
499 try self.parse_source.reader().readNoEof(mem.asBytes(&shdr));499 try self.parse_source.reader().readNoEof(mem.asBytes(&shdr));
500500
501 // ELF endianness does NOT match native endianness.501 // ELF endianness does NOT match native endianness.
502 if (self.elf_header.endian != std.builtin.endian) {502 if (self.elf_header.endian != native_endian) {
503 // Convert fields to native endianness.503 // Convert fields to native endianness.
504 shdr = .{504 shdr = .{
505 .sh_name = @byteSwap(@TypeOf(shdr.sh_name), shdr.sh_name),505 .sh_name = @byteSwap(@TypeOf(shdr.sh_name), shdr.sh_name),
src/test.zig+1-1
...@@ -135,7 +135,7 @@ pub const TestContext = struct {...@@ -135,7 +135,7 @@ pub const TestContext = struct {
135 /// to Executable.135 /// to Executable.
136 output_mode: std.builtin.OutputMode,136 output_mode: std.builtin.OutputMode,
137 updates: std.ArrayList(Update),137 updates: std.ArrayList(Update),
138 object_format: ?std.builtin.ObjectFormat = null,138 object_format: ?std.Target.ObjectFormat = null,
139 emit_h: bool = false,139 emit_h: bool = false,
140 llvm_backend: bool = false,140 llvm_backend: bool = false,
141141
test/stage2/test.zig+57-57
...@@ -66,7 +66,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -66,7 +66,7 @@ pub fn addCases(ctx: *TestContext) !void {
66 );66 );
67 // Now change the message only67 // Now change the message only
68 case.addCompareOutput(68 case.addCompareOutput(
69 \\export fn _start() noreturn {69 \\pub export fn _start() noreturn {
70 \\ print();70 \\ print();
71 \\71 \\
72 \\ exit();72 \\ exit();
...@@ -98,7 +98,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -98,7 +98,7 @@ pub fn addCases(ctx: *TestContext) !void {
98 );98 );
99 // Now we print it twice.99 // Now we print it twice.
100 case.addCompareOutput(100 case.addCompareOutput(
101 \\export fn _start() noreturn {101 \\pub export fn _start() noreturn {
102 \\ print();102 \\ print();
103 \\ print();103 \\ print();
104 \\104 \\
...@@ -136,7 +136,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -136,7 +136,7 @@ pub fn addCases(ctx: *TestContext) !void {
136 {136 {
137 var case = ctx.exe("adding numbers at comptime", linux_x64);137 var case = ctx.exe("adding numbers at comptime", linux_x64);
138 case.addCompareOutput(138 case.addCompareOutput(
139 \\export fn _start() noreturn {139 \\pub export fn _start() noreturn {
140 \\ asm volatile ("syscall"140 \\ asm volatile ("syscall"
141 \\ :141 \\ :
142 \\ : [number] "{rax}" (1),142 \\ : [number] "{rax}" (1),
...@@ -161,7 +161,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -161,7 +161,7 @@ pub fn addCases(ctx: *TestContext) !void {
161 {161 {
162 var case = ctx.exe("adding numbers at runtime and comptime", linux_x64);162 var case = ctx.exe("adding numbers at runtime and comptime", linux_x64);
163 case.addCompareOutput(163 case.addCompareOutput(
164 \\export fn _start() noreturn {164 \\pub export fn _start() noreturn {
165 \\ add(3, 4);165 \\ add(3, 4);
166 \\166 \\
167 \\ exit();167 \\ exit();
...@@ -185,7 +185,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -185,7 +185,7 @@ pub fn addCases(ctx: *TestContext) !void {
185 );185 );
186 // comptime function call186 // comptime function call
187 case.addCompareOutput(187 case.addCompareOutput(
188 \\export fn _start() noreturn {188 \\pub export fn _start() noreturn {
189 \\ exit();189 \\ exit();
190 \\}190 \\}
191 \\191 \\
...@@ -209,7 +209,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -209,7 +209,7 @@ pub fn addCases(ctx: *TestContext) !void {
209 );209 );
210 // Inline function call210 // Inline function call
211 case.addCompareOutput(211 case.addCompareOutput(
212 \\export fn _start() noreturn {212 \\pub export fn _start() noreturn {
213 \\ var x: usize = 3;213 \\ var x: usize = 3;
214 \\ const y = add(1, 2, x);214 \\ const y = add(1, 2, x);
215 \\ exit(y - 6);215 \\ exit(y - 6);
...@@ -236,7 +236,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -236,7 +236,7 @@ pub fn addCases(ctx: *TestContext) !void {
236 {236 {
237 var case = ctx.exe("subtracting numbers at runtime", linux_x64);237 var case = ctx.exe("subtracting numbers at runtime", linux_x64);
238 case.addCompareOutput(238 case.addCompareOutput(
239 \\export fn _start() noreturn {239 \\pub export fn _start() noreturn {
240 \\ sub(7, 4);240 \\ sub(7, 4);
241 \\241 \\
242 \\ exit();242 \\ exit();
...@@ -262,7 +262,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -262,7 +262,7 @@ pub fn addCases(ctx: *TestContext) !void {
262 {262 {
263 var case = ctx.exe("@TypeOf", linux_x64);263 var case = ctx.exe("@TypeOf", linux_x64);
264 case.addCompareOutput(264 case.addCompareOutput(
265 \\export fn _start() noreturn {265 \\pub export fn _start() noreturn {
266 \\ var x: usize = 0;266 \\ var x: usize = 0;
267 \\ const z = @TypeOf(x, @as(u128, 5));267 \\ const z = @TypeOf(x, @as(u128, 5));
268 \\ assert(z == u128);268 \\ assert(z == u128);
...@@ -287,7 +287,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -287,7 +287,7 @@ pub fn addCases(ctx: *TestContext) !void {
287 "",287 "",
288 );288 );
289 case.addCompareOutput(289 case.addCompareOutput(
290 \\export fn _start() noreturn {290 \\pub export fn _start() noreturn {
291 \\ const z = @TypeOf(true);291 \\ const z = @TypeOf(true);
292 \\ assert(z == bool);292 \\ assert(z == bool);
293 \\293 \\
...@@ -311,7 +311,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -311,7 +311,7 @@ pub fn addCases(ctx: *TestContext) !void {
311 "",311 "",
312 );312 );
313 case.addError(313 case.addError(
314 \\export fn _start() noreturn {314 \\pub export fn _start() noreturn {
315 \\ const z = @TypeOf(true, 1);315 \\ const z = @TypeOf(true, 1);
316 \\ unreachable;316 \\ unreachable;
317 \\}317 \\}
...@@ -321,7 +321,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -321,7 +321,7 @@ pub fn addCases(ctx: *TestContext) !void {
321 {321 {
322 var case = ctx.exe("assert function", linux_x64);322 var case = ctx.exe("assert function", linux_x64);
323 case.addCompareOutput(323 case.addCompareOutput(
324 \\export fn _start() noreturn {324 \\pub export fn _start() noreturn {
325 \\ add(3, 4);325 \\ add(3, 4);
326 \\326 \\
327 \\ exit();327 \\ exit();
...@@ -351,7 +351,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -351,7 +351,7 @@ pub fn addCases(ctx: *TestContext) !void {
351 // Tests copying a register. For the `c = a + b`, it has to351 // Tests copying a register. For the `c = a + b`, it has to
352 // preserve both a and b, because they are both used later.352 // preserve both a and b, because they are both used later.
353 case.addCompareOutput(353 case.addCompareOutput(
354 \\export fn _start() noreturn {354 \\pub export fn _start() noreturn {
355 \\ add(3, 4);355 \\ add(3, 4);
356 \\356 \\
357 \\ exit();357 \\ exit();
...@@ -383,7 +383,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -383,7 +383,7 @@ pub fn addCases(ctx: *TestContext) !void {
383383
384 // More stress on the liveness detection.384 // More stress on the liveness detection.
385 case.addCompareOutput(385 case.addCompareOutput(
386 \\export fn _start() noreturn {386 \\pub export fn _start() noreturn {
387 \\ add(3, 4);387 \\ add(3, 4);
388 \\388 \\
389 \\ exit();389 \\ exit();
...@@ -419,7 +419,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -419,7 +419,7 @@ pub fn addCases(ctx: *TestContext) !void {
419419
420 // Requires a second move. The register allocator should figure out to re-use rax.420 // Requires a second move. The register allocator should figure out to re-use rax.
421 case.addCompareOutput(421 case.addCompareOutput(
422 \\export fn _start() noreturn {422 \\pub export fn _start() noreturn {
423 \\ add(3, 4);423 \\ add(3, 4);
424 \\424 \\
425 \\ exit();425 \\ exit();
...@@ -456,7 +456,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -456,7 +456,7 @@ pub fn addCases(ctx: *TestContext) !void {
456456
457 // Now we test integer return values.457 // Now we test integer return values.
458 case.addCompareOutput(458 case.addCompareOutput(
459 \\export fn _start() noreturn {459 \\pub export fn _start() noreturn {
460 \\ assert(add(3, 4) == 7);460 \\ assert(add(3, 4) == 7);
461 \\ assert(add(20, 10) == 30);461 \\ assert(add(20, 10) == 30);
462 \\462 \\
...@@ -486,7 +486,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -486,7 +486,7 @@ pub fn addCases(ctx: *TestContext) !void {
486486
487 // Local mutable variables.487 // Local mutable variables.
488 case.addCompareOutput(488 case.addCompareOutput(
489 \\export fn _start() noreturn {489 \\pub export fn _start() noreturn {
490 \\ assert(add(3, 4) == 7);490 \\ assert(add(3, 4) == 7);
491 \\ assert(add(20, 10) == 30);491 \\ assert(add(20, 10) == 30);
492 \\492 \\
...@@ -520,7 +520,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -520,7 +520,7 @@ pub fn addCases(ctx: *TestContext) !void {
520520
521 // Optionals521 // Optionals
522 case.addCompareOutput(522 case.addCompareOutput(
523 \\export fn _start() noreturn {523 \\pub export fn _start() noreturn {
524 \\ const a: u32 = 2;524 \\ const a: u32 = 2;
525 \\ const b: ?u32 = a;525 \\ const b: ?u32 = a;
526 \\ const c = b.?;526 \\ const c = b.?;
...@@ -544,7 +544,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -544,7 +544,7 @@ pub fn addCases(ctx: *TestContext) !void {
544544
545 // While loops545 // While loops
546 case.addCompareOutput(546 case.addCompareOutput(
547 \\export fn _start() noreturn {547 \\pub export fn _start() noreturn {
548 \\ var i: u32 = 0;548 \\ var i: u32 = 0;
549 \\ while (i < 4) : (i += 1) print();549 \\ while (i < 4) : (i += 1) print();
550 \\ assert(i == 4);550 \\ assert(i == 4);
...@@ -583,7 +583,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -583,7 +583,7 @@ pub fn addCases(ctx: *TestContext) !void {
583583
584 // inline while requires the condition to be comptime known.584 // inline while requires the condition to be comptime known.
585 case.addError(585 case.addError(
586 \\export fn _start() noreturn {586 \\pub export fn _start() noreturn {
587 \\ var i: u32 = 0;587 \\ var i: u32 = 0;
588 \\ inline while (i < 4) : (i += 1) print();588 \\ inline while (i < 4) : (i += 1) print();
589 \\ assert(i == 4);589 \\ assert(i == 4);
...@@ -620,7 +620,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -620,7 +620,7 @@ pub fn addCases(ctx: *TestContext) !void {
620620
621 // Labeled blocks (no conditional branch)621 // Labeled blocks (no conditional branch)
622 case.addCompareOutput(622 case.addCompareOutput(
623 \\export fn _start() noreturn {623 \\pub export fn _start() noreturn {
624 \\ assert(add(3, 4) == 20);624 \\ assert(add(3, 4) == 20);
625 \\625 \\
626 \\ exit();626 \\ exit();
...@@ -657,7 +657,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -657,7 +657,7 @@ pub fn addCases(ctx: *TestContext) !void {
657657
658 // This catches a possible bug in the logic for re-using dying operands.658 // This catches a possible bug in the logic for re-using dying operands.
659 case.addCompareOutput(659 case.addCompareOutput(
660 \\export fn _start() noreturn {660 \\pub export fn _start() noreturn {
661 \\ assert(add(3, 4) == 116);661 \\ assert(add(3, 4) == 116);
662 \\662 \\
663 \\ exit();663 \\ exit();
...@@ -699,7 +699,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -699,7 +699,7 @@ pub fn addCases(ctx: *TestContext) !void {
699699
700 // Spilling registers to the stack.700 // Spilling registers to the stack.
701 case.addCompareOutput(701 case.addCompareOutput(
702 \\export fn _start() noreturn {702 \\pub export fn _start() noreturn {
703 \\ assert(add(3, 4) == 791);703 \\ assert(add(3, 4) == 791);
704 \\704 \\
705 \\ exit();705 \\ exit();
...@@ -751,7 +751,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -751,7 +751,7 @@ pub fn addCases(ctx: *TestContext) !void {
751751
752 // Reusing the registers of dead operands playing nicely with conditional branching.752 // Reusing the registers of dead operands playing nicely with conditional branching.
753 case.addCompareOutput(753 case.addCompareOutput(
754 \\export fn _start() noreturn {754 \\pub export fn _start() noreturn {
755 \\ assert(add(3, 4) == 791);755 \\ assert(add(3, 4) == 791);
756 \\ assert(add(4, 3) == 79);756 \\ assert(add(4, 3) == 79);
757 \\757 \\
...@@ -813,7 +813,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -813,7 +813,7 @@ pub fn addCases(ctx: *TestContext) !void {
813813
814 // Character literals and multiline strings.814 // Character literals and multiline strings.
815 case.addCompareOutput(815 case.addCompareOutput(
816 \\export fn _start() noreturn {816 \\pub export fn _start() noreturn {
817 \\ const ignore =817 \\ const ignore =
818 \\ \\ cool thx818 \\ \\ cool thx
819 \\ \\819 \\ \\
...@@ -846,7 +846,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -846,7 +846,7 @@ pub fn addCases(ctx: *TestContext) !void {
846846
847 // Global const.847 // Global const.
848 case.addCompareOutput(848 case.addCompareOutput(
849 \\export fn _start() noreturn {849 \\pub export fn _start() noreturn {
850 \\ add(aa, bb);850 \\ add(aa, bb);
851 \\851 \\
852 \\ exit();852 \\ exit();
...@@ -878,7 +878,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -878,7 +878,7 @@ pub fn addCases(ctx: *TestContext) !void {
878878
879 // Array access.879 // Array access.
880 case.addCompareOutput(880 case.addCompareOutput(
881 \\export fn _start() noreturn {881 \\pub export fn _start() noreturn {
882 \\ assert("hello"[0] == 'h');882 \\ assert("hello"[0] == 'h');
883 \\883 \\
884 \\ exit();884 \\ exit();
...@@ -904,7 +904,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -904,7 +904,7 @@ pub fn addCases(ctx: *TestContext) !void {
904 // Array access to a global array.904 // Array access to a global array.
905 case.addCompareOutput(905 case.addCompareOutput(
906 \\const hello = "hello".*;906 \\const hello = "hello".*;
907 \\export fn _start() noreturn {907 \\pub export fn _start() noreturn {
908 \\ assert(hello[1] == 'e');908 \\ assert(hello[1] == 'e');
909 \\909 \\
910 \\ exit();910 \\ exit();
...@@ -929,7 +929,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -929,7 +929,7 @@ pub fn addCases(ctx: *TestContext) !void {
929929
930 // 64bit set stack930 // 64bit set stack
931 case.addCompareOutput(931 case.addCompareOutput(
932 \\export fn _start() noreturn {932 \\pub export fn _start() noreturn {
933 \\ var i: u64 = 0xFFEEDDCCBBAA9988;933 \\ var i: u64 = 0xFFEEDDCCBBAA9988;
934 \\ assert(i == 0xFFEEDDCCBBAA9988);934 \\ assert(i == 0xFFEEDDCCBBAA9988);
935 \\935 \\
...@@ -955,7 +955,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -955,7 +955,7 @@ pub fn addCases(ctx: *TestContext) !void {
955955
956 // Basic for loop956 // Basic for loop
957 case.addCompareOutput(957 case.addCompareOutput(
958 \\export fn _start() noreturn {958 \\pub export fn _start() noreturn {
959 \\ for ("hello") |_| print();959 \\ for ("hello") |_| print();
960 \\960 \\
961 \\ exit();961 \\ exit();
...@@ -990,7 +990,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -990,7 +990,7 @@ pub fn addCases(ctx: *TestContext) !void {
990 {990 {
991 var case = ctx.exe("basic import", linux_x64);991 var case = ctx.exe("basic import", linux_x64);
992 case.addCompareOutput(992 case.addCompareOutput(
993 \\export fn _start() noreturn {993 \\pub export fn _start() noreturn {
994 \\ @import("print.zig").print();994 \\ @import("print.zig").print();
995 \\ exit();995 \\ exit();
996 \\}996 \\}
...@@ -1027,14 +1027,14 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1027,14 +1027,14 @@ pub fn addCases(ctx: *TestContext) !void {
1027 {1027 {
1028 var case = ctx.exe("redundant comptime", linux_x64);1028 var case = ctx.exe("redundant comptime", linux_x64);
1029 case.addError(1029 case.addError(
1030 \\export fn _start() void {1030 \\pub export fn _start() void {
1031 \\ var a: comptime u32 = 0;1031 \\ var a: comptime u32 = 0;
1032 \\}1032 \\}
1033 ,1033 ,
1034 &.{":2:21: error: redundant comptime keyword in already comptime scope"},1034 &.{":2:21: error: redundant comptime keyword in already comptime scope"},
1035 );1035 );
1036 case.addError(1036 case.addError(
1037 \\export fn _start() void {1037 \\pub export fn _start() void {
1038 \\ comptime {1038 \\ comptime {
1039 \\ var a: u32 = comptime 0;1039 \\ var a: u32 = comptime 0;
1040 \\ }1040 \\ }
...@@ -1046,7 +1046,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1046,7 +1046,7 @@ pub fn addCases(ctx: *TestContext) !void {
1046 {1046 {
1047 var case = ctx.exe("import private", linux_x64);1047 var case = ctx.exe("import private", linux_x64);
1048 case.addError(1048 case.addError(
1049 \\export fn _start() noreturn {1049 \\pub export fn _start() noreturn {
1050 \\ @import("print.zig").print();1050 \\ @import("print.zig").print();
1051 \\ exit();1051 \\ exit();
1052 \\}1052 \\}
...@@ -1104,7 +1104,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1104,7 +1104,7 @@ pub fn addCases(ctx: *TestContext) !void {
1104 });1104 });
11051105
1106 ctx.compileError("compileError", linux_x64,1106 ctx.compileError("compileError", linux_x64,
1107 \\export fn _start() noreturn {1107 \\pub export fn _start() noreturn {
1108 \\ @compileError("this is an error");1108 \\ @compileError("this is an error");
1109 \\ unreachable;1109 \\ unreachable;
1110 \\}1110 \\}
...@@ -1113,7 +1113,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1113,7 +1113,7 @@ pub fn addCases(ctx: *TestContext) !void {
1113 {1113 {
1114 var case = ctx.obj("variable shadowing", linux_x64);1114 var case = ctx.obj("variable shadowing", linux_x64);
1115 case.addError(1115 case.addError(
1116 \\export fn _start() noreturn {1116 \\pub export fn _start() noreturn {
1117 \\ var i: u32 = 10;1117 \\ var i: u32 = 10;
1118 \\ var i: u32 = 10;1118 \\ var i: u32 = 10;
1119 \\ unreachable;1119 \\ unreachable;
...@@ -1124,7 +1124,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1124,7 +1124,7 @@ pub fn addCases(ctx: *TestContext) !void {
1124 });1124 });
1125 case.addError(1125 case.addError(
1126 \\var testing: i64 = 10;1126 \\var testing: i64 = 10;
1127 \\export fn _start() noreturn {1127 \\pub export fn _start() noreturn {
1128 \\ var testing: i64 = 20;1128 \\ var testing: i64 = 20;
1129 \\ unreachable;1129 \\ unreachable;
1130 \\}1130 \\}
...@@ -1136,7 +1136,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1136,7 +1136,7 @@ pub fn addCases(ctx: *TestContext) !void {
1136 var case = ctx.obj("@compileLog", linux_x64);1136 var case = ctx.obj("@compileLog", linux_x64);
1137 // The other compile error prevents emission of a "found compile log" statement.1137 // The other compile error prevents emission of a "found compile log" statement.
1138 case.addError(1138 case.addError(
1139 \\export fn _start() noreturn {1139 \\pub export fn _start() noreturn {
1140 \\ const b = true;1140 \\ const b = true;
1141 \\ var f: u32 = 1;1141 \\ var f: u32 = 1;
1142 \\ @compileLog(b, 20, f, x);1142 \\ @compileLog(b, 20, f, x);
...@@ -1154,7 +1154,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1154,7 +1154,7 @@ pub fn addCases(ctx: *TestContext) !void {
11541154
1155 // Now only compile log statements remain. One per Decl.1155 // Now only compile log statements remain. One per Decl.
1156 case.addError(1156 case.addError(
1157 \\export fn _start() noreturn {1157 \\pub export fn _start() noreturn {
1158 \\ const b = true;1158 \\ const b = true;
1159 \\ var f: u32 = 1;1159 \\ var f: u32 = 1;
1160 \\ @compileLog(b, 20, f, x);1160 \\ @compileLog(b, 20, f, x);
...@@ -1192,7 +1192,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1192,7 +1192,7 @@ pub fn addCases(ctx: *TestContext) !void {
11921192
1193 // Break out of loop1193 // Break out of loop
1194 case.addCompareOutput(1194 case.addCompareOutput(
1195 \\export fn _start() noreturn {1195 \\pub export fn _start() noreturn {
1196 \\ while (true) {1196 \\ while (true) {
1197 \\ break;1197 \\ break;
1198 \\ }1198 \\ }
...@@ -1213,7 +1213,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1213,7 +1213,7 @@ pub fn addCases(ctx: *TestContext) !void {
1213 "",1213 "",
1214 );1214 );
1215 case.addCompareOutput(1215 case.addCompareOutput(
1216 \\export fn _start() noreturn {1216 \\pub export fn _start() noreturn {
1217 \\ foo: while (true) {1217 \\ foo: while (true) {
1218 \\ break :foo;1218 \\ break :foo;
1219 \\ }1219 \\ }
...@@ -1236,7 +1236,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1236,7 +1236,7 @@ pub fn addCases(ctx: *TestContext) !void {
12361236
1237 // Continue in loop1237 // Continue in loop
1238 case.addCompareOutput(1238 case.addCompareOutput(
1239 \\export fn _start() noreturn {1239 \\pub export fn _start() noreturn {
1240 \\ var i: u64 = 0;1240 \\ var i: u64 = 0;
1241 \\ while (true) : (i+=1) {1241 \\ while (true) : (i+=1) {
1242 \\ if (i == 4) exit();1242 \\ if (i == 4) exit();
...@@ -1257,7 +1257,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1257,7 +1257,7 @@ pub fn addCases(ctx: *TestContext) !void {
1257 "",1257 "",
1258 );1258 );
1259 case.addCompareOutput(1259 case.addCompareOutput(
1260 \\export fn _start() noreturn {1260 \\pub export fn _start() noreturn {
1261 \\ var i: u64 = 0;1261 \\ var i: u64 = 0;
1262 \\ foo: while (true) : (i+=1) {1262 \\ foo: while (true) : (i+=1) {
1263 \\ if (i == 4) exit();1263 \\ if (i == 4) exit();
...@@ -1318,7 +1318,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1318,7 +1318,7 @@ pub fn addCases(ctx: *TestContext) !void {
1318 {1318 {
1319 var case = ctx.exe("compile error in inline fn call fixed", linux_x64);1319 var case = ctx.exe("compile error in inline fn call fixed", linux_x64);
1320 case.addError(1320 case.addError(
1321 \\export fn _start() noreturn {1321 \\pub export fn _start() noreturn {
1322 \\ var x: usize = 3;1322 \\ var x: usize = 3;
1323 \\ const y = add(10, 2, x);1323 \\ const y = add(10, 2, x);
1324 \\ exit(y - 6);1324 \\ exit(y - 6);
...@@ -1341,7 +1341,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1341,7 +1341,7 @@ pub fn addCases(ctx: *TestContext) !void {
1341 , &[_][]const u8{":8:18: error: bad"});1341 , &[_][]const u8{":8:18: error: bad"});
13421342
1343 case.addCompareOutput(1343 case.addCompareOutput(
1344 \\export fn _start() noreturn {1344 \\pub export fn _start() noreturn {
1345 \\ var x: usize = 3;1345 \\ var x: usize = 3;
1346 \\ const y = add(1, 2, x);1346 \\ const y = add(1, 2, x);
1347 \\ exit(y - 6);1347 \\ exit(y - 6);
...@@ -1368,7 +1368,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1368,7 +1368,7 @@ pub fn addCases(ctx: *TestContext) !void {
1368 {1368 {
1369 var case = ctx.exe("recursive inline function", linux_x64);1369 var case = ctx.exe("recursive inline function", linux_x64);
1370 case.addCompareOutput(1370 case.addCompareOutput(
1371 \\export fn _start() noreturn {1371 \\pub export fn _start() noreturn {
1372 \\ const y = fibonacci(7);1372 \\ const y = fibonacci(7);
1373 \\ exit(y - 21);1373 \\ exit(y - 21);
1374 \\}1374 \\}
...@@ -1394,7 +1394,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1394,7 +1394,7 @@ pub fn addCases(ctx: *TestContext) !void {
1394 // Without storing source locations relative to the owner decl, the compile error1394 // Without storing source locations relative to the owner decl, the compile error
1395 // here would be off by 2 bytes (from the "7" -> "999").1395 // here would be off by 2 bytes (from the "7" -> "999").
1396 case.addError(1396 case.addError(
1397 \\export fn _start() noreturn {1397 \\pub export fn _start() noreturn {
1398 \\ const y = fibonacci(999);1398 \\ const y = fibonacci(999);
1399 \\ exit(y - 21);1399 \\ exit(y - 21);
1400 \\}1400 \\}
...@@ -1418,7 +1418,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1418,7 +1418,7 @@ pub fn addCases(ctx: *TestContext) !void {
1418 {1418 {
1419 var case = ctx.exe("orelse at comptime", linux_x64);1419 var case = ctx.exe("orelse at comptime", linux_x64);
1420 case.addCompareOutput(1420 case.addCompareOutput(
1421 \\export fn _start() noreturn {1421 \\pub export fn _start() noreturn {
1422 \\ const i: ?u64 = 0;1422 \\ const i: ?u64 = 0;
1423 \\ const orelsed = i orelse 5;1423 \\ const orelsed = i orelse 5;
1424 \\ assert(orelsed == 0);1424 \\ assert(orelsed == 0);
...@@ -1440,7 +1440,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1440,7 +1440,7 @@ pub fn addCases(ctx: *TestContext) !void {
1440 "",1440 "",
1441 );1441 );
1442 case.addCompareOutput(1442 case.addCompareOutput(
1443 \\export fn _start() noreturn {1443 \\pub export fn _start() noreturn {
1444 \\ const i: ?u64 = null;1444 \\ const i: ?u64 = null;
1445 \\ const orelsed = i orelse 5;1445 \\ const orelsed = i orelse 5;
1446 \\ assert(orelsed == 5);1446 \\ assert(orelsed == 5);
...@@ -1466,7 +1466,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1466,7 +1466,7 @@ pub fn addCases(ctx: *TestContext) !void {
1466 {1466 {
1467 var case = ctx.exe("only 1 function and it gets updated", linux_x64);1467 var case = ctx.exe("only 1 function and it gets updated", linux_x64);
1468 case.addCompareOutput(1468 case.addCompareOutput(
1469 \\export fn _start() noreturn {1469 \\pub export fn _start() noreturn {
1470 \\ asm volatile ("syscall"1470 \\ asm volatile ("syscall"
1471 \\ :1471 \\ :
1472 \\ : [number] "{rax}" (60), // exit1472 \\ : [number] "{rax}" (60), // exit
...@@ -1479,7 +1479,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1479,7 +1479,7 @@ pub fn addCases(ctx: *TestContext) !void {
1479 "",1479 "",
1480 );1480 );
1481 case.addCompareOutput(1481 case.addCompareOutput(
1482 \\export fn _start() noreturn {1482 \\pub export fn _start() noreturn {
1483 \\ asm volatile ("syscall"1483 \\ asm volatile ("syscall"
1484 \\ :1484 \\ :
1485 \\ : [number] "{rax}" (231), // exit_group1485 \\ : [number] "{rax}" (231), // exit_group
...@@ -1495,7 +1495,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1495,7 +1495,7 @@ pub fn addCases(ctx: *TestContext) !void {
1495 {1495 {
1496 var case = ctx.exe("passing u0 to function", linux_x64);1496 var case = ctx.exe("passing u0 to function", linux_x64);
1497 case.addCompareOutput(1497 case.addCompareOutput(
1498 \\export fn _start() noreturn {1498 \\pub export fn _start() noreturn {
1499 \\ doNothing(0);1499 \\ doNothing(0);
1500 \\ exit();1500 \\ exit();
1501 \\}1501 \\}
...@@ -1516,7 +1516,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1516,7 +1516,7 @@ pub fn addCases(ctx: *TestContext) !void {
1516 {1516 {
1517 var case = ctx.exe("catch at comptime", linux_x64);1517 var case = ctx.exe("catch at comptime", linux_x64);
1518 case.addCompareOutput(1518 case.addCompareOutput(
1519 \\export fn _start() noreturn {1519 \\pub export fn _start() noreturn {
1520 \\ const i: anyerror!u64 = 0;1520 \\ const i: anyerror!u64 = 0;
1521 \\ const caught = i catch 5;1521 \\ const caught = i catch 5;
1522 \\ assert(caught == 0);1522 \\ assert(caught == 0);
...@@ -1539,7 +1539,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1539,7 +1539,7 @@ pub fn addCases(ctx: *TestContext) !void {
1539 );1539 );
15401540
1541 case.addCompareOutput(1541 case.addCompareOutput(
1542 \\export fn _start() noreturn {1542 \\pub export fn _start() noreturn {
1543 \\ const i: anyerror!u64 = error.B;1543 \\ const i: anyerror!u64 = error.B;
1544 \\ const caught = i catch 5;1544 \\ const caught = i catch 5;
1545 \\ assert(caught == 5);1545 \\ assert(caught == 5);
...@@ -1562,7 +1562,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1562,7 +1562,7 @@ pub fn addCases(ctx: *TestContext) !void {
1562 );1562 );
15631563
1564 case.addCompareOutput(1564 case.addCompareOutput(
1565 \\export fn _start() noreturn {1565 \\pub export fn _start() noreturn {
1566 \\ const a: anyerror!comptime_int = 42;1566 \\ const a: anyerror!comptime_int = 42;
1567 \\ const b: *const comptime_int = &(a catch unreachable);1567 \\ const b: *const comptime_int = &(a catch unreachable);
1568 \\ assert(b.* == 42);1568 \\ assert(b.* == 42);
...@@ -1584,7 +1584,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1584,7 +1584,7 @@ pub fn addCases(ctx: *TestContext) !void {
1584 , "");1584 , "");
15851585
1586 case.addCompareOutput(1586 case.addCompareOutput(
1587 \\export fn _start() noreturn {1587 \\pub export fn _start() noreturn {
1588 \\ const a: anyerror!u32 = error.B;1588 \\ const a: anyerror!u32 = error.B;
1589 \\ _ = &(a catch |err| assert(err == error.B));1589 \\ _ = &(a catch |err| assert(err == error.B));
1590 \\ exit();1590 \\ exit();
...@@ -1604,7 +1604,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1604,7 +1604,7 @@ pub fn addCases(ctx: *TestContext) !void {
1604 , "");1604 , "");
16051605
1606 case.addCompareOutput(1606 case.addCompareOutput(
1607 \\export fn _start() noreturn {1607 \\pub export fn _start() noreturn {
1608 \\ const a: anyerror!u32 = error.Bar;1608 \\ const a: anyerror!u32 = error.Bar;
1609 \\ a catch |err| assert(err == error.Bar);1609 \\ a catch |err| assert(err == error.Bar);
1610 \\1610 \\
...@@ -1628,7 +1628,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1628,7 +1628,7 @@ pub fn addCases(ctx: *TestContext) !void {
1628 var case = ctx.exe("merge error sets", linux_x64);1628 var case = ctx.exe("merge error sets", linux_x64);
16291629
1630 case.addCompareOutput(1630 case.addCompareOutput(
1631 \\export fn _start() noreturn {1631 \\pub export fn _start() noreturn {
1632 \\ const E = error{ A, B, D } || error { A, B, C };1632 \\ const E = error{ A, B, D } || error { A, B, C };
1633 \\ const a = E.A;1633 \\ const a = E.A;
1634 \\ const b = E.B;1634 \\ const b = E.B;