From d8d12d51ecd9e893755ced927c79eb9a6c036b31 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Tue, 26 Apr 2022 15:17:41 +0200 Subject: [PATCH 01/26] test: abstract away test manifest parser into separate struct --- src/test.zig | 300 +++++++++++++++++++++++++++++++++++++ test/incremental/add.0.zig | 12 ++ test/incremental/add.1.zig | 14 ++ test/incremental/add.2.zig | 14 ++ 4 files changed, 340 insertions(+) create mode 100644 test/incremental/add.0.zig create mode 100644 test/incremental/add.1.zig create mode 100644 test/incremental/add.2.zig diff --git a/src/test.zig b/src/test.zig index 8c2a15e844..c0a7fe6dc0 100644 --- a/src/test.zig +++ b/src/test.zig @@ -72,6 +72,17 @@ test { } } + { + const dir_path = try std.fs.path.join(arena, &.{ + std.fs.path.dirname(@src().file).?, "..", "test", "incremental", + }); + + var dir = try std.fs.cwd().openDir(dir_path, .{ .iterate = true }); + defer dir.close(); + + ctx.addTestCasesFromDir(dir); + } + try @import("test_cases").addCases(&ctx); try ctx.run(); @@ -154,6 +165,125 @@ const ErrorMsg = union(enum) { } }; +/// Manifest syntax example: +/// (see https://github.com/ziglang/zig/issues/11288) +/// +/// error +/// backend=stage1,stage2 +/// output_mode=exe +/// +/// :3:19: error: foo +/// +/// run +/// target=x86_64-linux,aarch64-macos +/// +/// I am expected stdout! Hello! +/// +/// cli +/// +/// build test +const TestManifest = struct { + @"type": Type, + config_map: std.StringHashMap([]const u8), + trailing_bytes: []const u8 = "", + + const Type = enum { + @"error", + run, + cli, + }; + + const TrailingIterator = struct { + inner: std.mem.TokenIterator(u8), + + fn next(self: *TrailingIterator) ?[]const u8 { + const next_inner = self.inner.next() orelse return null; + return std.mem.trim(u8, next_inner, " \t"); + } + }; + + fn ConfigValueIterator(comptime T: type, comptime ParseFn: type) type { + return struct { + inner: std.mem.SplitIterator(u8), + parse_fn: ParseFn, + + fn next(self: *@This()) ?T { + const next_raw = self.inner.next() orelse return null; + return self.parse_fn(next_raw); + } + }; + } + + fn parse(arena: Allocator, bytes: []const u8) !TestManifest { + var it = std.mem.tokenize(u8, bytes, "\r\n"); + + // First line is the test type + const tt: Type = blk: { + const line = it.next() orelse return error.MissingTestCaseType; + const raw = std.mem.trim(u8, line[2..], " \t"); + if (std.mem.eql(u8, raw, "error")) { + break :blk .@"error"; + } else if (std.mem.eql(u8, raw, "run")) { + break :blk .run; + } else if (std.mem.eql(u8, raw, "cli")) { + break :blk .cli; + } else { + std.log.warn("unknown test case type requested: {s}", .{raw}); + return error.UnknownTestCaseType; + } + }; + + var manifest: TestManifest = .{ + .@"type" = tt, + .config_map = std.StringHashMap([]const u8).init(arena), + }; + + // Any subsequent line until a blank comment line is key=value(s) pair + while (it.next()) |line| { + const trimmed = std.mem.trim(u8, line[2..], " \t"); + if (trimmed.len == 0) break; + + // Parse key=value(s) + var kv_it = std.mem.split(u8, trimmed, "="); + const key = kv_it.next() orelse return error.MissingKeyForConfig; + try manifest.config_map.putNoClobber(key, kv_it.next() orelse return error.MissingValuesForConfig); + } + + // Finally, trailing is expected output + manifest.trailing_bytes = bytes[it.index..]; + + return manifest; + } + + fn getConfigValues( + self: TestManifest, + key: []const u8, + comptime T: type, + parse_fn: anytype, + ) ?ConfigValueIterator(T, @TypeOf(parse_fn)) { + const bytes = self.config_map.get(key) orelse return null; + return ConfigValueIterator(T, @TypeOf(parse_fn)){ + .inner = std.mem.split(u8, bytes, ","), + .parse_fn = parse_fn, + }; + } + + fn trailing(self: TestManifest) TrailingIterator { + return .{ + .inner = std.mem.tokenize(u8, self.trailing_bytes, "\r\n"), + }; + } + + fn trailingAlloc(self: TestManifest, arena: Allocator) ![]const []const u8 { + var out = std.ArrayList([]const u8).init(arena); + var it = self.trailing(); + while (it.next()) |line| { + try out.append(line); + } + return out.toOwnedSlice(); + } +}; + pub const TestContext = struct { arena: Allocator, cases: std.ArrayList(Case), @@ -197,6 +327,10 @@ pub const TestContext = struct { stage1, stage2, llvm, + + fn parse(str: []const u8) ?Backend { + return std.meta.stringToEnum(Backend, str); + } }; /// A `Case` consists of a list of `Update`. The same `Compilation` is used for each @@ -661,6 +795,10 @@ pub const TestContext = struct { /// Execute all tests as incremental updates to a single compilation. Explicitly /// incremental tests ("foo.0.zig", "foo.1.zig", etc.) still execute in order incremental, + + fn parse(str: []const u8) ?Strategy { + return std.meta.stringToEnum(Strategy, str); + } }; /// Adds a compile-error test for each file in the provided directory, using the @@ -689,6 +827,15 @@ pub const TestContext = struct { }; } + pub fn addTestCasesFromDir(ctx: *TestContext, dir: std.fs.Dir) void { + var current_file: []const u8 = "none"; + addTestCasesFromDirInner(ctx, dir, ¤t_file) catch |err| { + std.debug.panic("test harness failed to process file '{s}': {s}\n", .{ + current_file, @errorName(err), + }); + }; + } + /// For a filename in the format ".X." or ".", returns /// "", "" and X parsed as a decimal number. If X is not present, or /// cannot be parsed as a decimal number, it is treated as part of @@ -749,6 +896,159 @@ pub const TestContext = struct { std.sort.sort([]const u8, filenames, Context{}, Context.lessThan); } + fn addTestCasesFromDirInner( + ctx: *TestContext, + dir: std.fs.Dir, + /// This is kept up to date with the currently being processed file so + /// that if any errors occur the caller knows it happened during this file. + current_file: *[]const u8, + ) !void { + var opt_case: ?*Case = null; + + var it = dir.iterate(); + var filenames = std.ArrayList([]const u8).init(ctx.arena); + defer filenames.deinit(); + + while (try it.next()) |entry| { + if (entry.kind != .File) continue; + + // Ignore stuff such as .swp files + switch (Compilation.classifyFileExt(entry.name)) { + .unknown => continue, + else => {}, + } + try filenames.append(try ctx.arena.dupe(u8, entry.name)); + } + + // Sort filenames, so that incremental tests are contiguous and in-order + sortTestFilenames(filenames.items); + + var prev_filename: []const u8 = ""; + for (filenames.items) |filename| { + current_file.* = filename; + + { // First, check if this file is part of an incremental update sequence + + // Split filename into ".." + const prev_parts = getTestFileNameParts(prev_filename); + const new_parts = getTestFileNameParts(filename); + + // If base_name and file_ext match, these files are in the same test sequence + // and the new one should be the incremented version of the previous test + if (std.mem.eql(u8, prev_parts.base_name, new_parts.base_name) and + std.mem.eql(u8, prev_parts.file_ext, new_parts.file_ext)) + { + + // This is "foo.X.zig" followed by "foo.Y.zig". Make sure that X = Y + 1 + if (prev_parts.test_index == null) return error.InvalidIncrementalTestIndex; + if (new_parts.test_index == null) return error.InvalidIncrementalTestIndex; + if (new_parts.test_index.? != prev_parts.test_index.? + 1) return error.InvalidIncrementalTestIndex; + } else { + + // This is not the same test sequence, so the new file must be the first file + // in a new sequence ("*.0.zig") or an independent test file ("*.zig") + if (new_parts.test_index != null and new_parts.test_index.? != 0) return error.InvalidIncrementalTestIndex; + + // if (strategy == .independent) + // opt_case = null; // Generate a new independent test case for this update + } + } + prev_filename = filename; + + const max_file_size = 10 * 1024 * 1024; + const src = try dir.readFileAllocOptions(ctx.arena, filename, max_file_size, null, 1, 0); + + // The manifest is the last contiguous block of comments in the file + // We scan for the beginning by searching backward for the first non-empty line that does not start with "//" + var manifest_start: ?usize = null; + var manifest_end: usize = src.len; + if (src.len > 0) { + var cursor: usize = src.len - 1; + while (true) { + // Move to beginning of line + while (cursor > 0 and src[cursor - 1] != '\n') cursor -= 1; + + if (std.mem.startsWith(u8, src[cursor..], "//")) { + manifest_start = cursor; // Contiguous comment line, include in manifest + } else { + if (manifest_start != null) break; // Encountered non-comment line, end of manifest + + // We ignore all-whitespace lines following the comment block, but anything else + // means that there is no manifest present. + if (std.mem.trim(u8, src[cursor..manifest_end], " \r\n\t").len == 0) { + manifest_end = cursor; + } else break; // If it's not whitespace, there is no manifest + } + + // Move to previous line + if (cursor != 0) cursor -= 1 else break; + } + } + + if (manifest_start) |start| { + // Parse the manifest + var mani = try TestManifest.parse(ctx.arena, src[start..manifest_end]); + const strategy = mani.getConfigValues("strategy", Strategy, Strategy.parse).?.next().?; + const backend = mani.getConfigValues("backend", Backend, Backend.parse).?.next().?; + + switch (mani.@"type") { + .@"error" => { + const case = opt_case orelse case: { + const case = try ctx.cases.addOne(); + case.* = .{ + .name = "none", + .target = .{}, + .backend = backend, + .updates = std.ArrayList(TestContext.Update).init(ctx.cases.allocator), + .is_test = false, + .output_mode = .Obj, + .files = std.ArrayList(TestContext.File).init(ctx.cases.allocator), + }; + opt_case = case; + break :case case; + }; + const errors = try mani.trailingAlloc(ctx.arena); + + switch (strategy) { + .independent => { + case.addError(src, errors); + }, + .incremental => { + case.addErrorNamed("update", src, errors); + }, + } + }, + .run => { + const case = opt_case orelse case: { + const case = try ctx.cases.addOne(); + case.* = .{ + .name = "none", + .target = .{}, + .backend = backend, + .updates = std.ArrayList(TestContext.Update).init(ctx.cases.allocator), + .is_test = false, + .output_mode = .Exe, + .files = std.ArrayList(TestContext.File).init(ctx.cases.allocator), + }; + opt_case = case; + break :case case; + }; + + var output = std.ArrayList(u8).init(ctx.arena); + var trailing_it = mani.trailing(); + while (trailing_it.next()) |line| { + try output.appendSlice(line); + } + case.addCompareOutput(src, output.toOwnedSlice()); + }, + .cli => @panic("TODO cli tests"), + } + } else { + return error.MissingManifest; + } + } + } + fn addErrorCasesFromDirInner( ctx: *TestContext, name: []const u8, diff --git a/test/incremental/add.0.zig b/test/incremental/add.0.zig new file mode 100644 index 0000000000..f271bfed84 --- /dev/null +++ b/test/incremental/add.0.zig @@ -0,0 +1,12 @@ +pub fn main() void { + add(3, 4); +} + +fn add(a: u32, b: u32) void { + if (a + b != 7) unreachable; +} + +// run +// backend=stage2 +// strategy=incremental +// diff --git a/test/incremental/add.1.zig b/test/incremental/add.1.zig new file mode 100644 index 0000000000..a8cc3fa836 --- /dev/null +++ b/test/incremental/add.1.zig @@ -0,0 +1,14 @@ +pub fn main() void { + if (x - 7 != 0) unreachable; +} + +fn add(a: u32, b: u32) u32 { + return a + b; +} + +const x = add(3, 4); + +// run +// backend=stage2 +// strategy=incremental +// diff --git a/test/incremental/add.2.zig b/test/incremental/add.2.zig new file mode 100644 index 0000000000..0f4c18e28f --- /dev/null +++ b/test/incremental/add.2.zig @@ -0,0 +1,14 @@ +pub fn main() void { + var x: usize = 3; + const y = add(1, 2, x); + if (y - 6 != 0) unreachable; +} + +inline fn add(a: usize, b: usize, c: usize) usize { + return a + b + c; +} + +// run +// backend=stage2 +// strategy=incremental +// From d305a6fb550d68f4ee57bbb86f482969b819653b Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Tue, 26 Apr 2022 18:47:11 +0200 Subject: [PATCH 02/26] test: parse all of manifest in TestManifest abstraction --- src/test.zig | 186 +++++++++++++++++++++++++++------------------------ 1 file changed, 97 insertions(+), 89 deletions(-) diff --git a/src/test.zig b/src/test.zig index c0a7fe6dc0..08875ac909 100644 --- a/src/test.zig +++ b/src/test.zig @@ -215,7 +215,37 @@ const TestManifest = struct { } fn parse(arena: Allocator, bytes: []const u8) !TestManifest { - var it = std.mem.tokenize(u8, bytes, "\r\n"); + // The manifest is the last contiguous block of comments in the file + // We scan for the beginning by searching backward for the first non-empty line that does not start with "//" + var start: ?usize = null; + var end: usize = bytes.len; + if (bytes.len > 0) { + var cursor: usize = bytes.len - 1; + while (true) { + // Move to beginning of line + while (cursor > 0 and bytes[cursor - 1] != '\n') cursor -= 1; + + if (std.mem.startsWith(u8, bytes[cursor..], "//")) { + start = cursor; // Contiguous comment line, include in manifest + } else { + if (start != null) break; // Encountered non-comment line, end of manifest + + // We ignore all-whitespace lines following the comment block, but anything else + // means that there is no manifest present. + if (std.mem.trim(u8, bytes[cursor..end], " \r\n\t").len == 0) { + end = cursor; + } else break; // If it's not whitespace, there is no manifest + } + + // Move to previous line + if (cursor != 0) cursor -= 1 else break; + } + } + + const actual_start = start orelse return error.MissingTestManifest; + const manifest_bytes = bytes[actual_start..end]; + + var it = std.mem.tokenize(u8, manifest_bytes, "\r\n"); // First line is the test type const tt: Type = blk: { @@ -250,20 +280,29 @@ const TestManifest = struct { } // Finally, trailing is expected output - manifest.trailing_bytes = bytes[it.index..]; + manifest.trailing_bytes = manifest_bytes[it.index..]; return manifest; } - fn getConfigValues( + fn getConfigForKey( self: TestManifest, key: []const u8, comptime T: type, - parse_fn: anytype, - ) ?ConfigValueIterator(T, @TypeOf(parse_fn)) { - const bytes = self.config_map.get(key) orelse return null; + parse_fn: fn ([]const u8) ?T, + ) ConfigValueIterator(T, @TypeOf(parse_fn)) { + const delimiter = ","; + var inner: std.mem.SplitIterator(u8) = if (self.config_map.get(key)) |bytes| .{ + .buffer = bytes, + .delimiter = delimiter, + .index = 0, + } else .{ + .buffer = undefined, + .delimiter = delimiter, + .index = null, + }; return ConfigValueIterator(T, @TypeOf(parse_fn)){ - .inner = std.mem.split(u8, bytes, ","), + .inner = inner, .parse_fn = parse_fn, }; } @@ -958,93 +997,62 @@ pub const TestContext = struct { const max_file_size = 10 * 1024 * 1024; const src = try dir.readFileAllocOptions(ctx.arena, filename, max_file_size, null, 1, 0); - // The manifest is the last contiguous block of comments in the file - // We scan for the beginning by searching backward for the first non-empty line that does not start with "//" - var manifest_start: ?usize = null; - var manifest_end: usize = src.len; - if (src.len > 0) { - var cursor: usize = src.len - 1; - while (true) { - // Move to beginning of line - while (cursor > 0 and src[cursor - 1] != '\n') cursor -= 1; + // Parse the manifest + var manifest = try TestManifest.parse(ctx.arena, src); + const strategy = manifest.getConfigForKey("strategy", Strategy, Strategy.parse).next().?; + const backend = manifest.getConfigForKey("backend", Backend, Backend.parse).next().?; - if (std.mem.startsWith(u8, src[cursor..], "//")) { - manifest_start = cursor; // Contiguous comment line, include in manifest - } else { - if (manifest_start != null) break; // Encountered non-comment line, end of manifest + switch (manifest.@"type") { + .@"error" => { + const case = opt_case orelse case: { + const case = try ctx.cases.addOne(); + case.* = .{ + .name = "none", + .target = .{}, + .backend = backend, + .updates = std.ArrayList(TestContext.Update).init(ctx.cases.allocator), + .is_test = false, + .output_mode = .Obj, + .files = std.ArrayList(TestContext.File).init(ctx.cases.allocator), + }; + opt_case = case; + break :case case; + }; + const errors = try manifest.trailingAlloc(ctx.arena); - // We ignore all-whitespace lines following the comment block, but anything else - // means that there is no manifest present. - if (std.mem.trim(u8, src[cursor..manifest_end], " \r\n\t").len == 0) { - manifest_end = cursor; - } else break; // If it's not whitespace, there is no manifest + switch (strategy) { + .independent => { + case.addError(src, errors); + }, + .incremental => { + case.addErrorNamed("update", src, errors); + }, } - - // Move to previous line - if (cursor != 0) cursor -= 1 else break; - } - } - - if (manifest_start) |start| { - // Parse the manifest - var mani = try TestManifest.parse(ctx.arena, src[start..manifest_end]); - const strategy = mani.getConfigValues("strategy", Strategy, Strategy.parse).?.next().?; - const backend = mani.getConfigValues("backend", Backend, Backend.parse).?.next().?; - - switch (mani.@"type") { - .@"error" => { - const case = opt_case orelse case: { - const case = try ctx.cases.addOne(); - case.* = .{ - .name = "none", - .target = .{}, - .backend = backend, - .updates = std.ArrayList(TestContext.Update).init(ctx.cases.allocator), - .is_test = false, - .output_mode = .Obj, - .files = std.ArrayList(TestContext.File).init(ctx.cases.allocator), - }; - opt_case = case; - break :case case; + }, + .run => { + const case = opt_case orelse case: { + const case = try ctx.cases.addOne(); + case.* = .{ + .name = "none", + .target = .{}, + .backend = backend, + .updates = std.ArrayList(TestContext.Update).init(ctx.cases.allocator), + .is_test = false, + .output_mode = .Exe, + .files = std.ArrayList(TestContext.File).init(ctx.cases.allocator), }; - const errors = try mani.trailingAlloc(ctx.arena); + opt_case = case; + break :case case; + }; - switch (strategy) { - .independent => { - case.addError(src, errors); - }, - .incremental => { - case.addErrorNamed("update", src, errors); - }, - } - }, - .run => { - const case = opt_case orelse case: { - const case = try ctx.cases.addOne(); - case.* = .{ - .name = "none", - .target = .{}, - .backend = backend, - .updates = std.ArrayList(TestContext.Update).init(ctx.cases.allocator), - .is_test = false, - .output_mode = .Exe, - .files = std.ArrayList(TestContext.File).init(ctx.cases.allocator), - }; - opt_case = case; - break :case case; - }; - - var output = std.ArrayList(u8).init(ctx.arena); - var trailing_it = mani.trailing(); - while (trailing_it.next()) |line| { - try output.appendSlice(line); - } - case.addCompareOutput(src, output.toOwnedSlice()); - }, - .cli => @panic("TODO cli tests"), - } - } else { - return error.MissingManifest; + var output = std.ArrayList(u8).init(ctx.arena); + var trailing_it = manifest.trailing(); + while (trailing_it.next()) |line| { + try output.appendSlice(line); + } + case.addCompareOutput(src, output.toOwnedSlice()); + }, + .cli => @panic("TODO cli tests"), } } } From f41dd3617e3f630c3d5ec7745784076ccc0c3025 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Tue, 26 Apr 2022 18:58:16 +0200 Subject: [PATCH 03/26] test: pass Strategy per directory of tests --- src/test.zig | 19 ++++++++----------- test/incremental/add.0.zig | 1 - test/incremental/add.1.zig | 2 -- test/incremental/add.2.zig | 2 -- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/test.zig b/src/test.zig index 08875ac909..9840967bfc 100644 --- a/src/test.zig +++ b/src/test.zig @@ -80,7 +80,7 @@ test { var dir = try std.fs.cwd().openDir(dir_path, .{ .iterate = true }); defer dir.close(); - ctx.addTestCasesFromDir(dir); + ctx.addTestCasesFromDir(dir, .incremental); } try @import("test_cases").addCases(&ctx); @@ -834,10 +834,6 @@ pub const TestContext = struct { /// Execute all tests as incremental updates to a single compilation. Explicitly /// incremental tests ("foo.0.zig", "foo.1.zig", etc.) still execute in order incremental, - - fn parse(str: []const u8) ?Strategy { - return std.meta.stringToEnum(Strategy, str); - } }; /// Adds a compile-error test for each file in the provided directory, using the @@ -866,9 +862,9 @@ pub const TestContext = struct { }; } - pub fn addTestCasesFromDir(ctx: *TestContext, dir: std.fs.Dir) void { + pub fn addTestCasesFromDir(ctx: *TestContext, dir: std.fs.Dir, strategy: Strategy) void { var current_file: []const u8 = "none"; - addTestCasesFromDirInner(ctx, dir, ¤t_file) catch |err| { + addTestCasesFromDirInner(ctx, dir, strategy, ¤t_file) catch |err| { std.debug.panic("test harness failed to process file '{s}': {s}\n", .{ current_file, @errorName(err), }); @@ -938,6 +934,7 @@ pub const TestContext = struct { fn addTestCasesFromDirInner( ctx: *TestContext, dir: std.fs.Dir, + strategy: Strategy, /// This is kept up to date with the currently being processed file so /// that if any errors occur the caller knows it happened during this file. current_file: *[]const u8, @@ -988,8 +985,8 @@ pub const TestContext = struct { // in a new sequence ("*.0.zig") or an independent test file ("*.zig") if (new_parts.test_index != null and new_parts.test_index.? != 0) return error.InvalidIncrementalTestIndex; - // if (strategy == .independent) - // opt_case = null; // Generate a new independent test case for this update + if (strategy == .independent) + opt_case = null; // Generate a new independent test case for this update } } prev_filename = filename; @@ -999,13 +996,12 @@ pub const TestContext = struct { // Parse the manifest var manifest = try TestManifest.parse(ctx.arena, src); - const strategy = manifest.getConfigForKey("strategy", Strategy, Strategy.parse).next().?; - const backend = manifest.getConfigForKey("backend", Backend, Backend.parse).next().?; switch (manifest.@"type") { .@"error" => { const case = opt_case orelse case: { const case = try ctx.cases.addOne(); + const backend = manifest.getConfigForKey("backend", Backend, Backend.parse).next().?; case.* = .{ .name = "none", .target = .{}, @@ -1032,6 +1028,7 @@ pub const TestContext = struct { .run => { const case = opt_case orelse case: { const case = try ctx.cases.addOne(); + const backend = manifest.getConfigForKey("backend", Backend, Backend.parse).next().?; case.* = .{ .name = "none", .target = .{}, diff --git a/test/incremental/add.0.zig b/test/incremental/add.0.zig index f271bfed84..179e335044 100644 --- a/test/incremental/add.0.zig +++ b/test/incremental/add.0.zig @@ -8,5 +8,4 @@ fn add(a: u32, b: u32) void { // run // backend=stage2 -// strategy=incremental // diff --git a/test/incremental/add.1.zig b/test/incremental/add.1.zig index a8cc3fa836..d90dc6884d 100644 --- a/test/incremental/add.1.zig +++ b/test/incremental/add.1.zig @@ -9,6 +9,4 @@ fn add(a: u32, b: u32) u32 { const x = add(3, 4); // run -// backend=stage2 -// strategy=incremental // diff --git a/test/incremental/add.2.zig b/test/incremental/add.2.zig index 0f4c18e28f..6643d811fc 100644 --- a/test/incremental/add.2.zig +++ b/test/incremental/add.2.zig @@ -9,6 +9,4 @@ inline fn add(a: usize, b: usize, c: usize) usize { } // run -// backend=stage2 -// strategy=incremental // From bc370311cb76f570debf38f5d822a268f1dace83 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Tue, 26 Apr 2022 22:54:42 +0200 Subject: [PATCH 04/26] test: add comptime struct holding default config values --- src/test.zig | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/test.zig b/src/test.zig index 9840967bfc..d1ed3d5c28 100644 --- a/src/test.zig +++ b/src/test.zig @@ -165,6 +165,41 @@ const ErrorMsg = union(enum) { } }; +const TestManifestConfigDefaults = struct { + /// Asserts if the key doesn't exist - yep, it's an oversight alright. + fn get(@"type": TestManifest.Type, key: []const u8) []const u8 { + if (std.mem.eql(u8, key, "backend")) { + return "stage2"; + } else if (std.mem.eql(u8, key, "target")) { + comptime { + var defaults: []const u8 = ""; + // TODO should we only return "mainstream" targets by default here? + // Linux + inline for (&[_][]const u8{ "x86_64", "arm", "aarch64" }) |arch| { + inline for (&[_][]const u8{ "gnu", "musl" }) |abi| { + defaults = defaults ++ arch ++ "-linux-" ++ abi ++ ","; + } + } + // macOS + inline for (&[_][]const u8{ "x86_64", "aarch64" }) |arch| { + defaults = defaults ++ arch ++ "-macos" ++ ","; + } + // Wasm + defaults = defaults ++ "wasm32-wasi"; + return defaults[0 .. defaults.len - 2]; + } + } else if (std.mem.eql(u8, key, "output_mode")) { + return switch (@"type") { + .@"error" => "Obj", + .run => "Exe", + .cli => @panic("TODO test harness for CLI tests"), + }; + } else if (std.mem.eql(u8, key, "is_test")) { + return "0"; + } else unreachable; + } +}; + /// Manifest syntax example: /// (see https://github.com/ziglang/zig/issues/11288) /// From 46db5e2a44b38c92e97a438c4b6a67627cc12d16 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Tue, 26 Apr 2022 22:55:11 +0200 Subject: [PATCH 05/26] test: unroll into multiple cases, provide default parsers Provide default parsers for obvious config options such as `CrossTarget` or `Backend` (or any enum for that matter). Unroll iterator loops into multiple cases - we need to create a Cartesian product for all possibilities specified in the test manifest. --- src/test.zig | 169 ++++++++++++++++++++++--------------- test/incremental/add.0.zig | 1 - 2 files changed, 99 insertions(+), 71 deletions(-) diff --git a/src/test.zig b/src/test.zig index d1ed3d5c28..fb0c0fff35 100644 --- a/src/test.zig +++ b/src/test.zig @@ -237,10 +237,10 @@ const TestManifest = struct { } }; - fn ConfigValueIterator(comptime T: type, comptime ParseFn: type) type { + fn ConfigValueIterator(comptime T: type) type { return struct { inner: std.mem.SplitIterator(u8), - parse_fn: ParseFn, + parse_fn: ParseFn(T), fn next(self: *@This()) ?T { const next_raw = self.inner.next() orelse return null; @@ -320,26 +320,32 @@ const TestManifest = struct { return manifest; } + fn getConfigForKeyCustomParser( + self: TestManifest, + key: []const u8, + comptime T: type, + parse_fn: ParseFn(T), + ) ConfigValueIterator(T) { + const bytes = self.config_map.get(key) orelse TestManifestConfigDefaults.get(self.@"type", key); + return ConfigValueIterator(T){ + .inner = std.mem.split(u8, bytes, ","), + .parse_fn = parse_fn, + }; + } + fn getConfigForKey( self: TestManifest, key: []const u8, comptime T: type, - parse_fn: fn ([]const u8) ?T, - ) ConfigValueIterator(T, @TypeOf(parse_fn)) { - const delimiter = ","; - var inner: std.mem.SplitIterator(u8) = if (self.config_map.get(key)) |bytes| .{ - .buffer = bytes, - .delimiter = delimiter, - .index = 0, - } else .{ - .buffer = undefined, - .delimiter = delimiter, - .index = null, - }; - return ConfigValueIterator(T, @TypeOf(parse_fn)){ - .inner = inner, - .parse_fn = parse_fn, - }; + ) ConfigValueIterator(T) { + return self.getConfigForKeyCustomParser(key, T, getDefaultParser(T)); + } + + fn getConfigForKeyAssertSingle(self: TestManifest, key: []const u8, comptime T: type) T { + var it = self.getConfigForKey(key, T); + const res = it.next().?; + assert(it.next() == null); + return res; } fn trailing(self: TestManifest) TrailingIterator { @@ -356,6 +362,40 @@ const TestManifest = struct { } return out.toOwnedSlice(); } + + fn ParseFn(comptime T: type) type { + return fn ([]const u8) ?T; + } + + fn getDefaultParser(comptime T: type) ParseFn(T) { + switch (@typeInfo(T)) { + .Int => return struct { + fn parse(str: []const u8) ?T { + return std.fmt.parseInt(T, str, 0) catch null; + } + }.parse, + .Bool => return struct { + fn parse(str: []const u8) ?T { + const as_int = std.fmt.parseInt(u1, str, 0) catch return null; + return as_int > 0; + } + }.parse, + .Enum => return struct { + fn parse(str: []const u8) ?T { + return std.meta.stringToEnum(T, str); + } + }.parse, + .Struct => if (comptime std.mem.eql(u8, @typeName(T), "CrossTarget")) return struct { + fn parse(str: []const u8) ?T { + var opts = CrossTarget.ParseOptions{ + .arch_os_abi = str, + }; + return CrossTarget.parse(opts) catch null; + } + }.parse else @compileError("no default parser for " ++ @typeName(T)), + else => @compileError("no default parser for " ++ @typeName(T)), + } + } }; pub const TestContext = struct { @@ -401,10 +441,6 @@ pub const TestContext = struct { stage1, stage2, llvm, - - fn parse(str: []const u8) ?Backend { - return std.meta.stringToEnum(Backend, str); - } }; /// A `Case` consists of a list of `Update`. The same `Compilation` is used for each @@ -899,7 +935,7 @@ pub const TestContext = struct { pub fn addTestCasesFromDir(ctx: *TestContext, dir: std.fs.Dir, strategy: Strategy) void { var current_file: []const u8 = "none"; - addTestCasesFromDirInner(ctx, dir, strategy, ¤t_file) catch |err| { + ctx.addTestCasesFromDirInner(dir, strategy, ¤t_file) catch |err| { std.debug.panic("test harness failed to process file '{s}': {s}\n", .{ current_file, @errorName(err), }); @@ -974,11 +1010,10 @@ pub const TestContext = struct { /// that if any errors occur the caller knows it happened during this file. current_file: *[]const u8, ) !void { - var opt_case: ?*Case = null; + var cases = std.ArrayList(*Case).init(ctx.arena); var it = dir.iterate(); var filenames = std.ArrayList([]const u8).init(ctx.arena); - defer filenames.deinit(); while (try it.next()) |entry| { if (entry.kind != .File) continue; @@ -1021,7 +1056,7 @@ pub const TestContext = struct { if (new_parts.test_index != null and new_parts.test_index.? != 0) return error.InvalidIncrementalTestIndex; if (strategy == .independent) - opt_case = null; // Generate a new independent test case for this update + cases.clearRetainingCapacity(); // Generate a new independent test case for this update } } prev_filename = filename; @@ -1032,59 +1067,53 @@ pub const TestContext = struct { // Parse the manifest var manifest = try TestManifest.parse(ctx.arena, src); - switch (manifest.@"type") { - .@"error" => { - const case = opt_case orelse case: { + if (cases.items.len == 0) { + var backends = manifest.getConfigForKey("backend", Backend); + var targets = manifest.getConfigForKey("target", CrossTarget); + const is_test = manifest.getConfigForKeyAssertSingle("is_test", bool); + const output_mode = manifest.getConfigForKeyAssertSingle("output_mode", std.builtin.OutputMode); + + // Cross-product to get all possible test combinations + while (backends.next()) |backend| { + while (targets.next()) |target| { const case = try ctx.cases.addOne(); - const backend = manifest.getConfigForKey("backend", Backend, Backend.parse).next().?; case.* = .{ .name = "none", - .target = .{}, + .target = target, .backend = backend, .updates = std.ArrayList(TestContext.Update).init(ctx.cases.allocator), - .is_test = false, - .output_mode = .Obj, + .is_test = is_test, + .output_mode = output_mode, .files = std.ArrayList(TestContext.File).init(ctx.cases.allocator), }; - opt_case = case; - break :case case; - }; - const errors = try manifest.trailingAlloc(ctx.arena); - - switch (strategy) { - .independent => { - case.addError(src, errors); - }, - .incremental => { - case.addErrorNamed("update", src, errors); - }, + try cases.append(case); } - }, - .run => { - const case = opt_case orelse case: { - const case = try ctx.cases.addOne(); - const backend = manifest.getConfigForKey("backend", Backend, Backend.parse).next().?; - case.* = .{ - .name = "none", - .target = .{}, - .backend = backend, - .updates = std.ArrayList(TestContext.Update).init(ctx.cases.allocator), - .is_test = false, - .output_mode = .Exe, - .files = std.ArrayList(TestContext.File).init(ctx.cases.allocator), - }; - opt_case = case; - break :case case; - }; + } + } - var output = std.ArrayList(u8).init(ctx.arena); - var trailing_it = manifest.trailing(); - while (trailing_it.next()) |line| { - try output.appendSlice(line); - } - case.addCompareOutput(src, output.toOwnedSlice()); - }, - .cli => @panic("TODO cli tests"), + for (cases.items) |case| { + switch (manifest.@"type") { + .@"error" => { + const errors = try manifest.trailingAlloc(ctx.arena); + switch (strategy) { + .independent => { + case.addError(src, errors); + }, + .incremental => { + case.addErrorNamed("update", src, errors); + }, + } + }, + .run => { + var output = std.ArrayList(u8).init(ctx.arena); + var trailing_it = manifest.trailing(); + while (trailing_it.next()) |line| { + try output.appendSlice(line); + } + case.addCompareOutput(src, output.toOwnedSlice()); + }, + .cli => @panic("TODO cli tests"), + } } } } diff --git a/test/incremental/add.0.zig b/test/incremental/add.0.zig index 179e335044..e8c2196813 100644 --- a/test/incremental/add.0.zig +++ b/test/incremental/add.0.zig @@ -7,5 +7,4 @@ fn add(a: u32, b: u32) void { } // run -// backend=stage2 // From c1a98cd65d48693c9cfce5fbc5e5f5a1dbf4c1b7 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Wed, 27 Apr 2022 12:41:05 +0200 Subject: [PATCH 06/26] test: set case name from initial filename for a sequence Port more incremental tests. --- src/test.zig | 61 +++++++++-------- ...ing_numbers_at_runtime_and_comptime.0.zig} | 0 ...ing_numbers_at_runtime_and_comptime.1.zig} | 0 ...ing_numbers_at_runtime_and_comptime.2.zig} | 0 test/incremental/assert_function.0.zig | 15 +++++ test/incremental/assert_function.1.zig | 17 +++++ test/incremental/assert_function.10.zig | 27 ++++++++ test/incremental/assert_function.11.zig | 66 +++++++++++++++++++ test/incremental/assert_function.12.zig | 47 +++++++++++++ test/incremental/assert_function.13.zig | 19 ++++++ test/incremental/assert_function.14.zig | 17 +++++ test/incremental/assert_function.15.zig | 10 +++ test/incremental/assert_function.16.zig | 11 ++++ test/incremental/assert_function.17.zig | 11 ++++ test/incremental/assert_function.18.zig | 35 ++++++++++ test/incremental/assert_function.2.zig | 21 ++++++ test/incremental/assert_function.3.zig | 22 +++++++ test/incremental/assert_function.4.zig | 15 +++++ test/incremental/assert_function.5.zig | 19 ++++++ test/incremental/assert_function.6.zig | 9 +++ test/incremental/assert_function.7.zig | 40 +++++++++++ test/incremental/assert_function.8.zig | 36 ++++++++++ test/incremental/assert_function.9.zig | 22 +++++++ ...ying_numbers_at_runtime_and_comptime.0.zig | 11 ++++ ...ying_numbers_at_runtime_and_comptime.1.zig | 12 ++++ ...ying_numbers_at_runtime_and_comptime.2.zig | 12 ++++ .../subtracting_numbers_at_runtime.zig | 10 +++ test/incremental/unused_vars.zig | 7 ++ 28 files changed, 546 insertions(+), 26 deletions(-) rename test/incremental/{add.0.zig => adding_numbers_at_runtime_and_comptime.0.zig} (100%) rename test/incremental/{add.1.zig => adding_numbers_at_runtime_and_comptime.1.zig} (100%) rename test/incremental/{add.2.zig => adding_numbers_at_runtime_and_comptime.2.zig} (100%) create mode 100644 test/incremental/assert_function.0.zig create mode 100644 test/incremental/assert_function.1.zig create mode 100644 test/incremental/assert_function.10.zig create mode 100644 test/incremental/assert_function.11.zig create mode 100644 test/incremental/assert_function.12.zig create mode 100644 test/incremental/assert_function.13.zig create mode 100644 test/incremental/assert_function.14.zig create mode 100644 test/incremental/assert_function.15.zig create mode 100644 test/incremental/assert_function.16.zig create mode 100644 test/incremental/assert_function.17.zig create mode 100644 test/incremental/assert_function.18.zig create mode 100644 test/incremental/assert_function.2.zig create mode 100644 test/incremental/assert_function.3.zig create mode 100644 test/incremental/assert_function.4.zig create mode 100644 test/incremental/assert_function.5.zig create mode 100644 test/incremental/assert_function.6.zig create mode 100644 test/incremental/assert_function.7.zig create mode 100644 test/incremental/assert_function.8.zig create mode 100644 test/incremental/assert_function.9.zig create mode 100644 test/incremental/multiplying_numbers_at_runtime_and_comptime.0.zig create mode 100644 test/incremental/multiplying_numbers_at_runtime_and_comptime.1.zig create mode 100644 test/incremental/multiplying_numbers_at_runtime_and_comptime.2.zig create mode 100644 test/incremental/subtracting_numbers_at_runtime.zig create mode 100644 test/incremental/unused_vars.zig diff --git a/src/test.zig b/src/test.zig index fb0c0fff35..a701976381 100644 --- a/src/test.zig +++ b/src/test.zig @@ -233,7 +233,7 @@ const TestManifest = struct { fn next(self: *TrailingIterator) ?[]const u8 { const next_inner = self.inner.next() orelse return null; - return std.mem.trim(u8, next_inner, " \t"); + return std.mem.trim(u8, next_inner[2..], " \t"); } }; @@ -1033,31 +1033,25 @@ pub const TestContext = struct { for (filenames.items) |filename| { current_file.* = filename; - { // First, check if this file is part of an incremental update sequence + // First, check if this file is part of an incremental update sequence + // Split filename into ".." + const prev_parts = getTestFileNameParts(prev_filename); + const new_parts = getTestFileNameParts(filename); - // Split filename into ".." - const prev_parts = getTestFileNameParts(prev_filename); - const new_parts = getTestFileNameParts(filename); - - // If base_name and file_ext match, these files are in the same test sequence - // and the new one should be the incremented version of the previous test - if (std.mem.eql(u8, prev_parts.base_name, new_parts.base_name) and - std.mem.eql(u8, prev_parts.file_ext, new_parts.file_ext)) - { - - // This is "foo.X.zig" followed by "foo.Y.zig". Make sure that X = Y + 1 - if (prev_parts.test_index == null) return error.InvalidIncrementalTestIndex; - if (new_parts.test_index == null) return error.InvalidIncrementalTestIndex; - if (new_parts.test_index.? != prev_parts.test_index.? + 1) return error.InvalidIncrementalTestIndex; - } else { - - // This is not the same test sequence, so the new file must be the first file - // in a new sequence ("*.0.zig") or an independent test file ("*.zig") - if (new_parts.test_index != null and new_parts.test_index.? != 0) return error.InvalidIncrementalTestIndex; - - if (strategy == .independent) - cases.clearRetainingCapacity(); // Generate a new independent test case for this update - } + // If base_name and file_ext match, these files are in the same test sequence + // and the new one should be the incremented version of the previous test + if (std.mem.eql(u8, prev_parts.base_name, new_parts.base_name) and + std.mem.eql(u8, prev_parts.file_ext, new_parts.file_ext)) + { + // This is "foo.X.zig" followed by "foo.Y.zig". Make sure that X = Y + 1 + if (prev_parts.test_index == null) return error.InvalidIncrementalTestIndex; + if (new_parts.test_index == null) return error.InvalidIncrementalTestIndex; + if (new_parts.test_index.? != prev_parts.test_index.? + 1) return error.InvalidIncrementalTestIndex; + } else { + // This is not the same test sequence, so the new file must be the first file + // in a new sequence ("*.0.zig") or an independent test file ("*.zig") + if (new_parts.test_index != null and new_parts.test_index.? != 0) return error.InvalidIncrementalTestIndex; + cases.clearRetainingCapacity(); } prev_filename = filename; @@ -1073,12 +1067,23 @@ pub const TestContext = struct { const is_test = manifest.getConfigForKeyAssertSingle("is_test", bool); const output_mode = manifest.getConfigForKeyAssertSingle("output_mode", std.builtin.OutputMode); + const name_prefix = blk: { + const ext_index = std.mem.lastIndexOfScalar(u8, current_file.*, '.') orelse + return error.InvalidFilename; + const index = std.mem.lastIndexOfScalar(u8, current_file.*[0..ext_index], '.') orelse ext_index; + break :blk current_file.*[0..index]; + }; + // Cross-product to get all possible test combinations while (backends.next()) |backend| { while (targets.next()) |target| { + const name = try std.fmt.allocPrint(ctx.arena, "{s} ({s})", .{ + name_prefix, + try target.zigTriple(ctx.arena), + }); const case = try ctx.cases.addOne(); case.* = .{ - .name = "none", + .name = name, .target = target, .backend = backend, .updates = std.ArrayList(TestContext.Update).init(ctx.cases.allocator), @@ -1109,6 +1114,10 @@ pub const TestContext = struct { var trailing_it = manifest.trailing(); while (trailing_it.next()) |line| { try output.appendSlice(line); + try output.append('\n'); + } + if (output.items.len > 0) { + try output.resize(output.items.len - 1); } case.addCompareOutput(src, output.toOwnedSlice()); }, diff --git a/test/incremental/add.0.zig b/test/incremental/adding_numbers_at_runtime_and_comptime.0.zig similarity index 100% rename from test/incremental/add.0.zig rename to test/incremental/adding_numbers_at_runtime_and_comptime.0.zig diff --git a/test/incremental/add.1.zig b/test/incremental/adding_numbers_at_runtime_and_comptime.1.zig similarity index 100% rename from test/incremental/add.1.zig rename to test/incremental/adding_numbers_at_runtime_and_comptime.1.zig diff --git a/test/incremental/add.2.zig b/test/incremental/adding_numbers_at_runtime_and_comptime.2.zig similarity index 100% rename from test/incremental/add.2.zig rename to test/incremental/adding_numbers_at_runtime_and_comptime.2.zig diff --git a/test/incremental/assert_function.0.zig b/test/incremental/assert_function.0.zig new file mode 100644 index 0000000000..889c9b1572 --- /dev/null +++ b/test/incremental/assert_function.0.zig @@ -0,0 +1,15 @@ +pub fn main() void { + add(3, 4); +} + +fn add(a: u32, b: u32) void { + assert(a + b == 7); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// target=x86_64-linux,x86_64-macos +// diff --git a/test/incremental/assert_function.1.zig b/test/incremental/assert_function.1.zig new file mode 100644 index 0000000000..ac2df25d85 --- /dev/null +++ b/test/incremental/assert_function.1.zig @@ -0,0 +1,17 @@ +pub fn main() void { + add(3, 4); +} + +fn add(a: u32, b: u32) void { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + assert(e == 14); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/assert_function.10.zig b/test/incremental/assert_function.10.zig new file mode 100644 index 0000000000..b3f1610cd6 --- /dev/null +++ b/test/incremental/assert_function.10.zig @@ -0,0 +1,27 @@ +pub fn main() void { + assert(add(3, 4) == 116); +} + +fn add(a: u32, b: u32) u32 { + const x: u32 = blk: { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + const j = i + d; // 110 + break :blk j; + }; + const y = x + a; // 113 + const z = y + a; // 116 + return z; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/assert_function.11.zig b/test/incremental/assert_function.11.zig new file mode 100644 index 0000000000..d64130a677 --- /dev/null +++ b/test/incremental/assert_function.11.zig @@ -0,0 +1,66 @@ +pub fn main() void { + assert(add(3, 4) == 1221); + assert(mul(3, 4) == 21609); +} + +fn add(a: u32, b: u32) u32 { + const x: u32 = blk: { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + const j = i + d; // 110 + const k = i + j; // 210 + const l = j + k; // 320 + const m = l + c; // 327 + const n = m + d; // 337 + const o = n + e; // 351 + const p = o + f; // 375 + const q = p + g; // 413 + const r = q + h; // 475 + const s = r + i; // 575 + const t = s + j; // 685 + const u = t + k; // 895 + const v = u + l; // 1215 + break :blk v; + }; + const y = x + a; // 1218 + const z = y + a; // 1221 + return z; +} + +fn mul(a: u32, b: u32) u32 { + const x: u32 = blk: { + const c = a * a * a * a; // 81 + const d = a * a * a * b; // 108 + const e = a * a * b * a; // 108 + const f = a * a * b * b; // 144 + const g = a * b * a * a; // 108 + const h = a * b * a * b; // 144 + const i = a * b * b * a; // 144 + const j = a * b * b * b; // 192 + const k = b * a * a * a; // 108 + const l = b * a * a * b; // 144 + const m = b * a * b * a; // 144 + const n = b * a * b * b; // 192 + const o = b * b * a * a; // 144 + const p = b * b * a * b; // 192 + const q = b * b * b * a; // 192 + const r = b * b * b * b; // 256 + const s = c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r; // 2401 + break :blk s; + }; + const y = x * a; // 7203 + const z = y * a; // 21609 + return z; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/assert_function.12.zig b/test/incremental/assert_function.12.zig new file mode 100644 index 0000000000..4f64c1e062 --- /dev/null +++ b/test/incremental/assert_function.12.zig @@ -0,0 +1,47 @@ +pub fn main() void { + assert(add(3, 4) == 791); + assert(add(4, 3) == 79); +} + +fn add(a: u32, b: u32) u32 { + const x: u32 = if (a < b) blk: { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + const j = i + d; // 110 + const k = i + j; // 210 + const l = k + c; // 217 + const m = l + d; // 227 + const n = m + e; // 241 + const o = n + f; // 265 + const p = o + g; // 303 + const q = p + h; // 365 + const r = q + i; // 465 + const s = r + j; // 575 + const t = s + k; // 785 + break :blk t; + } else blk: { + const t = b + b + a; // 10 + const c = a + t; // 14 + const d = c + t; // 24 + const e = d + t; // 34 + const f = e + t; // 44 + const g = f + t; // 54 + const h = c + g; // 68 + break :blk h + b; // 71 + }; + const y = x + a; // 788, 75 + const z = y + a; // 791, 79 + return z; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/assert_function.13.zig b/test/incremental/assert_function.13.zig new file mode 100644 index 0000000000..240abf0108 --- /dev/null +++ b/test/incremental/assert_function.13.zig @@ -0,0 +1,19 @@ +pub fn main() void { + const ignore = + \\ cool thx + \\ + ; + _ = ignore; + add('ぁ', '\x03'); +} + +fn add(a: u32, b: u32) void { + assert(a + b == 12356); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/assert_function.14.zig b/test/incremental/assert_function.14.zig new file mode 100644 index 0000000000..d25100dcce --- /dev/null +++ b/test/incremental/assert_function.14.zig @@ -0,0 +1,17 @@ +pub fn main() void { + add(aa, bb); +} + +const aa = 'ぁ'; +const bb = '\x03'; + +fn add(a: u32, b: u32) void { + assert(a + b == 12356); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/assert_function.15.zig b/test/incremental/assert_function.15.zig new file mode 100644 index 0000000000..33ae1ed5af --- /dev/null +++ b/test/incremental/assert_function.15.zig @@ -0,0 +1,10 @@ +pub fn main() void { + assert("hello"[0] == 'h'); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/assert_function.16.zig b/test/incremental/assert_function.16.zig new file mode 100644 index 0000000000..eef1136423 --- /dev/null +++ b/test/incremental/assert_function.16.zig @@ -0,0 +1,11 @@ +const hello = "hello".*; +pub fn main() void { + assert(hello[1] == 'e'); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/assert_function.17.zig b/test/incremental/assert_function.17.zig new file mode 100644 index 0000000000..ac9dce3079 --- /dev/null +++ b/test/incremental/assert_function.17.zig @@ -0,0 +1,11 @@ +pub fn main() void { + var i: u64 = 0xFFEEDDCCBBAA9988; + assert(i == 0xFFEEDDCCBBAA9988); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/assert_function.18.zig b/test/incremental/assert_function.18.zig new file mode 100644 index 0000000000..31cf1207f3 --- /dev/null +++ b/test/incremental/assert_function.18.zig @@ -0,0 +1,35 @@ +const builtin = @import("builtin"); + +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + for ("hello") |_| print(); +} + +fn print() void { + switch (builtin.os.tag) { + .linux => { + asm volatile ("syscall" + : + : [number] "{rax}" (1), + [arg1] "{rdi}" (1), + [arg2] "{rsi}" (@ptrToInt("hello\n")), + [arg3] "{rdx}" (6), + : "rcx", "r11", "memory" + ); + }, + .macos => { + _ = write(1, @ptrToInt("hello\n"), 6); + }, + else => unreachable, + } +} + +// run +// +// hello +// hello +// hello +// hello +// hello +// diff --git a/test/incremental/assert_function.2.zig b/test/incremental/assert_function.2.zig new file mode 100644 index 0000000000..8c1c510486 --- /dev/null +++ b/test/incremental/assert_function.2.zig @@ -0,0 +1,21 @@ +pub fn main() void { + add(3, 4); +} + +fn add(a: u32, b: u32) void { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + assert(i == 100); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/assert_function.3.zig b/test/incremental/assert_function.3.zig new file mode 100644 index 0000000000..a6829f8e02 --- /dev/null +++ b/test/incremental/assert_function.3.zig @@ -0,0 +1,22 @@ +pub fn main() void { + add(3, 4); +} + +fn add(a: u32, b: u32) void { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + const j = i + d; // 110 + assert(j == 110); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/assert_function.4.zig b/test/incremental/assert_function.4.zig new file mode 100644 index 0000000000..69df4354c3 --- /dev/null +++ b/test/incremental/assert_function.4.zig @@ -0,0 +1,15 @@ +pub fn main() void { + assert(add(3, 4) == 7); + assert(add(20, 10) == 30); +} + +fn add(a: u32, b: u32) u32 { + return a + b; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/assert_function.5.zig b/test/incremental/assert_function.5.zig new file mode 100644 index 0000000000..89f3f7df4f --- /dev/null +++ b/test/incremental/assert_function.5.zig @@ -0,0 +1,19 @@ +pub fn main() void { + assert(add(3, 4) == 7); + assert(add(20, 10) == 30); +} + +fn add(a: u32, b: u32) u32 { + var x: u32 = undefined; + x = 0; + x += a; + x += b; + return x; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/assert_function.6.zig b/test/incremental/assert_function.6.zig new file mode 100644 index 0000000000..1b1b75e68e --- /dev/null +++ b/test/incremental/assert_function.6.zig @@ -0,0 +1,9 @@ +pub fn main() void { + const a: u32 = 2; + const b: ?u32 = a; + const c = b.?; + if (c != 2) unreachable; +} + +// run +// diff --git a/test/incremental/assert_function.7.zig b/test/incremental/assert_function.7.zig new file mode 100644 index 0000000000..f2f3ffcc3d --- /dev/null +++ b/test/incremental/assert_function.7.zig @@ -0,0 +1,40 @@ +const builtin = @import("builtin"); + +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + var i: u32 = 0; + while (i < 4) : (i += 1) print(); + assert(i == 4); +} + +fn print() void { + switch (builtin.os.tag) { + .linux => { + asm volatile ("syscall" + : + : [number] "{rax}" (1), + [arg1] "{rdi}" (1), + [arg2] "{rsi}" (@ptrToInt("hello\n")), + [arg3] "{rdx}" (6), + : "rcx", "r11", "memory" + ); + }, + .macos => { + _ = write(1, @ptrToInt("hello\n"), 6); + }, + else => unreachable, + } +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// +// hello +// hello +// hello +// hello +// diff --git a/test/incremental/assert_function.8.zig b/test/incremental/assert_function.8.zig new file mode 100644 index 0000000000..c8c30cfac6 --- /dev/null +++ b/test/incremental/assert_function.8.zig @@ -0,0 +1,36 @@ +const builtin = @import("builtin"); + +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + var i: u32 = 0; + inline while (i < 4) : (i += 1) print(); + assert(i == 4); +} + +fn print() void { + switch (builtin.os.tag) { + .linux => { + asm volatile ("syscall" + : + : [number] "{rax}" (1), + [arg1] "{rdi}" (1), + [arg2] "{rsi}" (@ptrToInt("hello\n")), + [arg3] "{rdx}" (6), + : "rcx", "r11", "memory" + ); + }, + .macos => { + _ = write(1, @ptrToInt("hello\n"), 6); + }, + else => unreachable, + } +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// error +// +// :3:21: error: unable to resolve comptime value diff --git a/test/incremental/assert_function.9.zig b/test/incremental/assert_function.9.zig new file mode 100644 index 0000000000..c754bb7711 --- /dev/null +++ b/test/incremental/assert_function.9.zig @@ -0,0 +1,22 @@ +pub fn main() void { + assert(add(3, 4) == 20); +} + +fn add(a: u32, b: u32) u32 { + const x: u32 = blk: { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + break :blk e; + }; + const y = x + a; // 17 + const z = y + a; // 20 + return z; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/multiplying_numbers_at_runtime_and_comptime.0.zig b/test/incremental/multiplying_numbers_at_runtime_and_comptime.0.zig new file mode 100644 index 0000000000..f113928982 --- /dev/null +++ b/test/incremental/multiplying_numbers_at_runtime_and_comptime.0.zig @@ -0,0 +1,11 @@ +pub fn main() void { + mul(3, 4); +} + +fn mul(a: u32, b: u32) void { + if (a * b != 12) unreachable; +} + +// run +// target=x86_64-linux,x86_64-macos +// diff --git a/test/incremental/multiplying_numbers_at_runtime_and_comptime.1.zig b/test/incremental/multiplying_numbers_at_runtime_and_comptime.1.zig new file mode 100644 index 0000000000..1dff884900 --- /dev/null +++ b/test/incremental/multiplying_numbers_at_runtime_and_comptime.1.zig @@ -0,0 +1,12 @@ +pub fn main() void { + if (x - 12 != 0) unreachable; +} + +fn mul(a: u32, b: u32) u32 { + return a * b; +} + +const x = mul(3, 4); + +// run +// diff --git a/test/incremental/multiplying_numbers_at_runtime_and_comptime.2.zig b/test/incremental/multiplying_numbers_at_runtime_and_comptime.2.zig new file mode 100644 index 0000000000..31093729ba --- /dev/null +++ b/test/incremental/multiplying_numbers_at_runtime_and_comptime.2.zig @@ -0,0 +1,12 @@ +pub fn main() void { + var x: usize = 5; + const y = mul(2, 3, x); + if (y - 30 != 0) unreachable; +} + +inline fn mul(a: usize, b: usize, c: usize) usize { + return a * b * c; +} + +// run +// diff --git a/test/incremental/subtracting_numbers_at_runtime.zig b/test/incremental/subtracting_numbers_at_runtime.zig new file mode 100644 index 0000000000..5ea81a34b8 --- /dev/null +++ b/test/incremental/subtracting_numbers_at_runtime.zig @@ -0,0 +1,10 @@ +pub fn main() void { + sub(7, 4); +} + +fn sub(a: u32, b: u32) void { + if (a - b != 3) unreachable; +} + +// run +// diff --git a/test/incremental/unused_vars.zig b/test/incremental/unused_vars.zig new file mode 100644 index 0000000000..85e168d19a --- /dev/null +++ b/test/incremental/unused_vars.zig @@ -0,0 +1,7 @@ +pub fn main() void { + const x = 1; +} + +// error +// +// :2:11: error: unused local constant From 81e90c7acbc90b06a9810b5bfe5812d06a537898 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Wed, 27 Apr 2022 13:21:20 +0200 Subject: [PATCH 07/26] test: fix pointer invalidation bug in the harness --- src/test.zig | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/test.zig b/src/test.zig index a701976381..a1edae01da 100644 --- a/src/test.zig +++ b/src/test.zig @@ -1010,7 +1010,7 @@ pub const TestContext = struct { /// that if any errors occur the caller knows it happened during this file. current_file: *[]const u8, ) !void { - var cases = std.ArrayList(*Case).init(ctx.arena); + var cases = std.ArrayList(usize).init(ctx.arena); var it = dir.iterate(); var filenames = std.ArrayList([]const u8).init(ctx.arena); @@ -1081,8 +1081,8 @@ pub const TestContext = struct { name_prefix, try target.zigTriple(ctx.arena), }); - const case = try ctx.cases.addOne(); - case.* = .{ + const next = ctx.cases.items.len; + try ctx.cases.append(.{ .name = name, .target = target, .backend = backend, @@ -1090,13 +1090,14 @@ pub const TestContext = struct { .is_test = is_test, .output_mode = output_mode, .files = std.ArrayList(TestContext.File).init(ctx.cases.allocator), - }; - try cases.append(case); + }); + try cases.append(next); } } } - for (cases.items) |case| { + for (cases.items) |case_index| { + const case = &ctx.cases.items[case_index]; switch (manifest.@"type") { .@"error" => { const errors = try manifest.trailingAlloc(ctx.arena); From 0998185f7762e029e037cbd77243965a78b2299e Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Wed, 27 Apr 2022 13:21:32 +0200 Subject: [PATCH 08/26] test: adjust error location for assert_function test --- test/incremental/assert_function.8.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/incremental/assert_function.8.zig b/test/incremental/assert_function.8.zig index c8c30cfac6..f845de9aa0 100644 --- a/test/incremental/assert_function.8.zig +++ b/test/incremental/assert_function.8.zig @@ -33,4 +33,4 @@ pub fn assert(ok: bool) void { // error // -// :3:21: error: unable to resolve comptime value +// :7:21: error: unable to resolve comptime value From 133708d9396defc46630adc6acd24a493277b7d5 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Wed, 27 Apr 2022 13:25:16 +0200 Subject: [PATCH 09/26] test: leave a todo note to explicitly specify ABI for targets in the future --- src/test.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test.zig b/src/test.zig index a1edae01da..e138afecb9 100644 --- a/src/test.zig +++ b/src/test.zig @@ -174,11 +174,11 @@ const TestManifestConfigDefaults = struct { comptime { var defaults: []const u8 = ""; // TODO should we only return "mainstream" targets by default here? + // TODO we should also specify ABIs explicitly as the backends are + // getting more and more complete // Linux inline for (&[_][]const u8{ "x86_64", "arm", "aarch64" }) |arch| { - inline for (&[_][]const u8{ "gnu", "musl" }) |abi| { - defaults = defaults ++ arch ++ "-linux-" ++ abi ++ ","; - } + defaults = defaults ++ arch ++ "-linux-" ++ ","; } // macOS inline for (&[_][]const u8{ "x86_64", "aarch64" }) |arch| { From 97b781955eca7c3fc6ee2713f8b5e355645fff58 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Wed, 27 Apr 2022 15:37:54 +0200 Subject: [PATCH 10/26] test: fix incorrect default target spec; port all incremental tests --- src/test.zig | 2 +- ..._slice_element_by_index_slice_elem_val.zig | 17 +++++++++ test/incremental/ambiguous_reference.zig | 13 +++++++ .../bad_inferred_variable_type.zig | 9 +++++ test/incremental/break_continue.0.zig | 9 +++++ test/incremental/break_continue.1.zig | 8 +++++ test/incremental/break_continue.2.zig | 10 ++++++ test/incremental/break_continue.3.zig | 10 ++++++ test/incremental/catch_at_comptime.0.zig | 11 ++++++ test/incremental/catch_at_comptime.1.zig | 11 ++++++ test/incremental/catch_at_comptime.2.zig | 11 ++++++ test/incremental/catch_at_comptime.3.zig | 10 ++++++ test/incremental/catch_at_comptime.4.zig | 10 ++++++ test/incremental/compile_error.zig | 7 ++++ ...ompile_error_in_inline_fn_call_fixed.0.zig | 16 +++++++++ ...ompile_error_in_inline_fn_call_fixed.1.zig | 13 +++++++ test/incremental/compile_log.0.zig | 17 +++++++++ test/incremental/compile_log.1.zig | 16 +++++++++ test/incremental/comptime_var.0.zig | 12 +++++++ test/incremental/comptime_var.1.zig | 13 +++++++ test/incremental/comptime_var.2.zig | 34 ++++++++++++++++++ test/incremental/comptime_var.3.zig | 10 ++++++ test/incremental/comptime_var.4.zig | 9 +++++ test/incremental/comptime_var.5.zig | 15 ++++++++ test/incremental/comptime_var.6.zig | 32 +++++++++++++++++ test/incremental/double_ampersand.0.zig | 6 ++++ test/incremental/double_ampersand.1.zig | 11 ++++++ test/incremental/double_ampersand.2.zig | 7 ++++ .../extern_variable_has_no_type.0.zig | 9 +++++ .../extern_variable_has_no_type.1.zig | 8 +++++ test/incremental/function_redeclaration.zig | 14 ++++++++ .../global_variable_redeclaration.zig | 8 +++++ ...ello_world_with_updates_x86_64_linux.0.zig | 5 +++ ...ello_world_with_updates_x86_64_linux.1.zig | 5 +++ ...ello_world_with_updates_x86_64_linux.2.zig | 32 +++++++++++++++++ ...ello_world_with_updates_x86_64_linux.3.zig | 20 +++++++++++ ...ello_world_with_updates_x86_64_linux.4.zig | 20 +++++++++++ ...ello_world_with_updates_x86_64_linux.5.zig | 22 ++++++++++++ ...ello_world_with_updates_x86_64_macos.0.zig | 5 +++ ...ello_world_with_updates_x86_64_macos.1.zig | 5 +++ ...ello_world_with_updates_x86_64_macos.2.zig | 19 ++++++++++ ...ello_world_with_updates_x86_64_macos.3.zig | 16 +++++++++ ...ello_world_with_updates_x86_64_macos.4.zig | 22 ++++++++++++ ...ello_world_with_updates_x86_64_macos.5.zig | 16 +++++++++ ...ello_world_with_updates_x86_64_macos.6.zig | 18 ++++++++++ .../inline_assembly_x86_64_linux.0.zig | 16 +++++++++ .../inline_assembly_x86_64_linux.1.zig | 15 ++++++++ .../inline_assembly_x86_64_linux.2.zig | 12 +++++++ .../inline_assembly_x86_64_linux.3.zig | 12 +++++++ .../inner_func_accessing_outer_var.zig | 15 ++++++++ test/incremental/int_to_ptr.0.zig | 8 +++++ test/incremental/int_to_ptr.1.zig | 7 ++++ ...ee_preserved_regs_working_x86_64_linux.zig | 31 ++++++++++++++++ ...7_miscompilation_with_bool_return_type.zig | 18 ++++++++++ .../load_store_via_pointer_deref.0.zig | 16 +++++++++ .../load_store_via_pointer_deref.1.zig | 16 +++++++++ .../load_store_via_pointer_deref.2.zig | 16 +++++++++ .../lower_unnamed_consts_structs.0.zig | 25 +++++++++++++ .../lower_unnamed_consts_structs.1.zig | 35 +++++++++++++++++++ .../lower_unnamed_consts_structs.2.zig | 25 +++++++++++++ test/incremental/merge_error_sets.0.zig | 18 ++++++++++ test/incremental/merge_error_sets.1.zig | 9 +++++ ...ion_and_it_gets_updated_x86_64_linux.0.zig | 13 +++++++ ...ion_and_it_gets_updated_x86_64_linux.1.zig | 12 +++++++ test/incremental/optional_payload.0.zig | 19 ++++++++++ test/incremental/optional_payload.1.zig | 17 +++++++++ test/incremental/optional_payload.2.zig | 18 ++++++++++ test/incremental/optional_payload.3.zig | 18 ++++++++++ test/incremental/orelse_at_comptime.0.zig | 11 ++++++ test/incremental/orelse_at_comptime.1.zig | 11 ++++++ test/incremental/passing_u0_to_function.zig | 9 +++++ .../recursive_inline_function.0.zig | 12 +++++++ .../recursive_inline_function.1.zig | 16 +++++++++ test/incremental/redundant_comptime.0.zig | 7 ++++ test/incremental/redundant_comptime.1.zig | 9 +++++ test/incremental/returns_in_try.zig | 16 +++++++++ test/incremental/runtime_bitwise_and.zig | 16 +++++++++ test/incremental/runtime_bitwise_or.zig | 16 +++++++++ ..._vars_of_different_abi_size_to_stack.0.zig | 16 +++++++++ ..._vars_of_different_abi_size_to_stack.1.zig | 16 +++++++++ ..._vars_of_different_abi_size_to_stack.2.zig | 16 +++++++++ ...g_an_address_space_on_a_local_variable.zig | 8 +++++ .../try_in_comptime_in_struct_in_test.zig | 13 +++++++ test/incremental/type_of.0.zig | 13 +++++++ test/incremental/type_of.1.zig | 11 ++++++ test/incremental/type_of.2.zig | 9 +++++ test/incremental/unused_labels.0.zig | 8 +++++ test/incremental/unused_labels.1.zig | 7 ++++ test/incremental/unused_labels.2.zig | 7 ++++ test/incremental/unused_labels.3.zig | 8 +++++ .../unwrap_error_union_simple_errors.0.zig | 10 ++++++ .../unwrap_error_union_simple_errors.1.zig | 11 ++++++ test/incremental/variable_shadowing.0.zig | 9 +++++ test/incremental/variable_shadowing.1.zig | 9 +++++ test/incremental/variable_shadowing.2.zig | 13 +++++++ test/incremental/variable_shadowing.3.zig | 10 ++++++ test/incremental/variable_shadowing.4.zig | 10 ++++++ test/incremental/variable_shadowing.5.zig | 10 ++++++ test/incremental/variable_shadowing.6.zig | 13 +++++++ test/incremental/variable_shadowing.7.zig | 9 +++++ test/incremental/variable_shadowing.8.zig | 9 +++++ test/incremental/variable_shadowing.9.zig | 9 +++++ 102 files changed, 1360 insertions(+), 1 deletion(-) create mode 100644 test/incremental/access_slice_element_by_index_slice_elem_val.zig create mode 100644 test/incremental/ambiguous_reference.zig create mode 100644 test/incremental/bad_inferred_variable_type.zig create mode 100644 test/incremental/break_continue.0.zig create mode 100644 test/incremental/break_continue.1.zig create mode 100644 test/incremental/break_continue.2.zig create mode 100644 test/incremental/break_continue.3.zig create mode 100644 test/incremental/catch_at_comptime.0.zig create mode 100644 test/incremental/catch_at_comptime.1.zig create mode 100644 test/incremental/catch_at_comptime.2.zig create mode 100644 test/incremental/catch_at_comptime.3.zig create mode 100644 test/incremental/catch_at_comptime.4.zig create mode 100644 test/incremental/compile_error.zig create mode 100644 test/incremental/compile_error_in_inline_fn_call_fixed.0.zig create mode 100644 test/incremental/compile_error_in_inline_fn_call_fixed.1.zig create mode 100644 test/incremental/compile_log.0.zig create mode 100644 test/incremental/compile_log.1.zig create mode 100644 test/incremental/comptime_var.0.zig create mode 100644 test/incremental/comptime_var.1.zig create mode 100644 test/incremental/comptime_var.2.zig create mode 100644 test/incremental/comptime_var.3.zig create mode 100644 test/incremental/comptime_var.4.zig create mode 100644 test/incremental/comptime_var.5.zig create mode 100644 test/incremental/comptime_var.6.zig create mode 100644 test/incremental/double_ampersand.0.zig create mode 100644 test/incremental/double_ampersand.1.zig create mode 100644 test/incremental/double_ampersand.2.zig create mode 100644 test/incremental/extern_variable_has_no_type.0.zig create mode 100644 test/incremental/extern_variable_has_no_type.1.zig create mode 100644 test/incremental/function_redeclaration.zig create mode 100644 test/incremental/global_variable_redeclaration.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_linux.0.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_linux.1.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_linux.2.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_linux.3.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_linux.4.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_linux.5.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_macos.0.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_macos.1.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_macos.2.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_macos.3.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_macos.4.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_macos.5.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_macos.6.zig create mode 100644 test/incremental/inline_assembly_x86_64_linux.0.zig create mode 100644 test/incremental/inline_assembly_x86_64_linux.1.zig create mode 100644 test/incremental/inline_assembly_x86_64_linux.2.zig create mode 100644 test/incremental/inline_assembly_x86_64_linux.3.zig create mode 100644 test/incremental/inner_func_accessing_outer_var.zig create mode 100644 test/incremental/int_to_ptr.0.zig create mode 100644 test/incremental/int_to_ptr.1.zig create mode 100644 test/incremental/issue_10138_callee_preserved_regs_working_x86_64_linux.zig create mode 100644 test/incremental/issue_7187_miscompilation_with_bool_return_type.zig create mode 100644 test/incremental/load_store_via_pointer_deref.0.zig create mode 100644 test/incremental/load_store_via_pointer_deref.1.zig create mode 100644 test/incremental/load_store_via_pointer_deref.2.zig create mode 100644 test/incremental/lower_unnamed_consts_structs.0.zig create mode 100644 test/incremental/lower_unnamed_consts_structs.1.zig create mode 100644 test/incremental/lower_unnamed_consts_structs.2.zig create mode 100644 test/incremental/merge_error_sets.0.zig create mode 100644 test/incremental/merge_error_sets.1.zig create mode 100644 test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.0.zig create mode 100644 test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.1.zig create mode 100644 test/incremental/optional_payload.0.zig create mode 100644 test/incremental/optional_payload.1.zig create mode 100644 test/incremental/optional_payload.2.zig create mode 100644 test/incremental/optional_payload.3.zig create mode 100644 test/incremental/orelse_at_comptime.0.zig create mode 100644 test/incremental/orelse_at_comptime.1.zig create mode 100644 test/incremental/passing_u0_to_function.zig create mode 100644 test/incremental/recursive_inline_function.0.zig create mode 100644 test/incremental/recursive_inline_function.1.zig create mode 100644 test/incremental/redundant_comptime.0.zig create mode 100644 test/incremental/redundant_comptime.1.zig create mode 100644 test/incremental/returns_in_try.zig create mode 100644 test/incremental/runtime_bitwise_and.zig create mode 100644 test/incremental/runtime_bitwise_or.zig create mode 100644 test/incremental/saving_vars_of_different_abi_size_to_stack.0.zig create mode 100644 test/incremental/saving_vars_of_different_abi_size_to_stack.1.zig create mode 100644 test/incremental/saving_vars_of_different_abi_size_to_stack.2.zig create mode 100644 test/incremental/setting_an_address_space_on_a_local_variable.zig create mode 100644 test/incremental/try_in_comptime_in_struct_in_test.zig create mode 100644 test/incremental/type_of.0.zig create mode 100644 test/incremental/type_of.1.zig create mode 100644 test/incremental/type_of.2.zig create mode 100644 test/incremental/unused_labels.0.zig create mode 100644 test/incremental/unused_labels.1.zig create mode 100644 test/incremental/unused_labels.2.zig create mode 100644 test/incremental/unused_labels.3.zig create mode 100644 test/incremental/unwrap_error_union_simple_errors.0.zig create mode 100644 test/incremental/unwrap_error_union_simple_errors.1.zig create mode 100644 test/incremental/variable_shadowing.0.zig create mode 100644 test/incremental/variable_shadowing.1.zig create mode 100644 test/incremental/variable_shadowing.2.zig create mode 100644 test/incremental/variable_shadowing.3.zig create mode 100644 test/incremental/variable_shadowing.4.zig create mode 100644 test/incremental/variable_shadowing.5.zig create mode 100644 test/incremental/variable_shadowing.6.zig create mode 100644 test/incremental/variable_shadowing.7.zig create mode 100644 test/incremental/variable_shadowing.8.zig create mode 100644 test/incremental/variable_shadowing.9.zig diff --git a/src/test.zig b/src/test.zig index e138afecb9..2f3389d7ff 100644 --- a/src/test.zig +++ b/src/test.zig @@ -178,7 +178,7 @@ const TestManifestConfigDefaults = struct { // getting more and more complete // Linux inline for (&[_][]const u8{ "x86_64", "arm", "aarch64" }) |arch| { - defaults = defaults ++ arch ++ "-linux-" ++ ","; + defaults = defaults ++ arch ++ "-linux" ++ ","; } // macOS inline for (&[_][]const u8{ "x86_64", "aarch64" }) |arch| { diff --git a/test/incremental/access_slice_element_by_index_slice_elem_val.zig b/test/incremental/access_slice_element_by_index_slice_elem_val.zig new file mode 100644 index 0000000000..a0bdae0826 --- /dev/null +++ b/test/incremental/access_slice_element_by_index_slice_elem_val.zig @@ -0,0 +1,17 @@ +var array = [_]usize{ 0, 42, 123, 34 }; +var slice: []const usize = &array; + +pub fn main() void { + assert(slice[0] == 0); + assert(slice[1] == 42); + assert(slice[2] == 123); + assert(slice[3] == 34); +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// target=x86_64-linux,x86_64-macos +// diff --git a/test/incremental/ambiguous_reference.zig b/test/incremental/ambiguous_reference.zig new file mode 100644 index 0000000000..66144a5645 --- /dev/null +++ b/test/incremental/ambiguous_reference.zig @@ -0,0 +1,13 @@ +const T = struct { + const T = struct { + fn f() void { + _ = T; + } + }; +}; + +// error +// +// :4:17: error: ambiguous reference +// :2:5: note: declared here +// :1:1: note: also declared here diff --git a/test/incremental/bad_inferred_variable_type.zig b/test/incremental/bad_inferred_variable_type.zig new file mode 100644 index 0000000000..47ceb9b638 --- /dev/null +++ b/test/incremental/bad_inferred_variable_type.zig @@ -0,0 +1,9 @@ +pub fn main() void { + var x = null; + _ = x; +} + +// error +// output_mode=Exe +// +// :2:9: error: variable of type '@TypeOf(null)' must be const or comptime diff --git a/test/incremental/break_continue.0.zig b/test/incremental/break_continue.0.zig new file mode 100644 index 0000000000..ac0abdb52d --- /dev/null +++ b/test/incremental/break_continue.0.zig @@ -0,0 +1,9 @@ +pub fn main() void { + while (true) { + break; + } +} + +// run +// target=x86_64-linux,x86_64-macos,aarch64-linux,aarch64-macos +// diff --git a/test/incremental/break_continue.1.zig b/test/incremental/break_continue.1.zig new file mode 100644 index 0000000000..9e4f79bd14 --- /dev/null +++ b/test/incremental/break_continue.1.zig @@ -0,0 +1,8 @@ +pub fn main() void { + foo: while (true) { + break :foo; + } +} + +// run +// diff --git a/test/incremental/break_continue.2.zig b/test/incremental/break_continue.2.zig new file mode 100644 index 0000000000..ba12f33e3f --- /dev/null +++ b/test/incremental/break_continue.2.zig @@ -0,0 +1,10 @@ +pub fn main() void { + var i: u64 = 0; + while (true) : (i += 1) { + if (i == 4) return; + continue; + } +} + +// run +// diff --git a/test/incremental/break_continue.3.zig b/test/incremental/break_continue.3.zig new file mode 100644 index 0000000000..03e224d265 --- /dev/null +++ b/test/incremental/break_continue.3.zig @@ -0,0 +1,10 @@ +pub fn main() void { + var i: u64 = 0; + foo: while (true) : (i += 1) { + if (i == 4) return; + continue :foo; + } +} + +// run +// diff --git a/test/incremental/catch_at_comptime.0.zig b/test/incremental/catch_at_comptime.0.zig new file mode 100644 index 0000000000..af1545832d --- /dev/null +++ b/test/incremental/catch_at_comptime.0.zig @@ -0,0 +1,11 @@ +pub fn main() void { + const i: anyerror!u64 = 0; + const caught = i catch 5; + assert(caught == 0); +} +fn assert(b: bool) void { + if (!b) unreachable; +} + +// run +// diff --git a/test/incremental/catch_at_comptime.1.zig b/test/incremental/catch_at_comptime.1.zig new file mode 100644 index 0000000000..e05caeae6d --- /dev/null +++ b/test/incremental/catch_at_comptime.1.zig @@ -0,0 +1,11 @@ +pub fn main() void { + const i: anyerror!u64 = error.B; + const caught = i catch 5; + assert(caught == 5); +} +fn assert(b: bool) void { + if (!b) unreachable; +} + +// run +// diff --git a/test/incremental/catch_at_comptime.2.zig b/test/incremental/catch_at_comptime.2.zig new file mode 100644 index 0000000000..326e6f0b61 --- /dev/null +++ b/test/incremental/catch_at_comptime.2.zig @@ -0,0 +1,11 @@ +pub fn main() void { + const a: anyerror!comptime_int = 42; + const b: *const comptime_int = &(a catch unreachable); + assert(b.* == 42); +} +fn assert(b: bool) void { + if (!b) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/catch_at_comptime.3.zig b/test/incremental/catch_at_comptime.3.zig new file mode 100644 index 0000000000..d00317f697 --- /dev/null +++ b/test/incremental/catch_at_comptime.3.zig @@ -0,0 +1,10 @@ +pub fn main() void { + const a: anyerror!u32 = error.B; + _ = &(a catch |err| assert(err == error.B)); +} +fn assert(b: bool) void { + if (!b) unreachable; +} + +// run +// diff --git a/test/incremental/catch_at_comptime.4.zig b/test/incremental/catch_at_comptime.4.zig new file mode 100644 index 0000000000..57cb602641 --- /dev/null +++ b/test/incremental/catch_at_comptime.4.zig @@ -0,0 +1,10 @@ +pub fn main() void { + const a: anyerror!u32 = error.Bar; + a catch |err| assert(err == error.Bar); +} +fn assert(b: bool) void { + if (!b) unreachable; +} + +// run +// diff --git a/test/incremental/compile_error.zig b/test/incremental/compile_error.zig new file mode 100644 index 0000000000..dab0f7f7cc --- /dev/null +++ b/test/incremental/compile_error.zig @@ -0,0 +1,7 @@ +export fn foo() void { + @compileError("this is an error"); +} + +// error +// +// :2:5: error: this is an error diff --git a/test/incremental/compile_error_in_inline_fn_call_fixed.0.zig b/test/incremental/compile_error_in_inline_fn_call_fixed.0.zig new file mode 100644 index 0000000000..1848490b07 --- /dev/null +++ b/test/incremental/compile_error_in_inline_fn_call_fixed.0.zig @@ -0,0 +1,16 @@ +pub fn main() void { + var x: usize = 3; + const y = add(10, 2, x); + if (y - 6 != 0) unreachable; +} + +inline fn add(a: usize, b: usize, c: usize) usize { + if (a == 10) @compileError("bad"); + return a + b + c; +} + +// error +// output_mode=Exe +// +// :8:18: error: bad +// :3:18: note: called from here diff --git a/test/incremental/compile_error_in_inline_fn_call_fixed.1.zig b/test/incremental/compile_error_in_inline_fn_call_fixed.1.zig new file mode 100644 index 0000000000..1e61c6c790 --- /dev/null +++ b/test/incremental/compile_error_in_inline_fn_call_fixed.1.zig @@ -0,0 +1,13 @@ +pub fn main() void { + var x: usize = 3; + const y = add(1, 2, x); + if (y - 6 != 0) unreachable; +} + +inline fn add(a: usize, b: usize, c: usize) usize { + if (a == 10) @compileError("bad"); + return a + b + c; +} + +// run +// diff --git a/test/incremental/compile_log.0.zig b/test/incremental/compile_log.0.zig new file mode 100644 index 0000000000..c213ebb930 --- /dev/null +++ b/test/incremental/compile_log.0.zig @@ -0,0 +1,17 @@ +export fn _start() noreturn { + const b = true; + var f: u32 = 1; + @compileLog(b, 20, f, x); + @compileLog(1000); + var bruh: usize = true; + _ = bruh; + unreachable; +} +export fn other() void { + @compileLog(1234); +} +fn x() void {} + +// error +// +// :6:23: error: expected usize, found bool diff --git a/test/incremental/compile_log.1.zig b/test/incremental/compile_log.1.zig new file mode 100644 index 0000000000..12e6641542 --- /dev/null +++ b/test/incremental/compile_log.1.zig @@ -0,0 +1,16 @@ +export fn _start() noreturn { + const b = true; + var f: u32 = 1; + @compileLog(b, 20, f, x); + @compileLog(1000); + unreachable; +} +export fn other() void { + @compileLog(1234); +} +fn x() void {} + +// error +// +// :9:5: error: found compile log statement +// :4:5: note: also here diff --git a/test/incremental/comptime_var.0.zig b/test/incremental/comptime_var.0.zig new file mode 100644 index 0000000000..019cf78abb --- /dev/null +++ b/test/incremental/comptime_var.0.zig @@ -0,0 +1,12 @@ +pub fn main() void { + var a: u32 = 0; + comptime var b: u32 = 0; + if (a == 0) b = 3; +} + +// error +// output_mode=Exe +// target=x86_64-linux,x86_64-macos +// +// :4:21: error: store to comptime variable depends on runtime condition +// :4:11: note: runtime condition here diff --git a/test/incremental/comptime_var.1.zig b/test/incremental/comptime_var.1.zig new file mode 100644 index 0000000000..efc51aafe3 --- /dev/null +++ b/test/incremental/comptime_var.1.zig @@ -0,0 +1,13 @@ +pub fn main() void { + var a: u32 = 0; + comptime var b: u32 = 0; + switch (a) { + 0 => {}, + else => b = 3, + } +} + +// error +// +// :6:21: error: store to comptime variable depends on runtime condition +// :4:13: note: runtime condition here diff --git a/test/incremental/comptime_var.2.zig b/test/incremental/comptime_var.2.zig new file mode 100644 index 0000000000..e91c0540ef --- /dev/null +++ b/test/incremental/comptime_var.2.zig @@ -0,0 +1,34 @@ +const builtin = @import("builtin"); + +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + comptime var len: u32 = 5; + print(len); + len += 9; + print(len); +} + +fn print(len: usize) void { + switch (builtin.os.tag) { + .linux => { + asm volatile ("syscall" + : + : [number] "{rax}" (1), + [arg1] "{rdi}" (1), + [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), + [arg3] "{rdx}" (len), + : "rcx", "r11", "memory" + ); + }, + .macos => { + _ = write(1, @ptrToInt("Hello, World!\n"), len); + }, + else => unreachable, + } +} + +// run +// +// HelloHello, World! +// diff --git a/test/incremental/comptime_var.3.zig b/test/incremental/comptime_var.3.zig new file mode 100644 index 0000000000..d4e6d85d9d --- /dev/null +++ b/test/incremental/comptime_var.3.zig @@ -0,0 +1,10 @@ +comptime { + var x: i32 = 1; + x += 1; + if (x != 1) unreachable; +} +pub fn main() void {} + +// error +// +// :4:17: error: unable to resolve comptime value diff --git a/test/incremental/comptime_var.4.zig b/test/incremental/comptime_var.4.zig new file mode 100644 index 0000000000..74da6ef448 --- /dev/null +++ b/test/incremental/comptime_var.4.zig @@ -0,0 +1,9 @@ +pub fn main() void { + comptime var i: u64 = 0; + while (i < 5) : (i += 1) {} +} + +// error +// +// :3:24: error: cannot store to comptime variable in non-inline loop +// :3:5: note: non-inline loop here diff --git a/test/incremental/comptime_var.5.zig b/test/incremental/comptime_var.5.zig new file mode 100644 index 0000000000..76a06f3d4b --- /dev/null +++ b/test/incremental/comptime_var.5.zig @@ -0,0 +1,15 @@ +pub fn main() void { + var a: u32 = 0; + if (a == 0) { + comptime var b: u32 = 0; + b = 1; + } +} +comptime { + var x: i32 = 1; + x += 1; + if (x != 2) unreachable; +} + +// run +// diff --git a/test/incremental/comptime_var.6.zig b/test/incremental/comptime_var.6.zig new file mode 100644 index 0000000000..0eb743a05b --- /dev/null +++ b/test/incremental/comptime_var.6.zig @@ -0,0 +1,32 @@ +const builtin = @import("builtin"); + +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + comptime var i: u64 = 2; + inline while (i < 6) : (i += 1) { + print(i); + } +} +fn print(len: usize) void { + switch (builtin.os.tag) { + .linux => { + asm volatile ("syscall" + : + : [number] "{rax}" (1), + [arg1] "{rdi}" (1), + [arg2] "{rsi}" (@ptrToInt("Hello")), + [arg3] "{rdx}" (len), + : "rcx", "r11", "memory" + ); + }, + .macos => { + _ = write(1, @ptrToInt("Hello"), len); + }, + else => unreachable, + } +} + +// run +// +// HeHelHellHello diff --git a/test/incremental/double_ampersand.0.zig b/test/incremental/double_ampersand.0.zig new file mode 100644 index 0000000000..b14c30ecb0 --- /dev/null +++ b/test/incremental/double_ampersand.0.zig @@ -0,0 +1,6 @@ +pub const a = if (true && false) 1 else 2; + +// error +// output_mode=Exe +// +// :1:24: error: ambiguous use of '&&'; use 'and' for logical AND, or change whitespace to ' & &' for bitwise AND diff --git a/test/incremental/double_ampersand.1.zig b/test/incremental/double_ampersand.1.zig new file mode 100644 index 0000000000..cd5bba02fd --- /dev/null +++ b/test/incremental/double_ampersand.1.zig @@ -0,0 +1,11 @@ +pub fn main() void { + const a = true; + const b = false; + _ = a & &b; +} + +// error +// +// :4:11: error: incompatible types: 'bool' and '*const bool' +// :4:9: note: type 'bool' here +// :4:13: note: type '*const bool' here diff --git a/test/incremental/double_ampersand.2.zig b/test/incremental/double_ampersand.2.zig new file mode 100644 index 0000000000..c6f461d661 --- /dev/null +++ b/test/incremental/double_ampersand.2.zig @@ -0,0 +1,7 @@ +pub fn main() void { + const b: u8 = 1; + _ = &&b; +} + +// run +// diff --git a/test/incremental/extern_variable_has_no_type.0.zig b/test/incremental/extern_variable_has_no_type.0.zig new file mode 100644 index 0000000000..2f03067b3a --- /dev/null +++ b/test/incremental/extern_variable_has_no_type.0.zig @@ -0,0 +1,9 @@ +comptime { + const x = foo + foo; + _ = x; +} +extern var foo: i32; + +// error +// +// :2:15: error: unable to resolve comptime value diff --git a/test/incremental/extern_variable_has_no_type.1.zig b/test/incremental/extern_variable_has_no_type.1.zig new file mode 100644 index 0000000000..f5c31244e5 --- /dev/null +++ b/test/incremental/extern_variable_has_no_type.1.zig @@ -0,0 +1,8 @@ +export fn entry() void { + _ = foo; +} +extern var foo; + +// error +// +// :4:8: error: unable to infer variable type diff --git a/test/incremental/function_redeclaration.zig b/test/incremental/function_redeclaration.zig new file mode 100644 index 0000000000..a9664646c9 --- /dev/null +++ b/test/incremental/function_redeclaration.zig @@ -0,0 +1,14 @@ +// dummy comment +fn entry() void {} +fn entry() void {} + +fn foo() void { + var foo = 1234; +} + +// error +// +// :3:1: error: redeclaration of 'entry' +// :2:1: note: other declaration here +// :6:9: error: local shadows declaration of 'foo' +// :5:1: note: declared here diff --git a/test/incremental/global_variable_redeclaration.zig b/test/incremental/global_variable_redeclaration.zig new file mode 100644 index 0000000000..9a0d5939fb --- /dev/null +++ b/test/incremental/global_variable_redeclaration.zig @@ -0,0 +1,8 @@ +// dummy comment +var foo = false; +var foo = true; + +// error +// +// :3:1: error: redeclaration of 'foo' +// :2:1: note: other declaration here diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.0.zig b/test/incremental/hello_world_with_updates_x86_64_linux.0.zig new file mode 100644 index 0000000000..960fae5e64 --- /dev/null +++ b/test/incremental/hello_world_with_updates_x86_64_linux.0.zig @@ -0,0 +1,5 @@ +// error +// output_mode=Exe +// target=x86_64-linux +// +// :109:9: error: struct 'tmp.tmp' has no member named 'main' diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.1.zig b/test/incremental/hello_world_with_updates_x86_64_linux.1.zig new file mode 100644 index 0000000000..0f347b7f50 --- /dev/null +++ b/test/incremental/hello_world_with_updates_x86_64_linux.1.zig @@ -0,0 +1,5 @@ +pub export fn _start() noreturn {} + +// error +// +// :1:34: error: expected noreturn, found void diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.2.zig b/test/incremental/hello_world_with_updates_x86_64_linux.2.zig new file mode 100644 index 0000000000..fcea1870ce --- /dev/null +++ b/test/incremental/hello_world_with_updates_x86_64_linux.2.zig @@ -0,0 +1,32 @@ +pub export fn _start() noreturn { + print(); + + exit(); +} + +fn print() void { + asm volatile ("syscall" + : + : [number] "{rax}" (1), + [arg1] "{rdi}" (1), + [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), + [arg3] "{rdx}" (14), + : "rcx", "r11", "memory" + ); + return; +} + +fn exit() noreturn { + asm volatile ("syscall" + : + : [number] "{rax}" (231), + [arg1] "{rdi}" (0), + : "rcx", "r11", "memory" + ); + unreachable; +} + +// run +// +// Hello, World! +// diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.3.zig b/test/incremental/hello_world_with_updates_x86_64_linux.3.zig new file mode 100644 index 0000000000..7812023372 --- /dev/null +++ b/test/incremental/hello_world_with_updates_x86_64_linux.3.zig @@ -0,0 +1,20 @@ +pub fn main() void { + print(); +} + +fn print() void { + asm volatile ("syscall" + : + : [number] "{rax}" (1), + [arg1] "{rdi}" (1), + [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), + [arg3] "{rdx}" (14), + : "rcx", "r11", "memory" + ); + return; +} + +// run +// +// Hello, World! +// diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.4.zig b/test/incremental/hello_world_with_updates_x86_64_linux.4.zig new file mode 100644 index 0000000000..cdf47012b8 --- /dev/null +++ b/test/incremental/hello_world_with_updates_x86_64_linux.4.zig @@ -0,0 +1,20 @@ +pub fn main() void { + print(); +} + +fn print() void { + asm volatile ("syscall" + : + : [number] "{rax}" (1), + [arg1] "{rdi}" (1), + [arg2] "{rsi}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")), + [arg3] "{rdx}" (104), + : "rcx", "r11", "memory" + ); + return; +} + +// run +// +// What is up? This is a longer message that will force the data to be relocated in virtual address space. +// diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.5.zig b/test/incremental/hello_world_with_updates_x86_64_linux.5.zig new file mode 100644 index 0000000000..68c1e305f7 --- /dev/null +++ b/test/incremental/hello_world_with_updates_x86_64_linux.5.zig @@ -0,0 +1,22 @@ +pub fn main() void { + print(); + print(); +} + +fn print() void { + asm volatile ("syscall" + : + : [number] "{rax}" (1), + [arg1] "{rdi}" (1), + [arg2] "{rsi}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")), + [arg3] "{rdx}" (104), + : "rcx", "r11", "memory" + ); + return; +} + +// run +// +// What is up? This is a longer message that will force the data to be relocated in virtual address space. +// What is up? This is a longer message that will force the data to be relocated in virtual address space. +// diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.0.zig b/test/incremental/hello_world_with_updates_x86_64_macos.0.zig new file mode 100644 index 0000000000..34440c4603 --- /dev/null +++ b/test/incremental/hello_world_with_updates_x86_64_macos.0.zig @@ -0,0 +1,5 @@ +// error +// output_mode=Exe +// target=x86_64-macos +// +// :109:9: error: struct 'tmp.tmp' has no member named 'main' diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.1.zig b/test/incremental/hello_world_with_updates_x86_64_macos.1.zig new file mode 100644 index 0000000000..909fc9ccfb --- /dev/null +++ b/test/incremental/hello_world_with_updates_x86_64_macos.1.zig @@ -0,0 +1,5 @@ +pub export fn main() noreturn {} + +// error +// +// :1:32: error: expected noreturn, found void diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.2.zig b/test/incremental/hello_world_with_updates_x86_64_macos.2.zig new file mode 100644 index 0000000000..fb8cb39edd --- /dev/null +++ b/test/incremental/hello_world_with_updates_x86_64_macos.2.zig @@ -0,0 +1,19 @@ +extern "c" fn write(usize, usize, usize) usize; +extern "c" fn exit(usize) noreturn; + +pub export fn main() noreturn { + print(); + + exit(0); +} + +fn print() void { + const msg = @ptrToInt("Hello, World!\n"); + const len = 14; + _ = write(1, msg, len); +} + +// run +// +// Hello, World! +// diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.3.zig b/test/incremental/hello_world_with_updates_x86_64_macos.3.zig new file mode 100644 index 0000000000..f6e233886b --- /dev/null +++ b/test/incremental/hello_world_with_updates_x86_64_macos.3.zig @@ -0,0 +1,16 @@ +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + print(); +} + +fn print() void { + const msg = @ptrToInt("Hello, World!\n"); + const len = 14; + _ = write(1, msg, len); +} + +// run +// +// Hello, World! +// diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.4.zig b/test/incremental/hello_world_with_updates_x86_64_macos.4.zig new file mode 100644 index 0000000000..f89cef7354 --- /dev/null +++ b/test/incremental/hello_world_with_updates_x86_64_macos.4.zig @@ -0,0 +1,22 @@ +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + print(); + print(); + print(); + print(); +} + +fn print() void { + const msg = @ptrToInt("Hello, World!\n"); + const len = 14; + _ = write(1, msg, len); +} + +// run +// +// Hello, World! +// Hello, World! +// Hello, World! +// Hello, World! +// diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.5.zig b/test/incremental/hello_world_with_updates_x86_64_macos.5.zig new file mode 100644 index 0000000000..0d7f97578a --- /dev/null +++ b/test/incremental/hello_world_with_updates_x86_64_macos.5.zig @@ -0,0 +1,16 @@ +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + print(); +} + +fn print() void { + const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); + const len = 104; + _ = write(1, msg, len); +} + +// run +// +// What is up? This is a longer message that will force the data to be relocated in virtual address space. +// diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.6.zig b/test/incremental/hello_world_with_updates_x86_64_macos.6.zig new file mode 100644 index 0000000000..3ce2cb7176 --- /dev/null +++ b/test/incremental/hello_world_with_updates_x86_64_macos.6.zig @@ -0,0 +1,18 @@ +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + print(); + print(); +} + +fn print() void { + const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); + const len = 104; + _ = write(1, msg, len); +} + +// run +// +// What is up? This is a longer message that will force the data to be relocated in virtual address space. +// What is up? This is a longer message that will force the data to be relocated in virtual address space. +// diff --git a/test/incremental/inline_assembly_x86_64_linux.0.zig b/test/incremental/inline_assembly_x86_64_linux.0.zig new file mode 100644 index 0000000000..e3c0f3badb --- /dev/null +++ b/test/incremental/inline_assembly_x86_64_linux.0.zig @@ -0,0 +1,16 @@ +pub fn main() void { + const number = 1234; + const x = asm volatile ("syscall" + : [o] "{rax}" (-> number), + : [number] "{rax}" (231), + [arg1] "{rdi}" (60), + : "rcx", "r11", "memory" + ); + _ = x; +} + +// error +// output_mode=Exe +// target=x86_64-linux +// +// :4:27: error: expected type, found comptime_int diff --git a/test/incremental/inline_assembly_x86_64_linux.1.zig b/test/incremental/inline_assembly_x86_64_linux.1.zig new file mode 100644 index 0000000000..b35014b0f6 --- /dev/null +++ b/test/incremental/inline_assembly_x86_64_linux.1.zig @@ -0,0 +1,15 @@ +const S = struct { + comptime { + asm volatile ( + \\zig_moment: + \\syscall + ); + } +}; +pub fn main() void { + _ = S; +} + +// error +// +// :3:13: error: volatile is meaningless on global assembly diff --git a/test/incremental/inline_assembly_x86_64_linux.2.zig b/test/incremental/inline_assembly_x86_64_linux.2.zig new file mode 100644 index 0000000000..1695265ab4 --- /dev/null +++ b/test/incremental/inline_assembly_x86_64_linux.2.zig @@ -0,0 +1,12 @@ +pub fn main() void { + var bruh: u32 = 1; + asm ("" + : + : [bruh] "{rax}" (4) + : "memory" + ); +} + +// error +// +// :3:5: error: assembly expression with no output must be marked volatile diff --git a/test/incremental/inline_assembly_x86_64_linux.3.zig b/test/incremental/inline_assembly_x86_64_linux.3.zig new file mode 100644 index 0000000000..765eaeb97e --- /dev/null +++ b/test/incremental/inline_assembly_x86_64_linux.3.zig @@ -0,0 +1,12 @@ +pub fn main() void {} +comptime { + asm ("" + : + : [bruh] "{rax}" (4) + : "memory" + ); +} + +// error +// +// :3:5: error: global assembly cannot have inputs, outputs, or clobbers diff --git a/test/incremental/inner_func_accessing_outer_var.zig b/test/incremental/inner_func_accessing_outer_var.zig new file mode 100644 index 0000000000..e30cf58ef8 --- /dev/null +++ b/test/incremental/inner_func_accessing_outer_var.zig @@ -0,0 +1,15 @@ +pub fn f() void { + var bar: bool = true; + const S = struct { + fn baz() bool { + return bar; + } + }; + _ = S; +} + +// error +// +// :5:20: error: mutable 'bar' not accessible from here +// :2:9: note: declared mutable here +// :3:15: note: crosses namespace boundary here diff --git a/test/incremental/int_to_ptr.0.zig b/test/incremental/int_to_ptr.0.zig new file mode 100644 index 0000000000..b7c70b90a4 --- /dev/null +++ b/test/incremental/int_to_ptr.0.zig @@ -0,0 +1,8 @@ +pub fn main() void { + _ = @intToPtr(*u8, 0); +} + +// error +// output_mode=Exe +// +// :2:24: error: pointer type '*u8' does not allow address zero diff --git a/test/incremental/int_to_ptr.1.zig b/test/incremental/int_to_ptr.1.zig new file mode 100644 index 0000000000..72c8c8c9d6 --- /dev/null +++ b/test/incremental/int_to_ptr.1.zig @@ -0,0 +1,7 @@ +pub fn main() void { + _ = @intToPtr(*u32, 2); +} + +// error +// +// :2:25: error: pointer type '*u32' requires aligned address diff --git a/test/incremental/issue_10138_callee_preserved_regs_working_x86_64_linux.zig b/test/incremental/issue_10138_callee_preserved_regs_working_x86_64_linux.zig new file mode 100644 index 0000000000..4c045496da --- /dev/null +++ b/test/incremental/issue_10138_callee_preserved_regs_working_x86_64_linux.zig @@ -0,0 +1,31 @@ +pub fn main() void { + const fd = open(); + _ = write(fd, "a", 1); + _ = close(fd); +} + +fn open() usize { + return 42; +} + +fn write(fd: usize, a: [*]const u8, len: usize) usize { + return syscall4(.WRITE, fd, @ptrToInt(a), len); +} + +fn syscall4(n: enum { WRITE }, a: usize, b: usize, c: usize) usize { + _ = n; + _ = a; + _ = b; + _ = c; + return 23; +} + +fn close(fd: usize) usize { + if (fd != 42) + unreachable; + return 0; +} + +// run +// target=x86_64-linux +// diff --git a/test/incremental/issue_7187_miscompilation_with_bool_return_type.zig b/test/incremental/issue_7187_miscompilation_with_bool_return_type.zig new file mode 100644 index 0000000000..3aed8685bf --- /dev/null +++ b/test/incremental/issue_7187_miscompilation_with_bool_return_type.zig @@ -0,0 +1,18 @@ +pub fn main() void { + var x: usize = 1; + var y: bool = getFalse(); + _ = y; + + assert(x == 1); +} + +fn getFalse() bool { + return false; +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// diff --git a/test/incremental/load_store_via_pointer_deref.0.zig b/test/incremental/load_store_via_pointer_deref.0.zig new file mode 100644 index 0000000000..96aedf3196 --- /dev/null +++ b/test/incremental/load_store_via_pointer_deref.0.zig @@ -0,0 +1,16 @@ +pub fn main() void { + var x: u32 = undefined; + set(&x); + assert(x == 123); +} + +fn set(x: *u32) void { + x.* = 123; +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// diff --git a/test/incremental/load_store_via_pointer_deref.1.zig b/test/incremental/load_store_via_pointer_deref.1.zig new file mode 100644 index 0000000000..e311092744 --- /dev/null +++ b/test/incremental/load_store_via_pointer_deref.1.zig @@ -0,0 +1,16 @@ +pub fn main() void { + var x: u16 = undefined; + set(&x); + assert(x == 123); +} + +fn set(x: *u16) void { + x.* = 123; +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// diff --git a/test/incremental/load_store_via_pointer_deref.2.zig b/test/incremental/load_store_via_pointer_deref.2.zig new file mode 100644 index 0000000000..3b1484faa1 --- /dev/null +++ b/test/incremental/load_store_via_pointer_deref.2.zig @@ -0,0 +1,16 @@ +pub fn main() void { + var x: u8 = undefined; + set(&x); + assert(x == 123); +} + +fn set(x: *u8) void { + x.* = 123; +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// diff --git a/test/incremental/lower_unnamed_consts_structs.0.zig b/test/incremental/lower_unnamed_consts_structs.0.zig new file mode 100644 index 0000000000..3123299646 --- /dev/null +++ b/test/incremental/lower_unnamed_consts_structs.0.zig @@ -0,0 +1,25 @@ +const Foo = struct { + a: u8, + b: u32, + + fn first(self: *Foo) u8 { + return self.a; + } + + fn second(self: *Foo) u32 { + return self.b; + } +}; + +pub fn main() void { + var foo = Foo{ .a = 1, .b = 5 }; + assert(foo.first() == 1); + assert(foo.second() == 5); +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// diff --git a/test/incremental/lower_unnamed_consts_structs.1.zig b/test/incremental/lower_unnamed_consts_structs.1.zig new file mode 100644 index 0000000000..37afdc8a09 --- /dev/null +++ b/test/incremental/lower_unnamed_consts_structs.1.zig @@ -0,0 +1,35 @@ +const Foo = struct { + a: u8, + b: u32, + + fn first(self: *Foo) u8 { + return self.a; + } + + fn second(self: *Foo) u32 { + return self.b; + } +}; + +pub fn main() void { + var foo = Foo{ .a = 1, .b = 5 }; + assert(foo.first() == 1); + assert(foo.second() == 5); + + foo.a = 10; + foo.b = 255; + + assert(foo.first() == 10); + assert(foo.second() == 255); + + var foo2 = Foo{ .a = 15, .b = 255 }; + assert(foo2.first() == 15); + assert(foo2.second() == 255); +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// diff --git a/test/incremental/lower_unnamed_consts_structs.2.zig b/test/incremental/lower_unnamed_consts_structs.2.zig new file mode 100644 index 0000000000..b437c4a030 --- /dev/null +++ b/test/incremental/lower_unnamed_consts_structs.2.zig @@ -0,0 +1,25 @@ +const Foo = struct { + a: u8, + b: u32, + + fn first(self: *Foo) u8 { + return self.a; + } + + fn second(self: *Foo) u32 { + return self.b; + } +}; + +pub fn main() void { + var foo2 = Foo{ .a = 15, .b = 255 }; + assert(foo2.first() == 15); + assert(foo2.second() == 255); +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// diff --git a/test/incremental/merge_error_sets.0.zig b/test/incremental/merge_error_sets.0.zig new file mode 100644 index 0000000000..f1f3b96883 --- /dev/null +++ b/test/incremental/merge_error_sets.0.zig @@ -0,0 +1,18 @@ +pub fn main() void { + const E = error{ A, B, D } || error{ A, B, C }; + E.A catch {}; + E.B catch {}; + E.C catch {}; + E.D catch {}; + const E2 = error{ X, Y } || @TypeOf(error.Z); + E2.X catch {}; + E2.Y catch {}; + E2.Z catch {}; + assert(anyerror || error{Z} == anyerror); +} +fn assert(b: bool) void { + if (!b) unreachable; +} + +// run +// diff --git a/test/incremental/merge_error_sets.1.zig b/test/incremental/merge_error_sets.1.zig new file mode 100644 index 0000000000..81c1cad134 --- /dev/null +++ b/test/incremental/merge_error_sets.1.zig @@ -0,0 +1,9 @@ +pub fn main() void { + const z = true || false; + _ = z; +} + +// error +// +// :2:15: error: expected error set type, found 'bool' +// :2:20: note: '||' merges error sets; 'or' performs boolean OR diff --git a/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.0.zig b/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.0.zig new file mode 100644 index 0000000000..ecba1c8133 --- /dev/null +++ b/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.0.zig @@ -0,0 +1,13 @@ +pub export fn _start() noreturn { + asm volatile ("syscall" + : + : [number] "{rax}" (60), // exit + [arg1] "{rdi}" (0), + : "rcx", "r11", "memory" + ); + unreachable; +} + +// run +// target=x86_64-linux +// diff --git a/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.1.zig b/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.1.zig new file mode 100644 index 0000000000..529acbcf38 --- /dev/null +++ b/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.1.zig @@ -0,0 +1,12 @@ +pub export fn _start() noreturn { + asm volatile ("syscall" + : + : [number] "{rax}" (231), // exit_group + [arg1] "{rdi}" (0), + : "rcx", "r11", "memory" + ); + unreachable; +} + +// run +// diff --git a/test/incremental/optional_payload.0.zig b/test/incremental/optional_payload.0.zig new file mode 100644 index 0000000000..65296875ff --- /dev/null +++ b/test/incremental/optional_payload.0.zig @@ -0,0 +1,19 @@ +pub fn main() void { + var x: u32 = undefined; + const maybe_x = byPtr(&x); + assert(maybe_x != null); + maybe_x.?.* = 123; + assert(x == 123); +} + +fn byPtr(x: *u32) ?*u32 { + return x; +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// target=x86_64-linux,x86_64-macos +// diff --git a/test/incremental/optional_payload.1.zig b/test/incremental/optional_payload.1.zig new file mode 100644 index 0000000000..2d4dafffb9 --- /dev/null +++ b/test/incremental/optional_payload.1.zig @@ -0,0 +1,17 @@ +pub fn main() void { + var x: u32 = undefined; + const maybe_x = byPtr(&x); + assert(maybe_x == null); +} + +fn byPtr(x: *u32) ?*u32 { + _ = x; + return null; +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// diff --git a/test/incremental/optional_payload.2.zig b/test/incremental/optional_payload.2.zig new file mode 100644 index 0000000000..608310923b --- /dev/null +++ b/test/incremental/optional_payload.2.zig @@ -0,0 +1,18 @@ +pub fn main() void { + var x: u8 = undefined; + const maybe_x = byPtr(&x); + assert(maybe_x != null); + maybe_x.?.* = 255; + assert(x == 255); +} + +fn byPtr(x: *u8) ?*u8 { + return x; +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// diff --git a/test/incremental/optional_payload.3.zig b/test/incremental/optional_payload.3.zig new file mode 100644 index 0000000000..b81ec398c7 --- /dev/null +++ b/test/incremental/optional_payload.3.zig @@ -0,0 +1,18 @@ +pub fn main() void { + var x: i8 = undefined; + const maybe_x = byPtr(&x); + assert(maybe_x != null); + maybe_x.?.* = -1; + assert(x == -1); +} + +fn byPtr(x: *i8) ?*i8 { + return x; +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// diff --git a/test/incremental/orelse_at_comptime.0.zig b/test/incremental/orelse_at_comptime.0.zig new file mode 100644 index 0000000000..5397ca3b0a --- /dev/null +++ b/test/incremental/orelse_at_comptime.0.zig @@ -0,0 +1,11 @@ +pub fn main() void { + const i: ?u64 = 0; + const result = i orelse 5; + assert(result == 0); +} +fn assert(b: bool) void { + if (!b) unreachable; +} + +// run +// diff --git a/test/incremental/orelse_at_comptime.1.zig b/test/incremental/orelse_at_comptime.1.zig new file mode 100644 index 0000000000..7d4fcd3178 --- /dev/null +++ b/test/incremental/orelse_at_comptime.1.zig @@ -0,0 +1,11 @@ +pub fn main() void { + const i: ?u64 = null; + const result = i orelse 5; + assert(result == 5); +} +fn assert(b: bool) void { + if (!b) unreachable; +} + +// run +// diff --git a/test/incremental/passing_u0_to_function.zig b/test/incremental/passing_u0_to_function.zig new file mode 100644 index 0000000000..f84c30be8a --- /dev/null +++ b/test/incremental/passing_u0_to_function.zig @@ -0,0 +1,9 @@ +pub fn main() void { + doNothing(0); +} +fn doNothing(arg: u0) void { + _ = arg; +} + +// run +// diff --git a/test/incremental/recursive_inline_function.0.zig b/test/incremental/recursive_inline_function.0.zig new file mode 100644 index 0000000000..c8333c9065 --- /dev/null +++ b/test/incremental/recursive_inline_function.0.zig @@ -0,0 +1,12 @@ +pub fn main() void { + const y = fibonacci(7); + if (y - 21 != 0) unreachable; +} + +inline fn fibonacci(n: usize) usize { + if (n <= 2) return n; + return fibonacci(n - 2) + fibonacci(n - 1); +} + +// run +// diff --git a/test/incremental/recursive_inline_function.1.zig b/test/incremental/recursive_inline_function.1.zig new file mode 100644 index 0000000000..139da1c371 --- /dev/null +++ b/test/incremental/recursive_inline_function.1.zig @@ -0,0 +1,16 @@ +// This additionally tests that the compile error reports the correct source location. +// Without storing source locations relative to the owner decl, the compile error +// here would be off by 2 bytes (from the "7" -> "999"). +pub fn main() void { + const y = fibonacci(999); + if (y - 21 != 0) unreachable; +} + +inline fn fibonacci(n: usize) usize { + if (n <= 2) return n; + return fibonacci(n - 2) + fibonacci(n - 1); +} + +// error +// +// :11:21: error: evaluation exceeded 1000 backwards branches diff --git a/test/incremental/redundant_comptime.0.zig b/test/incremental/redundant_comptime.0.zig new file mode 100644 index 0000000000..c1ecbf7ace --- /dev/null +++ b/test/incremental/redundant_comptime.0.zig @@ -0,0 +1,7 @@ +pub fn main() void { + var a: comptime u32 = 0; +} + +// error +// +// :2:12: error: redundant comptime keyword in already comptime scope diff --git a/test/incremental/redundant_comptime.1.zig b/test/incremental/redundant_comptime.1.zig new file mode 100644 index 0000000000..79226ae8a6 --- /dev/null +++ b/test/incremental/redundant_comptime.1.zig @@ -0,0 +1,9 @@ +pub fn main() void { + comptime { + var a: u32 = comptime 0; + } +} + +// error +// +// :3:22: error: redundant comptime keyword in already comptime scope diff --git a/test/incremental/returns_in_try.zig b/test/incremental/returns_in_try.zig new file mode 100644 index 0000000000..de5a9a3258 --- /dev/null +++ b/test/incremental/returns_in_try.zig @@ -0,0 +1,16 @@ +pub fn main() !void { + try a(); + try b(); +} + +pub fn a() !void { + defer try b(); +} +pub fn b() !void { + defer return a(); +} + +// error +// +// :7:11: error: 'try' not allowed inside defer expression +// :10:11: error: cannot return from defer expression diff --git a/test/incremental/runtime_bitwise_and.zig b/test/incremental/runtime_bitwise_and.zig new file mode 100644 index 0000000000..3ba3d3124c --- /dev/null +++ b/test/incremental/runtime_bitwise_and.zig @@ -0,0 +1,16 @@ +pub fn main() void { + var i: u32 = 10; + var j: u32 = 11; + assert(i & 1 == 0); + assert(j & 1 == 1); + var m1: u32 = 0b1111; + var m2: u32 = 0b0000; + assert(m1 & 0b1010 == 0b1010); + assert(m2 & 0b1010 == 0b0000); +} +fn assert(b: bool) void { + if (!b) unreachable; +} + +// run +// diff --git a/test/incremental/runtime_bitwise_or.zig b/test/incremental/runtime_bitwise_or.zig new file mode 100644 index 0000000000..b97c2acf02 --- /dev/null +++ b/test/incremental/runtime_bitwise_or.zig @@ -0,0 +1,16 @@ +pub fn main() void { + var i: u32 = 10; + var j: u32 = 11; + assert(i | 1 == 11); + assert(j | 1 == 11); + var m1: u32 = 0b1111; + var m2: u32 = 0b0000; + assert(m1 | 0b1010 == 0b1111); + assert(m2 | 0b1010 == 0b1010); +} +fn assert(b: bool) void { + if (!b) unreachable; +} + +// run +// diff --git a/test/incremental/saving_vars_of_different_abi_size_to_stack.0.zig b/test/incremental/saving_vars_of_different_abi_size_to_stack.0.zig new file mode 100644 index 0000000000..6134622a0e --- /dev/null +++ b/test/incremental/saving_vars_of_different_abi_size_to_stack.0.zig @@ -0,0 +1,16 @@ +pub fn main() void { + assert(callMe(2) == 24); +} + +fn callMe(a: u8) u8 { + var b: u8 = a + 10; + const c = 2 * b; + return c; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/saving_vars_of_different_abi_size_to_stack.1.zig b/test/incremental/saving_vars_of_different_abi_size_to_stack.1.zig new file mode 100644 index 0000000000..4d87d7b9c5 --- /dev/null +++ b/test/incremental/saving_vars_of_different_abi_size_to_stack.1.zig @@ -0,0 +1,16 @@ +pub fn main() void { + assert(callMe(2) == 24); +} + +fn callMe(a: u16) u16 { + var b: u16 = a + 10; + const c = 2 * b; + return c; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/saving_vars_of_different_abi_size_to_stack.2.zig b/test/incremental/saving_vars_of_different_abi_size_to_stack.2.zig new file mode 100644 index 0000000000..b665227962 --- /dev/null +++ b/test/incremental/saving_vars_of_different_abi_size_to_stack.2.zig @@ -0,0 +1,16 @@ +pub fn main() void { + assert(callMe(2) == 24); +} + +fn callMe(a: u32) u32 { + var b: u32 = a + 10; + const c = 2 * b; + return c; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/setting_an_address_space_on_a_local_variable.zig b/test/incremental/setting_an_address_space_on_a_local_variable.zig new file mode 100644 index 0000000000..dad282dc31 --- /dev/null +++ b/test/incremental/setting_an_address_space_on_a_local_variable.zig @@ -0,0 +1,8 @@ +export fn entry() i32 { + var foo: i32 addrspace(".general") = 1234; + return foo; +} + +// error +// +// :2:28: error: cannot set address space of local variable 'foo' diff --git a/test/incremental/try_in_comptime_in_struct_in_test.zig b/test/incremental/try_in_comptime_in_struct_in_test.zig new file mode 100644 index 0000000000..e88aa13a7b --- /dev/null +++ b/test/incremental/try_in_comptime_in_struct_in_test.zig @@ -0,0 +1,13 @@ +test "@unionInit on union w/ tag but no fields" { + const S = struct { + comptime { + try expect(false); + } + }; + _ = S; +} + +// error +// is_test=1 +// +// :4:13: error: 'try' outside function scope diff --git a/test/incremental/type_of.0.zig b/test/incremental/type_of.0.zig new file mode 100644 index 0000000000..d8a97d1444 --- /dev/null +++ b/test/incremental/type_of.0.zig @@ -0,0 +1,13 @@ +pub fn main() void { + var x: usize = 0; + _ = x; + const z = @TypeOf(x, @as(u128, 5)); + assert(z == u128); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/type_of.1.zig b/test/incremental/type_of.1.zig new file mode 100644 index 0000000000..86d7d87a19 --- /dev/null +++ b/test/incremental/type_of.1.zig @@ -0,0 +1,11 @@ +pub fn main() void { + const z = @TypeOf(true); + assert(z == bool); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/type_of.2.zig b/test/incremental/type_of.2.zig new file mode 100644 index 0000000000..cdbc8121fd --- /dev/null +++ b/test/incremental/type_of.2.zig @@ -0,0 +1,9 @@ +pub fn main() void { + _ = @TypeOf(true, 1); +} + +// error +// +// :2:9: error: incompatible types: 'bool' and 'comptime_int' +// :2:17: note: type 'bool' here +// :2:23: note: type 'comptime_int' here diff --git a/test/incremental/unused_labels.0.zig b/test/incremental/unused_labels.0.zig new file mode 100644 index 0000000000..9afa5facdd --- /dev/null +++ b/test/incremental/unused_labels.0.zig @@ -0,0 +1,8 @@ +comptime { + foo: {} +} + +// error +// output_mode=Exe +// +// :2:5: error: unused block label diff --git a/test/incremental/unused_labels.1.zig b/test/incremental/unused_labels.1.zig new file mode 100644 index 0000000000..c7ff576875 --- /dev/null +++ b/test/incremental/unused_labels.1.zig @@ -0,0 +1,7 @@ +comptime { + foo: while (true) {} +} + +// error +// +// :2:5: error: unused while loop label diff --git a/test/incremental/unused_labels.2.zig b/test/incremental/unused_labels.2.zig new file mode 100644 index 0000000000..babe3c7b0a --- /dev/null +++ b/test/incremental/unused_labels.2.zig @@ -0,0 +1,7 @@ +comptime { + foo: for ("foo") |_| {} +} + +// error +// +// :2:5: error: unused for loop label diff --git a/test/incremental/unused_labels.3.zig b/test/incremental/unused_labels.3.zig new file mode 100644 index 0000000000..e4f3ac05a4 --- /dev/null +++ b/test/incremental/unused_labels.3.zig @@ -0,0 +1,8 @@ +comptime { + blk: {blk: {}} +} + +// error +// +// :2:11: error: redefinition of label 'blk' +// :2:5: note: previous definition here diff --git a/test/incremental/unwrap_error_union_simple_errors.0.zig b/test/incremental/unwrap_error_union_simple_errors.0.zig new file mode 100644 index 0000000000..a1e2da9340 --- /dev/null +++ b/test/incremental/unwrap_error_union_simple_errors.0.zig @@ -0,0 +1,10 @@ +pub fn main() void { + maybeErr() catch unreachable; +} + +fn maybeErr() !void { + return; +} + +// run +// diff --git a/test/incremental/unwrap_error_union_simple_errors.1.zig b/test/incremental/unwrap_error_union_simple_errors.1.zig new file mode 100644 index 0000000000..830ee629bc --- /dev/null +++ b/test/incremental/unwrap_error_union_simple_errors.1.zig @@ -0,0 +1,11 @@ +pub fn main() void { + maybeErr() catch return; + unreachable; +} + +fn maybeErr() !void { + return error.NoWay; +} + +// run +// diff --git a/test/incremental/variable_shadowing.0.zig b/test/incremental/variable_shadowing.0.zig new file mode 100644 index 0000000000..0ab53a78f9 --- /dev/null +++ b/test/incremental/variable_shadowing.0.zig @@ -0,0 +1,9 @@ +pub fn main() void { + var i: u32 = 10; + var i: u32 = 10; +} + +// error +// +// :3:9: error: redeclaration of local variable 'i' +// :2:9: note: previous declaration here diff --git a/test/incremental/variable_shadowing.1.zig b/test/incremental/variable_shadowing.1.zig new file mode 100644 index 0000000000..af24af038d --- /dev/null +++ b/test/incremental/variable_shadowing.1.zig @@ -0,0 +1,9 @@ +var testing: i64 = 10; +pub fn main() void { + var testing: i64 = 20; +} + +// error +// +// :3:9: error: local shadows declaration of 'testing' +// :1:1: note: declared here diff --git a/test/incremental/variable_shadowing.2.zig b/test/incremental/variable_shadowing.2.zig new file mode 100644 index 0000000000..a44372f9b9 --- /dev/null +++ b/test/incremental/variable_shadowing.2.zig @@ -0,0 +1,13 @@ +fn a() type { + return struct { + pub fn b() void { + const c = 6; + const c = 69; + } + }; +} + +// error +// +// :5:19: error: redeclaration of local constant 'c' +// :4:19: note: previous declaration here diff --git a/test/incremental/variable_shadowing.3.zig b/test/incremental/variable_shadowing.3.zig new file mode 100644 index 0000000000..89288705e1 --- /dev/null +++ b/test/incremental/variable_shadowing.3.zig @@ -0,0 +1,10 @@ +pub fn main() void { + var i = 0; + for ("n") |_, i| { + } +} + +// error +// +// :3:19: error: redeclaration of local variable 'i' +// :2:9: note: previous declaration here diff --git a/test/incremental/variable_shadowing.4.zig b/test/incremental/variable_shadowing.4.zig new file mode 100644 index 0000000000..b798cc13c1 --- /dev/null +++ b/test/incremental/variable_shadowing.4.zig @@ -0,0 +1,10 @@ +pub fn main() void { + var i = 0; + for ("n") |i| { + } +} + +// error +// +// :3:16: error: redeclaration of local variable 'i' +// :2:9: note: previous declaration here diff --git a/test/incremental/variable_shadowing.5.zig b/test/incremental/variable_shadowing.5.zig new file mode 100644 index 0000000000..484d218ea2 --- /dev/null +++ b/test/incremental/variable_shadowing.5.zig @@ -0,0 +1,10 @@ +pub fn main() void { + var i = 0; + while ("n") |i| { + } +} + +// error +// +// :3:18: error: redeclaration of local variable 'i' +// :2:9: note: previous declaration here diff --git a/test/incremental/variable_shadowing.6.zig b/test/incremental/variable_shadowing.6.zig new file mode 100644 index 0000000000..3e53c4da2f --- /dev/null +++ b/test/incremental/variable_shadowing.6.zig @@ -0,0 +1,13 @@ +pub fn main() void { + var i = 0; + while ("n") |bruh| { + _ = bruh; + } else |i| { + + } +} + +// error +// +// :5:13: error: redeclaration of local variable 'i' +// :2:9: note: previous declaration here diff --git a/test/incremental/variable_shadowing.7.zig b/test/incremental/variable_shadowing.7.zig new file mode 100644 index 0000000000..95888839a7 --- /dev/null +++ b/test/incremental/variable_shadowing.7.zig @@ -0,0 +1,9 @@ +pub fn main() void { + var i = 0; + if (true) |i| {} +} + +// error +// +// :3:16: error: redeclaration of local variable 'i' +// :2:9: note: previous declaration here diff --git a/test/incremental/variable_shadowing.8.zig b/test/incremental/variable_shadowing.8.zig new file mode 100644 index 0000000000..57e616e1d6 --- /dev/null +++ b/test/incremental/variable_shadowing.8.zig @@ -0,0 +1,9 @@ +pub fn main() void { + var i = 0; + if (true) |i| {} else |e| {} +} + +// error +// +// :3:16: error: redeclaration of local variable 'i' +// :2:9: note: previous declaration here diff --git a/test/incremental/variable_shadowing.9.zig b/test/incremental/variable_shadowing.9.zig new file mode 100644 index 0000000000..b8a1198aed --- /dev/null +++ b/test/incremental/variable_shadowing.9.zig @@ -0,0 +1,9 @@ +pub fn main() void { + var i = 0; + if (true) |_| {} else |i| {} +} + +// error +// +// :3:28: error: redeclaration of local variable 'i' +// :2:9: note: previous declaration here From e4a8a665040b22b52519b68433ed58b1e34f841d Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Wed, 27 Apr 2022 17:53:24 +0200 Subject: [PATCH 11/26] test: remove incremental tests that were ported to the new harness --- test/stage2/x86_64.zig | 2295 +--------------------------------------- 1 file changed, 33 insertions(+), 2262 deletions(-) diff --git a/test/stage2/x86_64.zig b/test/stage2/x86_64.zig index 214b32b025..a4c506400a 100644 --- a/test/stage2/x86_64.zig +++ b/test/stage2/x86_64.zig @@ -16,2273 +16,44 @@ const all_targets: []const CrossTarget = &[_]CrossTarget{ }; pub fn addCases(ctx: *TestContext) !void { - try addLinuxTestCases(ctx); - try addMacOsTestCases(ctx); - - // Common tests for (all_targets) |target| { - { - var case = ctx.exe("adding numbers at runtime and comptime", target); - case.addCompareOutput( - \\pub fn main() void { - \\ add(3, 4); - \\} - \\ - \\fn add(a: u32, b: u32) void { - \\ if (a + b != 7) unreachable; - \\} - , - "", - ); - // comptime function call - case.addCompareOutput( - \\pub fn main() void { - \\ if (x - 7 != 0) unreachable; - \\} - \\ - \\fn add(a: u32, b: u32) u32 { - \\ return a + b; - \\} - \\ - \\const x = add(3, 4); - , - "", - ); - // Inline function call - case.addCompareOutput( - \\pub fn main() void { - \\ var x: usize = 3; - \\ const y = add(1, 2, x); - \\ if (y - 6 != 0) unreachable; - \\} - \\ - \\fn add(a: usize, b: usize, c: usize) callconv(.Inline) usize { - \\ return a + b + c; - \\} - , - "", - ); - } - - { - var case = ctx.exe("subtracting numbers at runtime", target); - case.addCompareOutput( - \\pub fn main() void { - \\ sub(7, 4); - \\} - \\ - \\fn sub(a: u32, b: u32) void { - \\ if (a - b != 3) unreachable; - \\} - , - "", - ); - } - - { - var case = ctx.exe("unused vars", target); - case.addError( - \\pub fn main() void { - \\ const x = 1; - \\} - , &.{":2:11: error: unused local constant"}); - } - - { - var case = ctx.exe("multiplying numbers at runtime and comptime", target); - case.addCompareOutput( - \\pub fn main() void { - \\ mul(3, 4); - \\} - \\ - \\fn mul(a: u32, b: u32) void { - \\ if (a * b != 12) unreachable; - \\} - , - "", - ); - // comptime function call - case.addCompareOutput( - \\pub fn main() void { - \\ if (x - 12 != 0) unreachable; - \\} - \\ - \\fn mul(a: u32, b: u32) u32 { - \\ return a * b; - \\} - \\ - \\const x = mul(3, 4); - , - "", - ); - // Inline function call - case.addCompareOutput( - \\pub fn main() void { - \\ var x: usize = 5; - \\ const y = mul(2, 3, x); - \\ if (y - 30 != 0) unreachable; - \\} - \\ - \\fn mul(a: usize, b: usize, c: usize) callconv(.Inline) usize { - \\ return a * b * c; - \\} - , - "", - ); - } - - { - var case = ctx.exe("assert function", target); - case.addCompareOutput( - \\pub fn main() void { - \\ add(3, 4); - \\} - \\ - \\fn add(a: u32, b: u32) void { - \\ assert(a + b == 7); - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - - // Tests copying a register. For the `c = a + b`, it has to - // preserve both a and b, because they are both used later. - case.addCompareOutput( - \\pub fn main() void { - \\ add(3, 4); - \\} - \\ - \\fn add(a: u32, b: u32) void { - \\ const c = a + b; // 7 - \\ const d = a + c; // 10 - \\ const e = d + b; // 14 - \\ assert(e == 14); - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - - // More stress on the liveness detection. - case.addCompareOutput( - \\pub fn main() void { - \\ add(3, 4); - \\} - \\ - \\fn add(a: u32, b: u32) void { - \\ const c = a + b; // 7 - \\ const d = a + c; // 10 - \\ const e = d + b; // 14 - \\ const f = d + e; // 24 - \\ const g = e + f; // 38 - \\ const h = f + g; // 62 - \\ const i = g + h; // 100 - \\ assert(i == 100); - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - - // Requires a second move. The register allocator should figure out to re-use rax. - case.addCompareOutput( - \\pub fn main() void { - \\ add(3, 4); - \\} - \\ - \\fn add(a: u32, b: u32) void { - \\ const c = a + b; // 7 - \\ const d = a + c; // 10 - \\ const e = d + b; // 14 - \\ const f = d + e; // 24 - \\ const g = e + f; // 38 - \\ const h = f + g; // 62 - \\ const i = g + h; // 100 - \\ const j = i + d; // 110 - \\ assert(j == 110); - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - - // Now we test integer return values. - case.addCompareOutput( - \\pub fn main() void { - \\ assert(add(3, 4) == 7); - \\ assert(add(20, 10) == 30); - \\} - \\ - \\fn add(a: u32, b: u32) u32 { - \\ return a + b; - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - - // Local mutable variables. - case.addCompareOutput( - \\pub fn main() void { - \\ assert(add(3, 4) == 7); - \\ assert(add(20, 10) == 30); - \\} - \\ - \\fn add(a: u32, b: u32) u32 { - \\ var x: u32 = undefined; - \\ x = 0; - \\ x += a; - \\ x += b; - \\ return x; - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - - // Optionals - case.addCompareOutput( - \\pub fn main() void { - \\ const a: u32 = 2; - \\ const b: ?u32 = a; - \\ const c = b.?; - \\ if (c != 2) unreachable; - \\} - , - "", - ); - - switch (target.getOsTag()) { - .linux => { - // While loops - case.addCompareOutput( - \\pub fn main() void { - \\ var i: u32 = 0; - \\ while (i < 4) : (i += 1) print(); - \\ assert(i == 4); - \\} - \\ - \\fn print() void { - \\ asm volatile ("syscall" - \\ : - \\ : [number] "{rax}" (1), - \\ [arg1] "{rdi}" (1), - \\ [arg2] "{rsi}" (@ptrToInt("hello\n")), - \\ [arg3] "{rdx}" (6) - \\ : "rcx", "r11", "memory" - \\ ); - \\ return; - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "hello\nhello\nhello\nhello\n", - ); - - // inline while requires the condition to be comptime known. - case.addError( - \\pub fn main() void { - \\ var i: u32 = 0; - \\ inline while (i < 4) : (i += 1) print(); - \\ assert(i == 4); - \\} - \\ - \\fn print() void { - \\ asm volatile ("syscall" - \\ : - \\ : [number] "{rax}" (1), - \\ [arg1] "{rdi}" (1), - \\ [arg2] "{rsi}" (@ptrToInt("hello\n")), - \\ [arg3] "{rdx}" (6) - \\ : "rcx", "r11", "memory" - \\ ); - \\ return; - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , &[_][]const u8{":3:21: error: unable to resolve comptime value"}); - }, - .macos => { - // While loops - case.addCompareOutput( - \\extern "c" fn write(usize, usize, usize) usize; - \\ - \\pub fn main() void { - \\ var i: u32 = 0; - \\ while (i < 4) : (i += 1) print(); - \\ assert(i == 4); - \\} - \\ - \\fn print() void { - \\ _ = write(1, @ptrToInt("hello\n"), 6); - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "hello\nhello\nhello\nhello\n", - ); - - // inline while requires the condition to be comptime known. - case.addError( - \\extern "c" fn write(usize, usize, usize) usize; - \\ - \\pub fn main() void { - \\ var i: u32 = 0; - \\ inline while (i < 4) : (i += 1) print(); - \\ assert(i == 4); - \\} - \\ - \\fn print() void { - \\ _ = write(1, @ptrToInt("hello\n"), 6); - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , &[_][]const u8{":5:21: error: unable to resolve comptime value"}); - }, - else => unreachable, - } - - // Labeled blocks (no conditional branch) - case.addCompareOutput( - \\pub fn main() void { - \\ assert(add(3, 4) == 20); - \\} - \\ - \\fn add(a: u32, b: u32) u32 { - \\ const x: u32 = blk: { - \\ const c = a + b; // 7 - \\ const d = a + c; // 10 - \\ const e = d + b; // 14 - \\ break :blk e; - \\ }; - \\ const y = x + a; // 17 - \\ const z = y + a; // 20 - \\ return z; - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - - // This catches a possible bug in the logic for re-using dying operands. - case.addCompareOutput( - \\pub fn main() void { - \\ assert(add(3, 4) == 116); - \\} - \\ - \\fn add(a: u32, b: u32) u32 { - \\ const x: u32 = blk: { - \\ const c = a + b; // 7 - \\ const d = a + c; // 10 - \\ const e = d + b; // 14 - \\ const f = d + e; // 24 - \\ const g = e + f; // 38 - \\ const h = f + g; // 62 - \\ const i = g + h; // 100 - \\ const j = i + d; // 110 - \\ break :blk j; - \\ }; - \\ const y = x + a; // 113 - \\ const z = y + a; // 116 - \\ return z; - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - - // Spilling registers to the stack. - case.addCompareOutput( - \\pub fn main() void { - \\ assert(add(3, 4) == 1221); - \\ assert(mul(3, 4) == 21609); - \\} - \\ - \\fn add(a: u32, b: u32) u32 { - \\ const x: u32 = blk: { - \\ const c = a + b; // 7 - \\ const d = a + c; // 10 - \\ const e = d + b; // 14 - \\ const f = d + e; // 24 - \\ const g = e + f; // 38 - \\ const h = f + g; // 62 - \\ const i = g + h; // 100 - \\ const j = i + d; // 110 - \\ const k = i + j; // 210 - \\ const l = j + k; // 320 - \\ const m = l + c; // 327 - \\ const n = m + d; // 337 - \\ const o = n + e; // 351 - \\ const p = o + f; // 375 - \\ const q = p + g; // 413 - \\ const r = q + h; // 475 - \\ const s = r + i; // 575 - \\ const t = s + j; // 685 - \\ const u = t + k; // 895 - \\ const v = u + l; // 1215 - \\ break :blk v; - \\ }; - \\ const y = x + a; // 1218 - \\ const z = y + a; // 1221 - \\ return z; - \\} - \\ - \\fn mul(a: u32, b: u32) u32 { - \\ const x: u32 = blk: { - \\ const c = a * a * a * a; // 81 - \\ const d = a * a * a * b; // 108 - \\ const e = a * a * b * a; // 108 - \\ const f = a * a * b * b; // 144 - \\ const g = a * b * a * a; // 108 - \\ const h = a * b * a * b; // 144 - \\ const i = a * b * b * a; // 144 - \\ const j = a * b * b * b; // 192 - \\ const k = b * a * a * a; // 108 - \\ const l = b * a * a * b; // 144 - \\ const m = b * a * b * a; // 144 - \\ const n = b * a * b * b; // 192 - \\ const o = b * b * a * a; // 144 - \\ const p = b * b * a * b; // 192 - \\ const q = b * b * b * a; // 192 - \\ const r = b * b * b * b; // 256 - \\ const s = c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r; // 2401 - \\ break :blk s; - \\ }; - \\ const y = x * a; // 7203 - \\ const z = y * a; // 21609 - \\ return z; - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - - // Reusing the registers of dead operands playing nicely with conditional branching. - case.addCompareOutput( - \\pub fn main() void { - \\ assert(add(3, 4) == 791); - \\ assert(add(4, 3) == 79); - \\} - \\ - \\fn add(a: u32, b: u32) u32 { - \\ const x: u32 = if (a < b) blk: { - \\ const c = a + b; // 7 - \\ const d = a + c; // 10 - \\ const e = d + b; // 14 - \\ const f = d + e; // 24 - \\ const g = e + f; // 38 - \\ const h = f + g; // 62 - \\ const i = g + h; // 100 - \\ const j = i + d; // 110 - \\ const k = i + j; // 210 - \\ const l = k + c; // 217 - \\ const m = l + d; // 227 - \\ const n = m + e; // 241 - \\ const o = n + f; // 265 - \\ const p = o + g; // 303 - \\ const q = p + h; // 365 - \\ const r = q + i; // 465 - \\ const s = r + j; // 575 - \\ const t = s + k; // 785 - \\ break :blk t; - \\ } else blk: { - \\ const t = b + b + a; // 10 - \\ const c = a + t; // 14 - \\ const d = c + t; // 24 - \\ const e = d + t; // 34 - \\ const f = e + t; // 44 - \\ const g = f + t; // 54 - \\ const h = c + g; // 68 - \\ break :blk h + b; // 71 - \\ }; - \\ const y = x + a; // 788, 75 - \\ const z = y + a; // 791, 79 - \\ return z; - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - - // Character literals and multiline strings. - case.addCompareOutput( - \\pub fn main() void { - \\ const ignore = - \\ \\ cool thx - \\ \\ - \\ ; - \\ _ = ignore; - \\ add('ぁ', '\x03'); - \\} - \\ - \\fn add(a: u32, b: u32) void { - \\ assert(a + b == 12356); - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - - // Global const. - case.addCompareOutput( - \\pub fn main() void { - \\ add(aa, bb); - \\} - \\ - \\const aa = 'ぁ'; - \\const bb = '\x03'; - \\ - \\fn add(a: u32, b: u32) void { - \\ assert(a + b == 12356); - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - - // Array access. - case.addCompareOutput( - \\pub fn main() void { - \\ assert("hello"[0] == 'h'); - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - - // Array access to a global array. - case.addCompareOutput( - \\const hello = "hello".*; - \\pub fn main() void { - \\ assert(hello[1] == 'e'); - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - - // 64bit set stack - case.addCompareOutput( - \\pub fn main() void { - \\ var i: u64 = 0xFFEEDDCCBBAA9988; - \\ assert(i == 0xFFEEDDCCBBAA9988); - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - - switch (target.getOsTag()) { - .linux => { - // Basic for loop - case.addCompareOutput( - \\pub fn main() void { - \\ for ("hello") |_| print(); - \\} - \\ - \\fn print() void { - \\ asm volatile ("syscall" - \\ : - \\ : [number] "{rax}" (1), - \\ [arg1] "{rdi}" (1), - \\ [arg2] "{rsi}" (@ptrToInt("hello\n")), - \\ [arg3] "{rdx}" (6) - \\ : "rcx", "r11", "memory" - \\ ); - \\ return; - \\} - , - "hello\nhello\nhello\nhello\nhello\n", - ); - }, - .macos => { - // Basic for loop - case.addCompareOutput( - \\extern "c" fn write(usize, usize, usize) usize; - \\ - \\pub fn main() void { - \\ for ("hello") |_| print(); - \\} - \\ - \\fn print() void { - \\ _ = write(1, @ptrToInt("hello\n"), 6); - \\} - , - "hello\nhello\nhello\nhello\nhello\n", - ); - }, - else => unreachable, - } - } - - { - var case = ctx.exe("@TypeOf", target); - case.addCompareOutput( - \\pub fn main() void { - \\ var x: usize = 0; - \\ _ = x; - \\ const z = @TypeOf(x, @as(u128, 5)); - \\ assert(z == u128); - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - case.addCompareOutput( - \\pub fn main() void { - \\ const z = @TypeOf(true); - \\ assert(z == bool); - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - case.addError( - \\pub fn main() void { - \\ _ = @TypeOf(true, 1); - \\} - , &[_][]const u8{ - ":2:9: error: incompatible types: 'bool' and 'comptime_int'", - ":2:17: note: type 'bool' here", - ":2:23: note: type 'comptime_int' here", - }); - } - - { - var case = ctx.exe("basic import", target); - case.addCompareOutput( - \\pub fn main() void { - \\ @import("print.zig").print(); - \\} - , - "Hello, World!\n", - ); - switch (target.getOsTag()) { - .linux => try case.files.append(.{ - .src = - \\pub fn print() void { - \\ asm volatile ("syscall" - \\ : - \\ : [number] "{rax}" (@as(usize, 1)), - \\ [arg1] "{rdi}" (@as(usize, 1)), - \\ [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), - \\ [arg3] "{rdx}" (@as(usize, 14)) - \\ : "rcx", "r11", "memory" - \\ ); - \\ return; - \\} - , - .path = "print.zig", - }), - .macos => try case.files.append(.{ - .src = - \\extern "c" fn write(usize, usize, usize) usize; - \\ - \\pub fn print() void { - \\ _ = write(1, @ptrToInt("Hello, World!\n"), 14); - \\} - , - .path = "print.zig", - }), - else => unreachable, - } - } - - { - var case = ctx.exe("redundant comptime", target); - case.addError( - \\pub fn main() void { - \\ var a: comptime u32 = 0; - \\} - , - &.{":2:12: error: redundant comptime keyword in already comptime scope"}, - ); - case.addError( - \\pub fn main() void { - \\ comptime { - \\ var a: u32 = comptime 0; - \\ } - \\} - , - &.{":3:22: error: redundant comptime keyword in already comptime scope"}, - ); - } - { - var case = ctx.exe("try in comptime in struct in test", target); - case.addError( - \\test "@unionInit on union w/ tag but no fields" { - \\ const S = struct { - \\ comptime { - \\ try expect(false); - \\ } - \\ }; - \\ _ = S; - \\} - , - &.{":4:13: error: 'try' outside function scope"}, - ); - } - { - var case = ctx.exe("import private", target); - case.addError( - \\pub fn main() void { - \\ @import("print.zig").print(); - \\} - , - &.{ - ":2:25: error: 'print' is not marked 'pub'", - "print.zig:2:1: note: declared here", - }, - ); - switch (target.getOsTag()) { - .linux => try case.files.append(.{ - .src = - \\// dummy comment to make print be on line 2 - \\fn print() void { - \\ asm volatile ("syscall" - \\ : - \\ : [number] "{rax}" (@as(usize, 1)), - \\ [arg1] "{rdi}" (@as(usize, 1)), - \\ [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), - \\ [arg3] "{rdx}" (@as(usize, 14)) - \\ : "rcx", "r11", "memory" - \\ ); - \\ return; - \\} - , - .path = "print.zig", - }), - .macos => try case.files.append(.{ - .src = - \\extern "c" fn write(usize, usize, usize) usize; - \\fn print() void { - \\ _ = write(1, @ptrToInt("Hello, World!\n"), 14); - \\} - , - .path = "print.zig", - }), - else => unreachable, - } - } - - ctx.compileError("function redeclaration", target, - \\// dummy comment - \\fn entry() void {} - \\fn entry() void {} - \\ - \\fn foo() void { - \\ var foo = 1234; + // TODO port this to the new test harness + var case = ctx.exe("basic import", target); + case.addCompareOutput( + \\pub fn main() void { + \\ @import("print.zig").print(); \\} - , &[_][]const u8{ - ":3:1: error: redeclaration of 'entry'", - ":2:1: note: other declaration here", - ":6:9: error: local shadows declaration of 'foo'", - ":5:1: note: declared here", - }); - - ctx.compileError("returns in try", target, - \\pub fn main() !void { - \\ try a(); - \\ try b(); - \\} - \\ - \\pub fn a() !void { - \\ defer try b(); - \\} - \\pub fn b() !void { - \\ defer return a(); - \\} - , &[_][]const u8{ - ":7:8: error: 'try' not allowed inside defer expression", - ":10:8: error: cannot return from defer expression", - }); - - ctx.compileError("ambiguous references", target, - \\const T = struct { - \\ const T = struct { - \\ fn f() void { - \\ _ = T; - \\ } - \\ }; - \\}; - , &.{ - ":4:17: error: ambiguous reference", - ":2:5: note: declared here", - ":1:1: note: also declared here", - }); - - ctx.compileError("inner func accessing outer var", target, - \\pub fn f() void { - \\ var bar: bool = true; - \\ const S = struct { - \\ fn baz() bool { - \\ return bar; - \\ } - \\ }; - \\ _ = S; - \\} - , &.{ - ":5:20: error: mutable 'bar' not accessible from here", - ":2:9: note: declared mutable here", - ":3:15: note: crosses namespace boundary here", - }); - - ctx.compileError("global variable redeclaration", target, - \\// dummy comment - \\var foo = false; - \\var foo = true; - , &[_][]const u8{ - ":3:1: error: redeclaration of 'foo'", - ":2:1: note: other declaration here", - }); - - ctx.compileError("compileError", target, - \\export fn foo() void { - \\ @compileError("this is an error"); - \\} - , &[_][]const u8{":2:3: error: this is an error"}); - - { - var case = ctx.exe("intToPtr", target); - case.addError( - \\pub fn main() void { - \\ _ = @intToPtr(*u8, 0); - \\} - , &[_][]const u8{ - ":2:24: error: pointer type '*u8' does not allow address zero", - }); - case.addError( - \\pub fn main() void { - \\ _ = @intToPtr(*u32, 2); - \\} - , &[_][]const u8{ - ":2:25: error: pointer type '*u32' requires aligned address", - }); - } - - { - var case = ctx.obj("variable shadowing", target); - case.addError( - \\pub fn main() void { - \\ var i: u32 = 10; - \\ var i: u32 = 10; - \\} - , &[_][]const u8{ - ":3:9: error: redeclaration of local variable 'i'", - ":2:9: note: previous declaration here", - }); - case.addError( - \\var testing: i64 = 10; - \\pub fn main() void { - \\ var testing: i64 = 20; - \\} - , &[_][]const u8{ - ":3:9: error: local shadows declaration of 'testing'", - ":1:1: note: declared here", - }); - case.addError( - \\fn a() type { - \\ return struct { - \\ pub fn b() void { - \\ const c = 6; - \\ const c = 69; - \\ } - \\ }; - \\} - , &[_][]const u8{ - ":5:19: error: redeclaration of local constant 'c'", - ":4:19: note: previous declaration here", - }); - case.addError( - \\pub fn main() void { - \\ var i = 0; - \\ for ("n") |_, i| { - \\ } - \\} - , &[_][]const u8{ - ":3:19: error: redeclaration of local variable 'i'", - ":2:9: note: previous declaration here", - }); - case.addError( - \\pub fn main() void { - \\ var i = 0; - \\ for ("n") |i| { - \\ } - \\} - , &[_][]const u8{ - ":3:16: error: redeclaration of local variable 'i'", - ":2:9: note: previous declaration here", - }); - case.addError( - \\pub fn main() void { - \\ var i = 0; - \\ while ("n") |i| { - \\ } - \\} - , &[_][]const u8{ - ":3:18: error: redeclaration of local variable 'i'", - ":2:9: note: previous declaration here", - }); - case.addError( - \\pub fn main() void { - \\ var i = 0; - \\ while ("n") |bruh| { - \\ _ = bruh; - \\ } else |i| { - \\ - \\ } - \\} - , &[_][]const u8{ - ":5:13: error: redeclaration of local variable 'i'", - ":2:9: note: previous declaration here", - }); - case.addError( - \\pub fn main() void { - \\ var i = 0; - \\ if (true) |i| {} - \\} - , &[_][]const u8{ - ":3:16: error: redeclaration of local variable 'i'", - ":2:9: note: previous declaration here", - }); - case.addError( - \\pub fn main() void { - \\ var i = 0; - \\ if (true) |i| {} else |e| {} - \\} - , &[_][]const u8{ - ":3:16: error: redeclaration of local variable 'i'", - ":2:9: note: previous declaration here", - }); - case.addError( - \\pub fn main() void { - \\ var i = 0; - \\ if (true) |_| {} else |i| {} - \\} - , &[_][]const u8{ - ":3:28: error: redeclaration of local variable 'i'", - ":2:9: note: previous declaration here", - }); - } - - { - // TODO make the test harness support checking the compile log output too - var case = ctx.obj("@compileLog", target); - // The other compile error prevents emission of a "found compile log" statement. - case.addError( - \\export fn _start() noreturn { - \\ const b = true; - \\ var f: u32 = 1; - \\ @compileLog(b, 20, f, x); - \\ @compileLog(1000); - \\ var bruh: usize = true; - \\ _ = bruh; - \\ unreachable; - \\} - \\export fn other() void { - \\ @compileLog(1234); - \\} - \\fn x() void {} - , &[_][]const u8{ - ":6:23: error: expected usize, found bool", - }); - - // Now only compile log statements remain. One per Decl. - case.addError( - \\export fn _start() noreturn { - \\ const b = true; - \\ var f: u32 = 1; - \\ @compileLog(b, 20, f, x); - \\ @compileLog(1000); - \\ unreachable; - \\} - \\export fn other() void { - \\ @compileLog(1234); - \\} - \\fn x() void {} - , &[_][]const u8{ - ":9:5: error: found compile log statement", - ":4:5: note: also here", - }); - } - - { - var case = ctx.obj("extern variable has no type", target); - case.addError( - \\comptime { - \\ const x = foo + foo; - \\ _ = x; - \\} - \\extern var foo: i32; - , &[_][]const u8{":2:15: error: unable to resolve comptime value"}); - case.addError( - \\export fn entry() void { - \\ _ = foo; - \\} - \\extern var foo; - , &[_][]const u8{":4:8: error: unable to infer variable type"}); - } - - { - var case = ctx.exe("break/continue", target); - - // Break out of loop - case.addCompareOutput( - \\pub fn main() void { - \\ while (true) { - \\ break; - \\ } - \\} - , - "", - ); - case.addCompareOutput( - \\pub fn main() void { - \\ foo: while (true) { - \\ break :foo; - \\ } - \\} - , - "", - ); - - // Continue in loop - case.addCompareOutput( - \\pub fn main() void { - \\ var i: u64 = 0; - \\ while (true) : (i+=1) { - \\ if (i == 4) return; - \\ continue; - \\ } - \\} - , - "", - ); - case.addCompareOutput( - \\pub fn main() void { - \\ var i: u64 = 0; - \\ foo: while (true) : (i+=1) { - \\ if (i == 4) return; - \\ continue :foo; - \\ } - \\} - , - "", - ); - } - - { - var case = ctx.exe("unused labels", target); - case.addError( - \\comptime { - \\ foo: {} - \\} - , &[_][]const u8{":2:5: error: unused block label"}); - case.addError( - \\comptime { - \\ foo: while (true) {} - \\} - , &[_][]const u8{":2:5: error: unused while loop label"}); - case.addError( - \\comptime { - \\ foo: for ("foo") |_| {} - \\} - , &[_][]const u8{":2:5: error: unused for loop label"}); - case.addError( - \\comptime { - \\ blk: {blk: {}} - \\} - , &[_][]const u8{ - ":2:11: error: redefinition of label 'blk'", - ":2:5: note: previous definition here", - }); - } - - { - var case = ctx.exe("bad inferred variable type", target); - case.addError( - \\pub fn main() void { - \\ var x = null; - \\ _ = x; - \\} - , &[_][]const u8{ - ":2:9: error: variable of type '@TypeOf(null)' must be const or comptime", - }); - } - - { - var case = ctx.exe("compile error in inline fn call fixed", target); - case.addError( - \\pub fn main() void { - \\ var x: usize = 3; - \\ const y = add(10, 2, x); - \\ if (y - 6 != 0) unreachable; - \\} - \\ - \\fn add(a: usize, b: usize, c: usize) callconv(.Inline) usize { - \\ if (a == 10) @compileError("bad"); - \\ return a + b + c; - \\} - , &[_][]const u8{ - ":8:18: error: bad", - ":3:18: note: called from here", - }); - - case.addCompareOutput( - \\pub fn main() void { - \\ var x: usize = 3; - \\ const y = add(1, 2, x); - \\ if (y - 6 != 0) unreachable; - \\} - \\ - \\fn add(a: usize, b: usize, c: usize) callconv(.Inline) usize { - \\ if (a == 10) @compileError("bad"); - \\ return a + b + c; - \\} - , - "", - ); - } - { - var case = ctx.exe("recursive inline function", target); - case.addCompareOutput( - \\pub fn main() void { - \\ const y = fibonacci(7); - \\ if (y - 21 != 0) unreachable; - \\} - \\ - \\fn fibonacci(n: usize) callconv(.Inline) usize { - \\ if (n <= 2) return n; - \\ return fibonacci(n - 2) + fibonacci(n - 1); - \\} - , - "", - ); - // This additionally tests that the compile error reports the correct source location. - // Without storing source locations relative to the owner decl, the compile error - // here would be off by 2 bytes (from the "7" -> "999"). - case.addError( - \\pub fn main() void { - \\ const y = fibonacci(999); - \\ if (y - 21 != 0) unreachable; - \\} - \\ - \\fn fibonacci(n: usize) callconv(.Inline) usize { - \\ if (n <= 2) return n; - \\ return fibonacci(n - 2) + fibonacci(n - 1); - \\} - , &[_][]const u8{":8:21: error: evaluation exceeded 1000 backwards branches"}); - } - { - var case = ctx.exe("orelse at comptime", target); - case.addCompareOutput( - \\pub fn main() void { - \\ const i: ?u64 = 0; - \\ const result = i orelse 5; - \\ assert(result == 0); - \\} - \\fn assert(b: bool) void { - \\ if (!b) unreachable; - \\} - , - "", - ); - case.addCompareOutput( - \\pub fn main() void { - \\ const i: ?u64 = null; - \\ const result = i orelse 5; - \\ assert(result == 5); - \\} - \\fn assert(b: bool) void { - \\ if (!b) unreachable; - \\} - , - "", - ); - } - - { - var case = ctx.exe("passing u0 to function", target); - case.addCompareOutput( - \\pub fn main() void { - \\ doNothing(0); - \\} - \\fn doNothing(arg: u0) void { - \\ _ = arg; - \\} - , - "", - ); - } - - { - var case = ctx.exe("catch at comptime", target); - case.addCompareOutput( - \\pub fn main() void { - \\ const i: anyerror!u64 = 0; - \\ const caught = i catch 5; - \\ assert(caught == 0); - \\} - \\fn assert(b: bool) void { - \\ if (!b) unreachable; - \\} - , - "", - ); - - case.addCompareOutput( - \\pub fn main() void { - \\ const i: anyerror!u64 = error.B; - \\ const caught = i catch 5; - \\ assert(caught == 5); - \\} - \\fn assert(b: bool) void { - \\ if (!b) unreachable; - \\} - , - "", - ); - - case.addCompareOutput( - \\pub fn main() void { - \\ const a: anyerror!comptime_int = 42; - \\ const b: *const comptime_int = &(a catch unreachable); - \\ assert(b.* == 42); - \\} - \\fn assert(b: bool) void { - \\ if (!b) unreachable; // assertion failure - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ const a: anyerror!u32 = error.B; - \\ _ = &(a catch |err| assert(err == error.B)); - \\} - \\fn assert(b: bool) void { - \\ if (!b) unreachable; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ const a: anyerror!u32 = error.Bar; - \\ a catch |err| assert(err == error.Bar); - \\} - \\fn assert(b: bool) void { - \\ if (!b) unreachable; - \\} - , ""); - } - - { - var case = ctx.exe("runtime bitwise and", target); - - case.addCompareOutput( - \\pub fn main() void { - \\ var i: u32 = 10; - \\ var j: u32 = 11; - \\ assert(i & 1 == 0); - \\ assert(j & 1 == 1); - \\ var m1: u32 = 0b1111; - \\ var m2: u32 = 0b0000; - \\ assert(m1 & 0b1010 == 0b1010); - \\ assert(m2 & 0b1010 == 0b0000); - \\} - \\fn assert(b: bool) void { - \\ if (!b) unreachable; - \\} - , - "", - ); - } - - { - var case = ctx.exe("runtime bitwise or", target); - - case.addCompareOutput( - \\pub fn main() void { - \\ var i: u32 = 10; - \\ var j: u32 = 11; - \\ assert(i | 1 == 11); - \\ assert(j | 1 == 11); - \\ var m1: u32 = 0b1111; - \\ var m2: u32 = 0b0000; - \\ assert(m1 | 0b1010 == 0b1111); - \\ assert(m2 | 0b1010 == 0b1010); - \\} - \\fn assert(b: bool) void { - \\ if (!b) unreachable; - \\} - , - "", - ); - } - - { - var case = ctx.exe("merge error sets", target); - - case.addCompareOutput( - \\pub fn main() void { - \\ const E = error{ A, B, D } || error { A, B, C }; - \\ E.A catch {}; - \\ E.B catch {}; - \\ E.C catch {}; - \\ E.D catch {}; - \\ const E2 = error { X, Y } || @TypeOf(error.Z); - \\ E2.X catch {}; - \\ E2.Y catch {}; - \\ E2.Z catch {}; - \\ assert(anyerror || error { Z } == anyerror); - \\} - \\fn assert(b: bool) void { - \\ if (!b) unreachable; - \\} - , - "", - ); - case.addError( - \\pub fn main() void { - \\ const z = true || false; - \\ _ = z; - \\} - , &.{ - ":2:15: error: expected error set type, found 'bool'", - ":2:20: note: '||' merges error sets; 'or' performs boolean OR", - }); - } - - { - var case = ctx.exe("comptime var", target); - - case.addError( - \\pub fn main() void { - \\ var a: u32 = 0; - \\ comptime var b: u32 = 0; - \\ if (a == 0) b = 3; - \\} - , &.{ - ":4:21: error: store to comptime variable depends on runtime condition", - ":4:11: note: runtime condition here", - }); - - case.addError( - \\pub fn main() void { - \\ var a: u32 = 0; - \\ comptime var b: u32 = 0; - \\ switch (a) { - \\ 0 => {}, - \\ else => b = 3, - \\ } - \\} - , &.{ - ":6:21: error: store to comptime variable depends on runtime condition", - ":4:13: note: runtime condition here", - }); - - switch (target.getOsTag()) { - .linux => case.addCompareOutput( - \\pub fn main() void { - \\ comptime var len: u32 = 5; - \\ print(len); - \\ len += 9; - \\ print(len); - \\} - \\ - \\fn print(len: usize) void { - \\ asm volatile ("syscall" - \\ : - \\ : [number] "{rax}" (1), - \\ [arg1] "{rdi}" (1), - \\ [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), - \\ [arg3] "{rdx}" (len) - \\ : "rcx", "r11", "memory" - \\ ); - \\ return; - \\} - , "HelloHello, World!\n"), - .macos => case.addCompareOutput( - \\extern "c" fn write(usize, usize, usize) usize; - \\ - \\pub fn main() void { - \\ comptime var len: u32 = 5; - \\ print(len); - \\ len += 9; - \\ print(len); - \\} - \\ - \\fn print(len: usize) void { - \\ _ = write(1, @ptrToInt("Hello, World!\n"), len); - \\} - , "HelloHello, World!\n"), - - else => unreachable, - } - - case.addError( - \\comptime { - \\ var x: i32 = 1; - \\ x += 1; - \\ if (x != 1) unreachable; - \\} - \\pub fn main() void {} - , &.{":4:17: error: unable to resolve comptime value"}); - - case.addError( - \\pub fn main() void { - \\ comptime var i: u64 = 0; - \\ while (i < 5) : (i += 1) {} - \\} - , &.{ - ":3:24: error: cannot store to comptime variable in non-inline loop", - ":3:5: note: non-inline loop here", - }); - - case.addCompareOutput( - \\pub fn main() void { - \\ var a: u32 = 0; - \\ if (a == 0) { - \\ comptime var b: u32 = 0; - \\ b = 1; - \\ } - \\} - \\comptime { - \\ var x: i32 = 1; - \\ x += 1; - \\ if (x != 2) unreachable; - \\} - , ""); - - switch (target.getOsTag()) { - .linux => case.addCompareOutput( - \\pub fn main() void { - \\ comptime var i: u64 = 2; - \\ inline while (i < 6) : (i+=1) { - \\ print(i); - \\ } - \\} - \\fn print(len: usize) void { - \\ asm volatile ("syscall" - \\ : - \\ : [number] "{rax}" (1), - \\ [arg1] "{rdi}" (1), - \\ [arg2] "{rsi}" (@ptrToInt("Hello")), - \\ [arg3] "{rdx}" (len) - \\ : "rcx", "r11", "memory" - \\ ); - \\ return; - \\} - , "HeHelHellHello"), - .macos => case.addCompareOutput( - \\extern "c" fn write(usize, usize, usize) usize; - \\ - \\pub fn main() void { - \\ comptime var i: u64 = 2; - \\ inline while (i < 6) : (i+=1) { - \\ print(i); - \\ } - \\} - \\fn print(len: usize) void { - \\ _ = write(1, @ptrToInt("Hello"), len); - \\} - , "HeHelHellHello"), - else => unreachable, - } - } - - { - var case = ctx.exe("double ampersand", target); - - case.addError( - \\pub const a = if (true && false) 1 else 2; - , &[_][]const u8{":1:24: error: ambiguous use of '&&'; use 'and' for logical AND, or change whitespace to ' & &' for bitwise AND"}); - - case.addError( - \\pub fn main() void { - \\ const a = true; - \\ const b = false; - \\ _ = a & &b; - \\} - , &[_][]const u8{ - ":4:11: error: incompatible types: 'bool' and '*const bool'", - ":4:9: note: type 'bool' here", - ":4:13: note: type '*const bool' here", - }); - - case.addCompareOutput( - \\pub fn main() void { - \\ const b: u8 = 1; - \\ _ = &&b; - \\} - , ""); - } - - { - var case = ctx.exe("setting an address space on a local variable", target); - case.addError( - \\export fn entry() i32 { - \\ var foo: i32 addrspace(".general") = 1234; - \\ return foo; - \\} - , &[_][]const u8{ - ":2:28: error: cannot set address space of local variable 'foo'", - }); - } - - { - var case = ctx.exe("saving vars of different ABI size to stack", target); - - case.addCompareOutput( - \\pub fn main() void { - \\ assert(callMe(2) == 24); - \\} - \\ - \\fn callMe(a: u8) u8 { - \\ var b: u8 = a + 10; - \\ const c = 2 * b; - \\ return c; - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - - case.addCompareOutput( - \\pub fn main() void { - \\ assert(callMe(2) == 24); - \\} - \\ - \\fn callMe(a: u16) u16 { - \\ var b: u16 = a + 10; - \\ const c = 2 * b; - \\ return c; - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - - case.addCompareOutput( - \\pub fn main() void { - \\ assert(callMe(2) == 24); - \\} - \\ - \\fn callMe(a: u32) u32 { - \\ var b: u32 = a + 10; - \\ const c = 2 * b; - \\ return c; - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - } - { - var case = ctx.exe("issue 7187: miscompilation with bool return type", target); - case.addCompareOutput( - \\pub fn main() void { - \\ var x: usize = 1; - \\ var y: bool = getFalse(); - \\ _ = y; - \\ - \\ assert(x == 1); - \\} - \\ - \\fn getFalse() bool { - \\ return false; - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , ""); - } - - { - var case = ctx.exe("load-store via pointer deref", target); - case.addCompareOutput( - \\pub fn main() void { - \\ var x: u32 = undefined; - \\ set(&x); - \\ assert(x == 123); - \\} - \\ - \\fn set(x: *u32) void { - \\ x.* = 123; - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , ""); - case.addCompareOutput( - \\pub fn main() void { - \\ var x: u16 = undefined; - \\ set(&x); - \\ assert(x == 123); - \\} - \\ - \\fn set(x: *u16) void { - \\ x.* = 123; - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , ""); - case.addCompareOutput( - \\pub fn main() void { - \\ var x: u8 = undefined; - \\ set(&x); - \\ assert(x == 123); - \\} - \\ - \\fn set(x: *u8) void { - \\ x.* = 123; - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , ""); - } - - { - var case = ctx.exe("optional payload", target); - case.addCompareOutput( - \\pub fn main() void { - \\ var x: u32 = undefined; - \\ const maybe_x = byPtr(&x); - \\ assert(maybe_x != null); - \\ maybe_x.?.* = 123; - \\ assert(x == 123); - \\} - \\ - \\fn byPtr(x: *u32) ?*u32 { - \\ return x; - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , ""); - case.addCompareOutput( - \\pub fn main() void { - \\ var x: u32 = undefined; - \\ const maybe_x = byPtr(&x); - \\ assert(maybe_x == null); - \\} - \\ - \\fn byPtr(x: *u32) ?*u32 { - \\ _ = x; - \\ return null; - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , ""); - case.addCompareOutput( - \\pub fn main() void { - \\ var x: u8 = undefined; - \\ const maybe_x = byPtr(&x); - \\ assert(maybe_x != null); - \\ maybe_x.?.* = 255; - \\ assert(x == 255); - \\} - \\ - \\fn byPtr(x: *u8) ?*u8 { - \\ return x; - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , ""); - case.addCompareOutput( - \\pub fn main() void { - \\ var x: i8 = undefined; - \\ const maybe_x = byPtr(&x); - \\ assert(maybe_x != null); - \\ maybe_x.?.* = -1; - \\ assert(x == -1); - \\} - \\ - \\fn byPtr(x: *i8) ?*i8 { - \\ return x; - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , ""); - } - - { - var case = ctx.exe("unwrap error union - simple errors", target); - case.addCompareOutput( - \\pub fn main() void { - \\ maybeErr() catch unreachable; - \\} - \\ - \\fn maybeErr() !void { + , + "Hello, World!\n", + ); + switch (target.getOsTag()) { + .linux => try case.files.append(.{ + .src = + \\pub fn print() void { + \\ asm volatile ("syscall" + \\ : + \\ : [number] "{rax}" (@as(usize, 1)), + \\ [arg1] "{rdi}" (@as(usize, 1)), + \\ [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), + \\ [arg3] "{rdx}" (@as(usize, 14)) + \\ : "rcx", "r11", "memory" + \\ ); \\ return; \\} - , ""); - case.addCompareOutput( - \\pub fn main() void { - \\ maybeErr() catch return; - \\ unreachable; + , + .path = "print.zig", + }), + .macos => try case.files.append(.{ + .src = + \\extern "c" fn write(usize, usize, usize) usize; + \\ + \\pub fn print() void { + \\ _ = write(1, @ptrToInt("Hello, World!\n"), 14); \\} - \\ - \\fn maybeErr() !void { - \\ return error.NoWay; - \\} - , ""); - } - - { - var case = ctx.exe("access slice element by index - slice_elem_val", target); - case.addCompareOutput( - \\var array = [_]usize{ 0, 42, 123, 34 }; - \\var slice: []const usize = &array; - \\ - \\pub fn main() void { - \\ assert(slice[0] == 0); - \\ assert(slice[1] == 42); - \\ assert(slice[2] == 123); - \\ assert(slice[3] == 34); - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , ""); - } - - { - var case = ctx.exe("lower unnamed constants - structs", target); - case.addCompareOutput( - \\const Foo = struct { - \\ a: u8, - \\ b: u32, - \\ - \\ fn first(self: *Foo) u8 { - \\ return self.a; - \\ } - \\ - \\ fn second(self: *Foo) u32 { - \\ return self.b; - \\ } - \\}; - \\ - \\pub fn main() void { - \\ var foo = Foo{ .a = 1, .b = 5 }; - \\ assert(foo.first() == 1); - \\ assert(foo.second() == 5); - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , ""); - - case.addCompareOutput( - \\const Foo = struct { - \\ a: u8, - \\ b: u32, - \\ - \\ fn first(self: *Foo) u8 { - \\ return self.a; - \\ } - \\ - \\ fn second(self: *Foo) u32 { - \\ return self.b; - \\ } - \\}; - \\ - \\pub fn main() void { - \\ var foo = Foo{ .a = 1, .b = 5 }; - \\ assert(foo.first() == 1); - \\ assert(foo.second() == 5); - \\ - \\ foo.a = 10; - \\ foo.b = 255; - \\ - \\ assert(foo.first() == 10); - \\ assert(foo.second() == 255); - \\ - \\ var foo2 = Foo{ .a = 15, .b = 255 }; - \\ assert(foo2.first() == 15); - \\ assert(foo2.second() == 255); - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , ""); - - case.addCompareOutput( - \\const Foo = struct { - \\ a: u8, - \\ b: u32, - \\ - \\ fn first(self: *Foo) u8 { - \\ return self.a; - \\ } - \\ - \\ fn second(self: *Foo) u32 { - \\ return self.b; - \\ } - \\}; - \\ - \\pub fn main() void { - \\ var foo2 = Foo{ .a = 15, .b = 255 }; - \\ assert(foo2.first() == 15); - \\ assert(foo2.second() == 255); - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , ""); + , + .path = "print.zig", + }), + else => unreachable, } } } - -fn addLinuxTestCases(ctx: *TestContext) !void { - // Linux tests - { - var case = ctx.exe("hello world with updates", linux_x64); - - case.addError("", &[_][]const u8{ - ":109:9: error: struct 'tmp.tmp' has no member named 'main'", - }); - - // Incorrect return type - case.addError( - \\pub export fn _start() noreturn { - \\} - , &[_][]const u8{":2:1: error: expected noreturn, found void"}); - - // Regular old hello world - case.addCompareOutput( - \\pub export fn _start() noreturn { - \\ print(); - \\ - \\ exit(); - \\} - \\ - \\fn print() void { - \\ asm volatile ("syscall" - \\ : - \\ : [number] "{rax}" (1), - \\ [arg1] "{rdi}" (1), - \\ [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), - \\ [arg3] "{rdx}" (14) - \\ : "rcx", "r11", "memory" - \\ ); - \\ return; - \\} - \\ - \\fn exit() noreturn { - \\ asm volatile ("syscall" - \\ : - \\ : [number] "{rax}" (231), - \\ [arg1] "{rdi}" (0) - \\ : "rcx", "r11", "memory" - \\ ); - \\ unreachable; - \\} - , - "Hello, World!\n", - ); - - // Convert to pub fn main - case.addCompareOutput( - \\pub fn main() void { - \\ print(); - \\} - \\ - \\fn print() void { - \\ asm volatile ("syscall" - \\ : - \\ : [number] "{rax}" (1), - \\ [arg1] "{rdi}" (1), - \\ [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), - \\ [arg3] "{rdx}" (14) - \\ : "rcx", "r11", "memory" - \\ ); - \\ return; - \\} - , - "Hello, World!\n", - ); - - // Now change the message only - case.addCompareOutput( - \\pub fn main() void { - \\ print(); - \\} - \\ - \\fn print() void { - \\ asm volatile ("syscall" - \\ : - \\ : [number] "{rax}" (1), - \\ [arg1] "{rdi}" (1), - \\ [arg2] "{rsi}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")), - \\ [arg3] "{rdx}" (104) - \\ : "rcx", "r11", "memory" - \\ ); - \\ return; - \\} - , - "What is up? This is a longer message that will force the data to be relocated in virtual address space.\n", - ); - // Now we print it twice. - case.addCompareOutput( - \\pub fn main() void { - \\ print(); - \\ print(); - \\} - \\ - \\fn print() void { - \\ asm volatile ("syscall" - \\ : - \\ : [number] "{rax}" (1), - \\ [arg1] "{rdi}" (1), - \\ [arg2] "{rsi}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")), - \\ [arg3] "{rdx}" (104) - \\ : "rcx", "r11", "memory" - \\ ); - \\ return; - \\} - , - \\What is up? This is a longer message that will force the data to be relocated in virtual address space. - \\What is up? This is a longer message that will force the data to be relocated in virtual address space. - \\ - ); - } - - { - var case = ctx.exe("adding numbers at comptime", linux_x64); - case.addCompareOutput( - \\pub export fn _start() noreturn { - \\ asm volatile ("syscall" - \\ : - \\ : [number] "{rax}" (1), - \\ [arg1] "{rdi}" (1), - \\ [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), - \\ [arg3] "{rdx}" (10 + 4) - \\ : "rcx", "r11", "memory" - \\ ); - \\ asm volatile ("syscall" - \\ : - \\ : [number] "{rax}" (@as(usize, 230) + @as(usize, 1)), - \\ [arg1] "{rdi}" (0) - \\ : "rcx", "r11", "memory" - \\ ); - \\ unreachable; - \\} - , - "Hello, World!\n", - ); - } - - { - var case = ctx.exe("only 1 function and it gets updated", linux_x64); - case.addCompareOutput( - \\pub export fn _start() noreturn { - \\ asm volatile ("syscall" - \\ : - \\ : [number] "{rax}" (60), // exit - \\ [arg1] "{rdi}" (0) - \\ : "rcx", "r11", "memory" - \\ ); - \\ unreachable; - \\} - , - "", - ); - case.addCompareOutput( - \\pub export fn _start() noreturn { - \\ asm volatile ("syscall" - \\ : - \\ : [number] "{rax}" (231), // exit_group - \\ [arg1] "{rdi}" (0) - \\ : "rcx", "r11", "memory" - \\ ); - \\ unreachable; - \\} - , - "", - ); - } - { - var case = ctx.exe("inline assembly", linux_x64); - - case.addError( - \\pub fn main() void { - \\ const number = 1234; - \\ const x = asm volatile ("syscall" - \\ : [o] "{rax}" (-> number) - \\ : [number] "{rax}" (231), - \\ [arg1] "{rdi}" (60) - \\ : "rcx", "r11", "memory" - \\ ); - \\ _ = x; - \\} - , &[_][]const u8{":4:27: error: expected type, found comptime_int"}); - case.addError( - \\const S = struct { - \\ comptime { - \\ asm volatile ( - \\ \\zig_moment: - \\ \\syscall - \\ ); - \\ } - \\}; - \\pub fn main() void { - \\ _ = S; - \\} - , &.{":3:13: error: volatile is meaningless on global assembly"}); - case.addError( - \\pub fn main() void { - \\ var bruh: u32 = 1; - \\ asm ("" - \\ : - \\ : [bruh] "{rax}" (4) - \\ : "memory" - \\ ); - \\} - , &.{":3:5: error: assembly expression with no output must be marked volatile"}); - case.addError( - \\pub fn main() void {} - \\comptime { - \\ asm ("" - \\ : - \\ : [bruh] "{rax}" (4) - \\ : "memory" - \\ ); - \\} - , &.{":3:5: error: global assembly cannot have inputs, outputs, or clobbers"}); - } - - { - var case = ctx.exe("issue 10138: callee preserved regs working", linux_x64); - case.addCompareOutput( - \\pub fn main() void { - \\ const fd = open(); - \\ _ = write(fd, "a", 1); - \\ _ = close(fd); - \\} - \\ - \\fn open() usize { - \\ return 42; - \\} - \\ - \\fn write(fd: usize, a: [*]const u8, len: usize) usize { - \\ return syscall4(.WRITE, fd, @ptrToInt(a), len); - \\} - \\ - \\fn syscall4(n: enum { WRITE }, a: usize, b: usize, c: usize) usize { - \\ _ = n; - \\ _ = a; - \\ _ = b; - \\ _ = c; - \\ return 23; - \\} - \\ - \\fn close(fd: usize) usize { - \\ if (fd != 42) - \\ unreachable; - \\ return 0; - \\} - , ""); - } -} - -fn addMacOsTestCases(ctx: *TestContext) !void { - // macOS tests - { - var case = ctx.exe("darwin hello world with updates", macos_x64); - case.addError("", &[_][]const u8{ - ":109:9: error: struct 'tmp.tmp' has no member named 'main'", - }); - - // Incorrect return type - case.addError( - \\pub export fn main() noreturn { - \\} - , &[_][]const u8{ - ":2:1: error: expected noreturn, found void", - }); - - // Regular old hello world - case.addCompareOutput( - \\extern "c" fn write(usize, usize, usize) usize; - \\extern "c" fn exit(usize) noreturn; - \\ - \\pub export fn main() noreturn { - \\ print(); - \\ - \\ exit(0); - \\} - \\ - \\fn print() void { - \\ const msg = @ptrToInt("Hello, World!\n"); - \\ const len = 14; - \\ _ = write(1, msg, len); - \\} - , - "Hello, World!\n", - ); - - // Now using start.zig without an explicit extern exit fn - case.addCompareOutput( - \\extern "c" fn write(usize, usize, usize) usize; - \\ - \\pub fn main() void { - \\ print(); - \\} - \\ - \\fn print() void { - \\ const msg = @ptrToInt("Hello, World!\n"); - \\ const len = 14; - \\ _ = write(1, msg, len); - \\} - , - "Hello, World!\n", - ); - - // Print it 4 times and force growth and realloc. - case.addCompareOutput( - \\extern "c" fn write(usize, usize, usize) usize; - \\ - \\pub fn main() void { - \\ print(); - \\ print(); - \\ print(); - \\ print(); - \\} - \\ - \\fn print() void { - \\ const msg = @ptrToInt("Hello, World!\n"); - \\ const len = 14; - \\ _ = write(1, msg, len); - \\} - , - \\Hello, World! - \\Hello, World! - \\Hello, World! - \\Hello, World! - \\ - ); - - // Print it once, and change the message. - case.addCompareOutput( - \\extern "c" fn write(usize, usize, usize) usize; - \\ - \\pub fn main() void { - \\ print(); - \\} - \\ - \\fn print() void { - \\ const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); - \\ const len = 104; - \\ _ = write(1, msg, len); - \\} - , - "What is up? This is a longer message that will force the data to be relocated in virtual address space.\n", - ); - - // Now we print it twice. - case.addCompareOutput( - \\extern "c" fn write(usize, usize, usize) usize; - \\ - \\pub fn main() void { - \\ print(); - \\ print(); - \\} - \\ - \\fn print() void { - \\ const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); - \\ const len = 104; - \\ _ = write(1, msg, len); - \\} - , - \\What is up? This is a longer message that will force the data to be relocated in virtual address space. - \\What is up? This is a longer message that will force the data to be relocated in virtual address space. - \\ - ); - } -} From c8a0d8ff2b8557e3e7c3956a37293a0ce06dd3d0 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Wed, 27 Apr 2022 17:58:53 +0200 Subject: [PATCH 12/26] ci: ignore fmt errors in test/incremental/ --- ci/zinc/linux_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/zinc/linux_test.sh b/ci/zinc/linux_test.sh index b0f65aefd3..ec999a483a 100755 --- a/ci/zinc/linux_test.sh +++ b/ci/zinc/linux_test.sh @@ -45,7 +45,7 @@ cd $WORKSPACE # Look for non-conforming code formatting. # Formatting errors can be fixed by running `zig fmt` on the files printed here. -$ZIG fmt --check . --exclude test/compile_errors/ +$ZIG fmt --check . --exclude test/compile_errors/ --exclude test/incremental/ # Build stage2 standalone so that we can test stage2 against stage2 compiler-rt. $ZIG build -p stage2 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" From 8d5acf769336051a18c4905b4fc258349092b36e Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Wed, 27 Apr 2022 21:29:25 +0200 Subject: [PATCH 13/26] test: recursively walk dir with tests Prune incremental tests by moving non-incremental behavior tests to behavior test suite instead. --- src/test.zig | 6 +++--- test/behavior.zig | 2 ++ .../bugs/10138.zig} | 13 ++++++++----- test/behavior/bugs/7187.zig | 18 ++++++++++++++++++ ...s_slice_element_by_index_slice_elem_val.zig | 17 ----------------- ...87_miscompilation_with_bool_return_type.zig | 18 ------------------ .../load_store_via_pointer_deref.0.zig | 16 ---------------- .../load_store_via_pointer_deref.1.zig | 16 ---------------- .../load_store_via_pointer_deref.2.zig | 16 ---------------- ...g_vars_of_different_abi_size_to_stack.0.zig | 16 ---------------- ...g_vars_of_different_abi_size_to_stack.1.zig | 16 ---------------- ...g_vars_of_different_abi_size_to_stack.2.zig | 16 ---------------- .../subtracting_numbers_at_runtime.zig | 10 ---------- .../unwrap_error_union_simple_errors.0.zig | 10 ---------- .../unwrap_error_union_simple_errors.1.zig | 11 ----------- .../hello_world_with_updates.0.zig} | 0 .../hello_world_with_updates.1.zig} | 0 .../hello_world_with_updates.2.zig} | 0 .../hello_world_with_updates.3.zig} | 0 .../hello_world_with_updates.4.zig} | 0 .../hello_world_with_updates.5.zig} | 0 .../inline_assembly.0.zig} | 0 .../inline_assembly.1.zig} | 0 .../inline_assembly.2.zig} | 0 .../inline_assembly.3.zig} | 0 .../only_1_function_and_it_gets_updated.0.zig} | 0 .../only_1_function_and_it_gets_updated.1.zig} | 0 .../hello_world_with_updates.0.zig} | 0 .../hello_world_with_updates.1.zig} | 0 .../hello_world_with_updates.2.zig} | 0 .../hello_world_with_updates.3.zig} | 0 .../hello_world_with_updates.4.zig} | 0 .../hello_world_with_updates.5.zig} | 0 .../hello_world_with_updates.6.zig} | 0 34 files changed, 31 insertions(+), 170 deletions(-) rename test/{incremental/issue_10138_callee_preserved_regs_working_x86_64_linux.zig => behavior/bugs/10138.zig} (54%) create mode 100644 test/behavior/bugs/7187.zig delete mode 100644 test/incremental/access_slice_element_by_index_slice_elem_val.zig delete mode 100644 test/incremental/issue_7187_miscompilation_with_bool_return_type.zig delete mode 100644 test/incremental/load_store_via_pointer_deref.0.zig delete mode 100644 test/incremental/load_store_via_pointer_deref.1.zig delete mode 100644 test/incremental/load_store_via_pointer_deref.2.zig delete mode 100644 test/incremental/saving_vars_of_different_abi_size_to_stack.0.zig delete mode 100644 test/incremental/saving_vars_of_different_abi_size_to_stack.1.zig delete mode 100644 test/incremental/saving_vars_of_different_abi_size_to_stack.2.zig delete mode 100644 test/incremental/subtracting_numbers_at_runtime.zig delete mode 100644 test/incremental/unwrap_error_union_simple_errors.0.zig delete mode 100644 test/incremental/unwrap_error_union_simple_errors.1.zig rename test/incremental/{hello_world_with_updates_x86_64_linux.0.zig => x86_64-linux/hello_world_with_updates.0.zig} (100%) rename test/incremental/{hello_world_with_updates_x86_64_linux.1.zig => x86_64-linux/hello_world_with_updates.1.zig} (100%) rename test/incremental/{hello_world_with_updates_x86_64_linux.2.zig => x86_64-linux/hello_world_with_updates.2.zig} (100%) rename test/incremental/{hello_world_with_updates_x86_64_linux.3.zig => x86_64-linux/hello_world_with_updates.3.zig} (100%) rename test/incremental/{hello_world_with_updates_x86_64_linux.4.zig => x86_64-linux/hello_world_with_updates.4.zig} (100%) rename test/incremental/{hello_world_with_updates_x86_64_linux.5.zig => x86_64-linux/hello_world_with_updates.5.zig} (100%) rename test/incremental/{inline_assembly_x86_64_linux.0.zig => x86_64-linux/inline_assembly.0.zig} (100%) rename test/incremental/{inline_assembly_x86_64_linux.1.zig => x86_64-linux/inline_assembly.1.zig} (100%) rename test/incremental/{inline_assembly_x86_64_linux.2.zig => x86_64-linux/inline_assembly.2.zig} (100%) rename test/incremental/{inline_assembly_x86_64_linux.3.zig => x86_64-linux/inline_assembly.3.zig} (100%) rename test/incremental/{only_1_function_and_it_gets_updated_x86_64_linux.0.zig => x86_64-linux/only_1_function_and_it_gets_updated.0.zig} (100%) rename test/incremental/{only_1_function_and_it_gets_updated_x86_64_linux.1.zig => x86_64-linux/only_1_function_and_it_gets_updated.1.zig} (100%) rename test/incremental/{hello_world_with_updates_x86_64_macos.0.zig => x86_64-macos/hello_world_with_updates.0.zig} (100%) rename test/incremental/{hello_world_with_updates_x86_64_macos.1.zig => x86_64-macos/hello_world_with_updates.1.zig} (100%) rename test/incremental/{hello_world_with_updates_x86_64_macos.2.zig => x86_64-macos/hello_world_with_updates.2.zig} (100%) rename test/incremental/{hello_world_with_updates_x86_64_macos.3.zig => x86_64-macos/hello_world_with_updates.3.zig} (100%) rename test/incremental/{hello_world_with_updates_x86_64_macos.4.zig => x86_64-macos/hello_world_with_updates.4.zig} (100%) rename test/incremental/{hello_world_with_updates_x86_64_macos.5.zig => x86_64-macos/hello_world_with_updates.5.zig} (100%) rename test/incremental/{hello_world_with_updates_x86_64_macos.6.zig => x86_64-macos/hello_world_with_updates.6.zig} (100%) diff --git a/src/test.zig b/src/test.zig index 2f3389d7ff..8ede838a5e 100644 --- a/src/test.zig +++ b/src/test.zig @@ -1012,18 +1012,18 @@ pub const TestContext = struct { ) !void { var cases = std.ArrayList(usize).init(ctx.arena); - var it = dir.iterate(); + var it = try dir.walk(ctx.arena); var filenames = std.ArrayList([]const u8).init(ctx.arena); while (try it.next()) |entry| { if (entry.kind != .File) continue; // Ignore stuff such as .swp files - switch (Compilation.classifyFileExt(entry.name)) { + switch (Compilation.classifyFileExt(entry.basename)) { .unknown => continue, else => {}, } - try filenames.append(try ctx.arena.dupe(u8, entry.name)); + try filenames.append(try ctx.arena.dupe(u8, entry.path)); } // Sort filenames, so that incremental tests are contiguous and in-order diff --git a/test/behavior.zig b/test/behavior.zig index 828a56a81f..4d8b3587bc 100644 --- a/test/behavior.zig +++ b/test/behavior.zig @@ -69,8 +69,10 @@ test { _ = @import("behavior/bugs/7003.zig"); _ = @import("behavior/bugs/7027.zig"); _ = @import("behavior/bugs/7047.zig"); + _ = @import("behavior/bugs/7187.zig"); _ = @import("behavior/bugs/7250.zig"); _ = @import("behavior/bugs/9584.zig"); + _ = @import("behavior/bugs/10138.zig"); _ = @import("behavior/bugs/10147.zig"); _ = @import("behavior/bugs/10970.zig"); _ = @import("behavior/bugs/11046.zig"); diff --git a/test/incremental/issue_10138_callee_preserved_regs_working_x86_64_linux.zig b/test/behavior/bugs/10138.zig similarity index 54% rename from test/incremental/issue_10138_callee_preserved_regs_working_x86_64_linux.zig rename to test/behavior/bugs/10138.zig index 4c045496da..88dc5acde7 100644 --- a/test/incremental/issue_10138_callee_preserved_regs_working_x86_64_linux.zig +++ b/test/behavior/bugs/10138.zig @@ -1,4 +1,11 @@ -pub fn main() void { +const std = @import("std"); +const builtin = @import("builtin"); + +test "registers get overwritten when ignoring return" { + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; + if (builtin.cpu.arch != .x86_64 or builtin.os.tag != .linux) return error.SkipZigTest; + const fd = open(); _ = write(fd, "a", 1); _ = close(fd); @@ -25,7 +32,3 @@ fn close(fd: usize) usize { unreachable; return 0; } - -// run -// target=x86_64-linux -// diff --git a/test/behavior/bugs/7187.zig b/test/behavior/bugs/7187.zig new file mode 100644 index 0000000000..86f5aa6706 --- /dev/null +++ b/test/behavior/bugs/7187.zig @@ -0,0 +1,18 @@ +const std = @import("std"); +const builtin = @import("builtin"); +const expect = std.testing.expect; + +test "miscompilation with bool return type" { + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; + + var x: usize = 1; + var y: bool = getFalse(); + _ = y; + + try expect(x == 1); +} + +fn getFalse() bool { + return false; +} diff --git a/test/incremental/access_slice_element_by_index_slice_elem_val.zig b/test/incremental/access_slice_element_by_index_slice_elem_val.zig deleted file mode 100644 index a0bdae0826..0000000000 --- a/test/incremental/access_slice_element_by_index_slice_elem_val.zig +++ /dev/null @@ -1,17 +0,0 @@ -var array = [_]usize{ 0, 42, 123, 34 }; -var slice: []const usize = &array; - -pub fn main() void { - assert(slice[0] == 0); - assert(slice[1] == 42); - assert(slice[2] == 123); - assert(slice[3] == 34); -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -// run -// target=x86_64-linux,x86_64-macos -// diff --git a/test/incremental/issue_7187_miscompilation_with_bool_return_type.zig b/test/incremental/issue_7187_miscompilation_with_bool_return_type.zig deleted file mode 100644 index 3aed8685bf..0000000000 --- a/test/incremental/issue_7187_miscompilation_with_bool_return_type.zig +++ /dev/null @@ -1,18 +0,0 @@ -pub fn main() void { - var x: usize = 1; - var y: bool = getFalse(); - _ = y; - - assert(x == 1); -} - -fn getFalse() bool { - return false; -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -// run -// diff --git a/test/incremental/load_store_via_pointer_deref.0.zig b/test/incremental/load_store_via_pointer_deref.0.zig deleted file mode 100644 index 96aedf3196..0000000000 --- a/test/incremental/load_store_via_pointer_deref.0.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() void { - var x: u32 = undefined; - set(&x); - assert(x == 123); -} - -fn set(x: *u32) void { - x.* = 123; -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -// run -// diff --git a/test/incremental/load_store_via_pointer_deref.1.zig b/test/incremental/load_store_via_pointer_deref.1.zig deleted file mode 100644 index e311092744..0000000000 --- a/test/incremental/load_store_via_pointer_deref.1.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() void { - var x: u16 = undefined; - set(&x); - assert(x == 123); -} - -fn set(x: *u16) void { - x.* = 123; -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -// run -// diff --git a/test/incremental/load_store_via_pointer_deref.2.zig b/test/incremental/load_store_via_pointer_deref.2.zig deleted file mode 100644 index 3b1484faa1..0000000000 --- a/test/incremental/load_store_via_pointer_deref.2.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() void { - var x: u8 = undefined; - set(&x); - assert(x == 123); -} - -fn set(x: *u8) void { - x.* = 123; -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -// run -// diff --git a/test/incremental/saving_vars_of_different_abi_size_to_stack.0.zig b/test/incremental/saving_vars_of_different_abi_size_to_stack.0.zig deleted file mode 100644 index 6134622a0e..0000000000 --- a/test/incremental/saving_vars_of_different_abi_size_to_stack.0.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() void { - assert(callMe(2) == 24); -} - -fn callMe(a: u8) u8 { - var b: u8 = a + 10; - const c = 2 * b; - return c; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/incremental/saving_vars_of_different_abi_size_to_stack.1.zig b/test/incremental/saving_vars_of_different_abi_size_to_stack.1.zig deleted file mode 100644 index 4d87d7b9c5..0000000000 --- a/test/incremental/saving_vars_of_different_abi_size_to_stack.1.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() void { - assert(callMe(2) == 24); -} - -fn callMe(a: u16) u16 { - var b: u16 = a + 10; - const c = 2 * b; - return c; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/incremental/saving_vars_of_different_abi_size_to_stack.2.zig b/test/incremental/saving_vars_of_different_abi_size_to_stack.2.zig deleted file mode 100644 index b665227962..0000000000 --- a/test/incremental/saving_vars_of_different_abi_size_to_stack.2.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() void { - assert(callMe(2) == 24); -} - -fn callMe(a: u32) u32 { - var b: u32 = a + 10; - const c = 2 * b; - return c; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/incremental/subtracting_numbers_at_runtime.zig b/test/incremental/subtracting_numbers_at_runtime.zig deleted file mode 100644 index 5ea81a34b8..0000000000 --- a/test/incremental/subtracting_numbers_at_runtime.zig +++ /dev/null @@ -1,10 +0,0 @@ -pub fn main() void { - sub(7, 4); -} - -fn sub(a: u32, b: u32) void { - if (a - b != 3) unreachable; -} - -// run -// diff --git a/test/incremental/unwrap_error_union_simple_errors.0.zig b/test/incremental/unwrap_error_union_simple_errors.0.zig deleted file mode 100644 index a1e2da9340..0000000000 --- a/test/incremental/unwrap_error_union_simple_errors.0.zig +++ /dev/null @@ -1,10 +0,0 @@ -pub fn main() void { - maybeErr() catch unreachable; -} - -fn maybeErr() !void { - return; -} - -// run -// diff --git a/test/incremental/unwrap_error_union_simple_errors.1.zig b/test/incremental/unwrap_error_union_simple_errors.1.zig deleted file mode 100644 index 830ee629bc..0000000000 --- a/test/incremental/unwrap_error_union_simple_errors.1.zig +++ /dev/null @@ -1,11 +0,0 @@ -pub fn main() void { - maybeErr() catch return; - unreachable; -} - -fn maybeErr() !void { - return error.NoWay; -} - -// run -// diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.0.zig b/test/incremental/x86_64-linux/hello_world_with_updates.0.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_linux.0.zig rename to test/incremental/x86_64-linux/hello_world_with_updates.0.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.1.zig b/test/incremental/x86_64-linux/hello_world_with_updates.1.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_linux.1.zig rename to test/incremental/x86_64-linux/hello_world_with_updates.1.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.2.zig b/test/incremental/x86_64-linux/hello_world_with_updates.2.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_linux.2.zig rename to test/incremental/x86_64-linux/hello_world_with_updates.2.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.3.zig b/test/incremental/x86_64-linux/hello_world_with_updates.3.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_linux.3.zig rename to test/incremental/x86_64-linux/hello_world_with_updates.3.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.4.zig b/test/incremental/x86_64-linux/hello_world_with_updates.4.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_linux.4.zig rename to test/incremental/x86_64-linux/hello_world_with_updates.4.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.5.zig b/test/incremental/x86_64-linux/hello_world_with_updates.5.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_linux.5.zig rename to test/incremental/x86_64-linux/hello_world_with_updates.5.zig diff --git a/test/incremental/inline_assembly_x86_64_linux.0.zig b/test/incremental/x86_64-linux/inline_assembly.0.zig similarity index 100% rename from test/incremental/inline_assembly_x86_64_linux.0.zig rename to test/incremental/x86_64-linux/inline_assembly.0.zig diff --git a/test/incremental/inline_assembly_x86_64_linux.1.zig b/test/incremental/x86_64-linux/inline_assembly.1.zig similarity index 100% rename from test/incremental/inline_assembly_x86_64_linux.1.zig rename to test/incremental/x86_64-linux/inline_assembly.1.zig diff --git a/test/incremental/inline_assembly_x86_64_linux.2.zig b/test/incremental/x86_64-linux/inline_assembly.2.zig similarity index 100% rename from test/incremental/inline_assembly_x86_64_linux.2.zig rename to test/incremental/x86_64-linux/inline_assembly.2.zig diff --git a/test/incremental/inline_assembly_x86_64_linux.3.zig b/test/incremental/x86_64-linux/inline_assembly.3.zig similarity index 100% rename from test/incremental/inline_assembly_x86_64_linux.3.zig rename to test/incremental/x86_64-linux/inline_assembly.3.zig diff --git a/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.0.zig b/test/incremental/x86_64-linux/only_1_function_and_it_gets_updated.0.zig similarity index 100% rename from test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.0.zig rename to test/incremental/x86_64-linux/only_1_function_and_it_gets_updated.0.zig diff --git a/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.1.zig b/test/incremental/x86_64-linux/only_1_function_and_it_gets_updated.1.zig similarity index 100% rename from test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.1.zig rename to test/incremental/x86_64-linux/only_1_function_and_it_gets_updated.1.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.0.zig b/test/incremental/x86_64-macos/hello_world_with_updates.0.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_macos.0.zig rename to test/incremental/x86_64-macos/hello_world_with_updates.0.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.1.zig b/test/incremental/x86_64-macos/hello_world_with_updates.1.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_macos.1.zig rename to test/incremental/x86_64-macos/hello_world_with_updates.1.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.2.zig b/test/incremental/x86_64-macos/hello_world_with_updates.2.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_macos.2.zig rename to test/incremental/x86_64-macos/hello_world_with_updates.2.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.3.zig b/test/incremental/x86_64-macos/hello_world_with_updates.3.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_macos.3.zig rename to test/incremental/x86_64-macos/hello_world_with_updates.3.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.4.zig b/test/incremental/x86_64-macos/hello_world_with_updates.4.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_macos.4.zig rename to test/incremental/x86_64-macos/hello_world_with_updates.4.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.5.zig b/test/incremental/x86_64-macos/hello_world_with_updates.5.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_macos.5.zig rename to test/incremental/x86_64-macos/hello_world_with_updates.5.zig diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.6.zig b/test/incremental/x86_64-macos/hello_world_with_updates.6.zig similarity index 100% rename from test/incremental/hello_world_with_updates_x86_64_macos.6.zig rename to test/incremental/x86_64-macos/hello_world_with_updates.6.zig From 815dc2c6e77eb6035921bb59fee0844b095ee064 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Wed, 27 Apr 2022 21:33:59 +0200 Subject: [PATCH 14/26] test: enable wasm32-wasi incremental tests --- src/test.zig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/test.zig b/src/test.zig index 8ede838a5e..1bb3aaa4a1 100644 --- a/src/test.zig +++ b/src/test.zig @@ -165,6 +165,12 @@ const ErrorMsg = union(enum) { } }; +/// Default config values for known test manifest key-value pairings. +/// Currently handled defaults are: +/// * backend +/// * target +/// * output_mode +/// * is_test const TestManifestConfigDefaults = struct { /// Asserts if the key doesn't exist - yep, it's an oversight alright. fn get(@"type": TestManifest.Type, key: []const u8) []const u8 { @@ -186,7 +192,7 @@ const TestManifestConfigDefaults = struct { } // Wasm defaults = defaults ++ "wasm32-wasi"; - return defaults[0 .. defaults.len - 2]; + return defaults; } } else if (std.mem.eql(u8, key, "output_mode")) { return switch (@"type") { From 8e05e6a1ed3089ce1161cca9980f9939440a421b Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Wed, 27 Apr 2022 22:59:55 +0200 Subject: [PATCH 15/26] test: migrate wasm incremental tests --- test/cases.zig | 1 - test/incremental/binary_operands.0.zig | 9 + test/incremental/binary_operands.1.zig | 8 + test/incremental/binary_operands.10.zig | 13 + test/incremental/binary_operands.11.zig | 9 + test/incremental/binary_operands.12.zig | 8 + test/incremental/binary_operands.13.zig | 8 + test/incremental/binary_operands.14.zig | 13 + test/incremental/binary_operands.15.zig | 8 + test/incremental/binary_operands.16.zig | 8 + test/incremental/binary_operands.17.zig | 8 + test/incremental/binary_operands.18.zig | 9 + test/incremental/binary_operands.19.zig | 9 + test/incremental/binary_operands.2.zig | 8 + test/incremental/binary_operands.20.zig | 9 + test/incremental/binary_operands.21.zig | 9 + test/incremental/binary_operands.22.zig | 9 + test/incremental/binary_operands.23.zig | 9 + test/incremental/binary_operands.24.zig | 9 + test/incremental/binary_operands.25.zig | 9 + test/incremental/binary_operands.3.zig | 7 + test/incremental/binary_operands.4.zig | 12 + test/incremental/binary_operands.5.zig | 8 + test/incremental/binary_operands.6.zig | 8 + test/incremental/binary_operands.7.zig | 8 + test/incremental/binary_operands.8.zig | 7 + test/incremental/binary_operands.9.zig | 12 + test/incremental/enum_values.0.zig | 18 + test/incremental/enum_values.1.zig | 22 + test/incremental/function_calls.0.zig | 12 + test/incremental/function_calls.1.zig | 15 + test/incremental/function_calls.2.zig | 14 + test/incremental/function_calls.3.zig | 10 + test/incremental/wasm-wasi/conditions.0.zig | 11 + test/incremental/wasm-wasi/conditions.1.zig | 12 + test/incremental/wasm-wasi/conditions.2.zig | 12 + test/incremental/wasm-wasi/conditions.3.zig | 16 + test/incremental/wasm-wasi/conditions.4.zig | 15 + test/incremental/wasm-wasi/conditions.5.zig | 20 + test/incremental/wasm-wasi/error_unions.0.zig | 15 + test/incremental/wasm-wasi/error_unions.1.zig | 8 + test/incremental/wasm-wasi/error_unions.2.zig | 8 + test/incremental/wasm-wasi/error_unions.3.zig | 12 + test/incremental/wasm-wasi/error_unions.4.zig | 12 + test/incremental/wasm-wasi/error_unions.5.zig | 12 + test/incremental/wasm-wasi/locals.0.zig | 14 + test/incremental/wasm-wasi/locals.1.zig | 17 + test/incremental/wasm-wasi/optionals.0.zig | 12 + test/incremental/wasm-wasi/optionals.1.zig | 11 + test/incremental/wasm-wasi/optionals.2.zig | 7 + test/incremental/wasm-wasi/optionals.3.zig | 8 + test/incremental/wasm-wasi/optionals.4.zig | 13 + test/incremental/wasm-wasi/pointers.0.zig | 14 + test/incremental/wasm-wasi/pointers.1.zig | 18 + test/incremental/wasm-wasi/structs.0.zig | 10 + test/incremental/wasm-wasi/structs.1.zig | 10 + test/incremental/wasm-wasi/structs.2.zig | 9 + test/incremental/wasm-wasi/structs.3.zig | 12 + test/incremental/wasm-wasi/structs.4.zig | 11 + test/incremental/wasm-wasi/switch.0.zig | 15 + test/incremental/wasm-wasi/switch.1.zig | 14 + test/incremental/wasm-wasi/switch.2.zig | 14 + test/incremental/wasm-wasi/switch.3.zig | 15 + test/incremental/wasm-wasi/while_loops.0.zig | 12 + test/incremental/wasm-wasi/while_loops.1.zig | 11 + test/incremental/wasm-wasi/while_loops.2.zig | 12 + test/stage2/wasm.zig | 796 ------------------ 67 files changed, 737 insertions(+), 797 deletions(-) create mode 100644 test/incremental/binary_operands.0.zig create mode 100644 test/incremental/binary_operands.1.zig create mode 100644 test/incremental/binary_operands.10.zig create mode 100644 test/incremental/binary_operands.11.zig create mode 100644 test/incremental/binary_operands.12.zig create mode 100644 test/incremental/binary_operands.13.zig create mode 100644 test/incremental/binary_operands.14.zig create mode 100644 test/incremental/binary_operands.15.zig create mode 100644 test/incremental/binary_operands.16.zig create mode 100644 test/incremental/binary_operands.17.zig create mode 100644 test/incremental/binary_operands.18.zig create mode 100644 test/incremental/binary_operands.19.zig create mode 100644 test/incremental/binary_operands.2.zig create mode 100644 test/incremental/binary_operands.20.zig create mode 100644 test/incremental/binary_operands.21.zig create mode 100644 test/incremental/binary_operands.22.zig create mode 100644 test/incremental/binary_operands.23.zig create mode 100644 test/incremental/binary_operands.24.zig create mode 100644 test/incremental/binary_operands.25.zig create mode 100644 test/incremental/binary_operands.3.zig create mode 100644 test/incremental/binary_operands.4.zig create mode 100644 test/incremental/binary_operands.5.zig create mode 100644 test/incremental/binary_operands.6.zig create mode 100644 test/incremental/binary_operands.7.zig create mode 100644 test/incremental/binary_operands.8.zig create mode 100644 test/incremental/binary_operands.9.zig create mode 100644 test/incremental/enum_values.0.zig create mode 100644 test/incremental/enum_values.1.zig create mode 100644 test/incremental/function_calls.0.zig create mode 100644 test/incremental/function_calls.1.zig create mode 100644 test/incremental/function_calls.2.zig create mode 100644 test/incremental/function_calls.3.zig create mode 100644 test/incremental/wasm-wasi/conditions.0.zig create mode 100644 test/incremental/wasm-wasi/conditions.1.zig create mode 100644 test/incremental/wasm-wasi/conditions.2.zig create mode 100644 test/incremental/wasm-wasi/conditions.3.zig create mode 100644 test/incremental/wasm-wasi/conditions.4.zig create mode 100644 test/incremental/wasm-wasi/conditions.5.zig create mode 100644 test/incremental/wasm-wasi/error_unions.0.zig create mode 100644 test/incremental/wasm-wasi/error_unions.1.zig create mode 100644 test/incremental/wasm-wasi/error_unions.2.zig create mode 100644 test/incremental/wasm-wasi/error_unions.3.zig create mode 100644 test/incremental/wasm-wasi/error_unions.4.zig create mode 100644 test/incremental/wasm-wasi/error_unions.5.zig create mode 100644 test/incremental/wasm-wasi/locals.0.zig create mode 100644 test/incremental/wasm-wasi/locals.1.zig create mode 100644 test/incremental/wasm-wasi/optionals.0.zig create mode 100644 test/incremental/wasm-wasi/optionals.1.zig create mode 100644 test/incremental/wasm-wasi/optionals.2.zig create mode 100644 test/incremental/wasm-wasi/optionals.3.zig create mode 100644 test/incremental/wasm-wasi/optionals.4.zig create mode 100644 test/incremental/wasm-wasi/pointers.0.zig create mode 100644 test/incremental/wasm-wasi/pointers.1.zig create mode 100644 test/incremental/wasm-wasi/structs.0.zig create mode 100644 test/incremental/wasm-wasi/structs.1.zig create mode 100644 test/incremental/wasm-wasi/structs.2.zig create mode 100644 test/incremental/wasm-wasi/structs.3.zig create mode 100644 test/incremental/wasm-wasi/structs.4.zig create mode 100644 test/incremental/wasm-wasi/switch.0.zig create mode 100644 test/incremental/wasm-wasi/switch.1.zig create mode 100644 test/incremental/wasm-wasi/switch.2.zig create mode 100644 test/incremental/wasm-wasi/switch.3.zig create mode 100644 test/incremental/wasm-wasi/while_loops.0.zig create mode 100644 test/incremental/wasm-wasi/while_loops.1.zig create mode 100644 test/incremental/wasm-wasi/while_loops.2.zig delete mode 100644 test/stage2/wasm.zig diff --git a/test/cases.zig b/test/cases.zig index 0fb6f381dd..cc77104fb9 100644 --- a/test/cases.zig +++ b/test/cases.zig @@ -12,7 +12,6 @@ pub fn addCases(ctx: *TestContext) !void { try @import("stage2/arm.zig").addCases(ctx); try @import("stage2/aarch64.zig").addCases(ctx); try @import("stage2/llvm.zig").addCases(ctx); - try @import("stage2/wasm.zig").addCases(ctx); try @import("stage2/riscv64.zig").addCases(ctx); try @import("stage2/plan9.zig").addCases(ctx); try @import("stage2/x86_64.zig").addCases(ctx); diff --git a/test/incremental/binary_operands.0.zig b/test/incremental/binary_operands.0.zig new file mode 100644 index 0000000000..e3688232aa --- /dev/null +++ b/test/incremental/binary_operands.0.zig @@ -0,0 +1,9 @@ +pub fn main() void { + var i: u8 = 5; + i += 20; + if (i != 25) unreachable; +} + +// run +// target=wasm32-wasi +// diff --git a/test/incremental/binary_operands.1.zig b/test/incremental/binary_operands.1.zig new file mode 100644 index 0000000000..fdee492d22 --- /dev/null +++ b/test/incremental/binary_operands.1.zig @@ -0,0 +1,8 @@ +pub fn main() void { + var i: i32 = 2147483647; + if (i +% 1 != -2147483648) unreachable; + return; +} + +// run +// diff --git a/test/incremental/binary_operands.10.zig b/test/incremental/binary_operands.10.zig new file mode 100644 index 0000000000..63e045c258 --- /dev/null +++ b/test/incremental/binary_operands.10.zig @@ -0,0 +1,13 @@ +pub fn main() void { + var i: u32 = 5; + i *= 7; + var result: u32 = foo(i, 10); + if (result != 350) unreachable; + return; +} +fn foo(x: u32, y: u32) u32 { + return x * y; +} + +// run +// diff --git a/test/incremental/binary_operands.11.zig b/test/incremental/binary_operands.11.zig new file mode 100644 index 0000000000..f461bcc0af --- /dev/null +++ b/test/incremental/binary_operands.11.zig @@ -0,0 +1,9 @@ +pub fn main() void { + var i: i32 = 2147483647; + const result = i *% 2; + if (result != -2) unreachable; + return; +} + +// run +// diff --git a/test/incremental/binary_operands.12.zig b/test/incremental/binary_operands.12.zig new file mode 100644 index 0000000000..0ffb5e2230 --- /dev/null +++ b/test/incremental/binary_operands.12.zig @@ -0,0 +1,8 @@ +pub fn main() void { + var i: u3 = 3; + if (i *% 3 != 1) unreachable; + return; +} + +// run +// diff --git a/test/incremental/binary_operands.13.zig b/test/incremental/binary_operands.13.zig new file mode 100644 index 0000000000..e62107b47e --- /dev/null +++ b/test/incremental/binary_operands.13.zig @@ -0,0 +1,8 @@ +pub fn main() void { + var i: i4 = 3; + if (i *% 3 != 1) unreachable; + return; +} + +// run +// diff --git a/test/incremental/binary_operands.14.zig b/test/incremental/binary_operands.14.zig new file mode 100644 index 0000000000..fcc7245ad9 --- /dev/null +++ b/test/incremental/binary_operands.14.zig @@ -0,0 +1,13 @@ +pub fn main() void { + var i: u32 = 352; + i /= 7; // i = 50 + var result: u32 = foo(i, 7); + if (result != 7) unreachable; + return; +} +fn foo(x: u32, y: u32) u32 { + return x / y; +} + +// run +// diff --git a/test/incremental/binary_operands.15.zig b/test/incremental/binary_operands.15.zig new file mode 100644 index 0000000000..c709e5dfd2 --- /dev/null +++ b/test/incremental/binary_operands.15.zig @@ -0,0 +1,8 @@ +pub fn main() u8 { + var i: u8 = 5; + i &= 6; + return i - 4; +} + +// run +// diff --git a/test/incremental/binary_operands.16.zig b/test/incremental/binary_operands.16.zig new file mode 100644 index 0000000000..fe1813b877 --- /dev/null +++ b/test/incremental/binary_operands.16.zig @@ -0,0 +1,8 @@ +pub fn main() u8 { + var i: u8 = 5; + i |= 6; + return i - 7; +} + +// run +// diff --git a/test/incremental/binary_operands.17.zig b/test/incremental/binary_operands.17.zig new file mode 100644 index 0000000000..439d3d6d6b --- /dev/null +++ b/test/incremental/binary_operands.17.zig @@ -0,0 +1,8 @@ +pub fn main() u8 { + var i: u8 = 5; + i ^= 6; + return i - 3; +} + +// run +// diff --git a/test/incremental/binary_operands.18.zig b/test/incremental/binary_operands.18.zig new file mode 100644 index 0000000000..c21aa586c5 --- /dev/null +++ b/test/incremental/binary_operands.18.zig @@ -0,0 +1,9 @@ +pub fn main() void { + var b: bool = false; + b = b or false; + if (b) unreachable; + return; +} + +// run +// diff --git a/test/incremental/binary_operands.19.zig b/test/incremental/binary_operands.19.zig new file mode 100644 index 0000000000..e95470391c --- /dev/null +++ b/test/incremental/binary_operands.19.zig @@ -0,0 +1,9 @@ +pub fn main() void { + var b: bool = true; + b = b or false; + if (!b) unreachable; + return; +} + +// run +// diff --git a/test/incremental/binary_operands.2.zig b/test/incremental/binary_operands.2.zig new file mode 100644 index 0000000000..7407ed7d95 --- /dev/null +++ b/test/incremental/binary_operands.2.zig @@ -0,0 +1,8 @@ +pub fn main() void { + var i: i4 = 7; + if (i +% 1 != 0) unreachable; + return; +} + +// run +// diff --git a/test/incremental/binary_operands.20.zig b/test/incremental/binary_operands.20.zig new file mode 100644 index 0000000000..9238bf97c0 --- /dev/null +++ b/test/incremental/binary_operands.20.zig @@ -0,0 +1,9 @@ +pub fn main() void { + var b: bool = false; + b = b or true; + if (!b) unreachable; + return; +} + +// run +// diff --git a/test/incremental/binary_operands.21.zig b/test/incremental/binary_operands.21.zig new file mode 100644 index 0000000000..a2d427bda9 --- /dev/null +++ b/test/incremental/binary_operands.21.zig @@ -0,0 +1,9 @@ +pub fn main() void { + var b: bool = true; + b = b or true; + if (!b) unreachable; + return; +} + +// run +// diff --git a/test/incremental/binary_operands.22.zig b/test/incremental/binary_operands.22.zig new file mode 100644 index 0000000000..aa8439a361 --- /dev/null +++ b/test/incremental/binary_operands.22.zig @@ -0,0 +1,9 @@ +pub fn main() void { + var b: bool = false; + b = b and false; + if (b) unreachable; + return; +} + +// run +// diff --git a/test/incremental/binary_operands.23.zig b/test/incremental/binary_operands.23.zig new file mode 100644 index 0000000000..8596ea7709 --- /dev/null +++ b/test/incremental/binary_operands.23.zig @@ -0,0 +1,9 @@ +pub fn main() void { + var b: bool = true; + b = b and false; + if (b) unreachable; + return; +} + +// run +// diff --git a/test/incremental/binary_operands.24.zig b/test/incremental/binary_operands.24.zig new file mode 100644 index 0000000000..08dc4430a2 --- /dev/null +++ b/test/incremental/binary_operands.24.zig @@ -0,0 +1,9 @@ +pub fn main() void { + var b: bool = false; + b = b and true; + if (b) unreachable; + return; +} + +// run +// diff --git a/test/incremental/binary_operands.25.zig b/test/incremental/binary_operands.25.zig new file mode 100644 index 0000000000..8aa0acfdb5 --- /dev/null +++ b/test/incremental/binary_operands.25.zig @@ -0,0 +1,9 @@ +pub fn main() void { + var b: bool = true; + b = b and true; + if (!b) unreachable; + return; +} + +// run +// diff --git a/test/incremental/binary_operands.3.zig b/test/incremental/binary_operands.3.zig new file mode 100644 index 0000000000..0297f1e7a4 --- /dev/null +++ b/test/incremental/binary_operands.3.zig @@ -0,0 +1,7 @@ +pub fn main() u8 { + var i: u8 = 255; + return i +% 1; +} + +// run +// diff --git a/test/incremental/binary_operands.4.zig b/test/incremental/binary_operands.4.zig new file mode 100644 index 0000000000..f0f8910e14 --- /dev/null +++ b/test/incremental/binary_operands.4.zig @@ -0,0 +1,12 @@ +pub fn main() u8 { + var i: u8 = 5; + i += 20; + var result: u8 = foo(i, 10); + return result - 35; +} +fn foo(x: u8, y: u8) u8 { + return x + y; +} + +// run +// diff --git a/test/incremental/binary_operands.5.zig b/test/incremental/binary_operands.5.zig new file mode 100644 index 0000000000..51ab437475 --- /dev/null +++ b/test/incremental/binary_operands.5.zig @@ -0,0 +1,8 @@ +pub fn main() u8 { + var i: u8 = 20; + i -= 5; + return i - 15; +} + +// run +// diff --git a/test/incremental/binary_operands.6.zig b/test/incremental/binary_operands.6.zig new file mode 100644 index 0000000000..5c9c5be68a --- /dev/null +++ b/test/incremental/binary_operands.6.zig @@ -0,0 +1,8 @@ +pub fn main() void { + var i: i32 = -2147483648; + if (i -% 1 != 2147483647) unreachable; + return; +} + +// run +// diff --git a/test/incremental/binary_operands.7.zig b/test/incremental/binary_operands.7.zig new file mode 100644 index 0000000000..634a47fb0c --- /dev/null +++ b/test/incremental/binary_operands.7.zig @@ -0,0 +1,8 @@ +pub fn main() void { + var i: i7 = -64; + if (i -% 1 != 63) unreachable; + return; +} + +// run +// diff --git a/test/incremental/binary_operands.8.zig b/test/incremental/binary_operands.8.zig new file mode 100644 index 0000000000..a20f664694 --- /dev/null +++ b/test/incremental/binary_operands.8.zig @@ -0,0 +1,7 @@ +pub fn main() void { + var i: u4 = 0; + if (i -% 1 != 15) unreachable; +} + +// run +// diff --git a/test/incremental/binary_operands.9.zig b/test/incremental/binary_operands.9.zig new file mode 100644 index 0000000000..e6c4f5d52b --- /dev/null +++ b/test/incremental/binary_operands.9.zig @@ -0,0 +1,12 @@ +pub fn main() u8 { + var i: u8 = 5; + i -= 3; + var result: u8 = foo(i, 10); + return result - 8; +} +fn foo(x: u8, y: u8) u8 { + return y - x; +} + +// run +// diff --git a/test/incremental/enum_values.0.zig b/test/incremental/enum_values.0.zig new file mode 100644 index 0000000000..d96841dd8c --- /dev/null +++ b/test/incremental/enum_values.0.zig @@ -0,0 +1,18 @@ +const Number = enum { One, Two, Three }; + +pub fn main() void { + var number1 = Number.One; + var number2: Number = .Two; + if (false) { + number1; + number2; + } + const number3 = @intToEnum(Number, 2); + if (@enumToInt(number3) != 2) { + unreachable; + } + return; +} + +// run +// diff --git a/test/incremental/enum_values.1.zig b/test/incremental/enum_values.1.zig new file mode 100644 index 0000000000..47b9e21a27 --- /dev/null +++ b/test/incremental/enum_values.1.zig @@ -0,0 +1,22 @@ +const Number = enum { One, Two, Three }; + +pub fn main() void { + var number1 = Number.One; + var number2: Number = .Two; + const number3 = @intToEnum(Number, 2); + assert(number1 != number2); + assert(number2 != number3); + assert(@enumToInt(number1) == 0); + assert(@enumToInt(number2) == 1); + assert(@enumToInt(number3) == 2); + var x: Number = .Two; + assert(number2 == x); + + return; +} +fn assert(val: bool) void { + if (!val) unreachable; +} + +// run +// diff --git a/test/incremental/function_calls.0.zig b/test/incremental/function_calls.0.zig new file mode 100644 index 0000000000..eb388bc49f --- /dev/null +++ b/test/incremental/function_calls.0.zig @@ -0,0 +1,12 @@ +pub fn main() void { + foo(); + bar(); +} +fn foo() void { + bar(); + bar(); +} +fn bar() void {} + +// run +// diff --git a/test/incremental/function_calls.1.zig b/test/incremental/function_calls.1.zig new file mode 100644 index 0000000000..60bc061bca --- /dev/null +++ b/test/incremental/function_calls.1.zig @@ -0,0 +1,15 @@ +pub fn main() void { + bar(); + foo(); + foo(); + bar(); + foo(); + bar(); +} +fn foo() void { + bar(); +} +fn bar() void {} + +// run +// diff --git a/test/incremental/function_calls.2.zig b/test/incremental/function_calls.2.zig new file mode 100644 index 0000000000..ce5627378a --- /dev/null +++ b/test/incremental/function_calls.2.zig @@ -0,0 +1,14 @@ +pub fn main() void { + bar(); + foo(); + return; +} +fn foo() void { + bar(); + bar(); + bar(); +} +fn bar() void {} + +// run +// diff --git a/test/incremental/function_calls.3.zig b/test/incremental/function_calls.3.zig new file mode 100644 index 0000000000..0316d9042d --- /dev/null +++ b/test/incremental/function_calls.3.zig @@ -0,0 +1,10 @@ +pub fn main() void { + foo(10, 20); +} +fn foo(x: u8, y: u8) void { + _ = x; + _ = y; +} + +// run +// diff --git a/test/incremental/wasm-wasi/conditions.0.zig b/test/incremental/wasm-wasi/conditions.0.zig new file mode 100644 index 0000000000..1167ea85a4 --- /dev/null +++ b/test/incremental/wasm-wasi/conditions.0.zig @@ -0,0 +1,11 @@ +pub fn main() u8 { + var i: u8 = 5; + if (i > @as(u8, 4)) { + i += 10; + } + return i - 15; +} + +// run +// target=wasm32-wasi +// diff --git a/test/incremental/wasm-wasi/conditions.1.zig b/test/incremental/wasm-wasi/conditions.1.zig new file mode 100644 index 0000000000..f9f03808b9 --- /dev/null +++ b/test/incremental/wasm-wasi/conditions.1.zig @@ -0,0 +1,12 @@ +pub fn main() u8 { + var i: u8 = 5; + if (i < @as(u8, 4)) { + i += 10; + } else { + i = 2; + } + return i - 2; +} + +// run +// diff --git a/test/incremental/wasm-wasi/conditions.2.zig b/test/incremental/wasm-wasi/conditions.2.zig new file mode 100644 index 0000000000..a80ead9ea5 --- /dev/null +++ b/test/incremental/wasm-wasi/conditions.2.zig @@ -0,0 +1,12 @@ +pub fn main() u8 { + var i: u8 = 5; + if (i < @as(u8, 4)) { + i += 10; + } else if (i == @as(u8, 5)) { + i = 20; + } + return i - 20; +} + +// run +// diff --git a/test/incremental/wasm-wasi/conditions.3.zig b/test/incremental/wasm-wasi/conditions.3.zig new file mode 100644 index 0000000000..bd016a47f3 --- /dev/null +++ b/test/incremental/wasm-wasi/conditions.3.zig @@ -0,0 +1,16 @@ +pub fn main() u8 { + var i: u8 = 11; + if (i < @as(u8, 4)) { + i += 10; + } else { + if (i > @as(u8, 10)) { + i += 20; + } else { + i = 20; + } + } + return i - 31; +} + +// run +// diff --git a/test/incremental/wasm-wasi/conditions.4.zig b/test/incremental/wasm-wasi/conditions.4.zig new file mode 100644 index 0000000000..e1bd9ce0f7 --- /dev/null +++ b/test/incremental/wasm-wasi/conditions.4.zig @@ -0,0 +1,15 @@ +pub fn main() void { + assert(foo(true) != @as(i32, 30)); +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +fn foo(ok: bool) i32 { + const x = if (ok) @as(i32, 20) else @as(i32, 10); + return x; +} + +// run +// diff --git a/test/incremental/wasm-wasi/conditions.5.zig b/test/incremental/wasm-wasi/conditions.5.zig new file mode 100644 index 0000000000..2d5ba338c7 --- /dev/null +++ b/test/incremental/wasm-wasi/conditions.5.zig @@ -0,0 +1,20 @@ +pub fn main() void { + assert(foo(false) == @as(i32, 20)); + assert(foo(true) == @as(i32, 30)); +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +fn foo(ok: bool) i32 { + const val: i32 = blk: { + var x: i32 = 1; + if (!ok) break :blk x + @as(i32, 9); + break :blk x + @as(i32, 19); + }; + return val + 10; +} + +// run +// diff --git a/test/incremental/wasm-wasi/error_unions.0.zig b/test/incremental/wasm-wasi/error_unions.0.zig new file mode 100644 index 0000000000..355698e4b6 --- /dev/null +++ b/test/incremental/wasm-wasi/error_unions.0.zig @@ -0,0 +1,15 @@ +pub fn main() void { + var e1 = error.Foo; + var e2 = error.Bar; + assert(e1 != e2); + assert(e1 == error.Foo); + assert(e2 == error.Bar); +} + +fn assert(b: bool) void { + if (!b) unreachable; +} + +// run +// target=wasm32-wasi +// diff --git a/test/incremental/wasm-wasi/error_unions.1.zig b/test/incremental/wasm-wasi/error_unions.1.zig new file mode 100644 index 0000000000..526e1a110d --- /dev/null +++ b/test/incremental/wasm-wasi/error_unions.1.zig @@ -0,0 +1,8 @@ +pub fn main() u8 { + var e: anyerror!u8 = 5; + const i = e catch 10; + return i - 5; +} + +// run +// diff --git a/test/incremental/wasm-wasi/error_unions.2.zig b/test/incremental/wasm-wasi/error_unions.2.zig new file mode 100644 index 0000000000..b66c7d78c0 --- /dev/null +++ b/test/incremental/wasm-wasi/error_unions.2.zig @@ -0,0 +1,8 @@ +pub fn main() u8 { + var e: anyerror!u8 = error.Foo; + const i = e catch 10; + return i - 10; +} + +// run +// diff --git a/test/incremental/wasm-wasi/error_unions.3.zig b/test/incremental/wasm-wasi/error_unions.3.zig new file mode 100644 index 0000000000..d37f826272 --- /dev/null +++ b/test/incremental/wasm-wasi/error_unions.3.zig @@ -0,0 +1,12 @@ +pub fn main() u8 { + var e = foo(); + const i = e catch 69; + return i - 5; +} + +fn foo() anyerror!u8 { + return 5; +} + +// run +// diff --git a/test/incremental/wasm-wasi/error_unions.4.zig b/test/incremental/wasm-wasi/error_unions.4.zig new file mode 100644 index 0000000000..bbc8dd34da --- /dev/null +++ b/test/incremental/wasm-wasi/error_unions.4.zig @@ -0,0 +1,12 @@ +pub fn main() u8 { + var e = foo(); + const i = e catch 69; + return i - 69; +} + +fn foo() anyerror!u8 { + return error.Bruh; +} + +// run +// diff --git a/test/incremental/wasm-wasi/error_unions.5.zig b/test/incremental/wasm-wasi/error_unions.5.zig new file mode 100644 index 0000000000..96d52d1de1 --- /dev/null +++ b/test/incremental/wasm-wasi/error_unions.5.zig @@ -0,0 +1,12 @@ +pub fn main() u8 { + var e = foo(); + const i = e catch 42; + return i - 42; +} + +fn foo() anyerror!u8 { + return error.Dab; +} + +// run +// diff --git a/test/incremental/wasm-wasi/locals.0.zig b/test/incremental/wasm-wasi/locals.0.zig new file mode 100644 index 0000000000..f2df242792 --- /dev/null +++ b/test/incremental/wasm-wasi/locals.0.zig @@ -0,0 +1,14 @@ +pub fn main() void { + var i: u8 = 5; + var y: f32 = 42.0; + var x: u8 = 10; + if (false) { + y; + x; + } + if (i != 5) unreachable; +} + +// run +// target=wasm32-wasi +// diff --git a/test/incremental/wasm-wasi/locals.1.zig b/test/incremental/wasm-wasi/locals.1.zig new file mode 100644 index 0000000000..f7e59e1c02 --- /dev/null +++ b/test/incremental/wasm-wasi/locals.1.zig @@ -0,0 +1,17 @@ +pub fn main() void { + var i: u8 = 5; + var y: f32 = 42.0; + _ = y; + var x: u8 = 10; + foo(i, x); + i = x; + if (i != 10) unreachable; +} +fn foo(x: u8, y: u8) void { + _ = y; + var i: u8 = 10; + i = x; +} + +// run +// diff --git a/test/incremental/wasm-wasi/optionals.0.zig b/test/incremental/wasm-wasi/optionals.0.zig new file mode 100644 index 0000000000..e602bf1c80 --- /dev/null +++ b/test/incremental/wasm-wasi/optionals.0.zig @@ -0,0 +1,12 @@ +pub fn main() u8 { + var x: ?u8 = 5; + var y: u8 = 0; + if (x) |val| { + y = val; + } + return y - 5; +} + +// run +// target=wasm32-wasi +// diff --git a/test/incremental/wasm-wasi/optionals.1.zig b/test/incremental/wasm-wasi/optionals.1.zig new file mode 100644 index 0000000000..26e81b8909 --- /dev/null +++ b/test/incremental/wasm-wasi/optionals.1.zig @@ -0,0 +1,11 @@ +pub fn main() u8 { + var x: ?u8 = null; + var y: u8 = 0; + if (x) |val| { + y = val; + } + return y; +} + +// run +// diff --git a/test/incremental/wasm-wasi/optionals.2.zig b/test/incremental/wasm-wasi/optionals.2.zig new file mode 100644 index 0000000000..b610c6d2e9 --- /dev/null +++ b/test/incremental/wasm-wasi/optionals.2.zig @@ -0,0 +1,7 @@ +pub fn main() u8 { + var x: ?u8 = 5; + return x.? - 5; +} + +// run +// diff --git a/test/incremental/wasm-wasi/optionals.3.zig b/test/incremental/wasm-wasi/optionals.3.zig new file mode 100644 index 0000000000..d513c10282 --- /dev/null +++ b/test/incremental/wasm-wasi/optionals.3.zig @@ -0,0 +1,8 @@ +pub fn main() u8 { + var x: u8 = 5; + var y: ?u8 = x; + return y.? - 5; +} + +// run +// diff --git a/test/incremental/wasm-wasi/optionals.4.zig b/test/incremental/wasm-wasi/optionals.4.zig new file mode 100644 index 0000000000..af3400b322 --- /dev/null +++ b/test/incremental/wasm-wasi/optionals.4.zig @@ -0,0 +1,13 @@ +pub fn main() u8 { + var val: ?u8 = 5; + while (val) |*v| { + v.* -= 1; + if (v.* == 2) { + val = null; + } + } + return 0; +} + +// run +// diff --git a/test/incremental/wasm-wasi/pointers.0.zig b/test/incremental/wasm-wasi/pointers.0.zig new file mode 100644 index 0000000000..958ee5ac88 --- /dev/null +++ b/test/incremental/wasm-wasi/pointers.0.zig @@ -0,0 +1,14 @@ +pub fn main() u8 { + var x: u8 = 0; + + foo(&x); + return x - 2; +} + +fn foo(x: *u8) void { + x.* = 2; +} + +// run +// target=wasm32-wasi +// diff --git a/test/incremental/wasm-wasi/pointers.1.zig b/test/incremental/wasm-wasi/pointers.1.zig new file mode 100644 index 0000000000..b3649cf520 --- /dev/null +++ b/test/incremental/wasm-wasi/pointers.1.zig @@ -0,0 +1,18 @@ +pub fn main() u8 { + var x: u8 = 0; + + foo(&x); + bar(&x); + return x - 4; +} + +fn foo(x: *u8) void { + x.* = 2; +} + +fn bar(x: *u8) void { + x.* += 2; +} + +// run +// diff --git a/test/incremental/wasm-wasi/structs.0.zig b/test/incremental/wasm-wasi/structs.0.zig new file mode 100644 index 0000000000..03a8938d9e --- /dev/null +++ b/test/incremental/wasm-wasi/structs.0.zig @@ -0,0 +1,10 @@ +const Example = struct { x: u8 }; + +pub fn main() u8 { + var example: Example = .{ .x = 5 }; + return example.x - 5; +} + +// run +// target=wasm32-wasi +// diff --git a/test/incremental/wasm-wasi/structs.1.zig b/test/incremental/wasm-wasi/structs.1.zig new file mode 100644 index 0000000000..8d4250e4a2 --- /dev/null +++ b/test/incremental/wasm-wasi/structs.1.zig @@ -0,0 +1,10 @@ +const Example = struct { x: u8 }; + +pub fn main() u8 { + var example: Example = .{ .x = 5 }; + example.x = 10; + return example.x - 10; +} + +// run +// diff --git a/test/incremental/wasm-wasi/structs.2.zig b/test/incremental/wasm-wasi/structs.2.zig new file mode 100644 index 0000000000..b1d3cbf080 --- /dev/null +++ b/test/incremental/wasm-wasi/structs.2.zig @@ -0,0 +1,9 @@ +const Example = struct { x: u8, y: u8 }; + +pub fn main() u8 { + var example: Example = .{ .x = 5, .y = 10 }; + return example.y + example.x - 15; +} + +// run +// diff --git a/test/incremental/wasm-wasi/structs.3.zig b/test/incremental/wasm-wasi/structs.3.zig new file mode 100644 index 0000000000..558b5a1e2d --- /dev/null +++ b/test/incremental/wasm-wasi/structs.3.zig @@ -0,0 +1,12 @@ +const Example = struct { x: u8, y: u8 }; + +pub fn main() u8 { + var example: Example = .{ .x = 5, .y = 10 }; + var example2: Example = .{ .x = 10, .y = 20 }; + + example = example2; + return example.y + example.x - 30; +} + +// run +// diff --git a/test/incremental/wasm-wasi/structs.4.zig b/test/incremental/wasm-wasi/structs.4.zig new file mode 100644 index 0000000000..2d37446c56 --- /dev/null +++ b/test/incremental/wasm-wasi/structs.4.zig @@ -0,0 +1,11 @@ +const Example = struct { x: u8, y: u8 }; + +pub fn main() u8 { + var example: Example = .{ .x = 5, .y = 10 }; + + example = .{ .x = 10, .y = 20 }; + return example.y + example.x - 30; +} + +// run +// diff --git a/test/incremental/wasm-wasi/switch.0.zig b/test/incremental/wasm-wasi/switch.0.zig new file mode 100644 index 0000000000..d0c0e43f8f --- /dev/null +++ b/test/incremental/wasm-wasi/switch.0.zig @@ -0,0 +1,15 @@ +pub fn main() u8 { + var val: u8 = 1; + var a: u8 = switch (val) { + 0, 1 => 2, + 2 => 3, + 3 => 4, + else => 5, + }; + + return a - 2; +} + +// run +// target=wasm32-wasi +// diff --git a/test/incremental/wasm-wasi/switch.1.zig b/test/incremental/wasm-wasi/switch.1.zig new file mode 100644 index 0000000000..fe503bf212 --- /dev/null +++ b/test/incremental/wasm-wasi/switch.1.zig @@ -0,0 +1,14 @@ +pub fn main() u8 { + var val: u8 = 2; + var a: u8 = switch (val) { + 0, 1 => 2, + 2 => 3, + 3 => 4, + else => 5, + }; + + return a - 3; +} + +// run +// diff --git a/test/incremental/wasm-wasi/switch.2.zig b/test/incremental/wasm-wasi/switch.2.zig new file mode 100644 index 0000000000..24f40d8402 --- /dev/null +++ b/test/incremental/wasm-wasi/switch.2.zig @@ -0,0 +1,14 @@ +pub fn main() u8 { + var val: u8 = 10; + var a: u8 = switch (val) { + 0, 1 => 2, + 2 => 3, + 3 => 4, + else => 5, + }; + + return a - 5; +} + +// run +// diff --git a/test/incremental/wasm-wasi/switch.3.zig b/test/incremental/wasm-wasi/switch.3.zig new file mode 100644 index 0000000000..e0b55db3bf --- /dev/null +++ b/test/incremental/wasm-wasi/switch.3.zig @@ -0,0 +1,15 @@ +const MyEnum = enum { One, Two, Three }; + +pub fn main() u8 { + var val: MyEnum = .Two; + var a: u8 = switch (val) { + .One => 1, + .Two => 2, + .Three => 3, + }; + + return a - 2; +} + +// run +// diff --git a/test/incremental/wasm-wasi/while_loops.0.zig b/test/incremental/wasm-wasi/while_loops.0.zig new file mode 100644 index 0000000000..721b127ff5 --- /dev/null +++ b/test/incremental/wasm-wasi/while_loops.0.zig @@ -0,0 +1,12 @@ +pub fn main() u8 { + var i: u8 = 0; + while (i < @as(u8, 5)) { + i += 1; + } + + return i - 5; +} + +// run +// target=wasm32-wasi +// diff --git a/test/incremental/wasm-wasi/while_loops.1.zig b/test/incremental/wasm-wasi/while_loops.1.zig new file mode 100644 index 0000000000..715a813b65 --- /dev/null +++ b/test/incremental/wasm-wasi/while_loops.1.zig @@ -0,0 +1,11 @@ +pub fn main() u8 { + var i: u8 = 0; + while (i < @as(u8, 10)) { + var x: u8 = 1; + i += x; + } + return i - 10; +} + +// run +// diff --git a/test/incremental/wasm-wasi/while_loops.2.zig b/test/incremental/wasm-wasi/while_loops.2.zig new file mode 100644 index 0000000000..7ad8101c37 --- /dev/null +++ b/test/incremental/wasm-wasi/while_loops.2.zig @@ -0,0 +1,12 @@ +pub fn main() u8 { + var i: u8 = 0; + while (i < @as(u8, 10)) { + var x: u8 = 1; + i += x; + if (i == @as(u8, 5)) break; + } + return i - 5; +} + +// run +// diff --git a/test/stage2/wasm.zig b/test/stage2/wasm.zig deleted file mode 100644 index 7c7e203b40..0000000000 --- a/test/stage2/wasm.zig +++ /dev/null @@ -1,796 +0,0 @@ -const std = @import("std"); -const TestContext = @import("../../src/test.zig").TestContext; - -const wasi = std.zig.CrossTarget{ - .cpu_arch = .wasm32, - .os_tag = .wasi, -}; - -pub fn addCases(ctx: *TestContext) !void { - { - var case = ctx.exe("wasm function calls", wasi); - - case.addCompareOutput( - \\pub fn main() void { - \\ foo(); - \\ bar(); - \\} - \\fn foo() void { - \\ bar(); - \\ bar(); - \\} - \\fn bar() void {} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ bar(); - \\ foo(); - \\ foo(); - \\ bar(); - \\ foo(); - \\ bar(); - \\} - \\fn foo() void { - \\ bar(); - \\} - \\fn bar() void {} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ bar(); - \\ foo(); - \\ return; - \\} - \\fn foo() void { - \\ bar(); - \\ bar(); - \\ bar(); - \\} - \\fn bar() void {} - , - "", - ); - - case.addCompareOutput( - \\pub fn main() void { - \\ foo(10, 20); - \\} - \\fn foo(x: u8, y: u8) void { _ = x; _ = y; } - , ""); - } - - { - var case = ctx.exe("wasm locals", wasi); - - case.addCompareOutput( - \\pub fn main() void { - \\ var i: u8 = 5; - \\ var y: f32 = 42.0; - \\ var x: u8 = 10; - \\ if (false) { - \\ y; - \\ x; - \\ } - \\ if (i != 5) unreachable; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ var i: u8 = 5; - \\ var y: f32 = 42.0; - \\ _ = y; - \\ var x: u8 = 10; - \\ foo(i, x); - \\ i = x; - \\ if (i != 10) unreachable; - \\} - \\fn foo(x: u8, y: u8) void { - \\ _ = y; - \\ var i: u8 = 10; - \\ i = x; - \\} - , ""); - } - - { - var case = ctx.exe("wasm binary operands", wasi); - - case.addCompareOutput( - \\pub fn main() void { - \\ var i: u8 = 5; - \\ i += 20; - \\ if (i != 25) unreachable; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ var i: i32 = 2147483647; - \\ if (i +% 1 != -2147483648) unreachable; - \\ return; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ var i: i4 = 7; - \\ if (i +% 1 != 0) unreachable; - \\ return; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var i: u8 = 255; - \\ return i +% 1; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var i: u8 = 5; - \\ i += 20; - \\ var result: u8 = foo(i, 10); - \\ return result - 35; - \\} - \\fn foo(x: u8, y: u8) u8 { - \\ return x + y; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var i: u8 = 20; - \\ i -= 5; - \\ return i - 15; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ var i: i32 = -2147483648; - \\ if (i -% 1 != 2147483647) unreachable; - \\ return; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ var i: i7 = -64; - \\ if (i -% 1 != 63) unreachable; - \\ return; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ var i: u4 = 0; - \\ if(i -% 1 != 15) unreachable; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var i: u8 = 5; - \\ i -= 3; - \\ var result: u8 = foo(i, 10); - \\ return result - 8; - \\} - \\fn foo(x: u8, y: u8) u8 { - \\ return y - x; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ var i: u32 = 5; - \\ i *= 7; - \\ var result: u32 = foo(i, 10); - \\ if (result != 350) unreachable; - \\ return; - \\} - \\fn foo(x: u32, y: u32) u32 { - \\ return x * y; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ var i: i32 = 2147483647; - \\ const result = i *% 2; - \\ if (result != -2) unreachable; - \\ return; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ var i: u3 = 3; - \\ if (i *% 3 != 1) unreachable; - \\ return; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ var i: i4 = 3; - \\ if (i *% 3 != 1) unreachable; - \\ return; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ var i: u32 = 352; - \\ i /= 7; // i = 50 - \\ var result: u32 = foo(i, 7); - \\ if (result != 7) unreachable; - \\ return; - \\} - \\fn foo(x: u32, y: u32) u32 { - \\ return x / y; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var i: u8 = 5; - \\ i &= 6; - \\ return i - 4; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var i: u8 = 5; - \\ i |= 6; - \\ return i - 7; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var i: u8 = 5; - \\ i ^= 6; - \\ return i - 3; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ var b: bool = false; - \\ b = b or false; - \\ if (b) unreachable; - \\ return; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ var b: bool = true; - \\ b = b or false; - \\ if (!b) unreachable; - \\ return; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ var b: bool = false; - \\ b = b or true; - \\ if (!b) unreachable; - \\ return; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ var b: bool = true; - \\ b = b or true; - \\ if (!b) unreachable; - \\ return; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ var b: bool = false; - \\ b = b and false; - \\ if (b) unreachable; - \\ return; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ var b: bool = true; - \\ b = b and false; - \\ if (b) unreachable; - \\ return; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ var b: bool = false; - \\ b = b and true; - \\ if (b) unreachable; - \\ return; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ var b: bool = true; - \\ b = b and true; - \\ if (!b) unreachable; - \\ return; - \\} - , ""); - } - - { - var case = ctx.exe("wasm conditions", wasi); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var i: u8 = 5; - \\ if (i > @as(u8, 4)) { - \\ i += 10; - \\ } - \\ return i - 15; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var i: u8 = 5; - \\ if (i < @as(u8, 4)) { - \\ i += 10; - \\ } else { - \\ i = 2; - \\ } - \\ return i - 2; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var i: u8 = 5; - \\ if (i < @as(u8, 4)) { - \\ i += 10; - \\ } else if(i == @as(u8, 5)) { - \\ i = 20; - \\ } - \\ return i - 20; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var i: u8 = 11; - \\ if (i < @as(u8, 4)) { - \\ i += 10; - \\ } else { - \\ if (i > @as(u8, 10)) { - \\ i += 20; - \\ } else { - \\ i = 20; - \\ } - \\ } - \\ return i - 31; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ assert(foo(true) != @as(i32, 30)); - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - \\ - \\fn foo(ok: bool) i32 { - \\ const x = if(ok) @as(i32, 20) else @as(i32, 10); - \\ return x; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() void { - \\ assert(foo(false) == @as(i32, 20)); - \\ assert(foo(true) == @as(i32, 30)); - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - \\ - \\fn foo(ok: bool) i32 { - \\ const val: i32 = blk: { - \\ var x: i32 = 1; - \\ if (!ok) break :blk x + @as(i32, 9); - \\ break :blk x + @as(i32, 19); - \\ }; - \\ return val + 10; - \\} - , ""); - } - - { - var case = ctx.exe("wasm while loops", wasi); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var i: u8 = 0; - \\ while(i < @as(u8, 5)){ - \\ i += 1; - \\ } - \\ - \\ return i - 5; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var i: u8 = 0; - \\ while(i < @as(u8, 10)){ - \\ var x: u8 = 1; - \\ i += x; - \\ } - \\ return i - 10; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var i: u8 = 0; - \\ while(i < @as(u8, 10)){ - \\ var x: u8 = 1; - \\ i += x; - \\ if (i == @as(u8, 5)) break; - \\ } - \\ return i - 5; - \\} - , ""); - } - - { - var case = ctx.exe("wasm enum values", wasi); - - case.addCompareOutput( - \\const Number = enum { One, Two, Three }; - \\ - \\pub fn main() void { - \\ var number1 = Number.One; - \\ var number2: Number = .Two; - \\ if (false) { - \\ number1; - \\ number2; - \\ } - \\ const number3 = @intToEnum(Number, 2); - \\ if (@enumToInt(number3) != 2) { - \\ unreachable; - \\ } - \\ return; - \\} - , ""); - - case.addCompareOutput( - \\const Number = enum { One, Two, Three }; - \\ - \\pub fn main() void { - \\ var number1 = Number.One; - \\ var number2: Number = .Two; - \\ const number3 = @intToEnum(Number, 2); - \\ assert(number1 != number2); - \\ assert(number2 != number3); - \\ assert(@enumToInt(number1) == 0); - \\ assert(@enumToInt(number2) == 1); - \\ assert(@enumToInt(number3) == 2); - \\ var x: Number = .Two; - \\ assert(number2 == x); - \\ - \\ return; - \\} - \\fn assert(val: bool) void { - \\ if(!val) unreachable; - \\} - , ""); - } - - { - var case = ctx.exe("wasm structs", wasi); - - case.addCompareOutput( - \\const Example = struct { x: u8 }; - \\ - \\pub fn main() u8 { - \\ var example: Example = .{ .x = 5 }; - \\ return example.x - 5; - \\} - , ""); - - case.addCompareOutput( - \\const Example = struct { x: u8 }; - \\ - \\pub fn main() u8 { - \\ var example: Example = .{ .x = 5 }; - \\ example.x = 10; - \\ return example.x - 10; - \\} - , ""); - - case.addCompareOutput( - \\const Example = struct { x: u8, y: u8 }; - \\ - \\pub fn main() u8 { - \\ var example: Example = .{ .x = 5, .y = 10 }; - \\ return example.y + example.x - 15; - \\} - , ""); - - case.addCompareOutput( - \\const Example = struct { x: u8, y: u8 }; - \\ - \\pub fn main() u8 { - \\ var example: Example = .{ .x = 5, .y = 10 }; - \\ var example2: Example = .{ .x = 10, .y = 20 }; - \\ - \\ example = example2; - \\ return example.y + example.x - 30; - \\} - , ""); - - case.addCompareOutput( - \\const Example = struct { x: u8, y: u8 }; - \\ - \\pub fn main() u8 { - \\ var example: Example = .{ .x = 5, .y = 10 }; - \\ - \\ example = .{ .x = 10, .y = 20 }; - \\ return example.y + example.x - 30; - \\} - , ""); - } - - { - var case = ctx.exe("wasm switch", wasi); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var val: u8 = 1; - \\ var a: u8 = switch (val) { - \\ 0, 1 => 2, - \\ 2 => 3, - \\ 3 => 4, - \\ else => 5, - \\ }; - \\ - \\ return a - 2; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var val: u8 = 2; - \\ var a: u8 = switch (val) { - \\ 0, 1 => 2, - \\ 2 => 3, - \\ 3 => 4, - \\ else => 5, - \\ }; - \\ - \\ return a - 3; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var val: u8 = 10; - \\ var a: u8 = switch (val) { - \\ 0, 1 => 2, - \\ 2 => 3, - \\ 3 => 4, - \\ else => 5, - \\ }; - \\ - \\ return a - 5; - \\} - , ""); - - case.addCompareOutput( - \\const MyEnum = enum { One, Two, Three }; - \\ - \\pub fn main() u8 { - \\ var val: MyEnum = .Two; - \\ var a: u8 = switch (val) { - \\ .One => 1, - \\ .Two => 2, - \\ .Three => 3, - \\ }; - \\ - \\ return a - 2; - \\} - , ""); - } - - { - var case = ctx.exe("wasm error unions", wasi); - - case.addCompareOutput( - \\pub fn main() void { - \\ var e1 = error.Foo; - \\ var e2 = error.Bar; - \\ assert(e1 != e2); - \\ assert(e1 == error.Foo); - \\ assert(e2 == error.Bar); - \\} - \\ - \\fn assert(b: bool) void { - \\ if (!b) unreachable; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var e: anyerror!u8 = 5; - \\ const i = e catch 10; - \\ return i - 5; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var e: anyerror!u8 = error.Foo; - \\ const i = e catch 10; - \\ return i - 10; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var e = foo(); - \\ const i = e catch 69; - \\ return i - 5; - \\} - \\ - \\fn foo() anyerror!u8 { - \\ return 5; - \\} - , ""); - } - - { - var case = ctx.exe("wasm error union part 2", wasi); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var e = foo(); - \\ const i = e catch 69; - \\ return i - 69; - \\} - \\ - \\fn foo() anyerror!u8 { - \\ return error.Bruh; - \\} - , ""); - case.addCompareOutput( - \\pub fn main() u8 { - \\ var e = foo(); - \\ const i = e catch 42; - \\ return i - 42; - \\} - \\ - \\fn foo() anyerror!u8 { - \\ return error.Dab; - \\} - , ""); - } - - { - var case = ctx.exe("wasm integer widening", wasi); - - case.addCompareOutput( - \\pub fn main() void{ - \\ var x: u8 = 5; - \\ var y: u64 = x; - \\ _ = y; - \\ return; - \\} - , ""); - } - - { - var case = ctx.exe("wasm optionals", wasi); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var x: ?u8 = 5; - \\ var y: u8 = 0; - \\ if (x) |val| { - \\ y = val; - \\ } - \\ return y - 5; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var x: ?u8 = null; - \\ var y: u8 = 0; - \\ if (x) |val| { - \\ y = val; - \\ } - \\ return y; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var x: ?u8 = 5; - \\ return x.? - 5; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var x: u8 = 5; - \\ var y: ?u8 = x; - \\ return y.? - 5; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var val: ?u8 = 5; - \\ while (val) |*v| { - \\ v.* -= 1; - \\ if (v.* == 2) { - \\ val = null; - \\ } - \\ } - \\ return 0; - \\} - , ""); - } - - { - var case = ctx.exe("wasm pointers", wasi); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var x: u8 = 0; - \\ - \\ foo(&x); - \\ return x - 2; - \\} - \\ - \\fn foo(x: *u8)void { - \\ x.* = 2; - \\} - , ""); - - case.addCompareOutput( - \\pub fn main() u8 { - \\ var x: u8 = 0; - \\ - \\ foo(&x); - \\ bar(&x); - \\ return x - 4; - \\} - \\ - \\fn foo(x: *u8)void { - \\ x.* = 2; - \\} - \\ - \\fn bar(x: *u8) void { - \\ x.* += 2; - \\} - , ""); - } -} From 7e17cbbda5de49759f7b130320578ed96b3810a1 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Wed, 27 Apr 2022 23:06:11 +0200 Subject: [PATCH 16/26] test: migrate riscv64 incremental tests --- test/cases.zig | 1 - .../hello_world_with_updates.0.zig | 21 ++++++++++++ .../hello_world_with_updates.1.zig | 27 +++++++++++++++ test/stage2/riscv64.zig | 33 ------------------- 4 files changed, 48 insertions(+), 34 deletions(-) create mode 100644 test/incremental/riscv64-linux/hello_world_with_updates.0.zig create mode 100644 test/incremental/riscv64-linux/hello_world_with_updates.1.zig delete mode 100644 test/stage2/riscv64.zig diff --git a/test/cases.zig b/test/cases.zig index cc77104fb9..fc38794cdd 100644 --- a/test/cases.zig +++ b/test/cases.zig @@ -12,7 +12,6 @@ pub fn addCases(ctx: *TestContext) !void { try @import("stage2/arm.zig").addCases(ctx); try @import("stage2/aarch64.zig").addCases(ctx); try @import("stage2/llvm.zig").addCases(ctx); - try @import("stage2/riscv64.zig").addCases(ctx); try @import("stage2/plan9.zig").addCases(ctx); try @import("stage2/x86_64.zig").addCases(ctx); try @import("stage2/sparcv9.zig").addCases(ctx); diff --git a/test/incremental/riscv64-linux/hello_world_with_updates.0.zig b/test/incremental/riscv64-linux/hello_world_with_updates.0.zig new file mode 100644 index 0000000000..dd119fd1f4 --- /dev/null +++ b/test/incremental/riscv64-linux/hello_world_with_updates.0.zig @@ -0,0 +1,21 @@ +pub fn main() void { + print(); +} + +fn print() void { + asm volatile ("ecall" + : + : [number] "{a7}" (64), + [arg1] "{a0}" (1), + [arg2] "{a1}" (@ptrToInt("Hello, World!\n")), + [arg3] "{a2}" ("Hello, World!\n".len), + : "rcx", "r11", "memory" + ); + return; +} + +// run +// target=riscv64-linux +// +// Hello, World! +// diff --git a/test/incremental/riscv64-linux/hello_world_with_updates.1.zig b/test/incremental/riscv64-linux/hello_world_with_updates.1.zig new file mode 100644 index 0000000000..26718738a9 --- /dev/null +++ b/test/incremental/riscv64-linux/hello_world_with_updates.1.zig @@ -0,0 +1,27 @@ +pub fn main() void { + print(); + print(); + print(); + print(); +} + +fn print() void { + asm volatile ("ecall" + : + : [number] "{a7}" (64), + [arg1] "{a0}" (1), + [arg2] "{a1}" (@ptrToInt("Hello, World!\n")), + [arg3] "{a2}" ("Hello, World!\n".len), + : "rcx", "r11", "memory" + ); + return; +} + +// run +// target=riscv64-linux +// +// Hello, World! +// Hello, World! +// Hello, World! +// Hello, World! +// diff --git a/test/stage2/riscv64.zig b/test/stage2/riscv64.zig deleted file mode 100644 index c492f1d6b7..0000000000 --- a/test/stage2/riscv64.zig +++ /dev/null @@ -1,33 +0,0 @@ -const std = @import("std"); -const TestContext = @import("../../src/test.zig").TestContext; - -const linux_riscv64 = std.zig.CrossTarget{ - .cpu_arch = .riscv64, - .os_tag = .linux, -}; - -pub fn addCases(ctx: *TestContext) !void { - { - var case = ctx.exe("riscv64 hello world", linux_riscv64); - // Regular old hello world - case.addCompareOutput( - \\pub fn main() void { - \\ print(); - \\} - \\ - \\fn print() void { - \\ asm volatile ("ecall" - \\ : - \\ : [number] "{a7}" (64), - \\ [arg1] "{a0}" (1), - \\ [arg2] "{a1}" (@ptrToInt("Hello, World!\n")), - \\ [arg3] "{a2}" ("Hello, World!\n".len) - \\ : "rcx", "r11", "memory" - \\ ); - \\ return; - \\} - , - "Hello, World!\n", - ); - } -} From fc4fbfe8e1689417da8130f02045e5cc9e120a1a Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Wed, 27 Apr 2022 23:36:29 +0200 Subject: [PATCH 17/26] test: migrate aarch64 incremental tests --- test/cases.zig | 1 - .../aarch64-linux/conditional_branches.0.zig | 26 ++ .../aarch64-linux/conditional_branches.1.zig | 25 ++ .../hello_world_with_updates.0.zig | 31 ++ .../hello_world_with_updates.1.zig | 36 +++ .../hello_world_with_updates.2.zig | 21 ++ .../hello_world_with_updates.0.zig | 5 + .../hello_world_with_updates.1.zig | 5 + .../hello_world_with_updates.2.zig | 19 ++ .../hello_world_with_updates.3.zig | 16 ++ .../hello_world_with_updates.4.zig | 22 ++ .../hello_world_with_updates.5.zig | 16 ++ .../hello_world_with_updates.6.zig | 18 ++ test/incremental/large_add_function.zig | 38 +++ test/stage2/aarch64.zig | 271 ------------------ 15 files changed, 278 insertions(+), 272 deletions(-) create mode 100644 test/incremental/aarch64-linux/conditional_branches.0.zig create mode 100644 test/incremental/aarch64-linux/conditional_branches.1.zig create mode 100644 test/incremental/aarch64-linux/hello_world_with_updates.0.zig create mode 100644 test/incremental/aarch64-linux/hello_world_with_updates.1.zig create mode 100644 test/incremental/aarch64-linux/hello_world_with_updates.2.zig create mode 100644 test/incremental/aarch64-macos/hello_world_with_updates.0.zig create mode 100644 test/incremental/aarch64-macos/hello_world_with_updates.1.zig create mode 100644 test/incremental/aarch64-macos/hello_world_with_updates.2.zig create mode 100644 test/incremental/aarch64-macos/hello_world_with_updates.3.zig create mode 100644 test/incremental/aarch64-macos/hello_world_with_updates.4.zig create mode 100644 test/incremental/aarch64-macos/hello_world_with_updates.5.zig create mode 100644 test/incremental/aarch64-macos/hello_world_with_updates.6.zig create mode 100644 test/incremental/large_add_function.zig delete mode 100644 test/stage2/aarch64.zig diff --git a/test/cases.zig b/test/cases.zig index fc38794cdd..c615d84099 100644 --- a/test/cases.zig +++ b/test/cases.zig @@ -10,7 +10,6 @@ pub fn addCases(ctx: *TestContext) !void { try @import("compile_errors.zig").addCases(ctx); try @import("stage2/cbe.zig").addCases(ctx); try @import("stage2/arm.zig").addCases(ctx); - try @import("stage2/aarch64.zig").addCases(ctx); try @import("stage2/llvm.zig").addCases(ctx); try @import("stage2/plan9.zig").addCases(ctx); try @import("stage2/x86_64.zig").addCases(ctx); diff --git a/test/incremental/aarch64-linux/conditional_branches.0.zig b/test/incremental/aarch64-linux/conditional_branches.0.zig new file mode 100644 index 0000000000..28435b9d4a --- /dev/null +++ b/test/incremental/aarch64-linux/conditional_branches.0.zig @@ -0,0 +1,26 @@ +pub fn main() void { + foo(123); +} + +fn foo(x: u64) void { + if (x > 42) { + print(); + } +} + +fn print() void { + asm volatile ("svc #0" + : + : [number] "{x8}" (64), + [arg1] "{x0}" (1), + [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), + [arg3] "{x2}" ("Hello, World!\n".len), + : "memory", "cc" + ); +} + +// run +// target=aarch64-linux +// +// Hello, World! +// diff --git a/test/incremental/aarch64-linux/conditional_branches.1.zig b/test/incremental/aarch64-linux/conditional_branches.1.zig new file mode 100644 index 0000000000..e03758fcb7 --- /dev/null +++ b/test/incremental/aarch64-linux/conditional_branches.1.zig @@ -0,0 +1,25 @@ +pub fn main() void { + foo(true); +} + +fn foo(x: bool) void { + if (x) { + print(); + } +} + +fn print() void { + asm volatile ("svc #0" + : + : [number] "{x8}" (64), + [arg1] "{x0}" (1), + [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), + [arg3] "{x2}" ("Hello, World!\n".len), + : "memory", "cc" + ); +} + +// run +// +// Hello, World! +// diff --git a/test/incremental/aarch64-linux/hello_world_with_updates.0.zig b/test/incremental/aarch64-linux/hello_world_with_updates.0.zig new file mode 100644 index 0000000000..7a87d74dc3 --- /dev/null +++ b/test/incremental/aarch64-linux/hello_world_with_updates.0.zig @@ -0,0 +1,31 @@ +pub export fn _start() noreturn { + print(); + exit(0); +} + +fn print() void { + asm volatile ("svc #0" + : + : [number] "{x8}" (64), + [arg1] "{x0}" (1), + [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), + [arg3] "{x2}" ("Hello, World!\n".len), + : "memory", "cc" + ); +} + +fn exit(ret: usize) noreturn { + asm volatile ("svc #0" + : + : [number] "{x8}" (93), + [arg1] "{x0}" (ret), + : "memory", "cc" + ); + unreachable; +} + +// run +// target=aarch64-linux +// +// Hello, World! +// diff --git a/test/incremental/aarch64-linux/hello_world_with_updates.1.zig b/test/incremental/aarch64-linux/hello_world_with_updates.1.zig new file mode 100644 index 0000000000..a5ca0d9926 --- /dev/null +++ b/test/incremental/aarch64-linux/hello_world_with_updates.1.zig @@ -0,0 +1,36 @@ +pub export fn _start() noreturn { + print(); + print(); + print(); + print(); + exit(0); +} + +fn print() void { + asm volatile ("svc #0" + : + : [number] "{x8}" (64), + [arg1] "{x0}" (1), + [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), + [arg3] "{x2}" ("Hello, World!\n".len), + : "memory", "cc" + ); +} + +fn exit(ret: usize) noreturn { + asm volatile ("svc #0" + : + : [number] "{x8}" (93), + [arg1] "{x0}" (ret), + : "memory", "cc" + ); + unreachable; +} + +// run +// +// Hello, World! +// Hello, World! +// Hello, World! +// Hello, World! +// diff --git a/test/incremental/aarch64-linux/hello_world_with_updates.2.zig b/test/incremental/aarch64-linux/hello_world_with_updates.2.zig new file mode 100644 index 0000000000..71f0f160bc --- /dev/null +++ b/test/incremental/aarch64-linux/hello_world_with_updates.2.zig @@ -0,0 +1,21 @@ +pub fn main() void { + print(); + print(); +} + +fn print() void { + asm volatile ("svc #0" + : + : [number] "{x8}" (64), + [arg1] "{x0}" (1), + [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), + [arg3] "{x2}" ("Hello, World!\n".len), + : "memory", "cc" + ); +} + +// run +// +// Hello, World! +// Hello, World! +// diff --git a/test/incremental/aarch64-macos/hello_world_with_updates.0.zig b/test/incremental/aarch64-macos/hello_world_with_updates.0.zig new file mode 100644 index 0000000000..11a379a9a9 --- /dev/null +++ b/test/incremental/aarch64-macos/hello_world_with_updates.0.zig @@ -0,0 +1,5 @@ +// error +// output_mode=Exe +// target=aarch64-macos +// +// :109:9: error: struct 'tmp.tmp' has no member named 'main' diff --git a/test/incremental/aarch64-macos/hello_world_with_updates.1.zig b/test/incremental/aarch64-macos/hello_world_with_updates.1.zig new file mode 100644 index 0000000000..909fc9ccfb --- /dev/null +++ b/test/incremental/aarch64-macos/hello_world_with_updates.1.zig @@ -0,0 +1,5 @@ +pub export fn main() noreturn {} + +// error +// +// :1:32: error: expected noreturn, found void diff --git a/test/incremental/aarch64-macos/hello_world_with_updates.2.zig b/test/incremental/aarch64-macos/hello_world_with_updates.2.zig new file mode 100644 index 0000000000..fb8cb39edd --- /dev/null +++ b/test/incremental/aarch64-macos/hello_world_with_updates.2.zig @@ -0,0 +1,19 @@ +extern "c" fn write(usize, usize, usize) usize; +extern "c" fn exit(usize) noreturn; + +pub export fn main() noreturn { + print(); + + exit(0); +} + +fn print() void { + const msg = @ptrToInt("Hello, World!\n"); + const len = 14; + _ = write(1, msg, len); +} + +// run +// +// Hello, World! +// diff --git a/test/incremental/aarch64-macos/hello_world_with_updates.3.zig b/test/incremental/aarch64-macos/hello_world_with_updates.3.zig new file mode 100644 index 0000000000..f6e233886b --- /dev/null +++ b/test/incremental/aarch64-macos/hello_world_with_updates.3.zig @@ -0,0 +1,16 @@ +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + print(); +} + +fn print() void { + const msg = @ptrToInt("Hello, World!\n"); + const len = 14; + _ = write(1, msg, len); +} + +// run +// +// Hello, World! +// diff --git a/test/incremental/aarch64-macos/hello_world_with_updates.4.zig b/test/incremental/aarch64-macos/hello_world_with_updates.4.zig new file mode 100644 index 0000000000..f89cef7354 --- /dev/null +++ b/test/incremental/aarch64-macos/hello_world_with_updates.4.zig @@ -0,0 +1,22 @@ +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + print(); + print(); + print(); + print(); +} + +fn print() void { + const msg = @ptrToInt("Hello, World!\n"); + const len = 14; + _ = write(1, msg, len); +} + +// run +// +// Hello, World! +// Hello, World! +// Hello, World! +// Hello, World! +// diff --git a/test/incremental/aarch64-macos/hello_world_with_updates.5.zig b/test/incremental/aarch64-macos/hello_world_with_updates.5.zig new file mode 100644 index 0000000000..0d7f97578a --- /dev/null +++ b/test/incremental/aarch64-macos/hello_world_with_updates.5.zig @@ -0,0 +1,16 @@ +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + print(); +} + +fn print() void { + const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); + const len = 104; + _ = write(1, msg, len); +} + +// run +// +// What is up? This is a longer message that will force the data to be relocated in virtual address space. +// diff --git a/test/incremental/aarch64-macos/hello_world_with_updates.6.zig b/test/incremental/aarch64-macos/hello_world_with_updates.6.zig new file mode 100644 index 0000000000..3ce2cb7176 --- /dev/null +++ b/test/incremental/aarch64-macos/hello_world_with_updates.6.zig @@ -0,0 +1,18 @@ +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + print(); + print(); +} + +fn print() void { + const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); + const len = 104; + _ = write(1, msg, len); +} + +// run +// +// What is up? This is a longer message that will force the data to be relocated in virtual address space. +// What is up? This is a longer message that will force the data to be relocated in virtual address space. +// diff --git a/test/incremental/large_add_function.zig b/test/incremental/large_add_function.zig new file mode 100644 index 0000000000..8b0e9b879b --- /dev/null +++ b/test/incremental/large_add_function.zig @@ -0,0 +1,38 @@ +pub fn main() void { + assert(add(3, 4) == 791); +} + +fn add(a: u32, b: u32) u32 { + const x: u32 = blk: { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + const j = i + d; // 110 + const k = i + j; // 210 + const l = k + c; // 217 + const m = l + d; // 227 + const n = m + e; // 241 + const o = n + f; // 265 + const p = o + g; // 303 + const q = p + h; // 365 + const r = q + i; // 465 + const s = r + j; // 575 + const t = s + k; // 785 + break :blk t; + }; + const y = x + a; // 788 + const z = y + a; // 791 + return z; +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// target=aarch64-linux,aarch64-macos +// diff --git a/test/stage2/aarch64.zig b/test/stage2/aarch64.zig deleted file mode 100644 index 84334c2a29..0000000000 --- a/test/stage2/aarch64.zig +++ /dev/null @@ -1,271 +0,0 @@ -const std = @import("std"); -const CrossTarget = std.zig.CrossTarget; -const TestContext = @import("../../src/test.zig").TestContext; - -const linux_aarch64 = CrossTarget{ - .cpu_arch = .aarch64, - .os_tag = .linux, -}; -const macos_aarch64 = CrossTarget{ - .cpu_arch = .aarch64, - .os_tag = .macos, -}; - -pub fn addCases(ctx: *TestContext) !void { - // Linux tests - { - var case = ctx.exe("linux_aarch64 hello world", linux_aarch64); - // Regular old hello world - case.addCompareOutput( - \\pub fn main() void { - \\ print(); - \\} - \\ - \\fn print() void { - \\ asm volatile ("svc #0" - \\ : - \\ : [number] "{x8}" (64), - \\ [arg1] "{x0}" (1), - \\ [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), - \\ [arg3] "{x2}" ("Hello, World!\n".len) - \\ : "memory", "cc" - \\ ); - \\} - , - "Hello, World!\n", - ); - } - - { - var case = ctx.exe("exit fn taking argument", linux_aarch64); - - case.addCompareOutput( - \\pub export fn _start() noreturn { - \\ exit(0); - \\} - \\ - \\fn exit(ret: usize) noreturn { - \\ asm volatile ("svc #0" - \\ : - \\ : [number] "{x8}" (93), - \\ [arg1] "{x0}" (ret) - \\ : "memory", "cc" - \\ ); - \\ unreachable; - \\} - , - "", - ); - } - - { - var case = ctx.exe("conditional branches", linux_aarch64); - - case.addCompareOutput( - \\pub fn main() void { - \\ foo(123); - \\} - \\ - \\fn foo(x: u64) void { - \\ if (x > 42) { - \\ print(); - \\ } - \\} - \\ - \\fn print() void { - \\ asm volatile ("svc #0" - \\ : - \\ : [number] "{x8}" (64), - \\ [arg1] "{x0}" (1), - \\ [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), - \\ [arg3] "{x2}" ("Hello, World!\n".len), - \\ : "memory", "cc" - \\ ); - \\} - , - "Hello, World!\n", - ); - - case.addCompareOutput( - \\pub fn main() void { - \\ foo(true); - \\} - \\ - \\fn foo(x: bool) void { - \\ if (x) { - \\ print(); - \\ } - \\} - \\ - \\fn print() void { - \\ asm volatile ("svc #0" - \\ : - \\ : [number] "{x8}" (64), - \\ [arg1] "{x0}" (1), - \\ [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), - \\ [arg3] "{x2}" ("Hello, World!\n".len), - \\ : "memory", "cc" - \\ ); - \\} - , - "Hello, World!\n", - ); - } - - { - var case = ctx.exe("large add function", linux_aarch64); - - case.addCompareOutput( - \\pub fn main() void { - \\ assert(add(3, 4) == 791); - \\} - \\ - \\fn add(a: u32, b: u32) u32 { - \\ const x: u32 = blk: { - \\ const c = a + b; // 7 - \\ const d = a + c; // 10 - \\ const e = d + b; // 14 - \\ const f = d + e; // 24 - \\ const g = e + f; // 38 - \\ const h = f + g; // 62 - \\ const i = g + h; // 100 - \\ const j = i + d; // 110 - \\ const k = i + j; // 210 - \\ const l = k + c; // 217 - \\ const m = l + d; // 227 - \\ const n = m + e; // 241 - \\ const o = n + f; // 265 - \\ const p = o + g; // 303 - \\ const q = p + h; // 365 - \\ const r = q + i; // 465 - \\ const s = r + j; // 575 - \\ const t = s + k; // 785 - \\ break :blk t; - \\ }; - \\ const y = x + a; // 788 - \\ const z = y + a; // 791 - \\ return z; - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , - "", - ); - } - - // macOS tests - { - var case = ctx.exe("hello world with updates", macos_aarch64); - case.addError("", &[_][]const u8{ - ":109:9: error: struct 'tmp.tmp' has no member named 'main'", - }); - - // Incorrect return type - case.addError( - \\pub export fn main() noreturn { - \\} - , &[_][]const u8{ - ":2:1: error: expected noreturn, found void", - }); - - // Regular old hello world - case.addCompareOutput( - \\extern "c" fn write(usize, usize, usize) usize; - \\extern "c" fn exit(usize) noreturn; - \\ - \\pub export fn main() noreturn { - \\ print(); - \\ - \\ exit(0); - \\} - \\ - \\fn print() void { - \\ const msg = @ptrToInt("Hello, World!\n"); - \\ const len = 14; - \\ _ = write(1, msg, len); - \\} - , - "Hello, World!\n", - ); - - // Now using start.zig without an explicit extern exit fn - case.addCompareOutput( - \\extern "c" fn write(usize, usize, usize) usize; - \\ - \\pub fn main() void { - \\ print(); - \\} - \\ - \\fn print() void { - \\ const msg = @ptrToInt("Hello, World!\n"); - \\ const len = 14; - \\ _ = write(1, msg, len); - \\} - , - "Hello, World!\n", - ); - - // Print it 4 times and force growth and realloc. - case.addCompareOutput( - \\extern "c" fn write(usize, usize, usize) usize; - \\ - \\pub fn main() void { - \\ print(); - \\ print(); - \\ print(); - \\ print(); - \\} - \\ - \\fn print() void { - \\ const msg = @ptrToInt("Hello, World!\n"); - \\ const len = 14; - \\ _ = write(1, msg, len); - \\} - , - \\Hello, World! - \\Hello, World! - \\Hello, World! - \\Hello, World! - \\ - ); - - // Print it once, and change the message. - case.addCompareOutput( - \\extern "c" fn write(usize, usize, usize) usize; - \\ - \\pub fn main() void { - \\ print(); - \\} - \\ - \\fn print() void { - \\ const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); - \\ const len = 104; - \\ _ = write(1, msg, len); - \\} - , - "What is up? This is a longer message that will force the data to be relocated in virtual address space.\n", - ); - - // Now we print it twice. - case.addCompareOutput( - \\extern "c" fn write(usize, usize, usize) usize; - \\ - \\pub fn main() void { - \\ print(); - \\ print(); - \\} - \\ - \\fn print() void { - \\ const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); - \\ const len = 104; - \\ _ = write(1, msg, len); - \\} - , - \\What is up? This is a longer message that will force the data to be relocated in virtual address space. - \\What is up? This is a longer message that will force the data to be relocated in virtual address space. - \\ - ); - } -} From ed51a5d02af58b3d11b555233781d71e6bde60af Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Thu, 28 Apr 2022 00:09:26 +0200 Subject: [PATCH 18/26] test: migrate arm incremental tests --- test/cases.zig | 1 - .../arm-linux/arithmetic_operations.0.zig | 21 + .../arm-linux/arithmetic_operations.1.zig | 20 + .../arm-linux/arithmetic_operations.2.zig | 20 + .../arm-linux/arithmetic_operations.3.zig | 20 + .../arm-linux/arithmetic_operations.4.zig | 20 + .../arm-linux/arithmetic_operations.5.zig | 15 + .../arm-linux/arithmetic_operations.6.zig | 21 + test/incremental/arm-linux/errors.0.zig | 21 + test/incremental/arm-linux/errors.1.zig | 24 + test/incremental/arm-linux/errors.2.zig | 27 + test/incremental/arm-linux/errors.3.zig | 12 + .../arm-linux/function_pointers.zig | 44 + .../arm-linux/hello_world_with_updates.0.zig | 32 + .../arm-linux/hello_world_with_updates.1.zig | 37 + .../arm-linux/hello_world_with_updates.2.zig | 22 + .../parameters_and_return_values.0.zig | 28 + .../parameters_and_return_values.1.zig | 14 + test/incremental/arm-linux/print_u32s.zig | 40 + .../arm-linux/spilling_registers.0.zig | 38 + .../arm-linux/spilling_registers.1.zig | 37 + test/incremental/non_leaf_functions.zig | 12 + test/incremental/recursive_fibonacci.zig | 24 + ...rn_values_in_callee_preserved_register.zig | 22 + test/stage2/arm.zig | 798 ------------------ 25 files changed, 571 insertions(+), 799 deletions(-) create mode 100644 test/incremental/arm-linux/arithmetic_operations.0.zig create mode 100644 test/incremental/arm-linux/arithmetic_operations.1.zig create mode 100644 test/incremental/arm-linux/arithmetic_operations.2.zig create mode 100644 test/incremental/arm-linux/arithmetic_operations.3.zig create mode 100644 test/incremental/arm-linux/arithmetic_operations.4.zig create mode 100644 test/incremental/arm-linux/arithmetic_operations.5.zig create mode 100644 test/incremental/arm-linux/arithmetic_operations.6.zig create mode 100644 test/incremental/arm-linux/errors.0.zig create mode 100644 test/incremental/arm-linux/errors.1.zig create mode 100644 test/incremental/arm-linux/errors.2.zig create mode 100644 test/incremental/arm-linux/errors.3.zig create mode 100644 test/incremental/arm-linux/function_pointers.zig create mode 100644 test/incremental/arm-linux/hello_world_with_updates.0.zig create mode 100644 test/incremental/arm-linux/hello_world_with_updates.1.zig create mode 100644 test/incremental/arm-linux/hello_world_with_updates.2.zig create mode 100644 test/incremental/arm-linux/parameters_and_return_values.0.zig create mode 100644 test/incremental/arm-linux/parameters_and_return_values.1.zig create mode 100644 test/incremental/arm-linux/print_u32s.zig create mode 100644 test/incremental/arm-linux/spilling_registers.0.zig create mode 100644 test/incremental/arm-linux/spilling_registers.1.zig create mode 100644 test/incremental/non_leaf_functions.zig create mode 100644 test/incremental/recursive_fibonacci.zig create mode 100644 test/incremental/save_function_return_values_in_callee_preserved_register.zig delete mode 100644 test/stage2/arm.zig diff --git a/test/cases.zig b/test/cases.zig index c615d84099..f90233df0f 100644 --- a/test/cases.zig +++ b/test/cases.zig @@ -9,7 +9,6 @@ const TestContext = @import("../src/test.zig").TestContext; pub fn addCases(ctx: *TestContext) !void { try @import("compile_errors.zig").addCases(ctx); try @import("stage2/cbe.zig").addCases(ctx); - try @import("stage2/arm.zig").addCases(ctx); try @import("stage2/llvm.zig").addCases(ctx); try @import("stage2/plan9.zig").addCases(ctx); try @import("stage2/x86_64.zig").addCases(ctx); diff --git a/test/incremental/arm-linux/arithmetic_operations.0.zig b/test/incremental/arm-linux/arithmetic_operations.0.zig new file mode 100644 index 0000000000..51a2dbd700 --- /dev/null +++ b/test/incremental/arm-linux/arithmetic_operations.0.zig @@ -0,0 +1,21 @@ +pub fn main() void { + print(2, 4); + print(1, 7); +} + +fn print(a: u32, b: u32) void { + asm volatile ("svc #0" + : + : [number] "{r7}" (4), + [arg3] "{r2}" (a + b), + [arg1] "{r0}" (1), + [arg2] "{r1}" (@ptrToInt("123456789")), + : "memory" + ); + return; +} + +// run +// target=arm-linux +// +// 12345612345678 diff --git a/test/incremental/arm-linux/arithmetic_operations.1.zig b/test/incremental/arm-linux/arithmetic_operations.1.zig new file mode 100644 index 0000000000..1e3793ed38 --- /dev/null +++ b/test/incremental/arm-linux/arithmetic_operations.1.zig @@ -0,0 +1,20 @@ +pub fn main() void { + print(10, 5); + print(4, 3); +} + +fn print(a: u32, b: u32) void { + asm volatile ("svc #0" + : + : [number] "{r7}" (4), + [arg3] "{r2}" (a - b), + [arg1] "{r0}" (1), + [arg2] "{r1}" (@ptrToInt("123456789")), + : "memory" + ); + return; +} + +// run +// +// 123451 diff --git a/test/incremental/arm-linux/arithmetic_operations.2.zig b/test/incremental/arm-linux/arithmetic_operations.2.zig new file mode 100644 index 0000000000..6b81e62198 --- /dev/null +++ b/test/incremental/arm-linux/arithmetic_operations.2.zig @@ -0,0 +1,20 @@ +pub fn main() void { + print(8, 9); + print(3, 7); +} + +fn print(a: u32, b: u32) void { + asm volatile ("svc #0" + : + : [number] "{r7}" (4), + [arg3] "{r2}" (a & b), + [arg1] "{r0}" (1), + [arg2] "{r1}" (@ptrToInt("123456789")), + : "memory" + ); + return; +} + +// run +// +// 12345678123 diff --git a/test/incremental/arm-linux/arithmetic_operations.3.zig b/test/incremental/arm-linux/arithmetic_operations.3.zig new file mode 100644 index 0000000000..23089127f5 --- /dev/null +++ b/test/incremental/arm-linux/arithmetic_operations.3.zig @@ -0,0 +1,20 @@ +pub fn main() void { + print(4, 2); + print(3, 7); +} + +fn print(a: u32, b: u32) void { + asm volatile ("svc #0" + : + : [number] "{r7}" (4), + [arg3] "{r2}" (a | b), + [arg1] "{r0}" (1), + [arg2] "{r1}" (@ptrToInt("123456789")), + : "memory" + ); + return; +} + +// run +// +// 1234561234567 diff --git a/test/incremental/arm-linux/arithmetic_operations.4.zig b/test/incremental/arm-linux/arithmetic_operations.4.zig new file mode 100644 index 0000000000..ce5133c465 --- /dev/null +++ b/test/incremental/arm-linux/arithmetic_operations.4.zig @@ -0,0 +1,20 @@ +pub fn main() void { + print(42, 42); + print(3, 5); +} + +fn print(a: u32, b: u32) void { + asm volatile ("svc #0" + : + : [number] "{r7}" (4), + [arg3] "{r2}" (a ^ b), + [arg1] "{r0}" (1), + [arg2] "{r1}" (@ptrToInt("123456789")), + : "memory" + ); + return; +} + +// run +// +// 123456 diff --git a/test/incremental/arm-linux/arithmetic_operations.5.zig b/test/incremental/arm-linux/arithmetic_operations.5.zig new file mode 100644 index 0000000000..b1c18ca7da --- /dev/null +++ b/test/incremental/arm-linux/arithmetic_operations.5.zig @@ -0,0 +1,15 @@ +pub fn main() void { + var x: u32 = 1; + assert(x << 1 == 2); + + x <<= 1; + assert(x << 2 == 8); + assert(x << 3 == 16); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/arm-linux/arithmetic_operations.6.zig b/test/incremental/arm-linux/arithmetic_operations.6.zig new file mode 100644 index 0000000000..e03731173c --- /dev/null +++ b/test/incremental/arm-linux/arithmetic_operations.6.zig @@ -0,0 +1,21 @@ +pub fn main() void { + var a: u32 = 1024; + assert(a >> 1 == 512); + + a >>= 1; + assert(a >> 2 == 128); + assert(a >> 3 == 64); + assert(a >> 4 == 32); + assert(a >> 5 == 16); + assert(a >> 6 == 8); + assert(a >> 7 == 4); + assert(a >> 8 == 2); + assert(a >> 9 == 1); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/arm-linux/errors.0.zig b/test/incremental/arm-linux/errors.0.zig new file mode 100644 index 0000000000..3e20d1d973 --- /dev/null +++ b/test/incremental/arm-linux/errors.0.zig @@ -0,0 +1,21 @@ +pub fn main() void { + foo() catch print(); +} + +fn foo() anyerror!void {} + +fn print() void { + asm volatile ("svc #0" + : + : [number] "{r7}" (4), + [arg1] "{r0}" (1), + [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), + [arg3] "{r2}" ("Hello, World!\n".len), + : "memory" + ); + return; +} + +// run +// target=arm-linux +// diff --git a/test/incremental/arm-linux/errors.1.zig b/test/incremental/arm-linux/errors.1.zig new file mode 100644 index 0000000000..43fbb12675 --- /dev/null +++ b/test/incremental/arm-linux/errors.1.zig @@ -0,0 +1,24 @@ +pub fn main() void { + foo() catch print(); +} + +fn foo() anyerror!void { + return error.Test; +} + +fn print() void { + asm volatile ("svc #0" + : + : [number] "{r7}" (4), + [arg1] "{r0}" (1), + [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), + [arg3] "{r2}" ("Hello, World!\n".len), + : "memory" + ); + return; +} + +// run +// +// Hello, World! +// diff --git a/test/incremental/arm-linux/errors.2.zig b/test/incremental/arm-linux/errors.2.zig new file mode 100644 index 0000000000..a1b9aef97d --- /dev/null +++ b/test/incremental/arm-linux/errors.2.zig @@ -0,0 +1,27 @@ +pub fn main() void { + foo() catch |err| { + assert(err == error.Foo); + assert(err != error.Bar); + assert(err != error.Baz); + }; + bar() catch |err| { + assert(err != error.Foo); + assert(err == error.Bar); + assert(err != error.Baz); + }; +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +fn foo() anyerror!void { + return error.Foo; +} + +fn bar() anyerror!void { + return error.Bar; +} + +// run +// diff --git a/test/incremental/arm-linux/errors.3.zig b/test/incremental/arm-linux/errors.3.zig new file mode 100644 index 0000000000..390696fcfc --- /dev/null +++ b/test/incremental/arm-linux/errors.3.zig @@ -0,0 +1,12 @@ +pub fn main() void { + foo() catch unreachable; +} + +fn foo() anyerror!void { + try bar(); +} + +fn bar() anyerror!void {} + +// run +// diff --git a/test/incremental/arm-linux/function_pointers.zig b/test/incremental/arm-linux/function_pointers.zig new file mode 100644 index 0000000000..0ef5df6745 --- /dev/null +++ b/test/incremental/arm-linux/function_pointers.zig @@ -0,0 +1,44 @@ +const PrintFn = *const fn () void; + +pub fn main() void { + var printFn: PrintFn = stopSayingThat; + var i: u32 = 0; + while (i < 4) : (i += 1) printFn(); + + printFn = moveEveryZig; + printFn(); +} + +fn stopSayingThat() void { + asm volatile ("svc #0" + : + : [number] "{r7}" (4), + [arg1] "{r0}" (1), + [arg2] "{r1}" (@ptrToInt("Hello, my name is Inigo Montoya; you killed my father, prepare to die.\n")), + [arg3] "{r2}" ("Hello, my name is Inigo Montoya; you killed my father, prepare to die.\n".len), + : "memory" + ); + return; +} + +fn moveEveryZig() void { + asm volatile ("svc #0" + : + : [number] "{r7}" (4), + [arg1] "{r0}" (1), + [arg2] "{r1}" (@ptrToInt("All your codebase are belong to us\n")), + [arg3] "{r2}" ("All your codebase are belong to us\n".len), + : "memory" + ); + return; +} + +// run +// target=arm-linux +// +// Hello, my name is Inigo Montoya; you killed my father, prepare to die. +// Hello, my name is Inigo Montoya; you killed my father, prepare to die. +// Hello, my name is Inigo Montoya; you killed my father, prepare to die. +// Hello, my name is Inigo Montoya; you killed my father, prepare to die. +// All your codebase are belong to us +// diff --git a/test/incremental/arm-linux/hello_world_with_updates.0.zig b/test/incremental/arm-linux/hello_world_with_updates.0.zig new file mode 100644 index 0000000000..4ffdc2ae0f --- /dev/null +++ b/test/incremental/arm-linux/hello_world_with_updates.0.zig @@ -0,0 +1,32 @@ +pub export fn _start() noreturn { + print(); + exit(); +} + +fn print() void { + asm volatile ("svc #0" + : + : [number] "{r7}" (4), + [arg1] "{r0}" (1), + [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), + [arg3] "{r2}" (14), + : "memory" + ); + return; +} + +fn exit() noreturn { + asm volatile ("svc #0" + : + : [number] "{r7}" (1), + [arg1] "{r0}" (0), + : "memory" + ); + unreachable; +} + +// run +// target=arm-linux +// +// Hello, World! +// diff --git a/test/incremental/arm-linux/hello_world_with_updates.1.zig b/test/incremental/arm-linux/hello_world_with_updates.1.zig new file mode 100644 index 0000000000..8372d757ad --- /dev/null +++ b/test/incremental/arm-linux/hello_world_with_updates.1.zig @@ -0,0 +1,37 @@ +pub export fn _start() noreturn { + print(); + print(); + print(); + print(); + exit(); +} + +fn print() void { + asm volatile ("svc #0" + : + : [number] "{r7}" (4), + [arg1] "{r0}" (1), + [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), + [arg3] "{r2}" (14), + : "memory" + ); + return; +} + +fn exit() noreturn { + asm volatile ("svc #0" + : + : [number] "{r7}" (1), + [arg1] "{r0}" (0), + : "memory" + ); + unreachable; +} + +// run +// +// Hello, World! +// Hello, World! +// Hello, World! +// Hello, World! +// diff --git a/test/incremental/arm-linux/hello_world_with_updates.2.zig b/test/incremental/arm-linux/hello_world_with_updates.2.zig new file mode 100644 index 0000000000..0b97bf2360 --- /dev/null +++ b/test/incremental/arm-linux/hello_world_with_updates.2.zig @@ -0,0 +1,22 @@ +pub fn main() void { + print(); + print(); +} + +fn print() void { + asm volatile ("svc #0" + : + : [number] "{r7}" (4), + [arg1] "{r0}" (1), + [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), + [arg3] "{r2}" (14), + : "memory" + ); + return; +} + +// run +// +// Hello, World! +// Hello, World! +// diff --git a/test/incremental/arm-linux/parameters_and_return_values.0.zig b/test/incremental/arm-linux/parameters_and_return_values.0.zig new file mode 100644 index 0000000000..6a306d802c --- /dev/null +++ b/test/incremental/arm-linux/parameters_and_return_values.0.zig @@ -0,0 +1,28 @@ +pub fn main() void { + print(id(14)); +} + +fn id(x: u32) u32 { + return x; +} + +// TODO: The parameters to the asm statement in print() had to +// be in a specific order because otherwise the write to r0 +// would overwrite the len parameter which resides in r0 +fn print(len: u32) void { + asm volatile ("svc #0" + : + : [number] "{r7}" (4), + [arg3] "{r2}" (len), + [arg1] "{r0}" (1), + [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), + : "memory" + ); + return; +} + +// run +// target=arm-linux +// +// Hello, World! +// diff --git a/test/incremental/arm-linux/parameters_and_return_values.1.zig b/test/incremental/arm-linux/parameters_and_return_values.1.zig new file mode 100644 index 0000000000..f2bc35d22e --- /dev/null +++ b/test/incremental/arm-linux/parameters_and_return_values.1.zig @@ -0,0 +1,14 @@ +pub fn main() void { + assert(add(1, 2, 3, 4, 5, 6) == 21); +} + +fn add(a: u32, b: u32, c: u32, d: u32, e: u32, f: u32) u32 { + return a + b + c + d + e + f; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/arm-linux/print_u32s.zig b/test/incremental/arm-linux/print_u32s.zig new file mode 100644 index 0000000000..92fad75ddf --- /dev/null +++ b/test/incremental/arm-linux/print_u32s.zig @@ -0,0 +1,40 @@ +pub fn main() void { + printNumberHex(0x00000000); + printNumberHex(0xaaaaaaaa); + printNumberHex(0xdeadbeef); + printNumberHex(0x31415926); +} + +fn printNumberHex(x: u32) void { + var i: u5 = 28; + while (true) : (i -= 4) { + const digit = (x >> i) & 0xf; + asm volatile ("svc #0" + : + : [number] "{r7}" (4), + [arg1] "{r0}" (1), + [arg2] "{r1}" (@ptrToInt("0123456789abcdef") + digit), + [arg3] "{r2}" (1), + : "memory" + ); + + if (i == 0) break; + } + asm volatile ("svc #0" + : + : [number] "{r7}" (4), + [arg1] "{r0}" (1), + [arg2] "{r1}" (@ptrToInt("\n")), + [arg3] "{r2}" (1), + : "memory" + ); +} + +// run +// target=arm-linux +// +// 00000000 +// aaaaaaaa +// deadbeef +// 31415926 +// diff --git a/test/incremental/arm-linux/spilling_registers.0.zig b/test/incremental/arm-linux/spilling_registers.0.zig new file mode 100644 index 0000000000..ac74e071ad --- /dev/null +++ b/test/incremental/arm-linux/spilling_registers.0.zig @@ -0,0 +1,38 @@ +pub fn main() void { + assert(add(3, 4) == 791); +} + +fn add(a: u32, b: u32) u32 { + const x: u32 = blk: { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + const j = i + d; // 110 + const k = i + j; // 210 + const l = k + c; // 217 + const m = l + d; // 227 + const n = m + e; // 241 + const o = n + f; // 265 + const p = o + g; // 303 + const q = p + h; // 365 + const r = q + i; // 465 + const s = r + j; // 575 + const t = s + k; // 785 + break :blk t; + }; + const y = x + a; // 788 + const z = y + a; // 791 + return z; +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// target=arm-linux +// diff --git a/test/incremental/arm-linux/spilling_registers.1.zig b/test/incremental/arm-linux/spilling_registers.1.zig new file mode 100644 index 0000000000..f401a5d7b7 --- /dev/null +++ b/test/incremental/arm-linux/spilling_registers.1.zig @@ -0,0 +1,37 @@ +pub fn main() void { + assert(addMul(3, 4) == 357747496); +} + +fn addMul(a: u32, b: u32) u32 { + const x: u32 = blk: { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + const j = i + d; // 110 + const k = i + j; // 210 + const l = k + c; // 217 + const m = l * d; // 2170 + const n = m + e; // 2184 + const o = n * f; // 52416 + const p = o + g; // 52454 + const q = p * h; // 3252148 + const r = q + i; // 3252248 + const s = r * j; // 357747280 + const t = s + k; // 357747490 + break :blk t; + }; + const y = x + a; // 357747493 + const z = y + a; // 357747496 + return z; +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// diff --git a/test/incremental/non_leaf_functions.zig b/test/incremental/non_leaf_functions.zig new file mode 100644 index 0000000000..cb1737130e --- /dev/null +++ b/test/incremental/non_leaf_functions.zig @@ -0,0 +1,12 @@ +pub fn main() void { + foo(); +} + +fn foo() void { + bar(); +} + +fn bar() void {} + +// run +// diff --git a/test/incremental/recursive_fibonacci.zig b/test/incremental/recursive_fibonacci.zig new file mode 100644 index 0000000000..4e284e3fc1 --- /dev/null +++ b/test/incremental/recursive_fibonacci.zig @@ -0,0 +1,24 @@ +pub fn main() void { + assert(fib(0) == 0); + assert(fib(1) == 1); + assert(fib(2) == 1); + assert(fib(3) == 2); + assert(fib(10) == 55); + assert(fib(20) == 6765); +} + +fn fib(n: u32) u32 { + if (n < 2) { + return n; + } else { + return fib(n - 2) + fib(n - 1); + } +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// target=arm-linux,x86_64-linux,x86_64-macos,wasm32-wasi +// diff --git a/test/incremental/save_function_return_values_in_callee_preserved_register.zig b/test/incremental/save_function_return_values_in_callee_preserved_register.zig new file mode 100644 index 0000000000..a201903808 --- /dev/null +++ b/test/incremental/save_function_return_values_in_callee_preserved_register.zig @@ -0,0 +1,22 @@ +pub fn main() void { + assert(foo() == 43); +} + +fn foo() u32 { + return bar() + baz(42); +} + +fn bar() u32 { + return 1; +} + +fn baz(x: u32) u32 { + return x; +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// diff --git a/test/stage2/arm.zig b/test/stage2/arm.zig deleted file mode 100644 index a0afcf9d6f..0000000000 --- a/test/stage2/arm.zig +++ /dev/null @@ -1,798 +0,0 @@ -const std = @import("std"); -const TestContext = @import("../../src/test.zig").TestContext; - -const linux_arm = std.zig.CrossTarget{ - .cpu_arch = .arm, - .os_tag = .linux, -}; - -pub fn addCases(ctx: *TestContext) !void { - { - var case = ctx.exe("linux_arm hello world", linux_arm); - // Hello world using _start and inline asm. - case.addCompareOutput( - \\pub export fn _start() noreturn { - \\ print(); - \\ exit(); - \\} - \\ - \\fn print() void { - \\ asm volatile ("svc #0" - \\ : - \\ : [number] "{r7}" (4), - \\ [arg1] "{r0}" (1), - \\ [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), - \\ [arg3] "{r2}" (14) - \\ : "memory" - \\ ); - \\ return; - \\} - \\ - \\fn exit() noreturn { - \\ asm volatile ("svc #0" - \\ : - \\ : [number] "{r7}" (1), - \\ [arg1] "{r0}" (0) - \\ : "memory" - \\ ); - \\ unreachable; - \\} - , - "Hello, World!\n", - ); - } - - { - var case = ctx.exe("parameters and return values", linux_arm); - // Testing simple parameters and return values - // - // TODO: The parameters to the asm statement in print() had to - // be in a specific order because otherwise the write to r0 - // would overwrite the len parameter which resides in r0 - case.addCompareOutput( - \\pub fn main() void { - \\ print(id(14)); - \\} - \\ - \\fn id(x: u32) u32 { - \\ return x; - \\} - \\ - \\fn print(len: u32) void { - \\ asm volatile ("svc #0" - \\ : - \\ : [number] "{r7}" (4), - \\ [arg3] "{r2}" (len), - \\ [arg1] "{r0}" (1), - \\ [arg2] "{r1}" (@ptrToInt("Hello, World!\n")) - \\ : "memory" - \\ ); - \\ return; - \\} - , - "Hello, World!\n", - ); - - case.addCompareOutput( - \\pub fn main() void { - \\ assert(add(1, 2, 3, 4, 5, 6) == 21); - \\} - \\ - \\fn add(a: u32, b: u32, c: u32, d: u32, e: u32, f: u32) u32 { - \\ return a + b + c + d + e + f; - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - } - - { - var case = ctx.exe("non-leaf functions", linux_arm); - // Testing non-leaf functions - case.addCompareOutput( - \\pub fn main() void { - \\ foo(); - \\} - \\ - \\fn foo() void { - \\ bar(); - \\} - \\ - \\fn bar() void {} - , - "", - ); - } - - { - var case = ctx.exe("arithmetic operations", linux_arm); - - // Add two numbers - case.addCompareOutput( - \\pub fn main() void { - \\ print(2, 4); - \\ print(1, 7); - \\} - \\ - \\fn print(a: u32, b: u32) void { - \\ asm volatile ("svc #0" - \\ : - \\ : [number] "{r7}" (4), - \\ [arg3] "{r2}" (a + b), - \\ [arg1] "{r0}" (1), - \\ [arg2] "{r1}" (@ptrToInt("123456789")) - \\ : "memory" - \\ ); - \\ return; - \\} - , - "12345612345678", - ); - - // Subtract two numbers - case.addCompareOutput( - \\pub fn main() void { - \\ print(10, 5); - \\ print(4, 3); - \\} - \\ - \\fn print(a: u32, b: u32) void { - \\ asm volatile ("svc #0" - \\ : - \\ : [number] "{r7}" (4), - \\ [arg3] "{r2}" (a - b), - \\ [arg1] "{r0}" (1), - \\ [arg2] "{r1}" (@ptrToInt("123456789")) - \\ : "memory" - \\ ); - \\ return; - \\} - , - "123451", - ); - - // Bitwise And - case.addCompareOutput( - \\pub fn main() void { - \\ print(8, 9); - \\ print(3, 7); - \\} - \\ - \\fn print(a: u32, b: u32) void { - \\ asm volatile ("svc #0" - \\ : - \\ : [number] "{r7}" (4), - \\ [arg3] "{r2}" (a & b), - \\ [arg1] "{r0}" (1), - \\ [arg2] "{r1}" (@ptrToInt("123456789")) - \\ : "memory" - \\ ); - \\ return; - \\} - , - "12345678123", - ); - - // Bitwise Or - case.addCompareOutput( - \\pub fn main() void { - \\ print(4, 2); - \\ print(3, 7); - \\} - \\ - \\fn print(a: u32, b: u32) void { - \\ asm volatile ("svc #0" - \\ : - \\ : [number] "{r7}" (4), - \\ [arg3] "{r2}" (a | b), - \\ [arg1] "{r0}" (1), - \\ [arg2] "{r1}" (@ptrToInt("123456789")) - \\ : "memory" - \\ ); - \\ return; - \\} - , - "1234561234567", - ); - - // Bitwise Xor - case.addCompareOutput( - \\pub fn main() void { - \\ print(42, 42); - \\ print(3, 5); - \\} - \\ - \\fn print(a: u32, b: u32) void { - \\ asm volatile ("svc #0" - \\ : - \\ : [number] "{r7}" (4), - \\ [arg3] "{r2}" (a ^ b), - \\ [arg1] "{r0}" (1), - \\ [arg2] "{r1}" (@ptrToInt("123456789")) - \\ : "memory" - \\ ); - \\ return; - \\} - , - "123456", - ); - - // Bit Shift Left - case.addCompareOutput( - \\pub fn main() void { - \\ var x: u32 = 1; - \\ assert(x << 1 == 2); - \\ - \\ x <<= 1; - \\ assert(x << 2 == 8); - \\ assert(x << 3 == 16); - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - - // Bit Shift Right - case.addCompareOutput( - \\pub fn main() void { - \\ var a: u32 = 1024; - \\ assert(a >> 1 == 512); - \\ - \\ a >>= 1; - \\ assert(a >> 2 == 128); - \\ assert(a >> 3 == 64); - \\ assert(a >> 4 == 32); - \\ assert(a >> 5 == 16); - \\ assert(a >> 6 == 8); - \\ assert(a >> 7 == 4); - \\ assert(a >> 8 == 2); - \\ assert(a >> 9 == 1); - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - } - - { - var case = ctx.exe("if statements", linux_arm); - // Simple if statement in assert - case.addCompareOutput( - \\pub fn main() void { - \\ var x: u32 = 123; - \\ var y: u32 = 42; - \\ assert(x > y); - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , - "", - ); - } - - { - var case = ctx.exe("while loops", linux_arm); - // Simple while loop with assert - case.addCompareOutput( - \\pub fn main() void { - \\ var x: u32 = 2020; - \\ var i: u32 = 0; - \\ while (x > 0) { - \\ x -= 2; - \\ i += 1; - \\ } - \\ assert(i == 1010); - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , - "", - ); - } - - { - var case = ctx.exe("integer multiplication", linux_arm); - // Simple u32 integer multiplication - case.addCompareOutput( - \\pub fn main() void { - \\ assert(mul(1, 1) == 1); - \\ assert(mul(42, 1) == 42); - \\ assert(mul(1, 42) == 42); - \\ assert(mul(123, 42) == 5166); - \\} - \\ - \\fn mul(x: u32, y: u32) u32 { - \\ return x * y; - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , - "", - ); - } - - { - var case = ctx.exe("save function return values in callee preserved register", linux_arm); - // Here, it is necessary to save the result of bar() into a - // callee preserved register, otherwise it will be overwritten - // by the first parameter to baz. - case.addCompareOutput( - \\pub fn main() void { - \\ assert(foo() == 43); - \\} - \\ - \\fn foo() u32 { - \\ return bar() + baz(42); - \\} - \\ - \\fn bar() u32 { - \\ return 1; - \\} - \\ - \\fn baz(x: u32) u32 { - \\ return x; - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , - "", - ); - } - - { - var case = ctx.exe("enums", linux_arm); - case.addCompareOutput( - \\const Number = enum { one, two, three }; - \\ - \\pub fn main() void { - \\ var x: Number = .one; - \\ var y = Number.two; - \\ var z = @intToEnum(Number, 2); - \\ assert(@enumToInt(x) == 0); - \\ assert(@enumToInt(y) == 1); - \\ assert(@enumToInt(z) == 2); - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - - case.addCompareOutput( - \\const Number = enum { one, two, three }; - \\ - \\pub fn main() void { - \\ var x: Number = .one; - \\ var y = Number.two; - \\ assert(@enumToInt(x) < @enumToInt(y)); - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - } - - { - var case = ctx.exe("recursive fibonacci", linux_arm); - case.addCompareOutput( - \\pub fn main() void { - \\ assert(fib(0) == 0); - \\ assert(fib(1) == 1); - \\ assert(fib(2) == 1); - \\ assert(fib(3) == 2); - \\ assert(fib(10) == 55); - \\ assert(fib(20) == 6765); - \\} - \\ - \\fn fib(n: u32) u32 { - \\ if (n < 2) { - \\ return n; - \\ } else { - \\ return fib(n - 2) + fib(n - 1); - \\ } - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , - "", - ); - } - - { - var case = ctx.exe("spilling registers", linux_arm); - case.addCompareOutput( - \\pub fn main() void { - \\ assert(add(3, 4) == 791); - \\} - \\ - \\fn add(a: u32, b: u32) u32 { - \\ const x: u32 = blk: { - \\ const c = a + b; // 7 - \\ const d = a + c; // 10 - \\ const e = d + b; // 14 - \\ const f = d + e; // 24 - \\ const g = e + f; // 38 - \\ const h = f + g; // 62 - \\ const i = g + h; // 100 - \\ const j = i + d; // 110 - \\ const k = i + j; // 210 - \\ const l = k + c; // 217 - \\ const m = l + d; // 227 - \\ const n = m + e; // 241 - \\ const o = n + f; // 265 - \\ const p = o + g; // 303 - \\ const q = p + h; // 365 - \\ const r = q + i; // 465 - \\ const s = r + j; // 575 - \\ const t = s + k; // 785 - \\ break :blk t; - \\ }; - \\ const y = x + a; // 788 - \\ const z = y + a; // 791 - \\ return z; - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , - "", - ); - - case.addCompareOutput( - \\pub fn main() void { - \\ assert(addMul(3, 4) == 357747496); - \\} - \\ - \\fn addMul(a: u32, b: u32) u32 { - \\ const x: u32 = blk: { - \\ const c = a + b; // 7 - \\ const d = a + c; // 10 - \\ const e = d + b; // 14 - \\ const f = d + e; // 24 - \\ const g = e + f; // 38 - \\ const h = f + g; // 62 - \\ const i = g + h; // 100 - \\ const j = i + d; // 110 - \\ const k = i + j; // 210 - \\ const l = k + c; // 217 - \\ const m = l * d; // 2170 - \\ const n = m + e; // 2184 - \\ const o = n * f; // 52416 - \\ const p = o + g; // 52454 - \\ const q = p * h; // 3252148 - \\ const r = q + i; // 3252248 - \\ const s = r * j; // 357747280 - \\ const t = s + k; // 357747490 - \\ break :blk t; - \\ }; - \\ const y = x + a; // 357747493 - \\ const z = y + a; // 357747496 - \\ return z; - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , - "", - ); - } - - { - var case = ctx.exe("print u32s", linux_arm); - case.addCompareOutput( - \\pub fn main() void { - \\ printNumberHex(0x00000000); - \\ printNumberHex(0xaaaaaaaa); - \\ printNumberHex(0xdeadbeef); - \\ printNumberHex(0x31415926); - \\} - \\ - \\fn printNumberHex(x: u32) void { - \\ var i: u5 = 28; - \\ while (true) : (i -= 4) { - \\ const digit = (x >> i) & 0xf; - \\ asm volatile ("svc #0" - \\ : - \\ : [number] "{r7}" (4), - \\ [arg1] "{r0}" (1), - \\ [arg2] "{r1}" (@ptrToInt("0123456789abcdef") + digit), - \\ [arg3] "{r2}" (1) - \\ : "memory" - \\ ); - \\ - \\ if (i == 0) break; - \\ } - \\ asm volatile ("svc #0" - \\ : - \\ : [number] "{r7}" (4), - \\ [arg1] "{r0}" (1), - \\ [arg2] "{r1}" (@ptrToInt("\n")), - \\ [arg3] "{r2}" (1) - \\ : "memory" - \\ ); - \\} - , - \\00000000 - \\aaaaaaaa - \\deadbeef - \\31415926 - \\ - , - ); - } - - { - var case = ctx.exe("save compare flags", linux_arm); - case.addCompareOutput( - \\pub fn main() void { - \\ foo(2, 1); - \\} - \\ - \\fn foo(x: u32, y: u32) void { - \\ const b = x > y; - \\ assert(b); - \\ assert(b); - \\} - \\ - \\pub fn assert(ok: bool) void { - \\ if (!ok) unreachable; // assertion failure - \\} - , - "", - ); - } - - { - var case = ctx.exe("optionals", linux_arm); - case.addCompareOutput( - \\var x: u32 = 42; - \\ - \\pub fn main() void { - \\ var p: ?*u32 = null; - \\ assert(p == null); - \\ p = &x; - \\ assert(p != null); - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , - "", - ); - } - - { - var case = ctx.exe("errors", linux_arm); - case.addCompareOutput( - \\pub fn main() void { - \\ foo() catch print(); - \\} - \\ - \\fn foo() anyerror!void {} - \\ - \\fn print() void { - \\ asm volatile ("svc #0" - \\ : - \\ : [number] "{r7}" (4), - \\ [arg1] "{r0}" (1), - \\ [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), - \\ [arg3] "{r2}" ("Hello, World!\n".len), - \\ : "memory" - \\ ); - \\ return; - \\} - , - "", - ); - - case.addCompareOutput( - \\pub fn main() void { - \\ foo() catch print(); - \\} - \\ - \\fn foo() anyerror!void { - \\ return error.Test; - \\} - \\ - \\fn print() void { - \\ asm volatile ("svc #0" - \\ : - \\ : [number] "{r7}" (4), - \\ [arg1] "{r0}" (1), - \\ [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), - \\ [arg3] "{r2}" ("Hello, World!\n".len), - \\ : "memory" - \\ ); - \\ return; - \\} - , - "Hello, World!\n", - ); - - case.addCompareOutput( - \\pub fn main() void { - \\ foo() catch |err| { - \\ assert(err == error.Foo); - \\ assert(err != error.Bar); - \\ assert(err != error.Baz); - \\ }; - \\ bar() catch |err| { - \\ assert(err != error.Foo); - \\ assert(err == error.Bar); - \\ assert(err != error.Baz); - \\ }; - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - \\ - \\fn foo() anyerror!void { - \\ return error.Foo; - \\} - \\ - \\fn bar() anyerror!void { - \\ return error.Bar; - \\} - , - "", - ); - - case.addCompareOutput( - \\pub fn main() void { - \\ foo() catch unreachable; - \\} - \\ - \\fn foo() anyerror!void { - \\ try bar(); - \\} - \\ - \\fn bar() anyerror!void {} - , - "", - ); - } - - { - var case = ctx.exe("slices", linux_arm); - case.addCompareOutput( - \\var array = [_]u32{ 0, 42, 123, 69 }; - \\var s: []const u32 = &array; - \\ - \\pub fn main() void { - \\ assert(s[0] == 0); - \\ assert(s[1] == 42); - \\ assert(s[2] == 123); - \\ assert(s[3] == 69); - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , - "", - ); - } - - { - var case = ctx.exe("structs", linux_arm); - case.addCompareOutput( - \\var array = [_]SomeStruct{ - \\ .{ .a = 0, .b = 42, .c = 69 }, - \\ .{ .a = 1, .b = 2, .c = 3 }, - \\ .{ .a = 123, .b = 456, .c = 789 }, - \\}; - \\var s: []const SomeStruct = &array; - \\ - \\var some_struct: SomeStruct = .{ - \\ .a = 0, - \\ .b = 42, - \\ .c = 69, - \\}; - \\ - \\const SomeStruct = struct { - \\ a: u32, - \\ b: u32, - \\ c: u32, - \\}; - \\ - \\pub fn main() void { - \\ assert(some_struct.a == 0); - \\ assert(some_struct.b == 42); - \\ assert(some_struct.c == 69); - \\ - \\ assert(s[0].a == 0); - \\ assert(s[0].b == 42); - \\ assert(s[0].c == 69); - \\ assert(s[1].a == 1); - \\ assert(s[1].b == 2); - \\ assert(s[1].c == 3); - \\ assert(s[2].a == 123); - \\ assert(s[2].b == 456); - \\ assert(s[2].c == 789); - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - , - "", - ); - } - - { - var case = ctx.exe("function pointers", linux_arm); - case.addCompareOutput( - \\const PrintFn = *const fn () void; - \\ - \\pub fn main() void { - \\ var printFn: PrintFn = stopSayingThat; - \\ var i: u32 = 0; - \\ while (i < 4) : (i += 1) printFn(); - \\ - \\ printFn = moveEveryZig; - \\ printFn(); - \\} - \\ - \\fn stopSayingThat() void { - \\ asm volatile ("svc #0" - \\ : - \\ : [number] "{r7}" (4), - \\ [arg1] "{r0}" (1), - \\ [arg2] "{r1}" (@ptrToInt("Hello, my name is Inigo Montoya; you killed my father, prepare to die.\n")), - \\ [arg3] "{r2}" ("Hello, my name is Inigo Montoya; you killed my father, prepare to die.\n".len), - \\ : "memory" - \\ ); - \\ return; - \\} - \\ - \\fn moveEveryZig() void { - \\ asm volatile ("svc #0" - \\ : - \\ : [number] "{r7}" (4), - \\ [arg1] "{r0}" (1), - \\ [arg2] "{r1}" (@ptrToInt("All your codebase are belong to us\n")), - \\ [arg3] "{r2}" ("All your codebase are belong to us\n".len), - \\ : "memory" - \\ ); - \\ return; - \\} - , - \\Hello, my name is Inigo Montoya; you killed my father, prepare to die. - \\Hello, my name is Inigo Montoya; you killed my father, prepare to die. - \\Hello, my name is Inigo Montoya; you killed my father, prepare to die. - \\Hello, my name is Inigo Montoya; you killed my father, prepare to die. - \\All your codebase are belong to us - \\ - , - ); - } -} From 495bb12e6a5b5783fa14cc08c2c940ee60b80607 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Thu, 28 Apr 2022 00:26:30 +0200 Subject: [PATCH 19/26] test: migrate plan9 and sparcv9 incremental tests --- test/cases.zig | 2 - test/incremental/plan9/exit.zig | 5 ++ .../plan9/hello_world_with_updates.0.zig | 28 ++++++++++ .../plan9/hello_world_with_updates.1.zig | 10 ++++ .../incremental/sparcv9-linux/hello_world.zig | 27 +++++++++ test/stage2/plan9.zig | 55 ------------------- test/stage2/sparcv9.zig | 39 ------------- 7 files changed, 70 insertions(+), 96 deletions(-) create mode 100644 test/incremental/plan9/exit.zig create mode 100644 test/incremental/plan9/hello_world_with_updates.0.zig create mode 100644 test/incremental/plan9/hello_world_with_updates.1.zig create mode 100644 test/incremental/sparcv9-linux/hello_world.zig delete mode 100644 test/stage2/plan9.zig delete mode 100644 test/stage2/sparcv9.zig diff --git a/test/cases.zig b/test/cases.zig index f90233df0f..2d4da15789 100644 --- a/test/cases.zig +++ b/test/cases.zig @@ -10,9 +10,7 @@ pub fn addCases(ctx: *TestContext) !void { try @import("compile_errors.zig").addCases(ctx); try @import("stage2/cbe.zig").addCases(ctx); try @import("stage2/llvm.zig").addCases(ctx); - try @import("stage2/plan9.zig").addCases(ctx); try @import("stage2/x86_64.zig").addCases(ctx); - try @import("stage2/sparcv9.zig").addCases(ctx); // https://github.com/ziglang/zig/issues/10968 //try @import("stage2/nvptx.zig").addCases(ctx); } diff --git a/test/incremental/plan9/exit.zig b/test/incremental/plan9/exit.zig new file mode 100644 index 0000000000..735818fb83 --- /dev/null +++ b/test/incremental/plan9/exit.zig @@ -0,0 +1,5 @@ +pub fn main() void {} + +// run +// target=x86_64-plan9,aarch64-plan9 +// diff --git a/test/incremental/plan9/hello_world_with_updates.0.zig b/test/incremental/plan9/hello_world_with_updates.0.zig new file mode 100644 index 0000000000..7e7c373251 --- /dev/null +++ b/test/incremental/plan9/hello_world_with_updates.0.zig @@ -0,0 +1,28 @@ +pub fn main() void { + const str = "Hello World!\n"; + asm volatile ( + \\push $0 + \\push %%r10 + \\push %%r11 + \\push $1 + \\push $0 + \\syscall + \\pop %%r11 + \\pop %%r11 + \\pop %%r11 + \\pop %%r11 + \\pop %%r11 + : + // pwrite + : [syscall_number] "{rbp}" (51), + [hey] "{r11}" (@ptrToInt(str)), + [strlen] "{r10}" (str.len), + : "rcx", "rbp", "r11", "memory" + ); +} + +// run +// target=x86_64-plan9 +// +// Hello World +// diff --git a/test/incremental/plan9/hello_world_with_updates.1.zig b/test/incremental/plan9/hello_world_with_updates.1.zig new file mode 100644 index 0000000000..4111a8dc08 --- /dev/null +++ b/test/incremental/plan9/hello_world_with_updates.1.zig @@ -0,0 +1,10 @@ +const std = @import("std"); +pub fn main() void { + const str = "Hello World!\n"; + _ = std.os.plan9.pwrite(1, str, str.len, 0); +} + +// run +// +// Hello World +// diff --git a/test/incremental/sparcv9-linux/hello_world.zig b/test/incremental/sparcv9-linux/hello_world.zig new file mode 100644 index 0000000000..327a8c56ad --- /dev/null +++ b/test/incremental/sparcv9-linux/hello_world.zig @@ -0,0 +1,27 @@ +const msg = "Hello, World!\n"; + +pub export fn _start() noreturn { + asm volatile ("ta 0x6d" + : + : [number] "{g1}" (4), + [arg1] "{o0}" (1), + [arg2] "{o1}" (@ptrToInt(msg)), + [arg3] "{o2}" (msg.len), + : "o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7", "memory" + ); + + asm volatile ("ta 0x6d" + : + : [number] "{g1}" (1), + [arg1] "{o0}" (0), + : "o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7", "memory" + ); + + unreachable; +} + +// run +// target=sparcv9-linux +// +// Hello, World! +// diff --git a/test/stage2/plan9.zig b/test/stage2/plan9.zig deleted file mode 100644 index c82f95aa7b..0000000000 --- a/test/stage2/plan9.zig +++ /dev/null @@ -1,55 +0,0 @@ -const std = @import("std"); -const TestContext = @import("../../src/test.zig").TestContext; - -pub fn addCases(ctx: *TestContext) !void { - const x64: std.zig.CrossTarget = .{ - .cpu_arch = .x86_64, - .os_tag = .plan9, - }; - const aarch64: std.zig.CrossTarget = .{ - .cpu_arch = .aarch64, - .os_tag = .plan9, - }; - { - var case = ctx.exe("plan9: exiting correctly x64", x64); - case.addCompareOutput("pub fn main() void {}", ""); - } - { - var case = ctx.exe("plan9: exiting correctly arm", aarch64); - case.addCompareOutput("pub fn main() void {}", ""); - } - { - var case = ctx.exe("plan9: hello world", x64); - case.addCompareOutput( - \\pub fn main() void { - \\ const str = "Hello World!\n"; - \\ asm volatile ( - \\ \\push $0 - \\ \\push %%r10 - \\ \\push %%r11 - \\ \\push $1 - \\ \\push $0 - \\ \\syscall - \\ \\pop %%r11 - \\ \\pop %%r11 - \\ \\pop %%r11 - \\ \\pop %%r11 - \\ \\pop %%r11 - \\ : - \\ // pwrite - \\ : [syscall_number] "{rbp}" (51), - \\ [hey] "{r11}" (@ptrToInt(str)), - \\ [strlen] "{r10}" (str.len) - \\ : "rcx", "rbp", "r11", "memory" - \\ ); - \\} - , "Hello World\n"); - case.addCompareOutput( - \\const std = @import("std"); - \\pub fn main() void { - \\ const str = "Hello World!\n"; - \\ _ = std.os.plan9.pwrite(1, str, str.len, 0); - \\} - , "Hello World\n"); - } -} diff --git a/test/stage2/sparcv9.zig b/test/stage2/sparcv9.zig deleted file mode 100644 index d5611a7fae..0000000000 --- a/test/stage2/sparcv9.zig +++ /dev/null @@ -1,39 +0,0 @@ -const std = @import("std"); -const TestContext = @import("../../src/test.zig").TestContext; - -const linux_sparcv9 = std.zig.CrossTarget{ - .cpu_arch = .sparcv9, - .os_tag = .linux, -}; - -pub fn addCases(ctx: *TestContext) !void { - { - var case = ctx.exe("sparcv9 hello world", linux_sparcv9); - // Regular old hello world - case.addCompareOutput( - \\const msg = "Hello, World!\n"; - \\ - \\pub export fn _start() noreturn { - \\ asm volatile ("ta 0x6d" - \\ : - \\ : [number] "{g1}" (4), - \\ [arg1] "{o0}" (1), - \\ [arg2] "{o1}" (@ptrToInt(msg)), - \\ [arg3] "{o2}" (msg.len) - \\ : "o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7", "memory" - \\ ); - \\ - \\ asm volatile ("ta 0x6d" - \\ : - \\ : [number] "{g1}" (1), - \\ [arg1] "{o0}" (0) - \\ : "o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7", "memory" - \\ ); - \\ - \\ unreachable; - \\} - , - "Hello, World!\n", - ); - } -} From 2cd456f8f451bc73d719381bcb0f3242a1de2e04 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Thu, 28 Apr 2022 00:54:20 +0200 Subject: [PATCH 20/26] test: correctly handle multiple backends To correctly handle multiple backends crossed with multiple targets, we need to push all elements in separate allocated arrays rather than operate on raw iterators. Hence, introduce `getConfigForKeyAlloc`. --- src/test.zig | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/test.zig b/src/test.zig index 1bb3aaa4a1..0377d8823f 100644 --- a/src/test.zig +++ b/src/test.zig @@ -347,6 +347,21 @@ const TestManifest = struct { return self.getConfigForKeyCustomParser(key, T, getDefaultParser(T)); } + fn getConfigForKeyAlloc( + self: TestManifest, + allocator: Allocator, + key: []const u8, + comptime T: type, + ) error{OutOfMemory}![]const T { + var out = std.ArrayList(T).init(allocator); + defer out.deinit(); + var it = self.getConfigForKey(key, T); + while (it.next()) |item| { + try out.append(item); + } + return out.toOwnedSlice(); + } + fn getConfigForKeyAssertSingle(self: TestManifest, key: []const u8, comptime T: type) T { var it = self.getConfigForKey(key, T); const res = it.next().?; @@ -360,8 +375,9 @@ const TestManifest = struct { }; } - fn trailingAlloc(self: TestManifest, arena: Allocator) ![]const []const u8 { - var out = std.ArrayList([]const u8).init(arena); + fn trailingAlloc(self: TestManifest, allocator: Allocator) error{OutOfMemory}![]const []const u8 { + var out = std.ArrayList([]const u8).init(allocator); + defer out.deinit(); var it = self.trailing(); while (it.next()) |line| { try out.append(line); @@ -1068,8 +1084,8 @@ pub const TestContext = struct { var manifest = try TestManifest.parse(ctx.arena, src); if (cases.items.len == 0) { - var backends = manifest.getConfigForKey("backend", Backend); - var targets = manifest.getConfigForKey("target", CrossTarget); + const backends = try manifest.getConfigForKeyAlloc(ctx.arena, "backend", Backend); + const targets = try manifest.getConfigForKeyAlloc(ctx.arena, "target", CrossTarget); const is_test = manifest.getConfigForKeyAssertSingle("is_test", bool); const output_mode = manifest.getConfigForKeyAssertSingle("output_mode", std.builtin.OutputMode); @@ -1081,10 +1097,11 @@ pub const TestContext = struct { }; // Cross-product to get all possible test combinations - while (backends.next()) |backend| { - while (targets.next()) |target| { - const name = try std.fmt.allocPrint(ctx.arena, "{s} ({s})", .{ + for (backends) |backend| { + for (targets) |target| { + const name = try std.fmt.allocPrint(ctx.arena, "{s} ({s}, {s})", .{ name_prefix, + @tagName(backend), try target.zigTriple(ctx.arena), }); const next = ctx.cases.items.len; @@ -1095,6 +1112,7 @@ pub const TestContext = struct { .updates = std.ArrayList(TestContext.Update).init(ctx.cases.allocator), .is_test = is_test, .output_mode = output_mode, + .link_libc = backend == .llvm, .files = std.ArrayList(TestContext.File).init(ctx.cases.allocator), }); try cases.append(next); From 5a5648c0f03058e1d3878cc8c072af968fc90aa8 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Thu, 28 Apr 2022 10:46:05 +0200 Subject: [PATCH 21/26] test: migrate llvm incremental tests --- test/cases.zig | 2 - ...ess_chaining_pointer_to_optional_array.zig | 12 + ..._pointer_access_chaining_array_pointer.zig | 12 + ...spaces_pointer_access_chaining_complex.zig | 13 + ...pointer_access_chaining_struct_pointer.zig | 13 + .../any_typed_null_to_any_typed_optional.zig | 11 + test/incremental/llvm/blocks.zig | 22 + ..._multiple_pointers_with_address_spaces.zig | 12 + ...ment_address_space_reading_and_writing.zig | 48 ++ test/incremental/llvm/for_loop.zig | 16 + test/incremental/llvm/hello_world.zig | 12 + .../llvm/invalid_address_space_coercion.zig | 13 + ...ace_when_taking_address_of_dereference.zig | 13 + test/incremental/llvm/nested_blocks.zig | 24 + test/incremental/llvm/optionals.zig | 45 ++ .../llvm/pointer_keeps_address_space.zig | 12 + ...ace_when_taking_address_of_dereference.zig | 12 + ...ress_space_coerces_to_implicit_pointer.zig | 12 + .../pointer_with_different_address_spaces.zig | 13 + ...pointers_with_different_address_spaces.zig | 13 + test/incremental/llvm/rem.zig | 15 + .../llvm/shift_right_plus_left.0.zig | 12 + .../llvm/shift_right_plus_left.1.zig | 10 + .../llvm/simple_addition_and_subtraction.zig | 20 + test/incremental/llvm/simple_if_statement.zig | 16 + test/incremental/llvm/while_loops.zig | 18 + test/stage2/llvm.zig | 438 ------------------ test/stage2/x86_64.zig | 59 --- 28 files changed, 419 insertions(+), 499 deletions(-) create mode 100644 test/incremental/llvm/address_space_pointer_access_chaining_pointer_to_optional_array.zig create mode 100644 test/incremental/llvm/address_spaces_pointer_access_chaining_array_pointer.zig create mode 100644 test/incremental/llvm/address_spaces_pointer_access_chaining_complex.zig create mode 100644 test/incremental/llvm/address_spaces_pointer_access_chaining_struct_pointer.zig create mode 100644 test/incremental/llvm/any_typed_null_to_any_typed_optional.zig create mode 100644 test/incremental/llvm/blocks.zig create mode 100644 test/incremental/llvm/dereferencing_though_multiple_pointers_with_address_spaces.zig create mode 100644 test/incremental/llvm/f_segment_address_space_reading_and_writing.zig create mode 100644 test/incremental/llvm/for_loop.zig create mode 100644 test/incremental/llvm/hello_world.zig create mode 100644 test/incremental/llvm/invalid_address_space_coercion.zig create mode 100644 test/incremental/llvm/invalid_pointer_keeps_address_space_when_taking_address_of_dereference.zig create mode 100644 test/incremental/llvm/nested_blocks.zig create mode 100644 test/incremental/llvm/optionals.zig create mode 100644 test/incremental/llvm/pointer_keeps_address_space.zig create mode 100644 test/incremental/llvm/pointer_keeps_address_space_when_taking_address_of_dereference.zig create mode 100644 test/incremental/llvm/pointer_to_explicit_generic_address_space_coerces_to_implicit_pointer.zig create mode 100644 test/incremental/llvm/pointer_with_different_address_spaces.zig create mode 100644 test/incremental/llvm/pointers_with_different_address_spaces.zig create mode 100644 test/incremental/llvm/rem.zig create mode 100644 test/incremental/llvm/shift_right_plus_left.0.zig create mode 100644 test/incremental/llvm/shift_right_plus_left.1.zig create mode 100644 test/incremental/llvm/simple_addition_and_subtraction.zig create mode 100644 test/incremental/llvm/simple_if_statement.zig create mode 100644 test/incremental/llvm/while_loops.zig delete mode 100644 test/stage2/llvm.zig delete mode 100644 test/stage2/x86_64.zig diff --git a/test/cases.zig b/test/cases.zig index 2d4da15789..3e340dcddb 100644 --- a/test/cases.zig +++ b/test/cases.zig @@ -9,8 +9,6 @@ const TestContext = @import("../src/test.zig").TestContext; pub fn addCases(ctx: *TestContext) !void { try @import("compile_errors.zig").addCases(ctx); try @import("stage2/cbe.zig").addCases(ctx); - try @import("stage2/llvm.zig").addCases(ctx); - try @import("stage2/x86_64.zig").addCases(ctx); // https://github.com/ziglang/zig/issues/10968 //try @import("stage2/nvptx.zig").addCases(ctx); } diff --git a/test/incremental/llvm/address_space_pointer_access_chaining_pointer_to_optional_array.zig b/test/incremental/llvm/address_space_pointer_access_chaining_pointer_to_optional_array.zig new file mode 100644 index 0000000000..592c82691d --- /dev/null +++ b/test/incremental/llvm/address_space_pointer_access_chaining_pointer_to_optional_array.zig @@ -0,0 +1,12 @@ +fn entry(a: *addrspace(.gs) ?[1]i32) *addrspace(.gs) i32 { + return &a.*.?[0]; +} +pub fn main() void { + _ = entry; +} + +// error +// output_mode=Exe +// backend=llvm +// target=x86_64-linux +// diff --git a/test/incremental/llvm/address_spaces_pointer_access_chaining_array_pointer.zig b/test/incremental/llvm/address_spaces_pointer_access_chaining_array_pointer.zig new file mode 100644 index 0000000000..2e342dc852 --- /dev/null +++ b/test/incremental/llvm/address_spaces_pointer_access_chaining_array_pointer.zig @@ -0,0 +1,12 @@ +fn entry(a: *addrspace(.gs) [1]i32) *addrspace(.gs) i32 { + return &a[0]; +} +pub fn main() void { + _ = entry; +} + +// error +// output_mode=Exe +// backend=stage2,llvm +// target=x86_64-linux +// diff --git a/test/incremental/llvm/address_spaces_pointer_access_chaining_complex.zig b/test/incremental/llvm/address_spaces_pointer_access_chaining_complex.zig new file mode 100644 index 0000000000..5e616bd1da --- /dev/null +++ b/test/incremental/llvm/address_spaces_pointer_access_chaining_complex.zig @@ -0,0 +1,13 @@ +const A = struct { a: ?[1]i32 }; +fn entry(a: *addrspace(.gs) [1]A) *addrspace(.gs) i32 { + return &a[0].a.?[0]; +} +pub fn main() void { + _ = entry; +} + +// error +// output_mode=Exe +// backend=llvm +// target=x86_64-linux +// diff --git a/test/incremental/llvm/address_spaces_pointer_access_chaining_struct_pointer.zig b/test/incremental/llvm/address_spaces_pointer_access_chaining_struct_pointer.zig new file mode 100644 index 0000000000..519833a0e8 --- /dev/null +++ b/test/incremental/llvm/address_spaces_pointer_access_chaining_struct_pointer.zig @@ -0,0 +1,13 @@ +const A = struct { a: i32 }; +fn entry(a: *addrspace(.gs) A) *addrspace(.gs) i32 { + return &a.a; +} +pub fn main() void { + _ = entry; +} + +// error +// output_mode=Exe +// backend=stage2,llvm +// target=x86_64-linux +// diff --git a/test/incremental/llvm/any_typed_null_to_any_typed_optional.zig b/test/incremental/llvm/any_typed_null_to_any_typed_optional.zig new file mode 100644 index 0000000000..af37ebf25d --- /dev/null +++ b/test/incremental/llvm/any_typed_null_to_any_typed_optional.zig @@ -0,0 +1,11 @@ +pub fn main() void { + var a: ?*anyopaque = undefined; + a = @as(?usize, null); +} + +// error +// output_mode=Exe +// backend=stage2,llvm +// target=x86_64-linux +// +// :3:21: error: expected *anyopaque, found ?usize diff --git a/test/incremental/llvm/blocks.zig b/test/incremental/llvm/blocks.zig new file mode 100644 index 0000000000..a2fbfeb618 --- /dev/null +++ b/test/incremental/llvm/blocks.zig @@ -0,0 +1,22 @@ +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +fn foo(ok: bool) i32 { + const val: i32 = blk: { + var x: i32 = 1; + if (!ok) break :blk x + 9; + break :blk x + 19; + }; + return val + 10; +} + +pub fn main() void { + assert(foo(false) == 20); + assert(foo(true) == 30); +} + +// run +// backend=stage2,llvm +// target=x86_64-linux +// diff --git a/test/incremental/llvm/dereferencing_though_multiple_pointers_with_address_spaces.zig b/test/incremental/llvm/dereferencing_though_multiple_pointers_with_address_spaces.zig new file mode 100644 index 0000000000..bc5c3d5b81 --- /dev/null +++ b/test/incremental/llvm/dereferencing_though_multiple_pointers_with_address_spaces.zig @@ -0,0 +1,12 @@ +fn entry(a: *addrspace(.fs) *addrspace(.gs) *i32) *i32 { + return a.*.*; +} +pub fn main() void { + _ = entry; +} + +// error +// output_mode=Exe +// backend=stage2,llvm +// target=x86_64-linux +// diff --git a/test/incremental/llvm/f_segment_address_space_reading_and_writing.zig b/test/incremental/llvm/f_segment_address_space_reading_and_writing.zig new file mode 100644 index 0000000000..62db92668b --- /dev/null +++ b/test/incremental/llvm/f_segment_address_space_reading_and_writing.zig @@ -0,0 +1,48 @@ +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +fn setFs(value: c_ulong) void { + asm volatile ( + \\syscall + : + : [number] "{rax}" (158), + [code] "{rdi}" (0x1002), + [val] "{rsi}" (value), + : "rcx", "r11", "memory" + ); +} + +fn getFs() c_ulong { + var result: c_ulong = undefined; + asm volatile ( + \\syscall + : + : [number] "{rax}" (158), + [code] "{rdi}" (0x1003), + [ptr] "{rsi}" (@ptrToInt(&result)), + : "rcx", "r11", "memory" + ); + return result; +} + +var test_value: u64 = 12345; + +pub fn main() void { + const orig_fs = getFs(); + + setFs(@ptrToInt(&test_value)); + assert(getFs() == @ptrToInt(&test_value)); + + var test_ptr = @intToPtr(*allowzero addrspace(.fs) u64, 0); + assert(test_ptr.* == 12345); + test_ptr.* = 98765; + assert(test_value == 98765); + + setFs(orig_fs); +} + +// run +// backend=llvm +// target=x86_64-linux +// diff --git a/test/incremental/llvm/for_loop.zig b/test/incremental/llvm/for_loop.zig new file mode 100644 index 0000000000..f58350f59c --- /dev/null +++ b/test/incremental/llvm/for_loop.zig @@ -0,0 +1,16 @@ +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +pub fn main() void { + var x: u32 = 0; + for ("hello") |_| { + x += 1; + } + assert("hello".len == x); +} + +// run +// backend=stage2,llvm +// target=x86_64-linux +// diff --git a/test/incremental/llvm/hello_world.zig b/test/incremental/llvm/hello_world.zig new file mode 100644 index 0000000000..bcd9d9f795 --- /dev/null +++ b/test/incremental/llvm/hello_world.zig @@ -0,0 +1,12 @@ +extern fn puts(s: [*:0]const u8) c_int; + +pub fn main() void { + _ = puts("hello world!"); +} + +// run +// backend=llvm +// target=x86_64-linux +// +// hello world! +// diff --git a/test/incremental/llvm/invalid_address_space_coercion.zig b/test/incremental/llvm/invalid_address_space_coercion.zig new file mode 100644 index 0000000000..e46b327bcf --- /dev/null +++ b/test/incremental/llvm/invalid_address_space_coercion.zig @@ -0,0 +1,13 @@ +fn entry(a: *addrspace(.gs) i32) *i32 { + return a; +} +pub fn main() void { + _ = entry; +} + +// error +// output_mode=Exe +// backend=stage2,llvm +// target=x86_64-linux +// +// :2:12: error: expected *i32, found *addrspace(.gs) i32 diff --git a/test/incremental/llvm/invalid_pointer_keeps_address_space_when_taking_address_of_dereference.zig b/test/incremental/llvm/invalid_pointer_keeps_address_space_when_taking_address_of_dereference.zig new file mode 100644 index 0000000000..18b3bebc4d --- /dev/null +++ b/test/incremental/llvm/invalid_pointer_keeps_address_space_when_taking_address_of_dereference.zig @@ -0,0 +1,13 @@ +fn entry(a: *addrspace(.gs) i32) *i32 { + return &a.*; +} +pub fn main() void { + _ = entry; +} + +// error +// output_mode=Exe +// backend=stage2,llvm +// target=x86_64-linux +// +// :2:12: error: expected *i32, found *addrspace(.gs) i32 diff --git a/test/incremental/llvm/nested_blocks.zig b/test/incremental/llvm/nested_blocks.zig new file mode 100644 index 0000000000..974315df96 --- /dev/null +++ b/test/incremental/llvm/nested_blocks.zig @@ -0,0 +1,24 @@ +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +fn foo(ok: bool) i32 { + var val: i32 = blk: { + const val2: i32 = another: { + if (!ok) break :blk 10; + break :another 10; + }; + break :blk val2 + 10; + }; + return val; +} + +pub fn main() void { + assert(foo(false) == 10); + assert(foo(true) == 20); +} + +// run +// backend=stage2, llvm +// target=x86_64-linux +// diff --git a/test/incremental/llvm/optionals.zig b/test/incremental/llvm/optionals.zig new file mode 100644 index 0000000000..05c221a8a8 --- /dev/null +++ b/test/incremental/llvm/optionals.zig @@ -0,0 +1,45 @@ +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +pub fn main() void { + var opt_val: ?i32 = 10; + var null_val: ?i32 = null; + + var val1: i32 = opt_val.?; + const val1_1: i32 = opt_val.?; + var ptr_val1 = &(opt_val.?); + const ptr_val1_1 = &(opt_val.?); + + var val2: i32 = null_val orelse 20; + const val2_2: i32 = null_val orelse 20; + + var value: i32 = 20; + var ptr_val2 = &(null_val orelse value); + + const val3 = opt_val orelse 30; + var val3_var = opt_val orelse 30; + + assert(val1 == 10); + assert(val1_1 == 10); + assert(ptr_val1.* == 10); + assert(ptr_val1_1.* == 10); + + assert(val2 == 20); + assert(val2_2 == 20); + assert(ptr_val2.* == 20); + + assert(val3 == 10); + assert(val3_var == 10); + + (null_val orelse val2) = 1234; + assert(val2 == 1234); + + (opt_val orelse val2) = 5678; + assert(opt_val.? == 5678); +} + +// run +// backend=llvm +// target=x86_64-linux +// diff --git a/test/incremental/llvm/pointer_keeps_address_space.zig b/test/incremental/llvm/pointer_keeps_address_space.zig new file mode 100644 index 0000000000..3d3718c83e --- /dev/null +++ b/test/incremental/llvm/pointer_keeps_address_space.zig @@ -0,0 +1,12 @@ +fn entry(a: *addrspace(.gs) i32) *addrspace(.gs) i32 { + return a; +} +pub fn main() void { + _ = entry; +} + +// error +// output_mode=Exe +// backend=stage2,llvm +// target=x86_64-linux +// diff --git a/test/incremental/llvm/pointer_keeps_address_space_when_taking_address_of_dereference.zig b/test/incremental/llvm/pointer_keeps_address_space_when_taking_address_of_dereference.zig new file mode 100644 index 0000000000..541522e3af --- /dev/null +++ b/test/incremental/llvm/pointer_keeps_address_space_when_taking_address_of_dereference.zig @@ -0,0 +1,12 @@ +fn entry(a: *addrspace(.gs) i32) *addrspace(.gs) i32 { + return &a.*; +} +pub fn main() void { + _ = entry; +} + +// error +// output_mode=Exe +// backend=stage2,llvm +// target=x86_64-linux +// diff --git a/test/incremental/llvm/pointer_to_explicit_generic_address_space_coerces_to_implicit_pointer.zig b/test/incremental/llvm/pointer_to_explicit_generic_address_space_coerces_to_implicit_pointer.zig new file mode 100644 index 0000000000..ff8ae13dab --- /dev/null +++ b/test/incremental/llvm/pointer_to_explicit_generic_address_space_coerces_to_implicit_pointer.zig @@ -0,0 +1,12 @@ +fn entry(a: *addrspace(.generic) i32) *i32 { + return a; +} +pub fn main() void { + _ = entry; +} + +// error +// output_mode=Exe +// backend=stage2,llvm +// target=x86_64-linux +// diff --git a/test/incremental/llvm/pointer_with_different_address_spaces.zig b/test/incremental/llvm/pointer_with_different_address_spaces.zig new file mode 100644 index 0000000000..eaeb669775 --- /dev/null +++ b/test/incremental/llvm/pointer_with_different_address_spaces.zig @@ -0,0 +1,13 @@ +fn entry(a: *addrspace(.gs) i32) *addrspace(.fs) i32 { + return a; +} +pub fn main() void { + _ = entry; +} + +// error +// output_mode=Exe +// backend=stage2,llvm +// target=x86_64-linux +// +// :2:12: error: expected *addrspace(.fs) i32, found *addrspace(.gs) i32 diff --git a/test/incremental/llvm/pointers_with_different_address_spaces.zig b/test/incremental/llvm/pointers_with_different_address_spaces.zig new file mode 100644 index 0000000000..aed6093ec7 --- /dev/null +++ b/test/incremental/llvm/pointers_with_different_address_spaces.zig @@ -0,0 +1,13 @@ +fn entry(a: ?*addrspace(.gs) i32) *i32 { + return a.?; +} +pub fn main() void { + _ = entry; +} + +// error +// output_mode=Exe +// backend=stage2,llvm +// target=x86_64-linux +// +// :2:13: error: expected *i32, found *addrspace(.gs) i32 diff --git a/test/incremental/llvm/rem.zig b/test/incremental/llvm/rem.zig new file mode 100644 index 0000000000..679932d3c2 --- /dev/null +++ b/test/incremental/llvm/rem.zig @@ -0,0 +1,15 @@ +fn assert(ok: bool) void { + if (!ok) unreachable; +} +fn rem(lhs: i32, rhs: i32, expected: i32) bool { + return @rem(lhs, rhs) == expected; +} +pub fn main() void { + assert(rem(-5, 3, -2)); + assert(rem(5, 3, 2)); +} + +// run +// backend=stage2,llvm +// target=x86_64-linux +// diff --git a/test/incremental/llvm/shift_right_plus_left.0.zig b/test/incremental/llvm/shift_right_plus_left.0.zig new file mode 100644 index 0000000000..91d324d084 --- /dev/null +++ b/test/incremental/llvm/shift_right_plus_left.0.zig @@ -0,0 +1,12 @@ +pub fn main() void { + var i: u32 = 16; + assert(i >> 1, 8); +} +fn assert(a: u32, b: u32) void { + if (a != b) unreachable; +} + +// run +// backend=llvm +// target=x86_64-linux +// diff --git a/test/incremental/llvm/shift_right_plus_left.1.zig b/test/incremental/llvm/shift_right_plus_left.1.zig new file mode 100644 index 0000000000..994b67b9d0 --- /dev/null +++ b/test/incremental/llvm/shift_right_plus_left.1.zig @@ -0,0 +1,10 @@ +pub fn main() void { + var i: u32 = 16; + assert(i << 1, 32); +} +fn assert(a: u32, b: u32) void { + if (a != b) unreachable; +} + +// run +// diff --git a/test/incremental/llvm/simple_addition_and_subtraction.zig b/test/incremental/llvm/simple_addition_and_subtraction.zig new file mode 100644 index 0000000000..59011c9d00 --- /dev/null +++ b/test/incremental/llvm/simple_addition_and_subtraction.zig @@ -0,0 +1,20 @@ +fn add(a: i32, b: i32) i32 { + return a + b; +} + +pub fn main() void { + var a: i32 = -5; + const x = add(a, 7); + var y = add(2, 0); + y -= x; + assert(y == 0); +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// backend=stage2,llvm +// target=x86_64-linux +// diff --git a/test/incremental/llvm/simple_if_statement.zig b/test/incremental/llvm/simple_if_statement.zig new file mode 100644 index 0000000000..436fd48e3f --- /dev/null +++ b/test/incremental/llvm/simple_if_statement.zig @@ -0,0 +1,16 @@ +fn add(a: i32, b: i32) i32 { + return a + b; +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +pub fn main() void { + assert(add(1, 2) == 3); +} + +// run +// backend=stage2,llvm +// target=x86_64-linux +// diff --git a/test/incremental/llvm/while_loops.zig b/test/incremental/llvm/while_loops.zig new file mode 100644 index 0000000000..3c092be628 --- /dev/null +++ b/test/incremental/llvm/while_loops.zig @@ -0,0 +1,18 @@ +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +pub fn main() void { + var sum: u32 = 0; + var i: u32 = 0; + while (i < 5) : (i += 1) { + sum += i; + } + assert(sum == 10); + assert(i == 5); +} + +// run +// backend=stage2,llvm +// target=x86_64-linux +// diff --git a/test/stage2/llvm.zig b/test/stage2/llvm.zig deleted file mode 100644 index bf538efaca..0000000000 --- a/test/stage2/llvm.zig +++ /dev/null @@ -1,438 +0,0 @@ -const std = @import("std"); -const TestContext = @import("../../src/test.zig").TestContext; -const build_options = @import("build_options"); - -// These tests should work with all platforms, but we're using linux_x64 for -// now for consistency. Will be expanded eventually. -const linux_x64 = std.zig.CrossTarget{ - .cpu_arch = .x86_64, - .os_tag = .linux, -}; - -pub fn addCases(ctx: *TestContext) !void { - { - var case = ctx.exeUsingLlvmBackend("simple addition and subtraction", linux_x64); - - case.addCompareOutput( - \\fn add(a: i32, b: i32) i32 { - \\ return a + b; - \\} - \\ - \\pub export fn main() c_int { - \\ var a: i32 = -5; - \\ const x = add(a, 7); - \\ var y = add(2, 0); - \\ y -= x; - \\ return y; - \\} - , ""); - } - - { - var case = ctx.exeUsingLlvmBackend("shift right + left", linux_x64); - - case.addCompareOutput( - \\pub export fn main() c_int { - \\ var i: u32 = 16; - \\ assert(i >> 1, 8); - \\ return 0; - \\} - \\fn assert(a: u32, b: u32) void { - \\ if (a != b) unreachable; - \\} - , ""); - case.addCompareOutput( - \\pub export fn main() c_int { - \\ var i: u32 = 16; - \\ assert(i << 1, 32); - \\ return 0; - \\} - \\fn assert(a: u32, b: u32) void { - \\ if (a != b) unreachable; - \\} - , ""); - } - - { - var case = ctx.exeUsingLlvmBackend("llvm hello world", linux_x64); - - case.addCompareOutput( - \\extern fn puts(s: [*:0]const u8) c_int; - \\ - \\pub export fn main() c_int { - \\ _ = puts("hello world!"); - \\ return 0; - \\} - , "hello world!" ++ std.cstr.line_sep); - } - - { - var case = ctx.exeUsingLlvmBackend("simple if statement", linux_x64); - - case.addCompareOutput( - \\fn add(a: i32, b: i32) i32 { - \\ return a + b; - \\} - \\ - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - \\ - \\pub export fn main() c_int { - \\ assert(add(1,2) == 3); - \\ return 0; - \\} - , ""); - } - - { - var case = ctx.exeUsingLlvmBackend("blocks", linux_x64); - - case.addCompareOutput( - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - \\ - \\fn foo(ok: bool) i32 { - \\ const val: i32 = blk: { - \\ var x: i32 = 1; - \\ if (!ok) break :blk x + 9; - \\ break :blk x + 19; - \\ }; - \\ return val + 10; - \\} - \\ - \\pub export fn main() c_int { - \\ assert(foo(false) == 20); - \\ assert(foo(true) == 30); - \\ return 0; - \\} - , ""); - } - - { - var case = ctx.exeUsingLlvmBackend("nested blocks", linux_x64); - - case.addCompareOutput( - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - \\ - \\fn foo(ok: bool) i32 { - \\ var val: i32 = blk: { - \\ const val2: i32 = another: { - \\ if (!ok) break :blk 10; - \\ break :another 10; - \\ }; - \\ break :blk val2 + 10; - \\ }; - \\ return val; - \\} - \\ - \\pub export fn main() c_int { - \\ assert(foo(false) == 10); - \\ assert(foo(true) == 20); - \\ return 0; - \\} - , ""); - } - - { - var case = ctx.exeUsingLlvmBackend("while loops", linux_x64); - - case.addCompareOutput( - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - \\ - \\pub export fn main() c_int { - \\ var sum: u32 = 0; - \\ var i: u32 = 0; - \\ while (i < 5) : (i += 1) { - \\ sum += i; - \\ } - \\ assert(sum == 10); - \\ assert(i == 5); - \\ return 0; - \\} - , ""); - } - - { - var case = ctx.exeUsingLlvmBackend("optionals", linux_x64); - - case.addCompareOutput( - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - \\ - \\pub export fn main() c_int { - \\ var opt_val: ?i32 = 10; - \\ var null_val: ?i32 = null; - \\ - \\ var val1: i32 = opt_val.?; - \\ const val1_1: i32 = opt_val.?; - \\ var ptr_val1 = &(opt_val.?); - \\ const ptr_val1_1 = &(opt_val.?); - \\ - \\ var val2: i32 = null_val orelse 20; - \\ const val2_2: i32 = null_val orelse 20; - \\ - \\ var value: i32 = 20; - \\ var ptr_val2 = &(null_val orelse value); - \\ - \\ const val3 = opt_val orelse 30; - \\ var val3_var = opt_val orelse 30; - \\ - \\ assert(val1 == 10); - \\ assert(val1_1 == 10); - \\ assert(ptr_val1.* == 10); - \\ assert(ptr_val1_1.* == 10); - \\ - \\ assert(val2 == 20); - \\ assert(val2_2 == 20); - \\ assert(ptr_val2.* == 20); - \\ - \\ assert(val3 == 10); - \\ assert(val3_var == 10); - \\ - \\ (null_val orelse val2) = 1234; - \\ assert(val2 == 1234); - \\ - \\ (opt_val orelse val2) = 5678; - \\ assert(opt_val.? == 5678); - \\ - \\ return 0; - \\} - , ""); - } - - { - var case = ctx.exeUsingLlvmBackend("for loop", linux_x64); - - case.addCompareOutput( - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - \\ - \\pub export fn main() c_int { - \\ var x: u32 = 0; - \\ for ("hello") |_| { - \\ x += 1; - \\ } - \\ assert("hello".len == x); - \\ return 0; - \\} - , ""); - } - - { - var case = ctx.exeUsingLlvmBackend("@rem", linux_x64); - case.addCompareOutput( - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - \\fn rem(lhs: i32, rhs: i32, expected: i32) bool { - \\ return @rem(lhs, rhs) == expected; - \\} - \\pub export fn main() c_int { - \\ assert(rem(-5, 3, -2)); - \\ assert(rem(5, 3, 2)); - \\ return 0; - \\} - , ""); - } - - { - var case = ctx.exeUsingLlvmBackend("invalid address space coercion", linux_x64); - case.addError( - \\fn entry(a: *addrspace(.gs) i32) *i32 { - \\ return a; - \\} - \\pub export fn main() void { _ = entry; } - , &[_][]const u8{ - ":2:12: error: expected *i32, found *addrspace(.gs) i32", - }); - } - - { - var case = ctx.exeUsingLlvmBackend("pointer keeps address space", linux_x64); - case.compiles( - \\fn entry(a: *addrspace(.gs) i32) *addrspace(.gs) i32 { - \\ return a; - \\} - \\pub export fn main() void { _ = entry; } - ); - } - - { - var case = ctx.exeUsingLlvmBackend("pointer to explicit generic address space coerces to implicit pointer", linux_x64); - case.compiles( - \\fn entry(a: *addrspace(.generic) i32) *i32 { - \\ return a; - \\} - \\pub export fn main() void { _ = entry; } - ); - } - - { - var case = ctx.exeUsingLlvmBackend("pointers with different address spaces", linux_x64); - case.addError( - \\fn entry(a: *addrspace(.gs) i32) *addrspace(.fs) i32 { - \\ return a; - \\} - \\pub export fn main() void { _ = entry; } - , &[_][]const u8{ - ":2:12: error: expected *addrspace(.fs) i32, found *addrspace(.gs) i32", - }); - } - - { - var case = ctx.exeUsingLlvmBackend("pointers with different address spaces", linux_x64); - case.addError( - \\fn entry(a: ?*addrspace(.gs) i32) *i32 { - \\ return a.?; - \\} - \\pub export fn main() void { _ = entry; } - , &[_][]const u8{ - ":2:13: error: expected *i32, found *addrspace(.gs) i32", - }); - } - - { - var case = ctx.exeUsingLlvmBackend("invalid pointer keeps address space when taking address of dereference", linux_x64); - case.addError( - \\fn entry(a: *addrspace(.gs) i32) *i32 { - \\ return &a.*; - \\} - \\pub export fn main() void { _ = entry; } - , &[_][]const u8{ - ":2:12: error: expected *i32, found *addrspace(.gs) i32", - }); - } - - { - var case = ctx.exeUsingLlvmBackend("pointer keeps address space when taking address of dereference", linux_x64); - case.compiles( - \\fn entry(a: *addrspace(.gs) i32) *addrspace(.gs) i32 { - \\ return &a.*; - \\} - \\pub export fn main() void { _ = entry; } - ); - } - - { - var case = ctx.exeUsingLlvmBackend("address spaces pointer access chaining: array pointer", linux_x64); - case.compiles( - \\fn entry(a: *addrspace(.gs) [1]i32) *addrspace(.gs) i32 { - \\ return &a[0]; - \\} - \\pub export fn main() void { _ = entry; } - ); - } - - { - var case = ctx.exeUsingLlvmBackend("address spaces pointer access chaining: pointer to optional array", linux_x64); - case.compiles( - \\fn entry(a: *addrspace(.gs) ?[1]i32) *addrspace(.gs) i32 { - \\ return &a.*.?[0]; - \\} - \\pub export fn main() void { _ = entry; } - ); - } - - { - var case = ctx.exeUsingLlvmBackend("address spaces pointer access chaining: struct pointer", linux_x64); - case.compiles( - \\const A = struct{ a: i32 }; - \\fn entry(a: *addrspace(.gs) A) *addrspace(.gs) i32 { - \\ return &a.a; - \\} - \\pub export fn main() void { _ = entry; } - ); - } - - { - var case = ctx.exeUsingLlvmBackend("address spaces pointer access chaining: complex", linux_x64); - case.compiles( - \\const A = struct{ a: ?[1]i32 }; - \\fn entry(a: *addrspace(.gs) [1]A) *addrspace(.gs) i32 { - \\ return &a[0].a.?[0]; - \\} - \\pub export fn main() void { _ = entry; } - ); - } - - { - var case = ctx.exeUsingLlvmBackend("dereferencing through multiple pointers with address spaces", linux_x64); - case.compiles( - \\fn entry(a: *addrspace(.fs) *addrspace(.gs) *i32) *i32 { - \\ return a.*.*; - \\} - \\pub export fn main() void { _ = entry; } - ); - } - - { - var case = ctx.exeUsingLlvmBackend("f segment address space reading and writing", linux_x64); - case.addCompareOutput( - \\fn assert(ok: bool) void { - \\ if (!ok) unreachable; - \\} - \\ - \\fn setFs(value: c_ulong) void { - \\ asm volatile ( - \\ \\syscall - \\ : - \\ : [number] "{rax}" (158), - \\ [code] "{rdi}" (0x1002), - \\ [val] "{rsi}" (value), - \\ : "rcx", "r11", "memory" - \\ ); - \\} - \\ - \\fn getFs() c_ulong { - \\ var result: c_ulong = undefined; - \\ asm volatile ( - \\ \\syscall - \\ : - \\ : [number] "{rax}" (158), - \\ [code] "{rdi}" (0x1003), - \\ [ptr] "{rsi}" (@ptrToInt(&result)), - \\ : "rcx", "r11", "memory" - \\ ); - \\ return result; - \\} - \\ - \\var test_value: u64 = 12345; - \\ - \\pub export fn main() c_int { - \\ const orig_fs = getFs(); - \\ - \\ setFs(@ptrToInt(&test_value)); - \\ assert(getFs() == @ptrToInt(&test_value)); - \\ - \\ var test_ptr = @intToPtr(*allowzero addrspace(.fs) u64, 0); - \\ assert(test_ptr.* == 12345); - \\ test_ptr.* = 98765; - \\ assert(test_value == 98765); - \\ - \\ setFs(orig_fs); - \\ return 0; - \\} - , ""); - } - - { - // This worked in stage1 and we expressly do not want this to work in stage2 - var case = ctx.exeUsingLlvmBackend("any typed null to any typed optional", linux_x64); - case.addError( - \\pub export fn main() void { - \\ var a: ?*anyopaque = undefined; - \\ a = @as(?usize, null); - \\} - , &[_][]const u8{ - ":3:21: error: expected *anyopaque, found ?usize", - }); - } -} diff --git a/test/stage2/x86_64.zig b/test/stage2/x86_64.zig deleted file mode 100644 index a4c506400a..0000000000 --- a/test/stage2/x86_64.zig +++ /dev/null @@ -1,59 +0,0 @@ -const std = @import("std"); -const CrossTarget = std.zig.CrossTarget; -const TestContext = @import("../../src/test.zig").TestContext; - -const linux_x64 = std.zig.CrossTarget{ - .cpu_arch = .x86_64, - .os_tag = .linux, -}; -const macos_x64 = CrossTarget{ - .cpu_arch = .x86_64, - .os_tag = .macos, -}; -const all_targets: []const CrossTarget = &[_]CrossTarget{ - linux_x64, - macos_x64, -}; - -pub fn addCases(ctx: *TestContext) !void { - for (all_targets) |target| { - // TODO port this to the new test harness - var case = ctx.exe("basic import", target); - case.addCompareOutput( - \\pub fn main() void { - \\ @import("print.zig").print(); - \\} - , - "Hello, World!\n", - ); - switch (target.getOsTag()) { - .linux => try case.files.append(.{ - .src = - \\pub fn print() void { - \\ asm volatile ("syscall" - \\ : - \\ : [number] "{rax}" (@as(usize, 1)), - \\ [arg1] "{rdi}" (@as(usize, 1)), - \\ [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), - \\ [arg3] "{rdx}" (@as(usize, 14)) - \\ : "rcx", "r11", "memory" - \\ ); - \\ return; - \\} - , - .path = "print.zig", - }), - .macos => try case.files.append(.{ - .src = - \\extern "c" fn write(usize, usize, usize) usize; - \\ - \\pub fn print() void { - \\ _ = write(1, @ptrToInt("Hello, World!\n"), 14); - \\} - , - .path = "print.zig", - }), - else => unreachable, - } - } -} From 2875216f8e01c4e71a76fe840a0b298f0d42758e Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Thu, 28 Apr 2022 11:42:14 +0200 Subject: [PATCH 22/26] test: fix x86_64-macos failures This is just a temporary fix - I would like to unify all of x86_64 tests across linux and macos OSes. --- test/incremental/assert_function.8.zig | 36 ---------- test/incremental/comptime_var.2.zig | 34 ---------- test/incremental/comptime_var.6.zig | 32 --------- ...ess_chaining_pointer_to_optional_array.zig | 2 +- ..._pointer_access_chaining_array_pointer.zig | 2 +- ...spaces_pointer_access_chaining_complex.zig | 2 +- ...pointer_access_chaining_struct_pointer.zig | 2 +- .../any_typed_null_to_any_typed_optional.zig | 2 +- test/incremental/llvm/blocks.zig | 2 +- ..._multiple_pointers_with_address_spaces.zig | 2 +- test/incremental/llvm/for_loop.zig | 2 +- test/incremental/llvm/hello_world.zig | 2 +- .../llvm/invalid_address_space_coercion.zig | 2 +- ...ace_when_taking_address_of_dereference.zig | 2 +- test/incremental/llvm/nested_blocks.zig | 2 +- test/incremental/llvm/optionals.zig | 2 +- .../llvm/pointer_keeps_address_space.zig | 2 +- ...ace_when_taking_address_of_dereference.zig | 2 +- ...ress_space_coerces_to_implicit_pointer.zig | 2 +- .../pointer_with_different_address_spaces.zig | 2 +- ...pointers_with_different_address_spaces.zig | 2 +- test/incremental/llvm/rem.zig | 2 +- .../llvm/shift_right_plus_left.0.zig | 2 +- .../llvm/simple_addition_and_subtraction.zig | 2 +- test/incremental/llvm/simple_if_statement.zig | 2 +- test/incremental/llvm/while_loops.zig | 2 +- .../{ => x86_64-linux}/assert_function.0.zig | 2 +- .../{ => x86_64-linux}/assert_function.1.zig | 0 .../{ => x86_64-linux}/assert_function.10.zig | 0 .../{ => x86_64-linux}/assert_function.11.zig | 0 .../{ => x86_64-linux}/assert_function.12.zig | 0 .../{ => x86_64-linux}/assert_function.13.zig | 0 .../{ => x86_64-linux}/assert_function.14.zig | 0 .../{ => x86_64-linux}/assert_function.15.zig | 0 .../{ => x86_64-linux}/assert_function.16.zig | 0 .../{ => x86_64-linux}/assert_function.17.zig | 0 .../{ => x86_64-linux}/assert_function.18.zig | 0 .../{ => x86_64-linux}/assert_function.2.zig | 0 .../{ => x86_64-linux}/assert_function.3.zig | 0 .../{ => x86_64-linux}/assert_function.4.zig | 0 .../{ => x86_64-linux}/assert_function.5.zig | 0 .../{ => x86_64-linux}/assert_function.6.zig | 0 .../x86_64-linux/assert_function.7.zig | 28 ++++++++ .../x86_64-linux/assert_function.8.zig | 24 +++++++ .../{ => x86_64-linux}/assert_function.9.zig | 0 .../{ => x86_64-linux}/comptime_var.0.zig | 2 +- .../{ => x86_64-linux}/comptime_var.1.zig | 0 .../x86_64-linux/comptime_var.2.zig | 22 +++++++ .../{ => x86_64-linux}/comptime_var.3.zig | 0 .../{ => x86_64-linux}/comptime_var.4.zig | 0 .../{ => x86_64-linux}/comptime_var.5.zig | 0 .../x86_64-linux/comptime_var.6.zig | 20 ++++++ .../x86_64-macos/assert_function.0.zig | 15 +++++ .../x86_64-macos/assert_function.1.zig | 17 +++++ .../x86_64-macos/assert_function.10.zig | 27 ++++++++ .../x86_64-macos/assert_function.11.zig | 66 +++++++++++++++++++ .../x86_64-macos/assert_function.12.zig | 47 +++++++++++++ .../x86_64-macos/assert_function.13.zig | 19 ++++++ .../x86_64-macos/assert_function.14.zig | 17 +++++ .../x86_64-macos/assert_function.15.zig | 10 +++ .../x86_64-macos/assert_function.16.zig | 11 ++++ .../x86_64-macos/assert_function.17.zig | 11 ++++ .../assert_function.18.zig} | 9 +-- .../x86_64-macos/assert_function.2.zig | 21 ++++++ .../x86_64-macos/assert_function.3.zig | 22 +++++++ .../x86_64-macos/assert_function.4.zig | 15 +++++ .../x86_64-macos/assert_function.5.zig | 19 ++++++ .../x86_64-macos/assert_function.6.zig | 9 +++ .../x86_64-macos/assert_function.7.zig | 23 +++++++ .../x86_64-macos/assert_function.8.zig | 19 ++++++ .../x86_64-macos/assert_function.9.zig | 22 +++++++ .../x86_64-macos/comptime_var.0.zig | 12 ++++ .../x86_64-macos/comptime_var.1.zig | 13 ++++ .../x86_64-macos/comptime_var.2.zig | 17 +++++ .../x86_64-macos/comptime_var.3.zig | 10 +++ .../x86_64-macos/comptime_var.4.zig | 9 +++ .../x86_64-macos/comptime_var.5.zig | 15 +++++ .../x86_64-macos/comptime_var.6.zig | 15 +++++ 78 files changed, 602 insertions(+), 134 deletions(-) delete mode 100644 test/incremental/assert_function.8.zig delete mode 100644 test/incremental/comptime_var.2.zig delete mode 100644 test/incremental/comptime_var.6.zig rename test/incremental/{ => x86_64-linux}/assert_function.0.zig (83%) rename test/incremental/{ => x86_64-linux}/assert_function.1.zig (100%) rename test/incremental/{ => x86_64-linux}/assert_function.10.zig (100%) rename test/incremental/{ => x86_64-linux}/assert_function.11.zig (100%) rename test/incremental/{ => x86_64-linux}/assert_function.12.zig (100%) rename test/incremental/{ => x86_64-linux}/assert_function.13.zig (100%) rename test/incremental/{ => x86_64-linux}/assert_function.14.zig (100%) rename test/incremental/{ => x86_64-linux}/assert_function.15.zig (100%) rename test/incremental/{ => x86_64-linux}/assert_function.16.zig (100%) rename test/incremental/{ => x86_64-linux}/assert_function.17.zig (100%) rename test/incremental/{ => x86_64-linux}/assert_function.18.zig (100%) rename test/incremental/{ => x86_64-linux}/assert_function.2.zig (100%) rename test/incremental/{ => x86_64-linux}/assert_function.3.zig (100%) rename test/incremental/{ => x86_64-linux}/assert_function.4.zig (100%) rename test/incremental/{ => x86_64-linux}/assert_function.5.zig (100%) rename test/incremental/{ => x86_64-linux}/assert_function.6.zig (100%) create mode 100644 test/incremental/x86_64-linux/assert_function.7.zig create mode 100644 test/incremental/x86_64-linux/assert_function.8.zig rename test/incremental/{ => x86_64-linux}/assert_function.9.zig (100%) rename test/incremental/{ => x86_64-linux}/comptime_var.0.zig (86%) rename test/incremental/{ => x86_64-linux}/comptime_var.1.zig (100%) create mode 100644 test/incremental/x86_64-linux/comptime_var.2.zig rename test/incremental/{ => x86_64-linux}/comptime_var.3.zig (100%) rename test/incremental/{ => x86_64-linux}/comptime_var.4.zig (100%) rename test/incremental/{ => x86_64-linux}/comptime_var.5.zig (100%) create mode 100644 test/incremental/x86_64-linux/comptime_var.6.zig create mode 100644 test/incremental/x86_64-macos/assert_function.0.zig create mode 100644 test/incremental/x86_64-macos/assert_function.1.zig create mode 100644 test/incremental/x86_64-macos/assert_function.10.zig create mode 100644 test/incremental/x86_64-macos/assert_function.11.zig create mode 100644 test/incremental/x86_64-macos/assert_function.12.zig create mode 100644 test/incremental/x86_64-macos/assert_function.13.zig create mode 100644 test/incremental/x86_64-macos/assert_function.14.zig create mode 100644 test/incremental/x86_64-macos/assert_function.15.zig create mode 100644 test/incremental/x86_64-macos/assert_function.16.zig create mode 100644 test/incremental/x86_64-macos/assert_function.17.zig rename test/incremental/{assert_function.7.zig => x86_64-macos/assert_function.18.zig} (80%) create mode 100644 test/incremental/x86_64-macos/assert_function.2.zig create mode 100644 test/incremental/x86_64-macos/assert_function.3.zig create mode 100644 test/incremental/x86_64-macos/assert_function.4.zig create mode 100644 test/incremental/x86_64-macos/assert_function.5.zig create mode 100644 test/incremental/x86_64-macos/assert_function.6.zig create mode 100644 test/incremental/x86_64-macos/assert_function.7.zig create mode 100644 test/incremental/x86_64-macos/assert_function.8.zig create mode 100644 test/incremental/x86_64-macos/assert_function.9.zig create mode 100644 test/incremental/x86_64-macos/comptime_var.0.zig create mode 100644 test/incremental/x86_64-macos/comptime_var.1.zig create mode 100644 test/incremental/x86_64-macos/comptime_var.2.zig create mode 100644 test/incremental/x86_64-macos/comptime_var.3.zig create mode 100644 test/incremental/x86_64-macos/comptime_var.4.zig create mode 100644 test/incremental/x86_64-macos/comptime_var.5.zig create mode 100644 test/incremental/x86_64-macos/comptime_var.6.zig diff --git a/test/incremental/assert_function.8.zig b/test/incremental/assert_function.8.zig deleted file mode 100644 index f845de9aa0..0000000000 --- a/test/incremental/assert_function.8.zig +++ /dev/null @@ -1,36 +0,0 @@ -const builtin = @import("builtin"); - -extern "c" fn write(usize, usize, usize) usize; - -pub fn main() void { - var i: u32 = 0; - inline while (i < 4) : (i += 1) print(); - assert(i == 4); -} - -fn print() void { - switch (builtin.os.tag) { - .linux => { - asm volatile ("syscall" - : - : [number] "{rax}" (1), - [arg1] "{rdi}" (1), - [arg2] "{rsi}" (@ptrToInt("hello\n")), - [arg3] "{rdx}" (6), - : "rcx", "r11", "memory" - ); - }, - .macos => { - _ = write(1, @ptrToInt("hello\n"), 6); - }, - else => unreachable, - } -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// error -// -// :7:21: error: unable to resolve comptime value diff --git a/test/incremental/comptime_var.2.zig b/test/incremental/comptime_var.2.zig deleted file mode 100644 index e91c0540ef..0000000000 --- a/test/incremental/comptime_var.2.zig +++ /dev/null @@ -1,34 +0,0 @@ -const builtin = @import("builtin"); - -extern "c" fn write(usize, usize, usize) usize; - -pub fn main() void { - comptime var len: u32 = 5; - print(len); - len += 9; - print(len); -} - -fn print(len: usize) void { - switch (builtin.os.tag) { - .linux => { - asm volatile ("syscall" - : - : [number] "{rax}" (1), - [arg1] "{rdi}" (1), - [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), - [arg3] "{rdx}" (len), - : "rcx", "r11", "memory" - ); - }, - .macos => { - _ = write(1, @ptrToInt("Hello, World!\n"), len); - }, - else => unreachable, - } -} - -// run -// -// HelloHello, World! -// diff --git a/test/incremental/comptime_var.6.zig b/test/incremental/comptime_var.6.zig deleted file mode 100644 index 0eb743a05b..0000000000 --- a/test/incremental/comptime_var.6.zig +++ /dev/null @@ -1,32 +0,0 @@ -const builtin = @import("builtin"); - -extern "c" fn write(usize, usize, usize) usize; - -pub fn main() void { - comptime var i: u64 = 2; - inline while (i < 6) : (i += 1) { - print(i); - } -} -fn print(len: usize) void { - switch (builtin.os.tag) { - .linux => { - asm volatile ("syscall" - : - : [number] "{rax}" (1), - [arg1] "{rdi}" (1), - [arg2] "{rsi}" (@ptrToInt("Hello")), - [arg3] "{rdx}" (len), - : "rcx", "r11", "memory" - ); - }, - .macos => { - _ = write(1, @ptrToInt("Hello"), len); - }, - else => unreachable, - } -} - -// run -// -// HeHelHellHello diff --git a/test/incremental/llvm/address_space_pointer_access_chaining_pointer_to_optional_array.zig b/test/incremental/llvm/address_space_pointer_access_chaining_pointer_to_optional_array.zig index 592c82691d..cf43513159 100644 --- a/test/incremental/llvm/address_space_pointer_access_chaining_pointer_to_optional_array.zig +++ b/test/incremental/llvm/address_space_pointer_access_chaining_pointer_to_optional_array.zig @@ -8,5 +8,5 @@ pub fn main() void { // error // output_mode=Exe // backend=llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // diff --git a/test/incremental/llvm/address_spaces_pointer_access_chaining_array_pointer.zig b/test/incremental/llvm/address_spaces_pointer_access_chaining_array_pointer.zig index 2e342dc852..5907c1dad5 100644 --- a/test/incremental/llvm/address_spaces_pointer_access_chaining_array_pointer.zig +++ b/test/incremental/llvm/address_spaces_pointer_access_chaining_array_pointer.zig @@ -8,5 +8,5 @@ pub fn main() void { // error // output_mode=Exe // backend=stage2,llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // diff --git a/test/incremental/llvm/address_spaces_pointer_access_chaining_complex.zig b/test/incremental/llvm/address_spaces_pointer_access_chaining_complex.zig index 5e616bd1da..ece0614f73 100644 --- a/test/incremental/llvm/address_spaces_pointer_access_chaining_complex.zig +++ b/test/incremental/llvm/address_spaces_pointer_access_chaining_complex.zig @@ -9,5 +9,5 @@ pub fn main() void { // error // output_mode=Exe // backend=llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // diff --git a/test/incremental/llvm/address_spaces_pointer_access_chaining_struct_pointer.zig b/test/incremental/llvm/address_spaces_pointer_access_chaining_struct_pointer.zig index 519833a0e8..9175bcbc0e 100644 --- a/test/incremental/llvm/address_spaces_pointer_access_chaining_struct_pointer.zig +++ b/test/incremental/llvm/address_spaces_pointer_access_chaining_struct_pointer.zig @@ -9,5 +9,5 @@ pub fn main() void { // error // output_mode=Exe // backend=stage2,llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // diff --git a/test/incremental/llvm/any_typed_null_to_any_typed_optional.zig b/test/incremental/llvm/any_typed_null_to_any_typed_optional.zig index af37ebf25d..c155d04497 100644 --- a/test/incremental/llvm/any_typed_null_to_any_typed_optional.zig +++ b/test/incremental/llvm/any_typed_null_to_any_typed_optional.zig @@ -6,6 +6,6 @@ pub fn main() void { // error // output_mode=Exe // backend=stage2,llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // // :3:21: error: expected *anyopaque, found ?usize diff --git a/test/incremental/llvm/blocks.zig b/test/incremental/llvm/blocks.zig index a2fbfeb618..c64909c7fe 100644 --- a/test/incremental/llvm/blocks.zig +++ b/test/incremental/llvm/blocks.zig @@ -18,5 +18,5 @@ pub fn main() void { // run // backend=stage2,llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // diff --git a/test/incremental/llvm/dereferencing_though_multiple_pointers_with_address_spaces.zig b/test/incremental/llvm/dereferencing_though_multiple_pointers_with_address_spaces.zig index bc5c3d5b81..8f36700757 100644 --- a/test/incremental/llvm/dereferencing_though_multiple_pointers_with_address_spaces.zig +++ b/test/incremental/llvm/dereferencing_though_multiple_pointers_with_address_spaces.zig @@ -8,5 +8,5 @@ pub fn main() void { // error // output_mode=Exe // backend=stage2,llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // diff --git a/test/incremental/llvm/for_loop.zig b/test/incremental/llvm/for_loop.zig index f58350f59c..e7e701aafa 100644 --- a/test/incremental/llvm/for_loop.zig +++ b/test/incremental/llvm/for_loop.zig @@ -12,5 +12,5 @@ pub fn main() void { // run // backend=stage2,llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // diff --git a/test/incremental/llvm/hello_world.zig b/test/incremental/llvm/hello_world.zig index bcd9d9f795..4243191b0f 100644 --- a/test/incremental/llvm/hello_world.zig +++ b/test/incremental/llvm/hello_world.zig @@ -6,7 +6,7 @@ pub fn main() void { // run // backend=llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // // hello world! // diff --git a/test/incremental/llvm/invalid_address_space_coercion.zig b/test/incremental/llvm/invalid_address_space_coercion.zig index e46b327bcf..6b72f1d5a8 100644 --- a/test/incremental/llvm/invalid_address_space_coercion.zig +++ b/test/incremental/llvm/invalid_address_space_coercion.zig @@ -8,6 +8,6 @@ pub fn main() void { // error // output_mode=Exe // backend=stage2,llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // // :2:12: error: expected *i32, found *addrspace(.gs) i32 diff --git a/test/incremental/llvm/invalid_pointer_keeps_address_space_when_taking_address_of_dereference.zig b/test/incremental/llvm/invalid_pointer_keeps_address_space_when_taking_address_of_dereference.zig index 18b3bebc4d..26f68ce789 100644 --- a/test/incremental/llvm/invalid_pointer_keeps_address_space_when_taking_address_of_dereference.zig +++ b/test/incremental/llvm/invalid_pointer_keeps_address_space_when_taking_address_of_dereference.zig @@ -8,6 +8,6 @@ pub fn main() void { // error // output_mode=Exe // backend=stage2,llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // // :2:12: error: expected *i32, found *addrspace(.gs) i32 diff --git a/test/incremental/llvm/nested_blocks.zig b/test/incremental/llvm/nested_blocks.zig index 974315df96..47b6c5069b 100644 --- a/test/incremental/llvm/nested_blocks.zig +++ b/test/incremental/llvm/nested_blocks.zig @@ -20,5 +20,5 @@ pub fn main() void { // run // backend=stage2, llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // diff --git a/test/incremental/llvm/optionals.zig b/test/incremental/llvm/optionals.zig index 05c221a8a8..7d52fc0f17 100644 --- a/test/incremental/llvm/optionals.zig +++ b/test/incremental/llvm/optionals.zig @@ -41,5 +41,5 @@ pub fn main() void { // run // backend=llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // diff --git a/test/incremental/llvm/pointer_keeps_address_space.zig b/test/incremental/llvm/pointer_keeps_address_space.zig index 3d3718c83e..bfd40566f8 100644 --- a/test/incremental/llvm/pointer_keeps_address_space.zig +++ b/test/incremental/llvm/pointer_keeps_address_space.zig @@ -8,5 +8,5 @@ pub fn main() void { // error // output_mode=Exe // backend=stage2,llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // diff --git a/test/incremental/llvm/pointer_keeps_address_space_when_taking_address_of_dereference.zig b/test/incremental/llvm/pointer_keeps_address_space_when_taking_address_of_dereference.zig index 541522e3af..8114e86c5d 100644 --- a/test/incremental/llvm/pointer_keeps_address_space_when_taking_address_of_dereference.zig +++ b/test/incremental/llvm/pointer_keeps_address_space_when_taking_address_of_dereference.zig @@ -8,5 +8,5 @@ pub fn main() void { // error // output_mode=Exe // backend=stage2,llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // diff --git a/test/incremental/llvm/pointer_to_explicit_generic_address_space_coerces_to_implicit_pointer.zig b/test/incremental/llvm/pointer_to_explicit_generic_address_space_coerces_to_implicit_pointer.zig index ff8ae13dab..78bc3e4bd6 100644 --- a/test/incremental/llvm/pointer_to_explicit_generic_address_space_coerces_to_implicit_pointer.zig +++ b/test/incremental/llvm/pointer_to_explicit_generic_address_space_coerces_to_implicit_pointer.zig @@ -8,5 +8,5 @@ pub fn main() void { // error // output_mode=Exe // backend=stage2,llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // diff --git a/test/incremental/llvm/pointer_with_different_address_spaces.zig b/test/incremental/llvm/pointer_with_different_address_spaces.zig index eaeb669775..8fbd8b07cf 100644 --- a/test/incremental/llvm/pointer_with_different_address_spaces.zig +++ b/test/incremental/llvm/pointer_with_different_address_spaces.zig @@ -8,6 +8,6 @@ pub fn main() void { // error // output_mode=Exe // backend=stage2,llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // // :2:12: error: expected *addrspace(.fs) i32, found *addrspace(.gs) i32 diff --git a/test/incremental/llvm/pointers_with_different_address_spaces.zig b/test/incremental/llvm/pointers_with_different_address_spaces.zig index aed6093ec7..39e5e6a6d1 100644 --- a/test/incremental/llvm/pointers_with_different_address_spaces.zig +++ b/test/incremental/llvm/pointers_with_different_address_spaces.zig @@ -8,6 +8,6 @@ pub fn main() void { // error // output_mode=Exe // backend=stage2,llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // // :2:13: error: expected *i32, found *addrspace(.gs) i32 diff --git a/test/incremental/llvm/rem.zig b/test/incremental/llvm/rem.zig index 679932d3c2..9804338ea6 100644 --- a/test/incremental/llvm/rem.zig +++ b/test/incremental/llvm/rem.zig @@ -11,5 +11,5 @@ pub fn main() void { // run // backend=stage2,llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // diff --git a/test/incremental/llvm/shift_right_plus_left.0.zig b/test/incremental/llvm/shift_right_plus_left.0.zig index 91d324d084..23b733c493 100644 --- a/test/incremental/llvm/shift_right_plus_left.0.zig +++ b/test/incremental/llvm/shift_right_plus_left.0.zig @@ -8,5 +8,5 @@ fn assert(a: u32, b: u32) void { // run // backend=llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // diff --git a/test/incremental/llvm/simple_addition_and_subtraction.zig b/test/incremental/llvm/simple_addition_and_subtraction.zig index 59011c9d00..8a6f419f4a 100644 --- a/test/incremental/llvm/simple_addition_and_subtraction.zig +++ b/test/incremental/llvm/simple_addition_and_subtraction.zig @@ -16,5 +16,5 @@ fn assert(ok: bool) void { // run // backend=stage2,llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // diff --git a/test/incremental/llvm/simple_if_statement.zig b/test/incremental/llvm/simple_if_statement.zig index 436fd48e3f..73cf08cda2 100644 --- a/test/incremental/llvm/simple_if_statement.zig +++ b/test/incremental/llvm/simple_if_statement.zig @@ -12,5 +12,5 @@ pub fn main() void { // run // backend=stage2,llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // diff --git a/test/incremental/llvm/while_loops.zig b/test/incremental/llvm/while_loops.zig index 3c092be628..3b9276cf7f 100644 --- a/test/incremental/llvm/while_loops.zig +++ b/test/incremental/llvm/while_loops.zig @@ -14,5 +14,5 @@ pub fn main() void { // run // backend=stage2,llvm -// target=x86_64-linux +// target=x86_64-linux,x86_64-macos // diff --git a/test/incremental/assert_function.0.zig b/test/incremental/x86_64-linux/assert_function.0.zig similarity index 83% rename from test/incremental/assert_function.0.zig rename to test/incremental/x86_64-linux/assert_function.0.zig index 889c9b1572..ab34f5328d 100644 --- a/test/incremental/assert_function.0.zig +++ b/test/incremental/x86_64-linux/assert_function.0.zig @@ -11,5 +11,5 @@ pub fn assert(ok: bool) void { } // run -// target=x86_64-linux,x86_64-macos +// target=x86_64-linux // diff --git a/test/incremental/assert_function.1.zig b/test/incremental/x86_64-linux/assert_function.1.zig similarity index 100% rename from test/incremental/assert_function.1.zig rename to test/incremental/x86_64-linux/assert_function.1.zig diff --git a/test/incremental/assert_function.10.zig b/test/incremental/x86_64-linux/assert_function.10.zig similarity index 100% rename from test/incremental/assert_function.10.zig rename to test/incremental/x86_64-linux/assert_function.10.zig diff --git a/test/incremental/assert_function.11.zig b/test/incremental/x86_64-linux/assert_function.11.zig similarity index 100% rename from test/incremental/assert_function.11.zig rename to test/incremental/x86_64-linux/assert_function.11.zig diff --git a/test/incremental/assert_function.12.zig b/test/incremental/x86_64-linux/assert_function.12.zig similarity index 100% rename from test/incremental/assert_function.12.zig rename to test/incremental/x86_64-linux/assert_function.12.zig diff --git a/test/incremental/assert_function.13.zig b/test/incremental/x86_64-linux/assert_function.13.zig similarity index 100% rename from test/incremental/assert_function.13.zig rename to test/incremental/x86_64-linux/assert_function.13.zig diff --git a/test/incremental/assert_function.14.zig b/test/incremental/x86_64-linux/assert_function.14.zig similarity index 100% rename from test/incremental/assert_function.14.zig rename to test/incremental/x86_64-linux/assert_function.14.zig diff --git a/test/incremental/assert_function.15.zig b/test/incremental/x86_64-linux/assert_function.15.zig similarity index 100% rename from test/incremental/assert_function.15.zig rename to test/incremental/x86_64-linux/assert_function.15.zig diff --git a/test/incremental/assert_function.16.zig b/test/incremental/x86_64-linux/assert_function.16.zig similarity index 100% rename from test/incremental/assert_function.16.zig rename to test/incremental/x86_64-linux/assert_function.16.zig diff --git a/test/incremental/assert_function.17.zig b/test/incremental/x86_64-linux/assert_function.17.zig similarity index 100% rename from test/incremental/assert_function.17.zig rename to test/incremental/x86_64-linux/assert_function.17.zig diff --git a/test/incremental/assert_function.18.zig b/test/incremental/x86_64-linux/assert_function.18.zig similarity index 100% rename from test/incremental/assert_function.18.zig rename to test/incremental/x86_64-linux/assert_function.18.zig diff --git a/test/incremental/assert_function.2.zig b/test/incremental/x86_64-linux/assert_function.2.zig similarity index 100% rename from test/incremental/assert_function.2.zig rename to test/incremental/x86_64-linux/assert_function.2.zig diff --git a/test/incremental/assert_function.3.zig b/test/incremental/x86_64-linux/assert_function.3.zig similarity index 100% rename from test/incremental/assert_function.3.zig rename to test/incremental/x86_64-linux/assert_function.3.zig diff --git a/test/incremental/assert_function.4.zig b/test/incremental/x86_64-linux/assert_function.4.zig similarity index 100% rename from test/incremental/assert_function.4.zig rename to test/incremental/x86_64-linux/assert_function.4.zig diff --git a/test/incremental/assert_function.5.zig b/test/incremental/x86_64-linux/assert_function.5.zig similarity index 100% rename from test/incremental/assert_function.5.zig rename to test/incremental/x86_64-linux/assert_function.5.zig diff --git a/test/incremental/assert_function.6.zig b/test/incremental/x86_64-linux/assert_function.6.zig similarity index 100% rename from test/incremental/assert_function.6.zig rename to test/incremental/x86_64-linux/assert_function.6.zig diff --git a/test/incremental/x86_64-linux/assert_function.7.zig b/test/incremental/x86_64-linux/assert_function.7.zig new file mode 100644 index 0000000000..e6d18a5c3f --- /dev/null +++ b/test/incremental/x86_64-linux/assert_function.7.zig @@ -0,0 +1,28 @@ +pub fn main() void { + var i: u32 = 0; + while (i < 4) : (i += 1) print(); + assert(i == 4); +} + +fn print() void { + asm volatile ("syscall" + : + : [number] "{rax}" (1), + [arg1] "{rdi}" (1), + [arg2] "{rsi}" (@ptrToInt("hello\n")), + [arg3] "{rdx}" (6), + : "rcx", "r11", "memory" + ); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// +// hello +// hello +// hello +// hello +// diff --git a/test/incremental/x86_64-linux/assert_function.8.zig b/test/incremental/x86_64-linux/assert_function.8.zig new file mode 100644 index 0000000000..4ce3ec0844 --- /dev/null +++ b/test/incremental/x86_64-linux/assert_function.8.zig @@ -0,0 +1,24 @@ +pub fn main() void { + var i: u32 = 0; + inline while (i < 4) : (i += 1) print(); + assert(i == 4); +} + +fn print() void { + asm volatile ("syscall" + : + : [number] "{rax}" (1), + [arg1] "{rdi}" (1), + [arg2] "{rsi}" (@ptrToInt("hello\n")), + [arg3] "{rdx}" (6), + : "rcx", "r11", "memory" + ); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// error +// +// :5:21: error: unable to resolve comptime value diff --git a/test/incremental/assert_function.9.zig b/test/incremental/x86_64-linux/assert_function.9.zig similarity index 100% rename from test/incremental/assert_function.9.zig rename to test/incremental/x86_64-linux/assert_function.9.zig diff --git a/test/incremental/comptime_var.0.zig b/test/incremental/x86_64-linux/comptime_var.0.zig similarity index 86% rename from test/incremental/comptime_var.0.zig rename to test/incremental/x86_64-linux/comptime_var.0.zig index 019cf78abb..45f87ecaa1 100644 --- a/test/incremental/comptime_var.0.zig +++ b/test/incremental/x86_64-linux/comptime_var.0.zig @@ -6,7 +6,7 @@ pub fn main() void { // error // output_mode=Exe -// target=x86_64-linux,x86_64-macos +// target=x86_64-linux // // :4:21: error: store to comptime variable depends on runtime condition // :4:11: note: runtime condition here diff --git a/test/incremental/comptime_var.1.zig b/test/incremental/x86_64-linux/comptime_var.1.zig similarity index 100% rename from test/incremental/comptime_var.1.zig rename to test/incremental/x86_64-linux/comptime_var.1.zig diff --git a/test/incremental/x86_64-linux/comptime_var.2.zig b/test/incremental/x86_64-linux/comptime_var.2.zig new file mode 100644 index 0000000000..72bdfad90c --- /dev/null +++ b/test/incremental/x86_64-linux/comptime_var.2.zig @@ -0,0 +1,22 @@ +pub fn main() void { + comptime var len: u32 = 5; + print(len); + len += 9; + print(len); +} + +fn print(len: usize) void { + asm volatile ("syscall" + : + : [number] "{rax}" (1), + [arg1] "{rdi}" (1), + [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), + [arg3] "{rdx}" (len), + : "rcx", "r11", "memory" + ); +} + +// run +// +// HelloHello, World! +// diff --git a/test/incremental/comptime_var.3.zig b/test/incremental/x86_64-linux/comptime_var.3.zig similarity index 100% rename from test/incremental/comptime_var.3.zig rename to test/incremental/x86_64-linux/comptime_var.3.zig diff --git a/test/incremental/comptime_var.4.zig b/test/incremental/x86_64-linux/comptime_var.4.zig similarity index 100% rename from test/incremental/comptime_var.4.zig rename to test/incremental/x86_64-linux/comptime_var.4.zig diff --git a/test/incremental/comptime_var.5.zig b/test/incremental/x86_64-linux/comptime_var.5.zig similarity index 100% rename from test/incremental/comptime_var.5.zig rename to test/incremental/x86_64-linux/comptime_var.5.zig diff --git a/test/incremental/x86_64-linux/comptime_var.6.zig b/test/incremental/x86_64-linux/comptime_var.6.zig new file mode 100644 index 0000000000..2790949561 --- /dev/null +++ b/test/incremental/x86_64-linux/comptime_var.6.zig @@ -0,0 +1,20 @@ +pub fn main() void { + comptime var i: u64 = 2; + inline while (i < 6) : (i += 1) { + print(i); + } +} +fn print(len: usize) void { + asm volatile ("syscall" + : + : [number] "{rax}" (1), + [arg1] "{rdi}" (1), + [arg2] "{rsi}" (@ptrToInt("Hello")), + [arg3] "{rdx}" (len), + : "rcx", "r11", "memory" + ); +} + +// run +// +// HeHelHellHello diff --git a/test/incremental/x86_64-macos/assert_function.0.zig b/test/incremental/x86_64-macos/assert_function.0.zig new file mode 100644 index 0000000000..20e5cf0b97 --- /dev/null +++ b/test/incremental/x86_64-macos/assert_function.0.zig @@ -0,0 +1,15 @@ +pub fn main() void { + add(3, 4); +} + +fn add(a: u32, b: u32) void { + assert(a + b == 7); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// target=x86_64-macos +// diff --git a/test/incremental/x86_64-macos/assert_function.1.zig b/test/incremental/x86_64-macos/assert_function.1.zig new file mode 100644 index 0000000000..ac2df25d85 --- /dev/null +++ b/test/incremental/x86_64-macos/assert_function.1.zig @@ -0,0 +1,17 @@ +pub fn main() void { + add(3, 4); +} + +fn add(a: u32, b: u32) void { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + assert(e == 14); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/x86_64-macos/assert_function.10.zig b/test/incremental/x86_64-macos/assert_function.10.zig new file mode 100644 index 0000000000..b3f1610cd6 --- /dev/null +++ b/test/incremental/x86_64-macos/assert_function.10.zig @@ -0,0 +1,27 @@ +pub fn main() void { + assert(add(3, 4) == 116); +} + +fn add(a: u32, b: u32) u32 { + const x: u32 = blk: { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + const j = i + d; // 110 + break :blk j; + }; + const y = x + a; // 113 + const z = y + a; // 116 + return z; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/x86_64-macos/assert_function.11.zig b/test/incremental/x86_64-macos/assert_function.11.zig new file mode 100644 index 0000000000..d64130a677 --- /dev/null +++ b/test/incremental/x86_64-macos/assert_function.11.zig @@ -0,0 +1,66 @@ +pub fn main() void { + assert(add(3, 4) == 1221); + assert(mul(3, 4) == 21609); +} + +fn add(a: u32, b: u32) u32 { + const x: u32 = blk: { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + const j = i + d; // 110 + const k = i + j; // 210 + const l = j + k; // 320 + const m = l + c; // 327 + const n = m + d; // 337 + const o = n + e; // 351 + const p = o + f; // 375 + const q = p + g; // 413 + const r = q + h; // 475 + const s = r + i; // 575 + const t = s + j; // 685 + const u = t + k; // 895 + const v = u + l; // 1215 + break :blk v; + }; + const y = x + a; // 1218 + const z = y + a; // 1221 + return z; +} + +fn mul(a: u32, b: u32) u32 { + const x: u32 = blk: { + const c = a * a * a * a; // 81 + const d = a * a * a * b; // 108 + const e = a * a * b * a; // 108 + const f = a * a * b * b; // 144 + const g = a * b * a * a; // 108 + const h = a * b * a * b; // 144 + const i = a * b * b * a; // 144 + const j = a * b * b * b; // 192 + const k = b * a * a * a; // 108 + const l = b * a * a * b; // 144 + const m = b * a * b * a; // 144 + const n = b * a * b * b; // 192 + const o = b * b * a * a; // 144 + const p = b * b * a * b; // 192 + const q = b * b * b * a; // 192 + const r = b * b * b * b; // 256 + const s = c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r; // 2401 + break :blk s; + }; + const y = x * a; // 7203 + const z = y * a; // 21609 + return z; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/x86_64-macos/assert_function.12.zig b/test/incremental/x86_64-macos/assert_function.12.zig new file mode 100644 index 0000000000..4f64c1e062 --- /dev/null +++ b/test/incremental/x86_64-macos/assert_function.12.zig @@ -0,0 +1,47 @@ +pub fn main() void { + assert(add(3, 4) == 791); + assert(add(4, 3) == 79); +} + +fn add(a: u32, b: u32) u32 { + const x: u32 = if (a < b) blk: { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + const j = i + d; // 110 + const k = i + j; // 210 + const l = k + c; // 217 + const m = l + d; // 227 + const n = m + e; // 241 + const o = n + f; // 265 + const p = o + g; // 303 + const q = p + h; // 365 + const r = q + i; // 465 + const s = r + j; // 575 + const t = s + k; // 785 + break :blk t; + } else blk: { + const t = b + b + a; // 10 + const c = a + t; // 14 + const d = c + t; // 24 + const e = d + t; // 34 + const f = e + t; // 44 + const g = f + t; // 54 + const h = c + g; // 68 + break :blk h + b; // 71 + }; + const y = x + a; // 788, 75 + const z = y + a; // 791, 79 + return z; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/x86_64-macos/assert_function.13.zig b/test/incremental/x86_64-macos/assert_function.13.zig new file mode 100644 index 0000000000..240abf0108 --- /dev/null +++ b/test/incremental/x86_64-macos/assert_function.13.zig @@ -0,0 +1,19 @@ +pub fn main() void { + const ignore = + \\ cool thx + \\ + ; + _ = ignore; + add('ぁ', '\x03'); +} + +fn add(a: u32, b: u32) void { + assert(a + b == 12356); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/x86_64-macos/assert_function.14.zig b/test/incremental/x86_64-macos/assert_function.14.zig new file mode 100644 index 0000000000..d25100dcce --- /dev/null +++ b/test/incremental/x86_64-macos/assert_function.14.zig @@ -0,0 +1,17 @@ +pub fn main() void { + add(aa, bb); +} + +const aa = 'ぁ'; +const bb = '\x03'; + +fn add(a: u32, b: u32) void { + assert(a + b == 12356); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/x86_64-macos/assert_function.15.zig b/test/incremental/x86_64-macos/assert_function.15.zig new file mode 100644 index 0000000000..33ae1ed5af --- /dev/null +++ b/test/incremental/x86_64-macos/assert_function.15.zig @@ -0,0 +1,10 @@ +pub fn main() void { + assert("hello"[0] == 'h'); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/x86_64-macos/assert_function.16.zig b/test/incremental/x86_64-macos/assert_function.16.zig new file mode 100644 index 0000000000..eef1136423 --- /dev/null +++ b/test/incremental/x86_64-macos/assert_function.16.zig @@ -0,0 +1,11 @@ +const hello = "hello".*; +pub fn main() void { + assert(hello[1] == 'e'); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/x86_64-macos/assert_function.17.zig b/test/incremental/x86_64-macos/assert_function.17.zig new file mode 100644 index 0000000000..ac9dce3079 --- /dev/null +++ b/test/incremental/x86_64-macos/assert_function.17.zig @@ -0,0 +1,11 @@ +pub fn main() void { + var i: u64 = 0xFFEEDDCCBBAA9988; + assert(i == 0xFFEEDDCCBBAA9988); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/assert_function.7.zig b/test/incremental/x86_64-macos/assert_function.18.zig similarity index 80% rename from test/incremental/assert_function.7.zig rename to test/incremental/x86_64-macos/assert_function.18.zig index f2f3ffcc3d..31cf1207f3 100644 --- a/test/incremental/assert_function.7.zig +++ b/test/incremental/x86_64-macos/assert_function.18.zig @@ -3,9 +3,7 @@ const builtin = @import("builtin"); extern "c" fn write(usize, usize, usize) usize; pub fn main() void { - var i: u32 = 0; - while (i < 4) : (i += 1) print(); - assert(i == 4); + for ("hello") |_| print(); } fn print() void { @@ -27,14 +25,11 @@ fn print() void { } } -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - // run // // hello // hello // hello // hello +// hello // diff --git a/test/incremental/x86_64-macos/assert_function.2.zig b/test/incremental/x86_64-macos/assert_function.2.zig new file mode 100644 index 0000000000..8c1c510486 --- /dev/null +++ b/test/incremental/x86_64-macos/assert_function.2.zig @@ -0,0 +1,21 @@ +pub fn main() void { + add(3, 4); +} + +fn add(a: u32, b: u32) void { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + assert(i == 100); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/x86_64-macos/assert_function.3.zig b/test/incremental/x86_64-macos/assert_function.3.zig new file mode 100644 index 0000000000..a6829f8e02 --- /dev/null +++ b/test/incremental/x86_64-macos/assert_function.3.zig @@ -0,0 +1,22 @@ +pub fn main() void { + add(3, 4); +} + +fn add(a: u32, b: u32) void { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + const j = i + d; // 110 + assert(j == 110); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/x86_64-macos/assert_function.4.zig b/test/incremental/x86_64-macos/assert_function.4.zig new file mode 100644 index 0000000000..69df4354c3 --- /dev/null +++ b/test/incremental/x86_64-macos/assert_function.4.zig @@ -0,0 +1,15 @@ +pub fn main() void { + assert(add(3, 4) == 7); + assert(add(20, 10) == 30); +} + +fn add(a: u32, b: u32) u32 { + return a + b; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/x86_64-macos/assert_function.5.zig b/test/incremental/x86_64-macos/assert_function.5.zig new file mode 100644 index 0000000000..89f3f7df4f --- /dev/null +++ b/test/incremental/x86_64-macos/assert_function.5.zig @@ -0,0 +1,19 @@ +pub fn main() void { + assert(add(3, 4) == 7); + assert(add(20, 10) == 30); +} + +fn add(a: u32, b: u32) u32 { + var x: u32 = undefined; + x = 0; + x += a; + x += b; + return x; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/x86_64-macos/assert_function.6.zig b/test/incremental/x86_64-macos/assert_function.6.zig new file mode 100644 index 0000000000..1b1b75e68e --- /dev/null +++ b/test/incremental/x86_64-macos/assert_function.6.zig @@ -0,0 +1,9 @@ +pub fn main() void { + const a: u32 = 2; + const b: ?u32 = a; + const c = b.?; + if (c != 2) unreachable; +} + +// run +// diff --git a/test/incremental/x86_64-macos/assert_function.7.zig b/test/incremental/x86_64-macos/assert_function.7.zig new file mode 100644 index 0000000000..27ba37029a --- /dev/null +++ b/test/incremental/x86_64-macos/assert_function.7.zig @@ -0,0 +1,23 @@ +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + var i: u32 = 0; + while (i < 4) : (i += 1) print(); + assert(i == 4); +} + +fn print() void { + _ = write(1, @ptrToInt("hello\n"), 6); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// +// hello +// hello +// hello +// hello +// diff --git a/test/incremental/x86_64-macos/assert_function.8.zig b/test/incremental/x86_64-macos/assert_function.8.zig new file mode 100644 index 0000000000..801cd2e3be --- /dev/null +++ b/test/incremental/x86_64-macos/assert_function.8.zig @@ -0,0 +1,19 @@ +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + var i: u32 = 0; + inline while (i < 4) : (i += 1) print(); + assert(i == 4); +} + +fn print() void { + _ = write(1, @ptrToInt("hello\n"), 6); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// error +// +// :5:21: error: unable to resolve comptime value diff --git a/test/incremental/x86_64-macos/assert_function.9.zig b/test/incremental/x86_64-macos/assert_function.9.zig new file mode 100644 index 0000000000..c754bb7711 --- /dev/null +++ b/test/incremental/x86_64-macos/assert_function.9.zig @@ -0,0 +1,22 @@ +pub fn main() void { + assert(add(3, 4) == 20); +} + +fn add(a: u32, b: u32) u32 { + const x: u32 = blk: { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + break :blk e; + }; + const y = x + a; // 17 + const z = y + a; // 20 + return z; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/incremental/x86_64-macos/comptime_var.0.zig b/test/incremental/x86_64-macos/comptime_var.0.zig new file mode 100644 index 0000000000..da82b35c6f --- /dev/null +++ b/test/incremental/x86_64-macos/comptime_var.0.zig @@ -0,0 +1,12 @@ +pub fn main() void { + var a: u32 = 0; + comptime var b: u32 = 0; + if (a == 0) b = 3; +} + +// error +// output_mode=Exe +// target=x86_64-macos +// +// :4:21: error: store to comptime variable depends on runtime condition +// :4:11: note: runtime condition here diff --git a/test/incremental/x86_64-macos/comptime_var.1.zig b/test/incremental/x86_64-macos/comptime_var.1.zig new file mode 100644 index 0000000000..efc51aafe3 --- /dev/null +++ b/test/incremental/x86_64-macos/comptime_var.1.zig @@ -0,0 +1,13 @@ +pub fn main() void { + var a: u32 = 0; + comptime var b: u32 = 0; + switch (a) { + 0 => {}, + else => b = 3, + } +} + +// error +// +// :6:21: error: store to comptime variable depends on runtime condition +// :4:13: note: runtime condition here diff --git a/test/incremental/x86_64-macos/comptime_var.2.zig b/test/incremental/x86_64-macos/comptime_var.2.zig new file mode 100644 index 0000000000..abd34255cd --- /dev/null +++ b/test/incremental/x86_64-macos/comptime_var.2.zig @@ -0,0 +1,17 @@ +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + comptime var len: u32 = 5; + print(len); + len += 9; + print(len); +} + +fn print(len: usize) void { + _ = write(1, @ptrToInt("Hello, World!\n"), len); +} + +// run +// +// HelloHello, World! +// diff --git a/test/incremental/x86_64-macos/comptime_var.3.zig b/test/incremental/x86_64-macos/comptime_var.3.zig new file mode 100644 index 0000000000..d4e6d85d9d --- /dev/null +++ b/test/incremental/x86_64-macos/comptime_var.3.zig @@ -0,0 +1,10 @@ +comptime { + var x: i32 = 1; + x += 1; + if (x != 1) unreachable; +} +pub fn main() void {} + +// error +// +// :4:17: error: unable to resolve comptime value diff --git a/test/incremental/x86_64-macos/comptime_var.4.zig b/test/incremental/x86_64-macos/comptime_var.4.zig new file mode 100644 index 0000000000..74da6ef448 --- /dev/null +++ b/test/incremental/x86_64-macos/comptime_var.4.zig @@ -0,0 +1,9 @@ +pub fn main() void { + comptime var i: u64 = 0; + while (i < 5) : (i += 1) {} +} + +// error +// +// :3:24: error: cannot store to comptime variable in non-inline loop +// :3:5: note: non-inline loop here diff --git a/test/incremental/x86_64-macos/comptime_var.5.zig b/test/incremental/x86_64-macos/comptime_var.5.zig new file mode 100644 index 0000000000..76a06f3d4b --- /dev/null +++ b/test/incremental/x86_64-macos/comptime_var.5.zig @@ -0,0 +1,15 @@ +pub fn main() void { + var a: u32 = 0; + if (a == 0) { + comptime var b: u32 = 0; + b = 1; + } +} +comptime { + var x: i32 = 1; + x += 1; + if (x != 2) unreachable; +} + +// run +// diff --git a/test/incremental/x86_64-macos/comptime_var.6.zig b/test/incremental/x86_64-macos/comptime_var.6.zig new file mode 100644 index 0000000000..381e609bd1 --- /dev/null +++ b/test/incremental/x86_64-macos/comptime_var.6.zig @@ -0,0 +1,15 @@ +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + comptime var i: u64 = 2; + inline while (i < 6) : (i += 1) { + print(i); + } +} +fn print(len: usize) void { + _ = write(1, @ptrToInt("Hello"), len); +} + +// run +// +// HeHelHellHello From 3c19f694d92c5a3d7f6e3a6d857252406df0d6e3 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Thu, 28 Apr 2022 12:10:56 +0200 Subject: [PATCH 23/26] test: fix incorrect error loc in assert_function x86_64-linux test --- test/incremental/x86_64-linux/assert_function.8.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/incremental/x86_64-linux/assert_function.8.zig b/test/incremental/x86_64-linux/assert_function.8.zig index 4ce3ec0844..ae618cc063 100644 --- a/test/incremental/x86_64-linux/assert_function.8.zig +++ b/test/incremental/x86_64-linux/assert_function.8.zig @@ -21,4 +21,4 @@ pub fn assert(ok: bool) void { // error // -// :5:21: error: unable to resolve comptime value +// :3:21: error: unable to resolve comptime value From c8d0fb0b212f2c618321caeeac315c1792b06035 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Thu, 28 Apr 2022 12:11:49 +0200 Subject: [PATCH 24/26] test: migrate stage2 independent compile errors to test manifest parser --- src/test.zig | 6 +++--- .../constant_inside_comptime_function_has_compile_error.zig | 2 +- test/compile_errors/stage2/duplicate-unused_labels.zig | 2 +- test/compile_errors/stage2/embed_outside_package.zig | 2 +- test/compile_errors/stage2/import_outside_package.zig | 2 +- test/compile_errors/stage2/out_of_bounds_index.zig | 2 +- test/compile_errors/stage2/slice_of_null_pointer.zig | 2 +- test/compile_errors/stage2/struct_duplicate_field_name.zig | 2 +- .../stage2/union_access_of_inactive_field.zig | 4 ++-- test/compile_errors/stage2/union_duplicate_enum_field.zig | 4 ++-- .../stage2/union_duplicate_field_definition.zig | 2 +- test/compile_errors/stage2/union_enum_field_missing.zig | 2 +- test/compile_errors/stage2/union_extra_field.zig | 2 +- .../stage2/union_runtime_coercion_from_enum.zig | 2 +- 14 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/test.zig b/src/test.zig index 0377d8823f..3579370c04 100644 --- a/src/test.zig +++ b/src/test.zig @@ -42,12 +42,12 @@ test { defer compile_errors_dir.close(); { - var stage2_dir = try compile_errors_dir.openDir("stage2", .{ .iterate = true }); - defer stage2_dir.close(); + var dir = try compile_errors_dir.openDir("stage2", .{ .iterate = true }); + defer dir.close(); // TODO make this incremental once the bug is solved that it triggers // See: https://github.com/ziglang/zig/issues/11344 - ctx.addErrorCasesFromDir("stage2", stage2_dir, .stage2, .Obj, false, .independent); + ctx.addTestCasesFromDir(dir, .independent); } if (!skip_stage1) { diff --git a/test/compile_errors/stage2/constant_inside_comptime_function_has_compile_error.zig b/test/compile_errors/stage2/constant_inside_comptime_function_has_compile_error.zig index 969b73713f..98d6104670 100644 --- a/test/compile_errors/stage2/constant_inside_comptime_function_has_compile_error.zig +++ b/test/compile_errors/stage2/constant_inside_comptime_function_has_compile_error.zig @@ -14,7 +14,7 @@ export fn entry() void { _ = allocator; } -// constant inside comptime function has compile error +// error // // :4:5: error: unreachable code // :4:25: note: control flow is diverted here diff --git a/test/compile_errors/stage2/duplicate-unused_labels.zig b/test/compile_errors/stage2/duplicate-unused_labels.zig index 82afe4e854..44ab48480d 100644 --- a/test/compile_errors/stage2/duplicate-unused_labels.zig +++ b/test/compile_errors/stage2/duplicate-unused_labels.zig @@ -17,7 +17,7 @@ comptime { blk: for(@as([0]void, undefined)) |_| {} } -// duplicate/unused labels +// error // // :2:12: error: redefinition of label 'blk' // :2:5: note: previous definition here diff --git a/test/compile_errors/stage2/embed_outside_package.zig b/test/compile_errors/stage2/embed_outside_package.zig index 8df6b3d9af..9cf1a8b905 100644 --- a/test/compile_errors/stage2/embed_outside_package.zig +++ b/test/compile_errors/stage2/embed_outside_package.zig @@ -2,6 +2,6 @@ export fn a() usize { return @embedFile("/root/foo").len; } -// embed outside package +// error // //:2:23: error: embed of file outside package path: '/root/foo' diff --git a/test/compile_errors/stage2/import_outside_package.zig b/test/compile_errors/stage2/import_outside_package.zig index f9de9202de..6b70778754 100644 --- a/test/compile_errors/stage2/import_outside_package.zig +++ b/test/compile_errors/stage2/import_outside_package.zig @@ -2,6 +2,6 @@ export fn a() usize { return @import("../../above.zig").len; } -// import outside package +// error // // :2:20: error: import of file outside package path: '../../above.zig' diff --git a/test/compile_errors/stage2/out_of_bounds_index.zig b/test/compile_errors/stage2/out_of_bounds_index.zig index 3c34bb5d0f..614c445d46 100644 --- a/test/compile_errors/stage2/out_of_bounds_index.zig +++ b/test/compile_errors/stage2/out_of_bounds_index.zig @@ -20,7 +20,7 @@ comptime { _ = slice; } -// out of bounds indexing +// error // // :4:26: error: end index 6 out of bounds for slice of length 4 +1 (sentinel) // :9:22: error: end index 6 out of bounds for array of length 4 +1 (sentinel) diff --git a/test/compile_errors/stage2/slice_of_null_pointer.zig b/test/compile_errors/stage2/slice_of_null_pointer.zig index 1e3f0d6aee..a33a904842 100644 --- a/test/compile_errors/stage2/slice_of_null_pointer.zig +++ b/test/compile_errors/stage2/slice_of_null_pointer.zig @@ -5,6 +5,6 @@ comptime { _ = y; } -// slice of null C pointer +// error // // :4:14: error: slice of null pointer diff --git a/test/compile_errors/stage2/struct_duplicate_field_name.zig b/test/compile_errors/stage2/struct_duplicate_field_name.zig index 274dce4e4a..e7bed78d06 100644 --- a/test/compile_errors/stage2/struct_duplicate_field_name.zig +++ b/test/compile_errors/stage2/struct_duplicate_field_name.zig @@ -8,7 +8,7 @@ export fn entry() void { _ = s; } -// duplicate struct field name +// error // // :3:5: error: duplicate struct field: 'foo' // :2:5: note: other field here diff --git a/test/compile_errors/stage2/union_access_of_inactive_field.zig b/test/compile_errors/stage2/union_access_of_inactive_field.zig index 34fa661d79..881279e1c3 100644 --- a/test/compile_errors/stage2/union_access_of_inactive_field.zig +++ b/test/compile_errors/stage2/union_access_of_inactive_field.zig @@ -3,12 +3,12 @@ const U = union { b: u64, }; comptime { - var u: U = .{.a = {}}; + var u: U = .{ .a = {} }; const v = u.b; _ = v; } -// access of inactive union field +// error // // :7:16: error: access of union field 'b' while field 'a' is active // :1:11: note: union declared here diff --git a/test/compile_errors/stage2/union_duplicate_enum_field.zig b/test/compile_errors/stage2/union_duplicate_enum_field.zig index 9044f9e97e..5a08256edb 100644 --- a/test/compile_errors/stage2/union_duplicate_enum_field.zig +++ b/test/compile_errors/stage2/union_duplicate_enum_field.zig @@ -1,4 +1,4 @@ -const E = enum {a, b}; +const E = enum { a, b }; const U = union(E) { a: u32, a: u32, @@ -9,7 +9,7 @@ export fn foo() void { _ = u; } -// union with enum and duplicate fields +// error // // :4:5: error: duplicate union field: 'a' // :3:5: note: other field here diff --git a/test/compile_errors/stage2/union_duplicate_field_definition.zig b/test/compile_errors/stage2/union_duplicate_field_definition.zig index 6ad2ae4f4e..7aab7c4695 100644 --- a/test/compile_errors/stage2/union_duplicate_field_definition.zig +++ b/test/compile_errors/stage2/union_duplicate_field_definition.zig @@ -8,7 +8,7 @@ export fn entry() void { _ = u; } -// duplicate union field name +// error // // :3:5: error: duplicate union field: 'foo' // :2:5: note: other field here diff --git a/test/compile_errors/stage2/union_enum_field_missing.zig b/test/compile_errors/stage2/union_enum_field_missing.zig index b29ca83d3a..638c9fec26 100644 --- a/test/compile_errors/stage2/union_enum_field_missing.zig +++ b/test/compile_errors/stage2/union_enum_field_missing.zig @@ -13,7 +13,7 @@ export fn entry() usize { return @sizeOf(U); } -// enum field missing in union +// error // // :7:1: error: enum field(s) missing in union // :4:5: note: field 'c' missing, declared here diff --git a/test/compile_errors/stage2/union_extra_field.zig b/test/compile_errors/stage2/union_extra_field.zig index e8ba581aad..cdfa482208 100644 --- a/test/compile_errors/stage2/union_extra_field.zig +++ b/test/compile_errors/stage2/union_extra_field.zig @@ -13,7 +13,7 @@ export fn entry() usize { return @sizeOf(U); } -// union extra field +// error // // :6:1: error: enum 'tmp.E' has no field named 'd' // :1:11: note: enum declared here diff --git a/test/compile_errors/stage2/union_runtime_coercion_from_enum.zig b/test/compile_errors/stage2/union_runtime_coercion_from_enum.zig index f7e96834fd..56cd2db83b 100644 --- a/test/compile_errors/stage2/union_runtime_coercion_from_enum.zig +++ b/test/compile_errors/stage2/union_runtime_coercion_from_enum.zig @@ -14,7 +14,7 @@ export fn doTheTest() u64 { return u.b; } -// runtime coercion from enum to union +// error // // :13:19: error: runtime coercion from enum 'tmp.E' to union 'tmp.U' which has non-void fields // :6:5: note: field 'a' has type 'u32' From 62625d9d9518644bcf4fa94e1d5c67edde22b91b Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Thu, 28 Apr 2022 14:44:34 +0200 Subject: [PATCH 25/26] test: migrate stage1 compile error tests to updated test manifest --- src/test.zig | 35 +-- test/cases.zig | 5 - test/compile_errors.zig | 218 ------------------ .../stage1/exe/main_missing_name.zig | 5 +- .../exe/missing_main_fn_in_executable.zig | 5 +- .../stage1/exe/private_main_fn.zig | 5 +- ..._ABI_compatible_type_or_has_align_attr.zig | 4 +- .../stage1/obj/C_pointer_to_anyopaque.zig | 4 +- .../stage1/obj/Frame_of_generic_function.zig | 4 +- ...nus_for_unsigned_types_a_compile_error.zig | 4 +- ...e_6823_dont_allow_._to_be_followed_by_.zig | 4 +- ...5_windows_tcp_server_compilation_error.zig | 4 +- ...ccess_non-existent_member_of_error_set.zig | 4 +- ..._runtime_parameter_from_outer_function.zig | 4 +- .../obj/add_assign_on_undefined_value.zig | 4 +- .../stage1/obj/add_on_undefined_value.zig | 4 +- .../add_overflow_in_function_evaluation.zig | 4 +- .../add_wrap_assign_on_undefined_value.zig | 4 +- .../obj/add_wrap_on_undefined_value.zig | 4 +- .../stage1/obj/addition_with_non_numbers.zig | 4 +- .../stage1/obj/address_of_number_literal.zig | 4 +- .../alignCast_expects_pointer_or_slice.zig | 4 +- ...r_function_pointers_is_a_compile_error.zig | 9 + .../obj/aligned_variable_of_zero-bit_type.zig | 4 +- .../obj/alignment_of_enum_field_specified.zig | 4 +- .../stage1/obj/ambiguous_decl_reference.zig | 4 +- .../stage1/obj/and_on_undefined_value.zig | 4 +- .../stage1/obj/array_access_of_non_array.zig | 4 +- .../stage1/obj/array_access_of_type.zig | 4 +- .../array_access_of_undeclared_identifier.zig | 4 +- .../array_access_with_non_integer_index.zig | 4 +- .../array_concatenation_with_wrong_type.zig | 4 +- .../obj/array_in_c_exported_function.zig | 4 +- .../stage1/obj/asm_at_compile_time.zig | 4 +- .../assign_inline_fn_to_non-comptime_var.zig | 4 +- .../assign_null_to_non-optional_pointer.zig | 4 +- .../obj/assign_through_constant_pointer.zig | 4 +- .../obj/assign_through_constant_slice.zig | 4 +- .../stage1/obj/assign_to_constant_field.zig | 4 +- .../obj/assign_to_constant_variable.zig | 4 +- .../obj/assign_to_invalid_dereference.zig | 4 +- .../obj/assign_too_big_number_to_u16.zig | 4 +- .../stage1/obj/assign_unreachable.zig | 4 +- ...th_a_function_that_returns_an_optional.zig | 4 +- ...sync_function_depends_on_its_own_frame.zig | 4 +- ...on_indirectly_depends_on_its_own_frame.zig | 4 +- ...rings_of_atomicStore_Acquire_or_AcqRel.zig | 4 +- ..._cmpxchg-failure_stricter_than_success.zig | 4 +- ..._cmpxchg-success_Monotonic_or_stricter.zig | 4 +- ...orderings_of_fence_Acquire_or_stricter.zig | 4 +- .../obj/atomicrmw_with_bool_op_not_.Xchg.zig | 4 +- .../obj/atomicrmw_with_enum_op_not_.Xchg.zig | 4 +- ...w_with_float_op_not_.Xchg_.Add_or_.Sub.zig | 4 +- .../attempt_to_cast_enum_literal_to_error.zig | 4 +- ...ver_comptime_variable_from_outer_scope.zig | 4 +- .../attempt_to_create_17_bit_float_type.zig | 4 +- ...n-integer_non-float_or_non-vector_type.zig | 4 +- ...attempt_to_use_0_bit_type_in_extern_fn.zig | 4 +- .../stage1/obj/attempted_double_ampersand.zig | 4 +- ...ttempted_double_pipe_on_boolean_values.zig | 4 +- ..._implicit_cast_from_T_to_slice_const_T.zig | 4 +- ...cit_cast_from_const_T_to_array_len_1_T.zig | 4 +- ...d_implicit_cast_from_const_T_to_sliceT.zig | 4 +- .../stage1/obj/bad_alignCast_at_comptime.zig | 4 +- .../stage1/obj/bad_alignment_in_asynccall.zig | 12 + ...licit_cast_from_array_pointer_to_slice.zig | 4 +- .../stage1/obj/bad_alignment_type.zig | 4 +- ..._function_which_references_local_const.zig | 4 +- test/compile_errors/stage1/obj/bad_import.zig | 4 +- .../stage1/obj/bad_usage_of_call.zig | 4 +- .../obj/bin_and_assign_on_undefined_value.zig | 4 +- .../stage1/obj/bin_and_on_undefined_value.zig | 4 +- .../stage1/obj/bin_not_on_undefined_value.zig | 4 +- .../obj/bin_or_assign_on_undefined_value.zig | 4 +- .../stage1/obj/bin_or_on_undefined_value.zig | 4 +- .../obj/bin_xor_assign_on_undefined_value.zig | 4 +- .../stage1/obj/bin_xor_on_undefined_value.zig | 4 +- .../obj/binary_not_on_number_literal.zig | 4 +- ...tCast_same_size_but_bit_count_mismatch.zig | 4 +- .../stage1/obj/bitCast_to_enum_type.zig | 4 +- ...h_different_sizes_inside_an_expression.zig | 4 +- ...t_shifting_only_works_on_integer_types.zig | 4 +- .../stage1/obj/bogus_compile_var.zig | 4 +- .../stage1/obj/bogus_method_call_on_slice.zig | 4 +- .../obj/bool_not_on_undefined_value.zig | 4 +- .../stage1/obj/branch_on_undefined_value.zig | 4 +- .../stage1/obj/cImport_with_bogus_include.zig | 4 +- .../stage1/obj/call_assigned_to_constant.zig | 4 +- ...l_with_new_stack_on_unsupported_target.zig | 11 + ...aapcs_aapcsvfp_on_unsupported_platform.zig | 11 + ...conv_interrupt_on_unsupported_platform.zig | 7 + ...allconv_signal_on_unsupported_platform.zig | 7 + ...all_thiscall_on_unsupported_platform-0.zig | 23 ++ ...all_thiscall_on_unsupported_platform-1.zig | 11 + ...onv_vectorcall_on_unsupported_platform.zig | 7 + ...generic_function_only_known_at_runtime.zig | 4 +- ...function_with_naked_calling_convention.zig | 4 +- ...ction_passing_array_instead_of_pointer.zig | 4 +- .../cannot_break_out_of_defer_expression.zig | 4 +- ...annot_continue_out_of_defer_expression.zig | 4 +- ..._prong_with_incompatible_payload_types.zig | 4 +- ...um_literal_to_enum_but_it_doesnt_match.zig | 4 +- ...et_to_error_union_of_smaller_error_set.zig | 4 +- .../cast_global_error_set_to_error_set.zig | 4 +- ...cast_negative_integer_literal_to_usize.zig | 4 +- ...ast_negative_value_to_unsigned_integer.zig | 4 +- .../stage1/obj/cast_unreachable.zig | 4 +- ..._bit_offset_pointer_to_regular_pointer.zig | 4 +- .../stage1/obj/catch_on_undefined_value.zig | 4 +- .../obj/chained_comparison_operators.zig | 4 +- .../stage1/obj/cmpxchg_with_float.zig | 4 +- .../colliding_invalid_top_level_functions.zig | 4 +- ...nal_to_non-optional_with_invalid_types.zig | 4 +- ...ng_a_non-optional_pointer_against_null.zig | 4 +- ...nst_undefined_produces_undefined_value.zig | 4 +- ...parison_operators_with_undefined_value.zig | 4 +- ...rison_with_error_union_and_error_value.zig | 4 +- .../obj/compile-time_division_by_zero.zig | 4 +- ...ompile-time_remainder_division_by_zero.zig | 4 +- ...traceback_of_references_that_caused_it.zig | 4 +- ..._tagged_enum_doesnt_crash_the_compiler.zig | 4 +- ...ompile_error_in_struct_init_expression.zig | 4 +- ...ting_return_type_of_inferred_error_set.zig | 4 +- .../compile_errors/stage1/obj/compile_log.zig | 4 +- ...mpile_log_a_pointer_to_an_opaque_value.zig | 4 +- ...ction_which_must_be_comptime_evaluated.zig | 4 +- ...nt_warning_deduplication_in_generic_fn.zig | 4 +- .../obj/compile_time_division_by_zero.zig | 4 +- ...st_enum_to_union_but_field_has_payload.zig | 4 +- ...comptime_continue_inside_runtime_catch.zig | 4 +- ...mptime_continue_inside_runtime_if_bool.zig | 4 +- ...ptime_continue_inside_runtime_if_error.zig | 4 +- ...me_continue_inside_runtime_if_optional.zig | 4 +- ...omptime_continue_inside_runtime_switch.zig | 4 +- ...ime_continue_inside_runtime_while_bool.zig | 4 +- ...me_continue_inside_runtime_while_error.zig | 4 +- ...continue_inside_runtime_while_optional.zig | 4 +- .../obj/comptime_float_in_asm_input.zig | 4 +- .../obj/comptime_implicit_cast_f64_to_f32.zig | 4 +- .../stage1/obj/comptime_int_in_asm_input.zig | 4 +- .../comptime_ptrcast_of_zero-sized_type.zig | 4 +- ...atch_memory_at_target_index_terminated.zig | 4 +- ...ch_memory_at_target_index_unterminated.zig | 4 +- ...entinel_does_not_match_target-sentinel.zig | 4 +- ...e-sentinel_is_out_of_bounds_terminated.zig | 4 +- ...sentinel_is_out_of_bounds_unterminated.zig | 4 +- .../comptime_slice_of_an_undefined_slice.zig | 4 +- ...lice_of_undefined_pointer_non-zero_len.zig | 4 +- .../comptime_struct_field_no_init_value.zig | 4 +- .../obj/const_frame_cast_to_anyframe.zig | 4 +- ...const_is_a_statement_not_an_expression.zig | 4 +- .../obj/container_init_with_non-type.zig | 4 +- ...trol_flow_uses_comptime_var_at_runtime.zig | 4 +- ...ntrol_reaches_end_of_non-void_function.zig | 4 +- .../stage1/obj/declaration_between_fields.zig | 4 +- ...e_as_primitive_must_use_special_syntax.zig | 4 +- .../obj/deduplicate_undeclared_identifier.zig | 4 +- .../stage1/obj/deref_on_undefined_value.zig | 4 +- .../obj/deref_slice_and_get_len_field.zig | 4 +- .../stage1/obj/dereference_an_array.zig | 4 +- .../dereference_unknown_length_pointer.zig | 4 +- .../stage1/obj/direct_struct_loop.zig | 4 +- ...edding_opaque_type_in_struct_and_union.zig | 4 +- ...ted_pointer_to_null-terminated_pointer.zig | 4 +- .../stage1/obj/discarding_error_value.zig | 4 +- .../obj/div_assign_on_undefined_value.zig | 4 +- .../stage1/obj/div_on_undefined_value.zig | 4 +- .../stage1/obj/division_by_zero.zig | 4 +- ...licit_cast_double_pointer_to_anyopaque.zig | 4 +- .../double_optional_on_main_return_value.zig | 4 +- .../obj/duplicate_boolean_switch_value.zig | 4 +- .../stage1/obj/duplicate_enum_field.zig | 4 +- .../stage1/obj/duplicate_error_in_switch.zig | 4 +- .../duplicate_error_value_in_error_set.zig | 4 +- ...icate_field_in_struct_value_expression.zig | 4 +- .../stage1/obj/duplicate_struct_field.zig | 4 +- .../stage1/obj/duplicate_union_field.zig | 4 +- .../stage1/obj/embedFile_with_bogus_file.zig | 4 +- .../stage1/obj/empty_for_loop_body.zig | 4 +- .../stage1/obj/empty_if_body.zig | 4 +- .../stage1/obj/empty_switch_on_an_integer.zig | 4 +- .../stage1/obj/empty_while_loop_body.zig | 4 +- .../endless_loop_in_function_evaluation.zig | 4 +- .../obj/enum_field_value_references_enum.zig | 4 +- ...field_count_range_but_not_matching_tag.zig | 4 +- .../stage1/obj/enum_value_already_taken.zig | 4 +- .../stage1/obj/enum_with_0_fields.zig | 4 +- ...eclarations_unavailable_for_reify_type.zig | 4 +- ...uality_but_sets_have_no_common_members.zig | 4 +- .../obj/error_not_handled_in_switch.zig | 4 +- ...for_function_parameter_incompatibility.zig | 4 +- ..._union_operator_with_non_error_set_LHS.zig | 4 +- .../obj/error_when_evaluating_return_type.zig | 4 +- .../exceeded_maximum_bit_width_of_integer.zig | 4 +- ...ger_when_there_is_a_fraction_component.zig | 4 +- ..._known_at_comptime_violates_error_sets.zig | 4 +- ...xplicitly_casting_non_tag_type_to_enum.zig | 4 +- ...xport_function_with_comptime_parameter.zig | 4 +- .../stage1/obj/export_generic_function.zig | 4 +- .../stage1/obj/exported_async_function.zig | 4 +- ...enum_without_explicit_integer_tag_type.zig | 4 +- .../obj/extern_function_pointer_mismatch.zig | 4 +- ...xtern_function_with_comptime_parameter.zig | 4 +- ...mpatible_but_inferred_integer_tag_type.zig | 4 +- ...non-extern-compatible_integer_tag_type.zig | 4 +- .../obj/extern_union_field_missing_type.zig | 4 +- .../obj/extern_union_given_enum_tag_type.zig | 4 +- .../obj/extern_variable_has_no_type.zig | 4 +- .../obj/fieldParentPtr-bad_field_name.zig | 4 +- ...comptime_field_ptr_not_based_on_struct.zig | 4 +- ...ldParentPtr-comptime_wrong_field_index.zig | 4 +- ...ParentPtr-field_pointer_is_not_pointer.zig | 4 +- .../stage1/obj/fieldParentPtr-non_struct.zig | 4 +- .../obj/field_access_of_opaque_type.zig | 4 +- .../stage1/obj/field_access_of_slices.zig | 4 +- ...field_access_of_unknown_length_pointer.zig | 4 +- .../obj/field_type_supplied_in_an_enum.zig | 4 +- .../stage1/obj/floatToInt_comptime_safety.zig | 4 +- .../obj/float_literal_too_large_error.zig | 4 +- ...float_literal_too_small_error_denormal.zig | 4 +- .../obj/for_loop_body_expression_ignored.zig | 4 +- ..._called_outside_of_function_definition.zig | 4 +- .../obj/frame_causes_function_to_be_async.zig | 4 +- .../obj/function_alignment_non_power_of_2.zig | 4 +- ...nction_call_assigned_to_incorrect_type.zig | 4 +- .../obj/function_parameter_is_opaque.zig | 4 +- .../obj/function_prototype_with_no_body.zig | 4 +- .../obj/function_returning_opaque_type.zig | 4 +- ..._ccc_indirectly_calling_async_function.zig | 4 +- .../obj/function_with_invalid_return_type.zig | 4 +- ...h_non-extern_non-packed_enum_parameter.zig | 4 +- ...non-extern_non-packed_struct_parameter.zig | 4 +- ..._non-extern_non-packed_union_parameter.zig | 4 +- ..._as_parameter_without_comptime_keyword.zig | 4 +- ...nction_call_assigned_to_incorrect_type.zig | 4 +- ..._instance_with_non-constant_expression.zig | 4 +- ...generic_function_returning_opaque_type.zig | 4 +- ...n_where_return_type_is_self-referenced.zig | 4 +- ...obal_variable_alignment_non_power_of_2.zig | 4 +- ...nitializer_must_be_constant_expression.zig | 4 +- .../stage1/obj/hasDecl_with_non-container.zig | 4 +- .../obj/if_condition_is_bool_not_int.zig | 4 +- .../ignored_assert-err-ok_return_value.zig | 4 +- .../obj/ignored_comptime_statement_value.zig | 4 +- .../stage1/obj/ignored_comptime_value.zig | 4 +- .../obj/ignored_deferred_function_call.zig | 4 +- .../obj/ignored_deferred_statement_value.zig | 4 +- ...nored_expression_in_while_continuation.zig | 4 +- .../stage1/obj/ignored_return_value.zig | 4 +- .../stage1/obj/ignored_statement_value.zig | 4 +- .../obj/illegal_comparison_of_types.zig | 4 +- ..._and_Zig_pointer-bad_const-align-child.zig | 4 +- ...icit_cast_const_array_to_mutable_slice.zig | 4 +- ...licit_cast_from_array_to_mutable_slice.zig | 4 +- .../obj/implicit_cast_from_f64_to_f32.zig | 4 +- ...mplicit_cast_of_error_set_not_a_subset.zig | 4 +- ...ers_which_would_mess_up_null_semantics.zig | 4 +- ..._casting_null_c_pointer_to_zig_pointer.zig | 4 +- ...casting_too_big_integers_to_C_pointers.zig | 4 +- ...ing_undefined_c_pointer_to_zig_pointer.zig | 4 +- .../obj/implicit_dependency_on_libc.zig | 11 + .../obj/implicit_semicolon-block_expr.zig | 4 +- .../implicit_semicolon-block_statement.zig | 4 +- ...implicit_semicolon-comptime_expression.zig | 4 +- .../implicit_semicolon-comptime_statement.zig | 4 +- .../stage1/obj/implicit_semicolon-defer.zig | 4 +- .../obj/implicit_semicolon-for_expression.zig | 4 +- .../obj/implicit_semicolon-for_statement.zig | 4 +- ...t_semicolon-if-else-if-else_expression.zig | 4 +- ...it_semicolon-if-else-if-else_statement.zig | 4 +- ...plicit_semicolon-if-else-if_expression.zig | 4 +- ...mplicit_semicolon-if-else-if_statement.zig | 4 +- .../implicit_semicolon-if-else_expression.zig | 4 +- .../implicit_semicolon-if-else_statement.zig | 4 +- .../obj/implicit_semicolon-if_expression.zig | 4 +- .../obj/implicit_semicolon-if_statement.zig | 4 +- .../implicit_semicolon-test_expression.zig | 4 +- .../obj/implicit_semicolon-test_statement.zig | 4 +- ...it_semicolon-while-continue_expression.zig | 4 +- ...cit_semicolon-while-continue_statement.zig | 4 +- .../implicit_semicolon-while_expression.zig | 4 +- .../implicit_semicolon-while_statement.zig | 4 +- .../implicitly_casting_enum_to_tag_type.zig | 4 +- ...mplicitly_increasing_pointer_alignment.zig | 4 +- .../implicitly_increasing_slice_alignment.zig | 4 +- .../obj/import_outside_package_path.zig | 4 +- .../stage1/obj/incompatible_sentinels.zig | 29 +++ .../stage1/obj/incorrect_return_type.zig | 4 +- .../increase_pointer_alignment_in_ptrCast.zig | 4 +- ...indexing_a_undefined_slice_at_comptime.zig | 4 +- .../obj/indexing_an_array_of_size_zero.zig | 4 +- ..._array_of_size_zero_with_runtime_index.zig | 4 +- .../obj/indexing_single-item_pointer.zig | 4 +- ..._recursion_of_async_functions_detected.zig | 4 +- .../stage1/obj/indirect_struct_loop.zig | 4 +- .../obj/inferred_array_size_invalid_here.zig | 4 +- ...nferring_error_set_of_function_pointer.zig | 4 +- .../initializing_array_with_struct_syntax.zig | 4 +- ...an_invalid_struct_that_contains_itself.zig | 4 +- .../obj/intToPtr_with_misaligned_address.zig | 4 +- .../obj/int_to_err_global_invalid_number.zig | 4 +- .../int_to_err_non_global_invalid_number.zig | 4 +- .../stage1/obj/int_to_ptr_of_0_bits.zig | 4 +- .../obj/integer_cast_truncates_bits.zig | 4 +- .../stage1/obj/integer_overflow_error.zig | 4 +- .../stage1/obj/integer_underflow_error.zig | 4 +- .../stage1/obj/invalid_break_expression.zig | 4 +- .../stage1/obj/invalid_builtin_fn.zig | 4 +- ...nvalid_cast_from_integral_type_to_enum.zig | 4 +- ...valid_comparison_for_function_pointers.zig | 4 +- .../obj/invalid_continue_expression.zig | 4 +- .../obj/invalid_deref_on_switch_target.zig | 4 +- .../obj/invalid_empty_unicode_escape.zig | 4 +- .../invalid_exponent_in_float_literal-1.zig | 4 +- .../invalid_exponent_in_float_literal-2.zig | 4 +- .../obj/invalid_field_access_in_comptime.zig | 4 +- ...valid_field_in_struct_value_expression.zig | 4 +- .../stage1/obj/invalid_float_literal.zig | 4 +- .../obj/invalid_legacy_unicode_escape.zig | 4 +- .../stage1/obj/invalid_maybe_type.zig | 4 +- .../obj/invalid_member_of_builtin_enum.zig | 4 +- .../obj/invalid_multiple_dereferences.zig | 4 +- ...invalid_optional_type_in_extern_struct.zig | 4 +- .../obj/invalid_pointer_for_var_type.zig | 4 +- .../stage1/obj/invalid_pointer_syntax.zig | 4 +- .../stage1/obj/invalid_shift_amount_error.zig | 4 +- .../stage1/obj/invalid_struct_field.zig | 4 +- .../invalid_suspend_in_exported_function.zig | 4 +- .../stage1/obj/invalid_type.zig | 4 +- .../obj/invalid_type_used_in_array_type.zig | 4 +- ...nderscore_placement_in_float_literal-1.zig | 4 +- ...derscore_placement_in_float_literal-10.zig | 4 +- ...derscore_placement_in_float_literal-11.zig | 4 +- ...derscore_placement_in_float_literal-12.zig | 4 +- ...derscore_placement_in_float_literal-13.zig | 4 +- ...derscore_placement_in_float_literal-14.zig | 4 +- ...nderscore_placement_in_float_literal-2.zig | 4 +- ...nderscore_placement_in_float_literal-3.zig | 4 +- ...nderscore_placement_in_float_literal-4.zig | 4 +- ...nderscore_placement_in_float_literal-5.zig | 4 +- ...nderscore_placement_in_float_literal-6.zig | 4 +- ...nderscore_placement_in_float_literal-7.zig | 4 +- ...nderscore_placement_in_float_literal-9.zig | 4 +- ..._underscore_placement_in_int_literal-1.zig | 4 +- ..._underscore_placement_in_int_literal-2.zig | 4 +- ..._underscore_placement_in_int_literal-3.zig | 4 +- ..._underscore_placement_in_int_literal-4.zig | 4 +- ...invalid_union_field_access_in_comptime.zig | 4 +- ...gnostic_string_for_top_level_decl_type.zig | 4 +- ..._from_undefined_array_pointer_to_slice.zig | 4 +- ..._3818_bitcast_from_parray-slice_to_u16.zig | 4 +- ...terminated-slice_to_terminated-pointer.zig | 4 +- ...d_by_typeInfo_and_passed_into_function.zig | 4 +- ...ional_anyopaque_to_anyopaque_must_fail.zig | 4 +- ...time_slice-len_increment_beyond_bounds.zig | 4 +- ..._9346_return_outside_of_function_scope.zig | 4 +- .../stage1/obj/labeled_break_not_found.zig | 4 +- .../stage1/obj/labeled_continue_not_found.zig | 4 +- ...zy_pointer_with_undefined_element_type.zig | 4 +- .../stage1/obj/libc_headers_note.zig | 12 + ...es_from_comptime_reinterpreted_pointer.zig | 4 +- ...tor_pointer_with_unknown_runtime_index.zig | 4 +- ...local_shadows_global_that_occurs_later.zig | 4 +- .../obj/local_variable_redeclaration.zig | 4 +- .../local_variable_redeclares_parameter.zig | 4 +- .../obj/local_variable_shadowing_global.zig | 4 +- .../locally_shadowing_a_primitive_type.zig | 4 +- .../main_function_with_bogus_args_type.zig | 4 +- ...hod_call_with_first_arg_type_primitive.zig | 4 +- ...ll_with_first_arg_type_wrong_container.zig | 4 +- .../obj/missing_boolean_switch_value.zig | 4 +- ..._const_in_slice_with_nested_array_type.zig | 4 +- .../stage1/obj/missing_else_clause.zig | 4 +- ...ssing_field_in_struct_value_expression.zig | 4 +- .../obj/missing_function_call_param.zig | 4 +- .../stage1/obj/missing_function_name.zig | 4 +- .../stage1/obj/missing_param_name.zig | 4 +- ...ing_parameter_name_of_generic_function.zig | 4 +- .../obj/missing_result_type_for_phi_node.zig | 4 +- ...elled_type_with_pointer_only_reference.zig | 4 +- .../obj/mod_assign_on_undefined_value.zig | 4 +- .../stage1/obj/mod_on_undefined_value.zig | 4 +- .../mul_overflow_in_function_evaluation.zig | 4 +- .../obj/mult_assign_on_undefined_value.zig | 4 +- .../stage1/obj/mult_on_undefined_value.zig | 4 +- .../mult_wrap_assign_on_undefined_value.zig | 4 +- .../obj/mult_wrap_on_undefined_value.zig | 4 +- .../obj/multiple_function_definitions.zig | 4 +- .../stage1/obj/negate_on_undefined_value.zig | 4 +- .../obj/negate_wrap_on_undefined_value.zig | 4 +- ...gation_overflow_in_function_evaluation.zig | 4 +- .../stage1/obj/nested_error_set_mismatch.zig | 4 +- ...se_prong_on_switch_on_global_error_set.zig | 4 +- .../obj/noalias_on_non_pointer_param.zig | 4 +- ...eventually_is_inferred_to_become_async.zig | 4 +- ...h_struct_return_value_outside_function.zig | 4 +- ...ion_in_struct_literal_outside_function.zig | 4 +- .../obj/non-const_switch_number_literal.zig | 4 +- ...of_things_that_require_const_variables.zig | 4 +- .../obj/non-enum_tag_type_passed_to_union.zig | 4 +- .../obj/non-extern_function_with_var_args.zig | 4 +- ..._loop_on_a_type_that_requires_comptime.zig | 4 +- ...teger_tag_type_to_automatic_union_enum.zig | 4 +- .../obj/non-pure_function_returns_type.zig | 4 +- ...c_function_pointer_passed_to_asyncCall.zig | 4 +- .../non_compile_time_array_concatenation.zig | 4 +- .../non_constant_expression_in_array_size.zig | 4 +- ...sets_used_in_merge_error_sets_operator.zig | 4 +- .../obj/non_float_passed_to_floatToInt.zig | 4 +- .../obj/non_int_passed_to_intToFloat.zig | 4 +- .../obj/non_pointer_given_to_ptrToInt.zig | 4 +- .../stage1/obj/normal_string_with_newline.zig | 4 +- .../stage1/obj/offsetOf-bad_field_name.zig | 4 +- .../stage1/obj/offsetOf-non_struct.zig | 4 +- ...binary_operator_allowed_for_error_sets.zig | 4 +- .../stage1/obj/opaque_type_with_field.zig | 4 +- ...ional_pointer_to_void_in_extern_struct.zig | 4 +- .../stage1/obj/or_on_undefined_value.zig | 4 +- .../stage1/obj/orelse_on_undefined_value.zig | 4 +- ...ange_comptime_int_passed_to_floatToInt.zig | 4 +- .../obj/overflow_in_enum_value_allocation.zig | 4 +- .../obj/packed_union_given_enum_tag_type.zig | 4 +- ...cked_union_with_automatic_layout_field.zig | 4 +- .../obj/panic_called_at_compile_time.zig | 4 +- .../stage1/obj/parameter_redeclaration.zig | 4 +- .../stage1/obj/parameter_shadowing_global.zig | 4 +- .../obj/pass_const_ptr_to_mutable_ptr_fn.zig | 4 +- ..._not-aligned-enough_pointer_to_cmpxchg.zig | 4 +- ...sing_an_under-aligned_function_pointer.zig | 4 +- ...ast_const_pointer_to_mutable_C_pointer.zig | 4 +- ...pointer_arithmetic_on_pointer-to-array.zig | 4 +- ..._when_coercing_pointer_to_anon_literal.zig | 4 +- .../stage1/obj/pointer_to_noreturn.zig | 4 +- .../stage1/obj/popCount-non-integer.zig | 4 +- ...bad_implicit_casting_of_anyframe_types.zig | 4 +- ...ives_take_precedence_over_declarations.zig | 4 +- ...Cast_a_0_bit_type_to_a_non-_0_bit_type.zig | 4 +- .../obj/ptrCast_discards_const_qualifier.zig | 4 +- .../ptrToInt_0_to_non_optional_pointer.zig | 4 +- .../stage1/obj/ptrToInt_on_void.zig | 4 +- .../stage1/obj/ptrcast_to_non-pointer.zig | 4 +- ...e_operator_in_switch_used_on_error_set.zig | 4 +- ...ading_past_end_of_pointer_casted_array.zig | 4 +- .../obj/recursive_inferred_error_set.zig | 4 +- .../stage1/obj/redefinition_of_enums.zig | 4 +- .../obj/redefinition_of_global_variables.zig | 4 +- .../stage1/obj/redefinition_of_struct.zig | 4 +- ...efer_to_the_type_of_a_generic_function.zig | 4 +- .../referring_to_a_struct_that_is_invalid.zig | 4 +- ...when_assigning_a_value_within_a_struct.zig | 4 +- .../reify_type.Fn_with_is_generic_true.zig | 4 +- ...th_is_var_args_true_and_non-C_callconv.zig | 4 +- .../reify_type.Fn_with_return_type_null.zig | 4 +- ...ype.Pointer_with_invalid_address_space.zig | 4 +- ...austive_enum_with_non-integer_tag_type.zig | 4 +- ...xhaustive_enum_with_undefined_tag_type.zig | 4 +- ...e_for_exhaustive_enum_with_zero_fields.zig | 4 +- ...for_tagged_union_with_extra_enum_field.zig | 4 +- ...or_tagged_union_with_extra_union_field.zig | 4 +- ...reify_type_for_union_with_opaque_field.zig | 4 +- .../reify_type_for_union_with_zero_fields.zig | 4 +- .../reify_type_union_payload_is_undefined.zig | 4 +- .../stage1/obj/reify_type_with_Type.Int.zig | 4 +- ...eify_type_with_non-constant_expression.zig | 4 +- .../stage1/obj/reify_type_with_undefined.zig | 4 +- ...ompatibility_mismatching_handle_is_ptr.zig | 4 +- ...mismatching_handle_is_ptr_generic_call.zig | 4 +- .../obj/return_from_defer_expression.zig | 4 +- ...turning_error_from_void_async_function.zig | 4 +- .../runtime-known_async_function_called.zig | 4 +- ...own_function_called_with_async_keyword.zig | 4 +- ...ime_assignment_to_comptime_struct_type.zig | 4 +- ...time_assignment_to_comptime_union_type.zig | 4 +- ...ast_to_union_which_has_non-void_fields.zig | 4 +- ...runtime_index_into_comptime_type_slice.zig | 4 +- ...ating_arithmetic_does_not_allow_floats.zig | 4 +- ...oes_not_allow_negative_rhs_at_comptime.zig | 4 +- ...oes_not_allow_negative_rhs_at_comptime.zig | 4 +- .../obj/setAlignStack_in_inline_function.zig | 4 +- .../obj/setAlignStack_in_naked_function.zig | 4 +- .../obj/setAlignStack_outside_function.zig | 4 +- .../stage1/obj/setAlignStack_set_twice.zig | 4 +- .../stage1/obj/setAlignStack_too_big.zig | 4 +- .../obj/setFloatMode_twice_for_same_scope.zig | 4 +- .../setRuntimeSafety_twice_for_same_scope.zig | 4 +- .../setting_a_section_on_a_local_variable.zig | 4 +- ...shift_amount_has_to_be_an_integer_type.zig | 4 +- .../shift_by_negative_comptime_integer.zig | 4 +- .../shift_left_assign_on_undefined_value.zig | 4 +- .../obj/shift_left_on_undefined_value.zig | 4 +- .../shift_right_assign_on_undefined_value.zig | 4 +- .../obj/shift_right_on_undefined_value.zig | 4 +- ...fting_RHS_is_log2_of_LHS_int_bit_width.zig | 4 +- ...ing_without_int_type_or_comptime_known.zig | 4 +- .../stage1/obj/shlExact_shifts_out_1_bits.zig | 4 +- .../stage1/obj/shrExact_shifts_out_1_bits.zig | 4 +- .../stage1/obj/signed_integer_division.zig | 4 +- .../obj/signed_integer_remainder_division.zig | 4 +- .../stage1/obj/sizeOf_bad_type.zig | 4 +- ...ce_cannot_have_its_bytes_reinterpreted.zig | 4 +- .../obj/slice_passed_as_array_init_type.zig | 4 +- ...e_passed_as_array_init_type_with_elems.zig | 4 +- .../stage1/obj/slice_sentinel_mismatch-1.zig | 4 +- .../stage1/obj/slice_sentinel_mismatch-2.zig | 4 +- .../slicing_of_global_undefined_pointer.zig | 4 +- .../obj/slicing_single-item_pointer.zig | 4 +- ...pecify_enum_tag_type_that_is_too_small.zig | 4 +- .../obj/specify_non-integer_enum_tag_type.zig | 4 +- .../stage1/obj/src_outside_function.zig | 4 +- .../std.fmt_error_for_unused_arguments.zig | 4 +- ...tor_pointer_with_unknown_runtime_index.zig | 4 +- ...in_compile_time_variable_then_using_it.zig | 4 +- ...t_depends_on_itself_via_optional_field.zig | 4 +- .../stage1/obj/struct_field_missing_type.zig | 4 +- .../obj/struct_init_syntax_for_array.zig | 4 +- ...eclarations_unavailable_for_reify_type.zig | 4 +- .../stage1/obj/struct_with_invalid_field.zig | 4 +- .../obj/sub_assign_on_undefined_value.zig | 4 +- .../stage1/obj/sub_on_undefined_value.zig | 4 +- .../sub_overflow_in_function_evaluation.zig | 4 +- .../sub_wrap_assign_on_undefined_value.zig | 4 +- .../obj/sub_wrap_on_undefined_value.zig | 4 +- .../obj/suspend_inside_suspend_block.zig | 4 +- ...expression-duplicate_enumeration_prong.zig | 4 +- ...te_enumeration_prong_when_else_present.zig | 4 +- ...duplicate_or_overlapping_integer_value.zig | 4 +- .../obj/switch_expression-duplicate_type.zig | 4 +- ...expression-duplicate_type_struct_alias.zig | 4 +- ...h_expression-missing_enumeration_prong.zig | 4 +- ...switch_expression-multiple_else_prongs.zig | 4 +- ...pression-non_exhaustive_integer_prongs.zig | 4 +- ...on-switch_on_pointer_type_with_no_else.zig | 4 +- ...expression-unreachable_else_prong_bool.zig | 4 +- ...expression-unreachable_else_prong_enum.zig | 4 +- ...ession-unreachable_else_prong_range_i8.zig | 4 +- ...ession-unreachable_else_prong_range_u8.zig | 4 +- ...h_expression-unreachable_else_prong_u1.zig | 4 +- ...h_expression-unreachable_else_prong_u2.zig | 4 +- ...ch_on_enum_with_1_field_with_no_prongs.zig | 4 +- .../switch_on_union_with_no_attached_enum.zig | 4 +- ...itch_with_invalid_expression_parameter.zig | 4 +- .../switch_with_overlapping_case_ranges.zig | 4 +- ...d_on_union_with_no_associated_enum_tag.zig | 4 +- .../obj/take_slice_of_invalid_dereference.zig | 4 +- ...ing_bit_offset_of_void_field_in_struct.zig | 4 +- ...ng_byte_offset_of_void_field_in_struct.zig | 4 +- .../obj/threadlocal_qualifier_on_const.zig | 4 +- .../obj/top_level_decl_dependency_loop.zig | 4 +- .../stage1/obj/truncate_sign_mismatch.zig | 4 +- .../stage1/obj/truncate_undefined_value.zig | 4 +- ...in_function_with_non_error_return_type.zig | 4 +- .../obj/type_checking_function_pointers.zig | 4 +- .../obj/type_variables_must_be_constant.zig | 4 +- .../stage1/obj/undeclared_identifier.zig | 4 +- ...ntifier_error_should_mark_fn_as_impure.zig | 4 +- ...clared_identifier_in_unanalyzed_branch.zig | 4 +- .../undefined_as_field_type_is_rejected.zig | 4 +- .../stage1/obj/undefined_function_call.zig | 4 +- .../underscore_is_not_a_declarable_symbol.zig | 4 +- ...rscore_should_not_be_usable_inside_for.zig | 4 +- ...core_should_not_be_usable_inside_while.zig | 4 +- ...should_not_be_usable_inside_while_else.zig | 4 +- .../union_auto-enum_value_already_taken.zig | 4 +- .../union_enum_field_does_not_match_enum.zig | 4 +- .../union_fields_with_value_assignments.zig | 4 +- .../stage1/obj/union_with_0_fields.zig | 4 +- .../union_with_specified_enum_omits_field.zig | 4 +- ...ith_too_small_explicit_signed_tag_type.zig | 4 +- ...h_too_small_explicit_unsigned_tag_type.zig | 4 +- .../obj/unknown_length_pointer_to_opaque.zig | 4 +- .../obj/unreachable_code-double_break.zig | 4 +- .../obj/unreachable_code-nested_returns.zig | 4 +- .../stage1/obj/unreachable_code.zig | 4 +- .../obj/unreachable_executed_at_comptime.zig | 4 +- .../stage1/obj/unreachable_parameter.zig | 4 +- .../stage1/obj/unreachable_variable.zig | 4 +- .../stage1/obj/unreachable_with_return.zig | 4 +- ...fier_at_start_of_asm_output_constraint.zig | 4 +- .../obj/unused_variable_error_on_errdefer.zig | 4 +- ...use_anyopaque_as_return_type_of_fn_ptr.zig | 4 +- ...to_assign_null_to_non-nullable_pointer.zig | 4 +- ..._invalid_number_literal_as_array_index.zig | 4 +- ...omptime-known_undefined_function_value.zig | 4 +- .../obj/use_of_undeclared_identifier.zig | 4 +- ..._unknown_len_ptr_type_instead_of_array.zig | 4 +- ...types_in_function_call_raises_an_error.zig | 4 +- .../obj/usingnamespace_with_wrong_type.zig | 4 +- .../stage1/obj/variable_has_wrong_type.zig | 4 +- ...line_assembly_template_cannot_be_found.zig | 12 + ...lization_compile_error_then_referenced.zig | 4 +- .../obj/variable_with_type_noreturn.zig | 4 +- .../stage1/obj/vector_index_out_of_bounds.zig | 4 +- .../obj/volatile_on_global_assembly.zig | 4 +- ...is_a_compile_error_in_non-Wasm_targets.zig | 4 +- ...is_a_compile_error_in_non-Wasm_targets.zig | 4 +- .../while_expected_bool_got_error_union.zig | 4 +- .../obj/while_expected_bool_got_optional.zig | 4 +- .../while_expected_error_union_got_bool.zig | 4 +- ...hile_expected_error_union_got_optional.zig | 4 +- .../obj/while_expected_optional_got_bool.zig | 4 +- ...hile_expected_optional_got_error_union.zig | 4 +- .../while_loop_body_expression_ignored.zig | 4 +- .../obj/write_to_const_global_variable.zig | 4 +- .../wrong_frame_type_used_for_async_call.zig | 4 +- .../stage1/obj/wrong_function_type.zig | 4 +- ...ializer_for_union_payload_of_type_type.zig | 4 +- .../stage1/obj/wrong_number_of_arguments.zig | 4 +- ...number_of_arguments_for_method_fn_call.zig | 4 +- ...wrong_panic_signature_generic_function.zig | 4 +- ...wrong_panic_signature_runtime_function.zig | 4 +- ...ointer_coerced_to_pointer_to_opaque_{}.zig | 4 +- .../stage1/obj/wrong_return_type_for_main.zig | 4 +- .../obj/wrong_size_to_an_array_literal.zig | 4 +- ...g_type_for_argument_tuple_to_asyncCall.zig | 4 +- .../stage1/obj/wrong_type_for_reify_type.zig | 4 +- ...wrong_type_for_result_ptr_to_asyncCall.zig | 4 +- .../stage1/obj/wrong_type_passed_to_panic.zig | 4 +- .../stage1/obj/wrong_type_to_hasField.zig | 4 +- ..._given_to_atomic_order_args_in_cmpxchg.zig | 4 +- .../obj/wrong_types_given_to_export.zig | 4 +- .../test/access_invalid_typeInfo_decl.zig | 5 +- .../test/alignCast_of_zero_sized_types.zig | 5 +- .../stage1/test/bad_splat_type.zig | 5 +- .../test/binary_OR_operator_on_error_sets.zig | 5 +- ...ts_non_comptime-known_fn-always_inline.zig | 5 +- ...cts_non_comptime-known_fn-compile_time.zig | 5 +- ...en_optional_T_where_T_is_not_a_pointer.zig | 5 +- .../combination_of_nosuspend_and_async.zig | 5 +- ...n_of_non-tagged_union_and_enum_literal.zig | 5 +- ...mptime_vector_overflow_shows_the_index.zig | 5 +- ...cate_field_in_anonymous_struct_literal.zig | 5 +- ..._initializer_doesnt_crash_the_compiler.zig | 5 +- ...rors_in_for_loop_bodies_are_propagated.zig | 5 +- .../test/export_with_empty_name_string.zig | 5 +- .../helpful_return_type_error_message.zig | 5 +- ...float_conversion_to_comptime_int-float.zig | 5 +- .../stage1/test/invalid_assignments.zig | 5 +- .../stage1/test/invalid_float_casts.zig | 5 +- .../stage1/test/invalid_int_casts.zig | 5 +- .../invalid_non-exhaustive_enum_to_union.zig | 5 +- .../test/invalid_pointer_with_reify_type.zig | 5 +- .../stage1/test/nested_vectors.zig | 5 +- ...xhaustive_enum_marker_assigned_a_value.zig | 5 +- .../stage1/test/non-exhaustive_enums.zig | 5 +- .../stage1/test/not_an_enum_type.zig | 5 +- ...truct_with_fields_of_not_allowed_types.zig | 5 +- ...rToInt_with_pointer_to_zero-sized_type.zig | 5 +- .../test/reassign_to_array_parameter.zig | 5 +- .../test/reassign_to_slice_parameter.zig | 5 +- .../test/reassign_to_struct_parameter.zig | 5 +- .../stage1/test/reference_to_const_data.zig | 5 +- ...ify_typeOf_with_incompatible_arguments.zig | 5 +- .../test/reify_typeOf_with_no_arguments.zig | 5 +- ..._extern_function_definitions_with_body.zig | 5 +- ...ect_extern_variables_with_initializers.zig | 5 +- ...n_returning_type_crashes_compiler_2655.zig | 5 +- .../test/return_invalid_type_from_test.zig | 5 +- ...ift_on_type_with_non-power-of-two_size.zig | 5 +- ...elected_index_past_first_vector_length.zig | 5 +- .../switch_ranges_endpoints_are_validated.zig | 5 +- ...hing_with_exhaustive_enum_has___prong_.zig | 5 +- .../switching_with_non-exhaustive_enums.zig | 5 +- ...n_invalid_value_of_non-exhaustive_enum.zig | 5 +- ...e_mismatch_in_C_prototype_with_varargs.zig | 5 +- ...type_mismatch_with_tuple_concatenation.zig | 5 +- ...de_comptime_function_has_compile_error.zig | 1 + .../stage2/duplicate-unused_labels.zig | 1 + .../stage2/embed_outside_package.zig | 1 + .../stage2/import_outside_package.zig | 1 + .../stage2/out_of_bounds_index.zig | 1 + .../stage2/slice_of_null_pointer.zig | 1 + .../stage2/struct_duplicate_field_name.zig | 1 + .../stage2/union_access_of_inactive_field.zig | 1 + .../stage2/union_duplicate_enum_field.zig | 1 + .../union_duplicate_field_definition.zig | 1 + .../stage2/union_enum_field_missing.zig | 1 + .../stage2/union_extra_field.zig | 1 + .../union_runtime_coercion_from_enum.zig | 1 + 678 files changed, 2175 insertions(+), 902 deletions(-) create mode 100644 test/compile_errors/stage1/obj/align_n_expr_function_pointers_is_a_compile_error.zig create mode 100644 test/compile_errors/stage1/obj/bad_alignment_in_asynccall.zig create mode 100644 test/compile_errors/stage1/obj/call_with_new_stack_on_unsupported_target.zig create mode 100644 test/compile_errors/stage1/obj/callconv_apcs_aapcs_aapcsvfp_on_unsupported_platform.zig create mode 100644 test/compile_errors/stage1/obj/callconv_interrupt_on_unsupported_platform.zig create mode 100644 test/compile_errors/stage1/obj/callconv_signal_on_unsupported_platform.zig create mode 100644 test/compile_errors/stage1/obj/callconv_stdcall_fastcall_thiscall_on_unsupported_platform-0.zig create mode 100644 test/compile_errors/stage1/obj/callconv_stdcall_fastcall_thiscall_on_unsupported_platform-1.zig create mode 100644 test/compile_errors/stage1/obj/callconv_vectorcall_on_unsupported_platform.zig create mode 100644 test/compile_errors/stage1/obj/implicit_dependency_on_libc.zig create mode 100644 test/compile_errors/stage1/obj/incompatible_sentinels.zig create mode 100644 test/compile_errors/stage1/obj/libc_headers_note.zig create mode 100644 test/compile_errors/stage1/obj/variable_in_inline_assembly_template_cannot_be_found.zig diff --git a/src/test.zig b/src/test.zig index 3579370c04..adcfeb8dff 100644 --- a/src/test.zig +++ b/src/test.zig @@ -34,15 +34,12 @@ test { var ctx = TestContext.init(std.testing.allocator, arena); defer ctx.deinit(); - const compile_errors_dir_path = try std.fs.path.join(arena, &.{ - std.fs.path.dirname(@src().file).?, "..", "test", "compile_errors", - }); - - var compile_errors_dir = try std.fs.cwd().openDir(compile_errors_dir_path, .{}); - defer compile_errors_dir.close(); - { - var dir = try compile_errors_dir.openDir("stage2", .{ .iterate = true }); + const dir_path = try std.fs.path.join(arena, &.{ + std.fs.path.dirname(@src().file).?, "..", "test", "compile_errors", + }); + + var dir = try std.fs.cwd().openDir(dir_path, .{ .iterate = true }); defer dir.close(); // TODO make this incremental once the bug is solved that it triggers @@ -50,28 +47,6 @@ test { ctx.addTestCasesFromDir(dir, .independent); } - if (!skip_stage1) { - var stage1_dir = try compile_errors_dir.openDir("stage1", .{}); - defer stage1_dir.close(); - - const Config = struct { - name: []const u8, - is_test: bool, - output_mode: std.builtin.OutputMode, - }; - - for ([_]Config{ - .{ .name = "obj", .is_test = false, .output_mode = .Obj }, - .{ .name = "exe", .is_test = false, .output_mode = .Exe }, - .{ .name = "test", .is_test = true, .output_mode = .Exe }, - }) |config| { - var dir = try stage1_dir.openDir(config.name, .{ .iterate = true }); - defer dir.close(); - - ctx.addErrorCasesFromDir("stage1", dir, .stage1, config.output_mode, config.is_test, .independent); - } - } - { const dir_path = try std.fs.path.join(arena, &.{ std.fs.path.dirname(@src().file).?, "..", "test", "incremental", diff --git a/test/cases.zig b/test/cases.zig index 3e340dcddb..65eec90f1b 100644 --- a/test/cases.zig +++ b/test/cases.zig @@ -1,11 +1,6 @@ const std = @import("std"); const TestContext = @import("../src/test.zig").TestContext; -// Self-hosted has differing levels of support for various architectures. For now we pass explicit -// target parameters to each test case. At some point we will take this to the next level and have -// a set of targets that all test cases run on unless specifically overridden. For now, each test -// case applies to only the specified target. - pub fn addCases(ctx: *TestContext) !void { try @import("compile_errors.zig").addCases(ctx); try @import("stage2/cbe.zig").addCases(ctx); diff --git a/test/compile_errors.zig b/test/compile_errors.zig index d0e4156f18..f79d2b8e92 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -3,207 +3,6 @@ const builtin = @import("builtin"); const TestContext = @import("../src/test.zig").TestContext; pub fn addCases(ctx: *TestContext) !void { - { - const case = ctx.obj("callconv(.Interrupt) on unsupported platform", .{ - .cpu_arch = .aarch64, - .os_tag = .linux, - .abi = .none, - }); - case.backend = .stage1; - case.addError( - \\export fn entry() callconv(.Interrupt) void {} - , &[_][]const u8{ - "tmp.zig:1:28: error: callconv 'Interrupt' is only available on x86, x86_64, AVR, and MSP430, not aarch64", - }); - } - { - var case = ctx.obj("callconv(.Signal) on unsupported platform", .{ - .cpu_arch = .x86_64, - .os_tag = .linux, - .abi = .none, - }); - case.backend = .stage1; - case.addError( - \\export fn entry() callconv(.Signal) void {} - , &[_][]const u8{ - "tmp.zig:1:28: error: callconv 'Signal' is only available on AVR, not x86_64", - }); - } - { - const case = ctx.obj("callconv(.Stdcall, .Fastcall, .Thiscall) on unsupported platform", .{ - .cpu_arch = .x86_64, - .os_tag = .linux, - .abi = .none, - }); - case.backend = .stage1; - case.addError( - \\const F1 = fn () callconv(.Stdcall) void; - \\const F2 = fn () callconv(.Fastcall) void; - \\const F3 = fn () callconv(.Thiscall) void; - \\export fn entry1() void { var a: F1 = undefined; _ = a; } - \\export fn entry2() void { var a: F2 = undefined; _ = a; } - \\export fn entry3() void { var a: F3 = undefined; _ = a; } - , &[_][]const u8{ - "tmp.zig:1:27: error: callconv 'Stdcall' is only available on x86, not x86_64", - "tmp.zig:2:27: error: callconv 'Fastcall' is only available on x86, not x86_64", - "tmp.zig:3:27: error: callconv 'Thiscall' is only available on x86, not x86_64", - }); - } - { - const case = ctx.obj("callconv(.Stdcall, .Fastcall, .Thiscall) on unsupported platform", .{ - .cpu_arch = .x86_64, - .os_tag = .linux, - .abi = .none, - }); - case.backend = .stage1; - case.addError( - \\export fn entry1() callconv(.Stdcall) void {} - \\export fn entry2() callconv(.Fastcall) void {} - \\export fn entry3() callconv(.Thiscall) void {} - , &[_][]const u8{ - "tmp.zig:1:29: error: callconv 'Stdcall' is only available on x86, not x86_64", - "tmp.zig:2:29: error: callconv 'Fastcall' is only available on x86, not x86_64", - "tmp.zig:3:29: error: callconv 'Thiscall' is only available on x86, not x86_64", - }); - } - { - const case = ctx.obj("callconv(.Vectorcall) on unsupported platform", .{ - .cpu_arch = .x86_64, - .os_tag = .linux, - .abi = .none, - }); - case.backend = .stage1; - case.addError( - \\export fn entry() callconv(.Vectorcall) void {} - , &[_][]const u8{ - "tmp.zig:1:28: error: callconv 'Vectorcall' is only available on x86 and AArch64, not x86_64", - }); - } - { - const case = ctx.obj("callconv(.APCS, .AAPCS, .AAPCSVFP) on unsupported platform", .{ - .cpu_arch = .x86_64, - .os_tag = .linux, - .abi = .none, - }); - case.backend = .stage1; - case.addError( - \\export fn entry1() callconv(.APCS) void {} - \\export fn entry2() callconv(.AAPCS) void {} - \\export fn entry3() callconv(.AAPCSVFP) void {} - , &[_][]const u8{ - "tmp.zig:1:29: error: callconv 'APCS' is only available on ARM, not x86_64", - "tmp.zig:2:29: error: callconv 'AAPCS' is only available on ARM, not x86_64", - "tmp.zig:3:29: error: callconv 'AAPCSVFP' is only available on ARM, not x86_64", - }); - } - - { - const case = ctx.obj("call with new stack on unsupported target", .{ - .cpu_arch = .wasm32, - .os_tag = .wasi, - .abi = .none, - }); - case.backend = .stage1; - case.addError( - \\var buf: [10]u8 align(16) = undefined; - \\export fn entry() void { - \\ @call(.{.stack = &buf}, foo, .{}); - \\} - \\fn foo() void {} - , &[_][]const u8{ - "tmp.zig:3:5: error: target arch 'wasm32' does not support calling with a new stack", - }); - } - - // Note: One of the error messages here is backwards. It would be nice to fix, but that's not - // going to stop me from merging this branch which fixes a bunch of other stuff. - ctx.objErrStage1("incompatible sentinels", - \\export fn entry1(ptr: [*:255]u8) [*:0]u8 { - \\ return ptr; - \\} - \\export fn entry2(ptr: [*]u8) [*:0]u8 { - \\ return ptr; - \\} - \\export fn entry3() void { - \\ var array: [2:0]u8 = [_:255]u8{1, 2}; - \\ _ = array; - \\} - \\export fn entry4() void { - \\ var array: [2:0]u8 = [_]u8{1, 2}; - \\ _ = array; - \\} - , &[_][]const u8{ - "tmp.zig:2:12: error: expected type '[*:0]u8', found '[*:255]u8'", - "tmp.zig:2:12: note: destination pointer requires a terminating '0' sentinel, but source pointer has a terminating '255' sentinel", - "tmp.zig:5:12: error: expected type '[*:0]u8', found '[*]u8'", - "tmp.zig:5:12: note: destination pointer requires a terminating '0' sentinel", - - "tmp.zig:8:35: error: expected type '[2:255]u8', found '[2:0]u8'", - "tmp.zig:8:35: note: destination array requires a terminating '255' sentinel, but source array has a terminating '0' sentinel", - "tmp.zig:12:31: error: expected type '[2:0]u8', found '[2]u8'", - "tmp.zig:12:31: note: destination array requires a terminating '0' sentinel", - }); - - { - const case = ctx.obj("variable in inline assembly template cannot be found", .{ - .cpu_arch = .x86_64, - .os_tag = .linux, - .abi = .gnu, - }); - case.backend = .stage1; - case.addError( - \\export fn entry() void { - \\ var sp = asm volatile ( - \\ "mov %[foo], sp" - \\ : [bar] "=r" (-> usize) - \\ ); - \\ _ = sp; - \\} - , &[_][]const u8{ - "tmp.zig:2:14: error: could not find 'foo' in the inputs or outputs", - }); - } - - { - const case = ctx.obj("bad alignment in @asyncCall", .{ - .cpu_arch = .aarch64, - .os_tag = .linux, - .abi = .none, - }); - case.backend = .stage1; - case.addError( - \\export fn entry() void { - \\ var ptr: fn () callconv(.Async) void = func; - \\ var bytes: [64]u8 = undefined; - \\ _ = @asyncCall(&bytes, {}, ptr, .{}); - \\} - \\fn func() callconv(.Async) void {} - , &[_][]const u8{ - "tmp.zig:4:21: error: expected type '[]align(8) u8', found '*[64]u8'", - }); - } - - if (builtin.os.tag == .linux) { - ctx.testErrStage1("implicit dependency on libc", - \\extern "c" fn exit(u8) void; - \\export fn entry() void { - \\ exit(0); - \\} - , &[_][]const u8{ - "tmp.zig:3:5: error: dependency on libc must be explicitly specified in the build command", - }); - - ctx.testErrStage1("libc headers note", - \\const c = @cImport(@cInclude("stdio.h")); - \\export fn entry() void { - \\ _ = c.printf("hello, world!\n"); - \\} - , &[_][]const u8{ - "tmp.zig:1:11: error: C import failed", - "tmp.zig:1:11: note: libc headers not available; compilation does not link against libc", - }); - } - { const case = ctx.obj("wrong same named struct", .{}); case.backend = .stage1; @@ -366,21 +165,4 @@ pub fn addCases(ctx: *TestContext) !void { //, &[_][]const u8{ // "tmp.zig:4:1: error: unable to inline function", //}); - - { - const case = ctx.obj("align(N) expr function pointers is a compile error", .{ - .cpu_arch = .wasm32, - .os_tag = .freestanding, - .abi = .none, - }); - case.backend = .stage1; - - case.addError( - \\export fn foo() align(1) void { - \\ return; - \\} - , &[_][]const u8{ - "tmp.zig:1:23: error: align(N) expr is not allowed on function prototypes in wasm32/wasm64", - }); - } } diff --git a/test/compile_errors/stage1/exe/main_missing_name.zig b/test/compile_errors/stage1/exe/main_missing_name.zig index c029665367..1a53e43cfb 100644 --- a/test/compile_errors/stage1/exe/main_missing_name.zig +++ b/test/compile_errors/stage1/exe/main_missing_name.zig @@ -1,5 +1,8 @@ pub fn (main) void {} -// main missing name +// error +// backend=stage1 +// target=native +// output_mode=Exe // // tmp.zig:1:5: error: missing function name diff --git a/test/compile_errors/stage1/exe/missing_main_fn_in_executable.zig b/test/compile_errors/stage1/exe/missing_main_fn_in_executable.zig index eb9ab469fd..65813abac3 100644 --- a/test/compile_errors/stage1/exe/missing_main_fn_in_executable.zig +++ b/test/compile_errors/stage1/exe/missing_main_fn_in_executable.zig @@ -1,5 +1,8 @@ -// missing main fn in executable +// error +// backend=stage1 +// target=native +// output_mode=Exe // // error: root source file has no member called 'main' diff --git a/test/compile_errors/stage1/exe/private_main_fn.zig b/test/compile_errors/stage1/exe/private_main_fn.zig index da617899a5..5a178389e8 100644 --- a/test/compile_errors/stage1/exe/private_main_fn.zig +++ b/test/compile_errors/stage1/exe/private_main_fn.zig @@ -1,6 +1,9 @@ fn main() void {} -// private main fn +// error +// backend=stage1 +// target=native +// output_mode=Exe // // error: 'main' is private // tmp.zig:1:1: note: declared here diff --git a/test/compile_errors/stage1/obj/C_pointer_pointing_to_non_C_ABI_compatible_type_or_has_align_attr.zig b/test/compile_errors/stage1/obj/C_pointer_pointing_to_non_C_ABI_compatible_type_or_has_align_attr.zig index 24fd0d1b9f..72c58adbd6 100644 --- a/test/compile_errors/stage1/obj/C_pointer_pointing_to_non_C_ABI_compatible_type_or_has_align_attr.zig +++ b/test/compile_errors/stage1/obj/C_pointer_pointing_to_non_C_ABI_compatible_type_or_has_align_attr.zig @@ -5,6 +5,8 @@ export fn a() void { _ = t; } -// C pointer pointing to non C ABI compatible type or has align attr +// error +// backend=stage1 +// target=native // // tmp.zig:3:19: error: C pointers cannot point to non-C-ABI-compatible type 'Foo' diff --git a/test/compile_errors/stage1/obj/C_pointer_to_anyopaque.zig b/test/compile_errors/stage1/obj/C_pointer_to_anyopaque.zig index 3012996145..36c9789d20 100644 --- a/test/compile_errors/stage1/obj/C_pointer_to_anyopaque.zig +++ b/test/compile_errors/stage1/obj/C_pointer_to_anyopaque.zig @@ -4,6 +4,8 @@ export fn a() void { _ = y; } -// C pointer to anyopaque +// error +// backend=stage1 +// target=native // // tmp.zig:3:16: error: C pointers cannot point to opaque types diff --git a/test/compile_errors/stage1/obj/Frame_of_generic_function.zig b/test/compile_errors/stage1/obj/Frame_of_generic_function.zig index b9b2280dd7..d90e53eb46 100644 --- a/test/compile_errors/stage1/obj/Frame_of_generic_function.zig +++ b/test/compile_errors/stage1/obj/Frame_of_generic_function.zig @@ -7,6 +7,8 @@ fn func(comptime T: type) void { _ = x; } -// @Frame() of generic function +// error +// backend=stage1 +// target=native // // tmp.zig:2:16: error: @Frame() of generic function diff --git a/test/compile_errors/stage1/obj/Issue_5586_Make_unary_minus_for_unsigned_types_a_compile_error.zig b/test/compile_errors/stage1/obj/Issue_5586_Make_unary_minus_for_unsigned_types_a_compile_error.zig index d01e68e4eb..e1d498e65f 100644 --- a/test/compile_errors/stage1/obj/Issue_5586_Make_unary_minus_for_unsigned_types_a_compile_error.zig +++ b/test/compile_errors/stage1/obj/Issue_5586_Make_unary_minus_for_unsigned_types_a_compile_error.zig @@ -8,7 +8,9 @@ export fn f2(x: V(4, u32)) V(4, u32) { return -y; } -// Issue #5586: Make unary minus for unsigned types a compile error +// error +// backend=stage1 +// target=native // // tmp.zig:3:12: error: negation of type 'u32' // tmp.zig:8:12: error: negation of type 'u32' diff --git a/test/compile_errors/stage1/obj/Issue_6823_dont_allow_._to_be_followed_by_.zig b/test/compile_errors/stage1/obj/Issue_6823_dont_allow_._to_be_followed_by_.zig index c21df43362..1aa0996ba4 100644 --- a/test/compile_errors/stage1/obj/Issue_6823_dont_allow_._to_be_followed_by_.zig +++ b/test/compile_errors/stage1/obj/Issue_6823_dont_allow_._to_be_followed_by_.zig @@ -3,6 +3,8 @@ fn foo() void { _ = sequence; } -// Issue #6823: don't allow .* to be followed by ** +// error +// backend=stage1 +// target=native // // tmp.zig:2:28: error: '.*' cannot be followed by '*'. Are you missing a space? diff --git a/test/compile_errors/stage1/obj/Issue_9165_windows_tcp_server_compilation_error.zig b/test/compile_errors/stage1/obj/Issue_9165_windows_tcp_server_compilation_error.zig index e3b9d4b009..3d150693f5 100644 --- a/test/compile_errors/stage1/obj/Issue_9165_windows_tcp_server_compilation_error.zig +++ b/test/compile_errors/stage1/obj/Issue_9165_windows_tcp_server_compilation_error.zig @@ -9,6 +9,8 @@ pub fn main() !void { } } -// Issue #9165: windows tcp server compilation error +// error +// backend=stage1 +// target=native // // error: Unsupported OS diff --git a/test/compile_errors/stage1/obj/access_non-existent_member_of_error_set.zig b/test/compile_errors/stage1/obj/access_non-existent_member_of_error_set.zig index 42a54b08cd..caddf36a84 100644 --- a/test/compile_errors/stage1/obj/access_non-existent_member_of_error_set.zig +++ b/test/compile_errors/stage1/obj/access_non-existent_member_of_error_set.zig @@ -4,6 +4,8 @@ comptime { _ = z; } -// access non-existent member of error set +// error +// backend=stage1 +// target=native // // tmp.zig:3:18: error: no error named 'Bar' in 'Foo' diff --git a/test/compile_errors/stage1/obj/accessing_runtime_parameter_from_outer_function.zig b/test/compile_errors/stage1/obj/accessing_runtime_parameter_from_outer_function.zig index 68b23c6a43..73a9e94d44 100644 --- a/test/compile_errors/stage1/obj/accessing_runtime_parameter_from_outer_function.zig +++ b/test/compile_errors/stage1/obj/accessing_runtime_parameter_from_outer_function.zig @@ -12,7 +12,9 @@ export fn entry() void { _ = x; } -// accessing runtime parameter from outer function +// error +// backend=stage1 +// target=native // // tmp.zig:4:24: error: 'y' not accessible from inner function // tmp.zig:3:28: note: crossed function definition here diff --git a/test/compile_errors/stage1/obj/add_assign_on_undefined_value.zig b/test/compile_errors/stage1/obj/add_assign_on_undefined_value.zig index 0076cf1bab..38e4fef81b 100644 --- a/test/compile_errors/stage1/obj/add_assign_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/add_assign_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { a += a; } -// add assign on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/add_on_undefined_value.zig b/test/compile_errors/stage1/obj/add_on_undefined_value.zig index 5f64c6999b..4a66f9c102 100644 --- a/test/compile_errors/stage1/obj/add_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/add_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = a + a; } -// add on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/add_overflow_in_function_evaluation.zig b/test/compile_errors/stage1/obj/add_overflow_in_function_evaluation.zig index b01e005a04..d4fa312482 100644 --- a/test/compile_errors/stage1/obj/add_overflow_in_function_evaluation.zig +++ b/test/compile_errors/stage1/obj/add_overflow_in_function_evaluation.zig @@ -5,6 +5,8 @@ fn add(a: u16, b: u16) u16 { export fn entry() usize { return @sizeOf(@TypeOf(y)); } -// add overflow in function evaluation +// error +// backend=stage1 +// target=native // // tmp.zig:3:14: error: operation caused overflow diff --git a/test/compile_errors/stage1/obj/add_wrap_assign_on_undefined_value.zig b/test/compile_errors/stage1/obj/add_wrap_assign_on_undefined_value.zig index 37dbf9106f..5f9a4c61fc 100644 --- a/test/compile_errors/stage1/obj/add_wrap_assign_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/add_wrap_assign_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { a +%= a; } -// add wrap assign on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/add_wrap_on_undefined_value.zig b/test/compile_errors/stage1/obj/add_wrap_on_undefined_value.zig index 3ba9bd11c6..582b8ec1cf 100644 --- a/test/compile_errors/stage1/obj/add_wrap_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/add_wrap_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = a +% a; } -// add wrap on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/addition_with_non_numbers.zig b/test/compile_errors/stage1/obj/addition_with_non_numbers.zig index 296b9f4103..8f343926f2 100644 --- a/test/compile_errors/stage1/obj/addition_with_non_numbers.zig +++ b/test/compile_errors/stage1/obj/addition_with_non_numbers.zig @@ -5,6 +5,8 @@ const x = Foo {.field = 1} + Foo {.field = 2}; export fn entry() usize { return @sizeOf(@TypeOf(x)); } -// addition with non numbers +// error +// backend=stage1 +// target=native // // tmp.zig:4:28: error: invalid operands to binary expression: 'Foo' and 'Foo' diff --git a/test/compile_errors/stage1/obj/address_of_number_literal.zig b/test/compile_errors/stage1/obj/address_of_number_literal.zig index ee61f2180f..76d321929d 100644 --- a/test/compile_errors/stage1/obj/address_of_number_literal.zig +++ b/test/compile_errors/stage1/obj/address_of_number_literal.zig @@ -3,6 +3,8 @@ const y = &x; fn foo() *const i32 { return y; } export fn entry() usize { return @sizeOf(@TypeOf(foo)); } -// address of number literal +// error +// backend=stage1 +// target=native // // tmp.zig:3:30: error: expected type '*const i32', found '*const comptime_int' diff --git a/test/compile_errors/stage1/obj/alignCast_expects_pointer_or_slice.zig b/test/compile_errors/stage1/obj/alignCast_expects_pointer_or_slice.zig index 91b269cef4..9f76d3ca4f 100644 --- a/test/compile_errors/stage1/obj/alignCast_expects_pointer_or_slice.zig +++ b/test/compile_errors/stage1/obj/alignCast_expects_pointer_or_slice.zig @@ -2,6 +2,8 @@ export fn entry() void { @alignCast(4, @as(u32, 3)); } -// @alignCast expects pointer or slice +// error +// backend=stage1 +// target=native // // tmp.zig:2:19: error: expected pointer or slice, found 'u32' diff --git a/test/compile_errors/stage1/obj/align_n_expr_function_pointers_is_a_compile_error.zig b/test/compile_errors/stage1/obj/align_n_expr_function_pointers_is_a_compile_error.zig new file mode 100644 index 0000000000..bd41b3e657 --- /dev/null +++ b/test/compile_errors/stage1/obj/align_n_expr_function_pointers_is_a_compile_error.zig @@ -0,0 +1,9 @@ +export fn foo() align(1) void { + return; +} + +// error +// backend=stage1 +// target=wasm32-freestanding-none +// +// tmp.zig:1:23: error: align(N) expr is not allowed on function prototypes in wasm32/wasm64 diff --git a/test/compile_errors/stage1/obj/aligned_variable_of_zero-bit_type.zig b/test/compile_errors/stage1/obj/aligned_variable_of_zero-bit_type.zig index 90e690056d..f09f92aca7 100644 --- a/test/compile_errors/stage1/obj/aligned_variable_of_zero-bit_type.zig +++ b/test/compile_errors/stage1/obj/aligned_variable_of_zero-bit_type.zig @@ -3,6 +3,8 @@ export fn f() void { _ = s; } -// aligned variable of zero-bit type +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: variable 's' of zero-bit type 'struct:2:12' has no in-memory representation, it cannot be aligned diff --git a/test/compile_errors/stage1/obj/alignment_of_enum_field_specified.zig b/test/compile_errors/stage1/obj/alignment_of_enum_field_specified.zig index cf5cdfd213..9b6f1e452d 100644 --- a/test/compile_errors/stage1/obj/alignment_of_enum_field_specified.zig +++ b/test/compile_errors/stage1/obj/alignment_of_enum_field_specified.zig @@ -7,6 +7,8 @@ export fn entry1() void { _ = x; } -// alignment of enum field specified +// error +// backend=stage1 +// target=native // // tmp.zig:3:7: error: expected ',' after field diff --git a/test/compile_errors/stage1/obj/ambiguous_decl_reference.zig b/test/compile_errors/stage1/obj/ambiguous_decl_reference.zig index 421c41d2c2..82e6a0a24c 100644 --- a/test/compile_errors/stage1/obj/ambiguous_decl_reference.zig +++ b/test/compile_errors/stage1/obj/ambiguous_decl_reference.zig @@ -12,7 +12,9 @@ export fn entry() void { bar(); } -// ambiguous decl reference +// error +// backend=stage1 +// target=native // // tmp.zig:5:13: error: ambiguous reference // tmp.zig:7:9: note: declared here diff --git a/test/compile_errors/stage1/obj/and_on_undefined_value.zig b/test/compile_errors/stage1/obj/and_on_undefined_value.zig index 82363848f3..6071d81062 100644 --- a/test/compile_errors/stage1/obj/and_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/and_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = a and a; } -// and on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/array_access_of_non_array.zig b/test/compile_errors/stage1/obj/array_access_of_non_array.zig index e4420debcd..7045f2fdbd 100644 --- a/test/compile_errors/stage1/obj/array_access_of_non_array.zig +++ b/test/compile_errors/stage1/obj/array_access_of_non_array.zig @@ -7,7 +7,9 @@ export fn g() void { _ = bad[0]; } -// array access of non array +// error +// backend=stage1 +// target=native // // tmp.zig:3:8: error: array access of non-array type 'bool' // tmp.zig:7:12: error: array access of non-array type 'bool' diff --git a/test/compile_errors/stage1/obj/array_access_of_type.zig b/test/compile_errors/stage1/obj/array_access_of_type.zig index 82708eed6c..c0029f2492 100644 --- a/test/compile_errors/stage1/obj/array_access_of_type.zig +++ b/test/compile_errors/stage1/obj/array_access_of_type.zig @@ -3,6 +3,8 @@ export fn foo() void { _ = b; } -// array access of type +// error +// backend=stage1 +// target=native // // tmp.zig:2:14: error: array access of non-array type 'type' diff --git a/test/compile_errors/stage1/obj/array_access_of_undeclared_identifier.zig b/test/compile_errors/stage1/obj/array_access_of_undeclared_identifier.zig index 193a7bf5de..7d16a0d60e 100644 --- a/test/compile_errors/stage1/obj/array_access_of_undeclared_identifier.zig +++ b/test/compile_errors/stage1/obj/array_access_of_undeclared_identifier.zig @@ -2,6 +2,8 @@ export fn f() void { i[i] = i[i]; } -// array access of undeclared identifier +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: use of undeclared identifier 'i' diff --git a/test/compile_errors/stage1/obj/array_access_with_non_integer_index.zig b/test/compile_errors/stage1/obj/array_access_with_non_integer_index.zig index 1a3e17d896..de0a58656c 100644 --- a/test/compile_errors/stage1/obj/array_access_with_non_integer_index.zig +++ b/test/compile_errors/stage1/obj/array_access_with_non_integer_index.zig @@ -9,7 +9,9 @@ export fn g() void { _ = array[bad]; } -// array access with non integer index +// error +// backend=stage1 +// target=native // // tmp.zig:4:11: error: expected type 'usize', found 'bool' // tmp.zig:9:15: error: expected type 'usize', found 'bool' diff --git a/test/compile_errors/stage1/obj/array_concatenation_with_wrong_type.zig b/test/compile_errors/stage1/obj/array_concatenation_with_wrong_type.zig index 91036e5f25..ccddc7efbd 100644 --- a/test/compile_errors/stage1/obj/array_concatenation_with_wrong_type.zig +++ b/test/compile_errors/stage1/obj/array_concatenation_with_wrong_type.zig @@ -4,6 +4,8 @@ const a = derp ++ "foo"; export fn entry() usize { return @sizeOf(@TypeOf(a)); } -// array concatenation with wrong type +// error +// backend=stage1 +// target=native // // tmp.zig:3:11: error: expected array, found 'usize' diff --git a/test/compile_errors/stage1/obj/array_in_c_exported_function.zig b/test/compile_errors/stage1/obj/array_in_c_exported_function.zig index fe03d220b1..5137755474 100644 --- a/test/compile_errors/stage1/obj/array_in_c_exported_function.zig +++ b/test/compile_errors/stage1/obj/array_in_c_exported_function.zig @@ -6,7 +6,9 @@ export fn zig_return_array() [10]u8 { return "1234567890".*; } -// array in c exported function +// error +// backend=stage1 +// target=native // // tmp.zig:1:24: error: parameter of type '[10]u8' not allowed in function with calling convention 'C' // tmp.zig:5:30: error: return type '[10]u8' not allowed in function with calling convention 'C' diff --git a/test/compile_errors/stage1/obj/asm_at_compile_time.zig b/test/compile_errors/stage1/obj/asm_at_compile_time.zig index e08b500c6e..fcfd5e7da6 100644 --- a/test/compile_errors/stage1/obj/asm_at_compile_time.zig +++ b/test/compile_errors/stage1/obj/asm_at_compile_time.zig @@ -10,6 +10,8 @@ fn doSomeAsm() void { ); } -// asm at compile time +// error +// backend=stage1 +// target=native // // tmp.zig:6:5: error: unable to evaluate constant expression diff --git a/test/compile_errors/stage1/obj/assign_inline_fn_to_non-comptime_var.zig b/test/compile_errors/stage1/obj/assign_inline_fn_to_non-comptime_var.zig index aa7bb91d1b..7714bb7282 100644 --- a/test/compile_errors/stage1/obj/assign_inline_fn_to_non-comptime_var.zig +++ b/test/compile_errors/stage1/obj/assign_inline_fn_to_non-comptime_var.zig @@ -4,7 +4,9 @@ export fn entry() void { } fn b() callconv(.Inline) void { } -// assign inline fn to non-comptime var +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: functions marked inline must be stored in const or comptime var // tmp.zig:5:1: note: declared here diff --git a/test/compile_errors/stage1/obj/assign_null_to_non-optional_pointer.zig b/test/compile_errors/stage1/obj/assign_null_to_non-optional_pointer.zig index 9c1aaf5031..110d6c2629 100644 --- a/test/compile_errors/stage1/obj/assign_null_to_non-optional_pointer.zig +++ b/test/compile_errors/stage1/obj/assign_null_to_non-optional_pointer.zig @@ -2,6 +2,8 @@ const a: *u8 = null; export fn entry() usize { return @sizeOf(@TypeOf(a)); } -// assign null to non-optional pointer +// error +// backend=stage1 +// target=native // // tmp.zig:1:16: error: expected type '*u8', found '@Type(.Null)' diff --git a/test/compile_errors/stage1/obj/assign_through_constant_pointer.zig b/test/compile_errors/stage1/obj/assign_through_constant_pointer.zig index 452e3ea617..69ba383843 100644 --- a/test/compile_errors/stage1/obj/assign_through_constant_pointer.zig +++ b/test/compile_errors/stage1/obj/assign_through_constant_pointer.zig @@ -3,6 +3,8 @@ export fn f() void { cstr[0] = 'W'; } -// assign through constant pointer +// error +// backend=stage1 +// target=native // // tmp.zig:3:13: error: cannot assign to constant diff --git a/test/compile_errors/stage1/obj/assign_through_constant_slice.zig b/test/compile_errors/stage1/obj/assign_through_constant_slice.zig index e36991897b..55d2e7e7c7 100644 --- a/test/compile_errors/stage1/obj/assign_through_constant_slice.zig +++ b/test/compile_errors/stage1/obj/assign_through_constant_slice.zig @@ -3,6 +3,8 @@ export fn f() void { cstr[0] = 'W'; } -// assign through constant slice +// error +// backend=stage1 +// target=native // // tmp.zig:3:13: error: cannot assign to constant diff --git a/test/compile_errors/stage1/obj/assign_to_constant_field.zig b/test/compile_errors/stage1/obj/assign_to_constant_field.zig index f371655fb5..610818118a 100644 --- a/test/compile_errors/stage1/obj/assign_to_constant_field.zig +++ b/test/compile_errors/stage1/obj/assign_to_constant_field.zig @@ -6,6 +6,8 @@ export fn derp() void { f.field = 0; } -// assign to constant field +// error +// backend=stage1 +// target=native // // tmp.zig:6:15: error: cannot assign to constant diff --git a/test/compile_errors/stage1/obj/assign_to_constant_variable.zig b/test/compile_errors/stage1/obj/assign_to_constant_variable.zig index 1e8dd6c06f..531f669c1a 100644 --- a/test/compile_errors/stage1/obj/assign_to_constant_variable.zig +++ b/test/compile_errors/stage1/obj/assign_to_constant_variable.zig @@ -3,6 +3,8 @@ export fn f() void { a = 4; } -// assign to constant variable +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: cannot assign to constant diff --git a/test/compile_errors/stage1/obj/assign_to_invalid_dereference.zig b/test/compile_errors/stage1/obj/assign_to_invalid_dereference.zig index 6466f7afc8..7fef5db83c 100644 --- a/test/compile_errors/stage1/obj/assign_to_invalid_dereference.zig +++ b/test/compile_errors/stage1/obj/assign_to_invalid_dereference.zig @@ -2,6 +2,8 @@ export fn entry() void { 'a'.* = 1; } -// assign to invalid dereference +// error +// backend=stage1 +// target=native // // tmp.zig:2:8: error: attempt to dereference non-pointer type 'comptime_int' diff --git a/test/compile_errors/stage1/obj/assign_too_big_number_to_u16.zig b/test/compile_errors/stage1/obj/assign_too_big_number_to_u16.zig index 13b5280588..3138ed5faf 100644 --- a/test/compile_errors/stage1/obj/assign_too_big_number_to_u16.zig +++ b/test/compile_errors/stage1/obj/assign_too_big_number_to_u16.zig @@ -3,6 +3,8 @@ export fn foo() void { _ = vga_mem; } -// assign too big number to u16 +// error +// backend=stage1 +// target=native // // tmp.zig:2:24: error: integer value 753664 cannot be coerced to type 'u16' diff --git a/test/compile_errors/stage1/obj/assign_unreachable.zig b/test/compile_errors/stage1/obj/assign_unreachable.zig index 78e2305abc..f87adcd994 100644 --- a/test/compile_errors/stage1/obj/assign_unreachable.zig +++ b/test/compile_errors/stage1/obj/assign_unreachable.zig @@ -2,7 +2,9 @@ export fn f() void { const a = return; } -// assign unreachable +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: unreachable code // tmp.zig:2:15: note: control flow is diverted here diff --git a/test/compile_errors/stage1/obj/assigning_to_struct_or_union_fields_that_are_not_optionals_with_a_function_that_returns_an_optional.zig b/test/compile_errors/stage1/obj/assigning_to_struct_or_union_fields_that_are_not_optionals_with_a_function_that_returns_an_optional.zig index f93650821b..8285991c05 100644 --- a/test/compile_errors/stage1/obj/assigning_to_struct_or_union_fields_that_are_not_optionals_with_a_function_that_returns_an_optional.zig +++ b/test/compile_errors/stage1/obj/assigning_to_struct_or_union_fields_that_are_not_optionals_with_a_function_that_returns_an_optional.zig @@ -14,6 +14,8 @@ export fn entry() void { _ = s; } -// assigning to struct or union fields that are not optionals with a function that returns an optional +// error +// backend=stage1 +// target=native // // tmp.zig:11:27: error: cannot convert optional to payload type. consider using `.?`, `orelse`, or `if`. expected type 'u8', found '?u8' diff --git a/test/compile_errors/stage1/obj/async_function_depends_on_its_own_frame.zig b/test/compile_errors/stage1/obj/async_function_depends_on_its_own_frame.zig index 0d1cd7f77e..4dde5860ba 100644 --- a/test/compile_errors/stage1/obj/async_function_depends_on_its_own_frame.zig +++ b/test/compile_errors/stage1/obj/async_function_depends_on_its_own_frame.zig @@ -6,6 +6,8 @@ fn amain() callconv(.Async) void { _ = x; } -// async function depends on its own frame +// error +// backend=stage1 +// target=native // // tmp.zig:4:1: error: cannot resolve '@Frame(amain)': function not fully analyzed yet diff --git a/test/compile_errors/stage1/obj/async_function_indirectly_depends_on_its_own_frame.zig b/test/compile_errors/stage1/obj/async_function_indirectly_depends_on_its_own_frame.zig index 809409f524..4dac0d4fa3 100644 --- a/test/compile_errors/stage1/obj/async_function_indirectly_depends_on_its_own_frame.zig +++ b/test/compile_errors/stage1/obj/async_function_indirectly_depends_on_its_own_frame.zig @@ -9,7 +9,9 @@ fn other() void { _ = x; } -// async function indirectly depends on its own frame +// error +// backend=stage1 +// target=native // // tmp.zig:4:1: error: unable to determine async function frame of 'amain' // tmp.zig:5:10: note: analysis of function 'other' depends on the frame diff --git a/test/compile_errors/stage1/obj/atomic_orderings_of_atomicStore_Acquire_or_AcqRel.zig b/test/compile_errors/stage1/obj/atomic_orderings_of_atomicStore_Acquire_or_AcqRel.zig index 7d97c2813e..dfc7ff5036 100644 --- a/test/compile_errors/stage1/obj/atomic_orderings_of_atomicStore_Acquire_or_AcqRel.zig +++ b/test/compile_errors/stage1/obj/atomic_orderings_of_atomicStore_Acquire_or_AcqRel.zig @@ -3,6 +3,8 @@ export fn entry() void { @atomicStore(u32, &x, 1, .Acquire); } -// atomic orderings of atomicStore Acquire or AcqRel +// error +// backend=stage1 +// target=native // // tmp.zig:3:30: error: @atomicStore atomic ordering must not be Acquire or AcqRel diff --git a/test/compile_errors/stage1/obj/atomic_orderings_of_cmpxchg-failure_stricter_than_success.zig b/test/compile_errors/stage1/obj/atomic_orderings_of_cmpxchg-failure_stricter_than_success.zig index d6d9ab478b..929950e754 100644 --- a/test/compile_errors/stage1/obj/atomic_orderings_of_cmpxchg-failure_stricter_than_success.zig +++ b/test/compile_errors/stage1/obj/atomic_orderings_of_cmpxchg-failure_stricter_than_success.zig @@ -4,6 +4,8 @@ export fn f() void { while (!@cmpxchgWeak(i32, &x, 1234, 5678, AtomicOrder.Monotonic, AtomicOrder.SeqCst)) {} } -// atomic orderings of cmpxchg - failure stricter than success +// error +// backend=stage1 +// target=native // // tmp.zig:4:81: error: failure atomic ordering must be no stricter than success diff --git a/test/compile_errors/stage1/obj/atomic_orderings_of_cmpxchg-success_Monotonic_or_stricter.zig b/test/compile_errors/stage1/obj/atomic_orderings_of_cmpxchg-success_Monotonic_or_stricter.zig index 770c08f3fe..fe3344e536 100644 --- a/test/compile_errors/stage1/obj/atomic_orderings_of_cmpxchg-success_Monotonic_or_stricter.zig +++ b/test/compile_errors/stage1/obj/atomic_orderings_of_cmpxchg-success_Monotonic_or_stricter.zig @@ -4,6 +4,8 @@ export fn f() void { while (!@cmpxchgWeak(i32, &x, 1234, 5678, AtomicOrder.Unordered, AtomicOrder.Unordered)) {} } -// atomic orderings of cmpxchg - success Monotonic or stricter +// error +// backend=stage1 +// target=native // // tmp.zig:4:58: error: success atomic ordering must be Monotonic or stricter diff --git a/test/compile_errors/stage1/obj/atomic_orderings_of_fence_Acquire_or_stricter.zig b/test/compile_errors/stage1/obj/atomic_orderings_of_fence_Acquire_or_stricter.zig index 34ee200eeb..8a01871a80 100644 --- a/test/compile_errors/stage1/obj/atomic_orderings_of_fence_Acquire_or_stricter.zig +++ b/test/compile_errors/stage1/obj/atomic_orderings_of_fence_Acquire_or_stricter.zig @@ -2,6 +2,8 @@ export fn entry() void { @fence(.Monotonic); } -// atomic orderings of fence Acquire or stricter +// error +// backend=stage1 +// target=native // // tmp.zig:2:12: error: atomic ordering must be Acquire or stricter diff --git a/test/compile_errors/stage1/obj/atomicrmw_with_bool_op_not_.Xchg.zig b/test/compile_errors/stage1/obj/atomicrmw_with_bool_op_not_.Xchg.zig index 03309737cf..0b5b0cd3c1 100644 --- a/test/compile_errors/stage1/obj/atomicrmw_with_bool_op_not_.Xchg.zig +++ b/test/compile_errors/stage1/obj/atomicrmw_with_bool_op_not_.Xchg.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = @atomicRmw(bool, &x, .Add, true, .SeqCst); } -// atomicrmw with bool op not .Xchg +// error +// backend=stage1 +// target=native // // tmp.zig:3:30: error: @atomicRmw with bool only allowed with .Xchg diff --git a/test/compile_errors/stage1/obj/atomicrmw_with_enum_op_not_.Xchg.zig b/test/compile_errors/stage1/obj/atomicrmw_with_enum_op_not_.Xchg.zig index 95e6a7d95d..adbf4ca45e 100644 --- a/test/compile_errors/stage1/obj/atomicrmw_with_enum_op_not_.Xchg.zig +++ b/test/compile_errors/stage1/obj/atomicrmw_with_enum_op_not_.Xchg.zig @@ -9,6 +9,8 @@ export fn entry() void { _ = @atomicRmw(E, &x, .Add, .b, .SeqCst); } -// atomicrmw with enum op not .Xchg +// error +// backend=stage1 +// target=native // // tmp.zig:9:27: error: @atomicRmw with enum only allowed with .Xchg diff --git a/test/compile_errors/stage1/obj/atomicrmw_with_float_op_not_.Xchg_.Add_or_.Sub.zig b/test/compile_errors/stage1/obj/atomicrmw_with_float_op_not_.Xchg_.Add_or_.Sub.zig index a7359dbf32..4f3ebfcef6 100644 --- a/test/compile_errors/stage1/obj/atomicrmw_with_float_op_not_.Xchg_.Add_or_.Sub.zig +++ b/test/compile_errors/stage1/obj/atomicrmw_with_float_op_not_.Xchg_.Add_or_.Sub.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = @atomicRmw(f32, &x, .And, 2, .SeqCst); } -// atomicrmw with float op not .Xchg, .Add or .Sub +// error +// backend=stage1 +// target=native // // tmp.zig:3:29: error: @atomicRmw with float only allowed with .Xchg, .Add and .Sub diff --git a/test/compile_errors/stage1/obj/attempt_to_cast_enum_literal_to_error.zig b/test/compile_errors/stage1/obj/attempt_to_cast_enum_literal_to_error.zig index fd120af3eb..f1c30815fc 100644 --- a/test/compile_errors/stage1/obj/attempt_to_cast_enum_literal_to_error.zig +++ b/test/compile_errors/stage1/obj/attempt_to_cast_enum_literal_to_error.zig @@ -4,6 +4,8 @@ export fn entry() void { } } -// attempt to cast enum literal to error +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: expected type 'error{Hi}', found '@Type(.EnumLiteral)' diff --git a/test/compile_errors/stage1/obj/attempt_to_close_over_comptime_variable_from_outer_scope.zig b/test/compile_errors/stage1/obj/attempt_to_close_over_comptime_variable_from_outer_scope.zig index 5eb5db3dc8..58eb9d19d2 100644 --- a/test/compile_errors/stage1/obj/attempt_to_close_over_comptime_variable_from_outer_scope.zig +++ b/test/compile_errors/stage1/obj/attempt_to_close_over_comptime_variable_from_outer_scope.zig @@ -5,7 +5,9 @@ fn SimpleList(comptime L: usize) type { }; } -// attempt to close over comptime variable from outer scope +// error +// backend=stage1 +// target=native // // tmp.zig:4:19: error: mutable 'T' not accessible from here // tmp.zig:2:9: note: declared mutable here diff --git a/test/compile_errors/stage1/obj/attempt_to_create_17_bit_float_type.zig b/test/compile_errors/stage1/obj/attempt_to_create_17_bit_float_type.zig index bdea578696..ba7393fcb7 100644 --- a/test/compile_errors/stage1/obj/attempt_to_create_17_bit_float_type.zig +++ b/test/compile_errors/stage1/obj/attempt_to_create_17_bit_float_type.zig @@ -3,6 +3,8 @@ comptime { _ = @Type(.{ .Float = .{ .bits = 17 } }); } -// attempt to create 17 bit float type +// error +// backend=stage1 +// target=native // // tmp.zig:3:16: error: 17-bit float unsupported diff --git a/test/compile_errors/stage1/obj/attempt_to_negate_a_non-integer_non-float_or_non-vector_type.zig b/test/compile_errors/stage1/obj/attempt_to_negate_a_non-integer_non-float_or_non-vector_type.zig index 00ee26033d..e9bbf921ab 100644 --- a/test/compile_errors/stage1/obj/attempt_to_negate_a_non-integer_non-float_or_non-vector_type.zig +++ b/test/compile_errors/stage1/obj/attempt_to_negate_a_non-integer_non-float_or_non-vector_type.zig @@ -7,6 +7,8 @@ export fn entry() void { _ = x; } -// attempt to negate a non-integer, non-float or non-vector type +// error +// backend=stage1 +// target=native // // tmp.zig:6:15: error: negation of type 'anyerror!u32' diff --git a/test/compile_errors/stage1/obj/attempt_to_use_0_bit_type_in_extern_fn.zig b/test/compile_errors/stage1/obj/attempt_to_use_0_bit_type_in_extern_fn.zig index d7767e25e9..021cd97f19 100644 --- a/test/compile_errors/stage1/obj/attempt_to_use_0_bit_type_in_extern_fn.zig +++ b/test/compile_errors/stage1/obj/attempt_to_use_0_bit_type_in_extern_fn.zig @@ -9,7 +9,9 @@ export fn entry2() void { bar(&{}); } -// attempt to use 0 bit type in extern fn +// error +// backend=stage1 +// target=native // // tmp.zig:1:23: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'C' // tmp.zig:7:11: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'C' diff --git a/test/compile_errors/stage1/obj/attempted_double_ampersand.zig b/test/compile_errors/stage1/obj/attempted_double_ampersand.zig index cc92bc2fae..c749b172c6 100644 --- a/test/compile_errors/stage1/obj/attempted_double_ampersand.zig +++ b/test/compile_errors/stage1/obj/attempted_double_ampersand.zig @@ -5,6 +5,8 @@ export fn entry(a: bool, b: bool) i32 { return 5678; } -// attempted `&&` +// error +// backend=stage1 +// target=native // // tmp.zig:2:11: error: ambiguous use of '&&'; use 'and' for logical AND, or change whitespace to ' & &' for bitwise AND diff --git a/test/compile_errors/stage1/obj/attempted_double_pipe_on_boolean_values.zig b/test/compile_errors/stage1/obj/attempted_double_pipe_on_boolean_values.zig index 8e67b4950d..b991b1b61b 100644 --- a/test/compile_errors/stage1/obj/attempted_double_pipe_on_boolean_values.zig +++ b/test/compile_errors/stage1/obj/attempted_double_pipe_on_boolean_values.zig @@ -5,7 +5,9 @@ export fn entry(a: bool, b: bool) i32 { return 5678; } -// attempted `||` on boolean values +// error +// backend=stage1 +// target=native // // tmp.zig:2:9: error: expected error set type, found 'bool' // tmp.zig:2:11: note: `||` merges error sets; `or` performs boolean OR diff --git a/test/compile_errors/stage1/obj/attempted_implicit_cast_from_T_to_slice_const_T.zig b/test/compile_errors/stage1/obj/attempted_implicit_cast_from_T_to_slice_const_T.zig index 4776104928..c3b0847129 100644 --- a/test/compile_errors/stage1/obj/attempted_implicit_cast_from_T_to_slice_const_T.zig +++ b/test/compile_errors/stage1/obj/attempted_implicit_cast_from_T_to_slice_const_T.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = x; } -// attempted implicit cast from T to [*]const T +// error +// backend=stage1 +// target=native // // tmp.zig:2:30: error: expected type '[*]const bool', found 'bool' diff --git a/test/compile_errors/stage1/obj/attempted_implicit_cast_from_const_T_to_array_len_1_T.zig b/test/compile_errors/stage1/obj/attempted_implicit_cast_from_const_T_to_array_len_1_T.zig index d389c572ca..760866dd65 100644 --- a/test/compile_errors/stage1/obj/attempted_implicit_cast_from_const_T_to_array_len_1_T.zig +++ b/test/compile_errors/stage1/obj/attempted_implicit_cast_from_const_T_to_array_len_1_T.zig @@ -6,7 +6,9 @@ export fn entry(byte: u8) void { _ = byte; } -// attempted implicit cast from *const T to *[1]T +// error +// backend=stage1 +// target=native // // tmp.zig:4:22: error: expected type '*[1]i32', found '*const i32' // tmp.zig:4:22: note: cast discards const qualifier diff --git a/test/compile_errors/stage1/obj/attempted_implicit_cast_from_const_T_to_sliceT.zig b/test/compile_errors/stage1/obj/attempted_implicit_cast_from_const_T_to_sliceT.zig index 70d1cbece2..3ff9937983 100644 --- a/test/compile_errors/stage1/obj/attempted_implicit_cast_from_const_T_to_sliceT.zig +++ b/test/compile_errors/stage1/obj/attempted_implicit_cast_from_const_T_to_sliceT.zig @@ -4,6 +4,8 @@ export fn entry() void { _ = x; } -// attempted implicit cast from *const T to []T +// error +// backend=stage1 +// target=native // // tmp.zig:3:23: error: expected type '[]u32', found '*const u32' diff --git a/test/compile_errors/stage1/obj/bad_alignCast_at_comptime.zig b/test/compile_errors/stage1/obj/bad_alignCast_at_comptime.zig index 7396dfc4dd..f1ed25e191 100644 --- a/test/compile_errors/stage1/obj/bad_alignCast_at_comptime.zig +++ b/test/compile_errors/stage1/obj/bad_alignCast_at_comptime.zig @@ -4,6 +4,8 @@ comptime { _ = aligned; } -// bad @alignCast at comptime +// error +// backend=stage1 +// target=native // // tmp.zig:3:35: error: pointer address 0x1 is not aligned to 4 bytes diff --git a/test/compile_errors/stage1/obj/bad_alignment_in_asynccall.zig b/test/compile_errors/stage1/obj/bad_alignment_in_asynccall.zig new file mode 100644 index 0000000000..3999140009 --- /dev/null +++ b/test/compile_errors/stage1/obj/bad_alignment_in_asynccall.zig @@ -0,0 +1,12 @@ +export fn entry() void { + var ptr: fn () callconv(.Async) void = func; + var bytes: [64]u8 = undefined; + _ = @asyncCall(&bytes, {}, ptr, .{}); +} +fn func() callconv(.Async) void {} + +// error +// backend=stage1 +// target=aarch64-linux-none +// +// tmp.zig:4:21: error: expected type '[]align(8) u8', found '*[64]u8' diff --git a/test/compile_errors/stage1/obj/bad_alignment_in_implicit_cast_from_array_pointer_to_slice.zig b/test/compile_errors/stage1/obj/bad_alignment_in_implicit_cast_from_array_pointer_to_slice.zig index ecfc5523d0..12064bd9ab 100644 --- a/test/compile_errors/stage1/obj/bad_alignment_in_implicit_cast_from_array_pointer_to_slice.zig +++ b/test/compile_errors/stage1/obj/bad_alignment_in_implicit_cast_from_array_pointer_to_slice.zig @@ -4,6 +4,8 @@ export fn a() void { _ = y; } -// bad alignment in implicit cast from array pointer to slice +// error +// backend=stage1 +// target=native // // tmp.zig:3:30: error: expected type '[]align(16) u8', found '*[10]u8' diff --git a/test/compile_errors/stage1/obj/bad_alignment_type.zig b/test/compile_errors/stage1/obj/bad_alignment_type.zig index 902ffc79d6..a4d8b7d68f 100644 --- a/test/compile_errors/stage1/obj/bad_alignment_type.zig +++ b/test/compile_errors/stage1/obj/bad_alignment_type.zig @@ -7,7 +7,9 @@ export fn entry2() void { _ = x; } -// bad alignment type +// error +// backend=stage1 +// target=native // // tmp.zig:2:20: error: expected type 'u29', found 'bool' // tmp.zig:6:19: error: fractional component prevents float value 12.340000 from being casted to type 'u29' diff --git a/test/compile_errors/stage1/obj/bad_identifier_in_function_with_struct_defined_inside_function_which_references_local_const.zig b/test/compile_errors/stage1/obj/bad_identifier_in_function_with_struct_defined_inside_function_which_references_local_const.zig index f32301f9ff..7e44ad5057 100644 --- a/test/compile_errors/stage1/obj/bad_identifier_in_function_with_struct_defined_inside_function_which_references_local_const.zig +++ b/test/compile_errors/stage1/obj/bad_identifier_in_function_with_struct_defined_inside_function_which_references_local_const.zig @@ -10,6 +10,8 @@ export fn entry() void { _ = Block; } -// bad identifier in function with struct defined inside function which references local const +// error +// backend=stage1 +// target=native // // tmp.zig:8:5: error: use of undeclared identifier 'bogus' diff --git a/test/compile_errors/stage1/obj/bad_import.zig b/test/compile_errors/stage1/obj/bad_import.zig index f6e93559b2..1a7ab5f00b 100644 --- a/test/compile_errors/stage1/obj/bad_import.zig +++ b/test/compile_errors/stage1/obj/bad_import.zig @@ -1,5 +1,7 @@ const bogus = @import("bogus-does-not-exist.zig",); -// bad import +// error +// backend=stage1 +// target=native // // tmp.zig:1:23: error: unable to load '${DIR}bogus-does-not-exist.zig': FileNotFound diff --git a/test/compile_errors/stage1/obj/bad_usage_of_call.zig b/test/compile_errors/stage1/obj/bad_usage_of_call.zig index 928c39b5a8..c77ccf1a52 100644 --- a/test/compile_errors/stage1/obj/bad_usage_of_call.zig +++ b/test/compile_errors/stage1/obj/bad_usage_of_call.zig @@ -19,7 +19,9 @@ fn bar() callconv(.Inline) void {} fn baz1() void {} fn baz2() void {} -// bad usage of @call +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected tuple or struct, found 'void' // tmp.zig:5:14: error: unable to perform 'never_inline' call at compile-time diff --git a/test/compile_errors/stage1/obj/bin_and_assign_on_undefined_value.zig b/test/compile_errors/stage1/obj/bin_and_assign_on_undefined_value.zig index d9dbdea741..1076f9abdb 100644 --- a/test/compile_errors/stage1/obj/bin_and_assign_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/bin_and_assign_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { a &= a; } -// bin and assign on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/bin_and_on_undefined_value.zig b/test/compile_errors/stage1/obj/bin_and_on_undefined_value.zig index 6775cd56ea..a53d9a10ac 100644 --- a/test/compile_errors/stage1/obj/bin_and_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/bin_and_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = a & a; } -// bin and on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/bin_not_on_undefined_value.zig b/test/compile_errors/stage1/obj/bin_not_on_undefined_value.zig index 0e543c4f00..7e0f554f0b 100644 --- a/test/compile_errors/stage1/obj/bin_not_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/bin_not_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = ~a; } -// bin not on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:10: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/bin_or_assign_on_undefined_value.zig b/test/compile_errors/stage1/obj/bin_or_assign_on_undefined_value.zig index bfbeb7ce3e..cc61fc03e1 100644 --- a/test/compile_errors/stage1/obj/bin_or_assign_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/bin_or_assign_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { a |= a; } -// bin or assign on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/bin_or_on_undefined_value.zig b/test/compile_errors/stage1/obj/bin_or_on_undefined_value.zig index 7a62ace9dd..7ac30bcb4e 100644 --- a/test/compile_errors/stage1/obj/bin_or_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/bin_or_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = a | a; } -// bin or on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/bin_xor_assign_on_undefined_value.zig b/test/compile_errors/stage1/obj/bin_xor_assign_on_undefined_value.zig index bea5e1e089..37e3eae321 100644 --- a/test/compile_errors/stage1/obj/bin_xor_assign_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/bin_xor_assign_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { a ^= a; } -// bin xor assign on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/bin_xor_on_undefined_value.zig b/test/compile_errors/stage1/obj/bin_xor_on_undefined_value.zig index f6ddb24521..f1656b6013 100644 --- a/test/compile_errors/stage1/obj/bin_xor_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/bin_xor_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = a ^ a; } -// bin xor on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/binary_not_on_number_literal.zig b/test/compile_errors/stage1/obj/binary_not_on_number_literal.zig index 12f5953f16..34ddf9adfa 100644 --- a/test/compile_errors/stage1/obj/binary_not_on_number_literal.zig +++ b/test/compile_errors/stage1/obj/binary_not_on_number_literal.zig @@ -4,6 +4,8 @@ var block_aligned_stuff: usize = (4 + TINY_QUANTUM_SIZE) & ~(TINY_QUANTUM_SIZE - export fn entry() usize { return @sizeOf(@TypeOf(block_aligned_stuff)); } -// binary not on number literal +// error +// backend=stage1 +// target=native // // tmp.zig:3:60: error: unable to perform binary not operation on type 'comptime_int' diff --git a/test/compile_errors/stage1/obj/bitCast_same_size_but_bit_count_mismatch.zig b/test/compile_errors/stage1/obj/bitCast_same_size_but_bit_count_mismatch.zig index e4945a1194..9150dc3285 100644 --- a/test/compile_errors/stage1/obj/bitCast_same_size_but_bit_count_mismatch.zig +++ b/test/compile_errors/stage1/obj/bitCast_same_size_but_bit_count_mismatch.zig @@ -3,6 +3,8 @@ export fn entry(byte: u8) void { _ = oops; } -// @bitCast same size but bit count mismatch +// error +// backend=stage1 +// target=native // // tmp.zig:2:25: error: destination type 'u7' has 7 bits but source type 'u8' has 8 bits diff --git a/test/compile_errors/stage1/obj/bitCast_to_enum_type.zig b/test/compile_errors/stage1/obj/bitCast_to_enum_type.zig index dbb73eba18..4d63ab9e01 100644 --- a/test/compile_errors/stage1/obj/bitCast_to_enum_type.zig +++ b/test/compile_errors/stage1/obj/bitCast_to_enum_type.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = y; } -// bitCast to enum type +// error +// backend=stage1 +// target=native // // tmp.zig:2:24: error: cannot cast a value of type 'y' diff --git a/test/compile_errors/stage1/obj/bitCast_with_different_sizes_inside_an_expression.zig b/test/compile_errors/stage1/obj/bitCast_with_different_sizes_inside_an_expression.zig index bb5c0c5936..64caef7cd0 100644 --- a/test/compile_errors/stage1/obj/bitCast_with_different_sizes_inside_an_expression.zig +++ b/test/compile_errors/stage1/obj/bitCast_with_different_sizes_inside_an_expression.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = foo; } -// @bitCast with different sizes inside an expression +// error +// backend=stage1 +// target=native // // tmp.zig:2:25: error: destination type 'u8' has size 1 but source type 'f32' has size 4 diff --git a/test/compile_errors/stage1/obj/bit_shifting_only_works_on_integer_types.zig b/test/compile_errors/stage1/obj/bit_shifting_only_works_on_integer_types.zig index 98fa3128aa..7d1c5873a1 100644 --- a/test/compile_errors/stage1/obj/bit_shifting_only_works_on_integer_types.zig +++ b/test/compile_errors/stage1/obj/bit_shifting_only_works_on_integer_types.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = x; } -// bit shifting only works on integer types +// error +// backend=stage1 +// target=native // // tmp.zig:2:16: error: bit shifting operation expected integer type, found '*const u8' diff --git a/test/compile_errors/stage1/obj/bogus_compile_var.zig b/test/compile_errors/stage1/obj/bogus_compile_var.zig index 05777b9ecd..845d943c7d 100644 --- a/test/compile_errors/stage1/obj/bogus_compile_var.zig +++ b/test/compile_errors/stage1/obj/bogus_compile_var.zig @@ -1,6 +1,8 @@ const x = @import("builtin").bogus; export fn entry() usize { return @sizeOf(@TypeOf(x)); } -// bogus compile var +// error +// backend=stage1 +// target=native // // tmp.zig:1:29: error: container 'builtin' has no member called 'bogus' diff --git a/test/compile_errors/stage1/obj/bogus_method_call_on_slice.zig b/test/compile_errors/stage1/obj/bogus_method_call_on_slice.zig index 8d34a09817..3ede578b34 100644 --- a/test/compile_errors/stage1/obj/bogus_method_call_on_slice.zig +++ b/test/compile_errors/stage1/obj/bogus_method_call_on_slice.zig @@ -4,6 +4,8 @@ fn f(m: []const u8) void { } export fn entry() usize { return @sizeOf(@TypeOf(f)); } -// bogus method call on slice +// error +// backend=stage1 +// target=native // // tmp.zig:3:6: error: no member named 'copy' in '[]const u8' diff --git a/test/compile_errors/stage1/obj/bool_not_on_undefined_value.zig b/test/compile_errors/stage1/obj/bool_not_on_undefined_value.zig index 71ea7d5e96..5c99a9739b 100644 --- a/test/compile_errors/stage1/obj/bool_not_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/bool_not_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = !a; } -// bool not on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:10: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/branch_on_undefined_value.zig b/test/compile_errors/stage1/obj/branch_on_undefined_value.zig index d02ac22a2a..f4b922a332 100644 --- a/test/compile_errors/stage1/obj/branch_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/branch_on_undefined_value.zig @@ -2,6 +2,8 @@ const x = if (undefined) true else false; export fn entry() usize { return @sizeOf(@TypeOf(x)); } -// branch on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:1:15: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/cImport_with_bogus_include.zig b/test/compile_errors/stage1/obj/cImport_with_bogus_include.zig index 89627b354f..141f21cb9a 100644 --- a/test/compile_errors/stage1/obj/cImport_with_bogus_include.zig +++ b/test/compile_errors/stage1/obj/cImport_with_bogus_include.zig @@ -1,7 +1,9 @@ const c = @cImport(@cInclude("bogus.h")); export fn entry() usize { return @sizeOf(@TypeOf(c.bogo)); } -// @cImport with bogus include +// error +// backend=stage1 +// target=native // // tmp.zig:1:11: error: C import failed // .h:1:10: note: 'bogus.h' file not found diff --git a/test/compile_errors/stage1/obj/call_assigned_to_constant.zig b/test/compile_errors/stage1/obj/call_assigned_to_constant.zig index fb2febadb2..ca4e8b67cd 100644 --- a/test/compile_errors/stage1/obj/call_assigned_to_constant.zig +++ b/test/compile_errors/stage1/obj/call_assigned_to_constant.zig @@ -16,7 +16,9 @@ export fn entry1() void { baz = bar(42); } -// call assigned to constant +// error +// backend=stage1 +// target=native // // tmp.zig:12:14: error: cannot assign to constant // tmp.zig:16:14: error: cannot assign to constant diff --git a/test/compile_errors/stage1/obj/call_with_new_stack_on_unsupported_target.zig b/test/compile_errors/stage1/obj/call_with_new_stack_on_unsupported_target.zig new file mode 100644 index 0000000000..7cb504a3f9 --- /dev/null +++ b/test/compile_errors/stage1/obj/call_with_new_stack_on_unsupported_target.zig @@ -0,0 +1,11 @@ +var buf: [10]u8 align(16) = undefined; +export fn entry() void { + @call(.{ .stack = &buf }, foo, .{}); +} +fn foo() void {} + +// error +// backend=stage1 +// target=wasm32-wasi-none +// +// tmp.zig:3:5: error: target arch 'wasm32' does not support calling with a new stack diff --git a/test/compile_errors/stage1/obj/callconv_apcs_aapcs_aapcsvfp_on_unsupported_platform.zig b/test/compile_errors/stage1/obj/callconv_apcs_aapcs_aapcsvfp_on_unsupported_platform.zig new file mode 100644 index 0000000000..fa06287803 --- /dev/null +++ b/test/compile_errors/stage1/obj/callconv_apcs_aapcs_aapcsvfp_on_unsupported_platform.zig @@ -0,0 +1,11 @@ +export fn entry1() callconv(.APCS) void {} +export fn entry2() callconv(.AAPCS) void {} +export fn entry3() callconv(.AAPCSVFP) void {} + +// error +// backend=stage1 +// target=x86_64-linux-none +// +// tmp.zig:1:29: error: callconv 'APCS' is only available on ARM, not x86_64 +// tmp.zig:2:29: error: callconv 'AAPCS' is only available on ARM, not x86_64 +// tmp.zig:3:29: error: callconv 'AAPCSVFP' is only available on ARM, not x86_64 diff --git a/test/compile_errors/stage1/obj/callconv_interrupt_on_unsupported_platform.zig b/test/compile_errors/stage1/obj/callconv_interrupt_on_unsupported_platform.zig new file mode 100644 index 0000000000..8304fb90c1 --- /dev/null +++ b/test/compile_errors/stage1/obj/callconv_interrupt_on_unsupported_platform.zig @@ -0,0 +1,7 @@ +export fn entry() callconv(.Interrupt) void {} + +// error +// backend=stage1 +// target=aarch64-linux-none +// +// tmp.zig:1:28: error: callconv 'Interrupt' is only available on x86, x86_64, AVR, and MSP430, not aarch64 diff --git a/test/compile_errors/stage1/obj/callconv_signal_on_unsupported_platform.zig b/test/compile_errors/stage1/obj/callconv_signal_on_unsupported_platform.zig new file mode 100644 index 0000000000..4b19b188fd --- /dev/null +++ b/test/compile_errors/stage1/obj/callconv_signal_on_unsupported_platform.zig @@ -0,0 +1,7 @@ +export fn entry() callconv(.Signal) void {} + +// error +// backend=stage1 +// target=x86_64-linux-none +// +// tmp.zig:1:28: error: callconv 'Signal' is only available on AVR, not x86_64 diff --git a/test/compile_errors/stage1/obj/callconv_stdcall_fastcall_thiscall_on_unsupported_platform-0.zig b/test/compile_errors/stage1/obj/callconv_stdcall_fastcall_thiscall_on_unsupported_platform-0.zig new file mode 100644 index 0000000000..f4994107cd --- /dev/null +++ b/test/compile_errors/stage1/obj/callconv_stdcall_fastcall_thiscall_on_unsupported_platform-0.zig @@ -0,0 +1,23 @@ +const F1 = fn () callconv(.Stdcall) void; +const F2 = fn () callconv(.Fastcall) void; +const F3 = fn () callconv(.Thiscall) void; +export fn entry1() void { + var a: F1 = undefined; + _ = a; +} +export fn entry2() void { + var a: F2 = undefined; + _ = a; +} +export fn entry3() void { + var a: F3 = undefined; + _ = a; +} + +// error +// backend=stage1 +// target=x86_64-linux-none +// +// tmp.zig:1:27: error: callconv 'Stdcall' is only available on x86, not x86_64 +// tmp.zig:2:27: error: callconv 'Fastcall' is only available on x86, not x86_64 +// tmp.zig:3:27: error: callconv 'Thiscall' is only available on x86, not x86_64 diff --git a/test/compile_errors/stage1/obj/callconv_stdcall_fastcall_thiscall_on_unsupported_platform-1.zig b/test/compile_errors/stage1/obj/callconv_stdcall_fastcall_thiscall_on_unsupported_platform-1.zig new file mode 100644 index 0000000000..aa23f9ae51 --- /dev/null +++ b/test/compile_errors/stage1/obj/callconv_stdcall_fastcall_thiscall_on_unsupported_platform-1.zig @@ -0,0 +1,11 @@ +export fn entry1() callconv(.Stdcall) void {} +export fn entry2() callconv(.Fastcall) void {} +export fn entry3() callconv(.Thiscall) void {} + +// error +// backend=stage1 +// target=x86_64-linux-none +// +// tmp.zig:1:29: error: callconv 'Stdcall' is only available on x86, not x86_64 +// tmp.zig:2:29: error: callconv 'Fastcall' is only available on x86, not x86_64 +// tmp.zig:3:29: error: callconv 'Thiscall' is only available on x86, not x86_64 diff --git a/test/compile_errors/stage1/obj/callconv_vectorcall_on_unsupported_platform.zig b/test/compile_errors/stage1/obj/callconv_vectorcall_on_unsupported_platform.zig new file mode 100644 index 0000000000..e60e6ab42c --- /dev/null +++ b/test/compile_errors/stage1/obj/callconv_vectorcall_on_unsupported_platform.zig @@ -0,0 +1,7 @@ +export fn entry() callconv(.Vectorcall) void {} + +// error +// backend=stage1 +// target=x86_64-linux-none +// +// tmp.zig:1:28: error: callconv 'Vectorcall' is only available on x86 and AArch64, not x86_64 diff --git a/test/compile_errors/stage1/obj/calling_a_generic_function_only_known_at_runtime.zig b/test/compile_errors/stage1/obj/calling_a_generic_function_only_known_at_runtime.zig index c31b18bb6f..3081f0f1e1 100644 --- a/test/compile_errors/stage1/obj/calling_a_generic_function_only_known_at_runtime.zig +++ b/test/compile_errors/stage1/obj/calling_a_generic_function_only_known_at_runtime.zig @@ -7,6 +7,8 @@ pub fn main() !void { foos[0](true); } -// calling a generic function only known at runtime +// error +// backend=stage1 +// target=native // // tmp.zig:7:9: error: calling a generic function requires compile-time known function value diff --git a/test/compile_errors/stage1/obj/calling_function_with_naked_calling_convention.zig b/test/compile_errors/stage1/obj/calling_function_with_naked_calling_convention.zig index c99e5b7831..401f84e687 100644 --- a/test/compile_errors/stage1/obj/calling_function_with_naked_calling_convention.zig +++ b/test/compile_errors/stage1/obj/calling_function_with_naked_calling_convention.zig @@ -3,7 +3,9 @@ export fn entry() void { } fn foo() callconv(.Naked) void { } -// calling function with naked calling convention +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: unable to call function with naked calling convention // tmp.zig:4:1: note: declared here diff --git a/test/compile_errors/stage1/obj/calling_var_args_extern_function_passing_array_instead_of_pointer.zig b/test/compile_errors/stage1/obj/calling_var_args_extern_function_passing_array_instead_of_pointer.zig index e3cc4425db..a71ab051f2 100644 --- a/test/compile_errors/stage1/obj/calling_var_args_extern_function_passing_array_instead_of_pointer.zig +++ b/test/compile_errors/stage1/obj/calling_var_args_extern_function_passing_array_instead_of_pointer.zig @@ -3,6 +3,8 @@ export fn entry() void { } pub extern fn foo(format: *const u8, ...) void; -// calling var args extern function, passing array instead of pointer +// error +// backend=stage1 +// target=native // // tmp.zig:2:16: error: expected type '*const u8', found '[5:0]u8' diff --git a/test/compile_errors/stage1/obj/cannot_break_out_of_defer_expression.zig b/test/compile_errors/stage1/obj/cannot_break_out_of_defer_expression.zig index 002a7717d3..3c7ae4fa2f 100644 --- a/test/compile_errors/stage1/obj/cannot_break_out_of_defer_expression.zig +++ b/test/compile_errors/stage1/obj/cannot_break_out_of_defer_expression.zig @@ -6,6 +6,8 @@ export fn foo() void { } } -// cannot break out of defer expression +// error +// backend=stage1 +// target=native // // tmp.zig:4:13: error: cannot break out of defer expression diff --git a/test/compile_errors/stage1/obj/cannot_continue_out_of_defer_expression.zig b/test/compile_errors/stage1/obj/cannot_continue_out_of_defer_expression.zig index 8adb7eafd6..56b8ced05b 100644 --- a/test/compile_errors/stage1/obj/cannot_continue_out_of_defer_expression.zig +++ b/test/compile_errors/stage1/obj/cannot_continue_out_of_defer_expression.zig @@ -6,6 +6,8 @@ export fn foo() void { } } -// cannot continue out of defer expression +// error +// backend=stage1 +// target=native // // tmp.zig:4:13: error: cannot continue out of defer expression diff --git a/test/compile_errors/stage1/obj/capture_group_on_switch_prong_with_incompatible_payload_types.zig b/test/compile_errors/stage1/obj/capture_group_on_switch_prong_with_incompatible_payload_types.zig index 8a4c94f503..ce2068d6c7 100644 --- a/test/compile_errors/stage1/obj/capture_group_on_switch_prong_with_incompatible_payload_types.zig +++ b/test/compile_errors/stage1/obj/capture_group_on_switch_prong_with_incompatible_payload_types.zig @@ -12,7 +12,9 @@ comptime { } } -// capture group on switch prong with incompatible payload types +// error +// backend=stage1 +// target=native // // tmp.zig:8:20: error: capture group with incompatible types // tmp.zig:8:9: note: type 'usize' here diff --git a/test/compile_errors/stage1/obj/cast_enum_literal_to_enum_but_it_doesnt_match.zig b/test/compile_errors/stage1/obj/cast_enum_literal_to_enum_but_it_doesnt_match.zig index 10717ff392..ba53646efc 100644 --- a/test/compile_errors/stage1/obj/cast_enum_literal_to_enum_but_it_doesnt_match.zig +++ b/test/compile_errors/stage1/obj/cast_enum_literal_to_enum_but_it_doesnt_match.zig @@ -7,7 +7,9 @@ export fn entry() void { _ = x; } -// cast enum literal to enum but it doesn't match +// error +// backend=stage1 +// target=native // // tmp.zig:6:20: error: enum 'Foo' has no field named 'c' // tmp.zig:1:13: note: 'Foo' declared here diff --git a/test/compile_errors/stage1/obj/cast_error_union_of_global_error_set_to_error_union_of_smaller_error_set.zig b/test/compile_errors/stage1/obj/cast_error_union_of_global_error_set_to_error_union_of_smaller_error_set.zig index fbb68c30c8..08962afc85 100644 --- a/test/compile_errors/stage1/obj/cast_error_union_of_global_error_set_to_error_union_of_smaller_error_set.zig +++ b/test/compile_errors/stage1/obj/cast_error_union_of_global_error_set_to_error_union_of_smaller_error_set.zig @@ -7,7 +7,9 @@ fn foo() anyerror!i32 { return error.B; } -// cast error union of global error set to error union of smaller error set +// error +// backend=stage1 +// target=native // // tmp.zig:3:35: error: expected type 'SmallErrorSet!i32', found 'anyerror!i32' // tmp.zig:3:35: note: error set 'anyerror' cannot cast into error set 'SmallErrorSet' diff --git a/test/compile_errors/stage1/obj/cast_global_error_set_to_error_set.zig b/test/compile_errors/stage1/obj/cast_global_error_set_to_error_set.zig index f37ffce229..be9487cc5a 100644 --- a/test/compile_errors/stage1/obj/cast_global_error_set_to_error_set.zig +++ b/test/compile_errors/stage1/obj/cast_global_error_set_to_error_set.zig @@ -7,7 +7,9 @@ fn foo() anyerror { return error.B; } -// cast global error set to error set +// error +// backend=stage1 +// target=native // // tmp.zig:3:31: error: expected type 'SmallErrorSet', found 'anyerror' // tmp.zig:3:31: note: cannot cast global error set into smaller set diff --git a/test/compile_errors/stage1/obj/cast_negative_integer_literal_to_usize.zig b/test/compile_errors/stage1/obj/cast_negative_integer_literal_to_usize.zig index 37e42c062c..763e0c8a23 100644 --- a/test/compile_errors/stage1/obj/cast_negative_integer_literal_to_usize.zig +++ b/test/compile_errors/stage1/obj/cast_negative_integer_literal_to_usize.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = x; } -// cast negative integer literal to usize +// error +// backend=stage1 +// target=native // // tmp.zig:2:26: error: cannot cast negative value -10 to unsigned integer type 'usize' diff --git a/test/compile_errors/stage1/obj/cast_negative_value_to_unsigned_integer.zig b/test/compile_errors/stage1/obj/cast_negative_value_to_unsigned_integer.zig index e740d406f6..d2e3187140 100644 --- a/test/compile_errors/stage1/obj/cast_negative_value_to_unsigned_integer.zig +++ b/test/compile_errors/stage1/obj/cast_negative_value_to_unsigned_integer.zig @@ -9,7 +9,9 @@ export fn entry1() void { _ = unsigned; } -// cast negative value to unsigned integer +// error +// backend=stage1 +// target=native // // tmp.zig:3:22: error: attempt to cast negative value to unsigned integer // tmp.zig:8:27: error: cannot cast negative value -1 to unsigned integer type 'u32' diff --git a/test/compile_errors/stage1/obj/cast_unreachable.zig b/test/compile_errors/stage1/obj/cast_unreachable.zig index 94fa121770..b043108737 100644 --- a/test/compile_errors/stage1/obj/cast_unreachable.zig +++ b/test/compile_errors/stage1/obj/cast_unreachable.zig @@ -3,7 +3,9 @@ fn f() i32 { } export fn entry() void { _ = f(); } -// cast unreachable +// error +// backend=stage1 +// target=native // // tmp.zig:2:12: error: unreachable code // tmp.zig:2:21: note: control flow is diverted here diff --git a/test/compile_errors/stage1/obj/casting_bit_offset_pointer_to_regular_pointer.zig b/test/compile_errors/stage1/obj/casting_bit_offset_pointer_to_regular_pointer.zig index 9b6c5ea0e6..f109cdf295 100644 --- a/test/compile_errors/stage1/obj/casting_bit_offset_pointer_to_regular_pointer.zig +++ b/test/compile_errors/stage1/obj/casting_bit_offset_pointer_to_regular_pointer.zig @@ -14,6 +14,8 @@ fn bar(x: *const u3) u3 { export fn entry() usize { return @sizeOf(@TypeOf(foo)); } -// casting bit offset pointer to regular pointer +// error +// backend=stage1 +// target=native // // tmp.zig:8:26: error: expected type '*const u3', found '*align(:3:1) const u3' diff --git a/test/compile_errors/stage1/obj/catch_on_undefined_value.zig b/test/compile_errors/stage1/obj/catch_on_undefined_value.zig index 9d22d07219..53a5f1c2a9 100644 --- a/test/compile_errors/stage1/obj/catch_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/catch_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = a catch false; } -// catch on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:11: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/chained_comparison_operators.zig b/test/compile_errors/stage1/obj/chained_comparison_operators.zig index 89e1ea1e75..1e4ed8d82e 100644 --- a/test/compile_errors/stage1/obj/chained_comparison_operators.zig +++ b/test/compile_errors/stage1/obj/chained_comparison_operators.zig @@ -2,6 +2,8 @@ export fn a(value: u32) bool { return 1 < value < 1000; } -// chained comparison operators +// error +// backend=stage1 +// target=native // // tmp.zig:2:22: error: comparison operators cannot be chained diff --git a/test/compile_errors/stage1/obj/cmpxchg_with_float.zig b/test/compile_errors/stage1/obj/cmpxchg_with_float.zig index 8926ffc36b..11f2dc21c3 100644 --- a/test/compile_errors/stage1/obj/cmpxchg_with_float.zig +++ b/test/compile_errors/stage1/obj/cmpxchg_with_float.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = @cmpxchgWeak(f32, &x, 1, 2, .SeqCst, .SeqCst); } -// cmpxchg with float +// error +// backend=stage1 +// target=native // // tmp.zig:3:22: error: expected bool, integer, enum or pointer type, found 'f32' diff --git a/test/compile_errors/stage1/obj/colliding_invalid_top_level_functions.zig b/test/compile_errors/stage1/obj/colliding_invalid_top_level_functions.zig index f4e5d24c46..344edbaa9f 100644 --- a/test/compile_errors/stage1/obj/colliding_invalid_top_level_functions.zig +++ b/test/compile_errors/stage1/obj/colliding_invalid_top_level_functions.zig @@ -2,7 +2,9 @@ fn func() bogus {} fn func() bogus {} export fn entry() usize { return @sizeOf(@TypeOf(func)); } -// colliding invalid top level functions +// error +// backend=stage1 +// target=native // // tmp.zig:2:1: error: redeclaration of 'func' // tmp.zig:1:1: note: other declaration here diff --git a/test/compile_errors/stage1/obj/compare_optional_to_non-optional_with_invalid_types.zig b/test/compile_errors/stage1/obj/compare_optional_to_non-optional_with_invalid_types.zig index 8713cf4501..32e1fe9b24 100644 --- a/test/compile_errors/stage1/obj/compare_optional_to_non-optional_with_invalid_types.zig +++ b/test/compile_errors/stage1/obj/compare_optional_to_non-optional_with_invalid_types.zig @@ -22,7 +22,9 @@ export fn invalidChildType() void { _ = (x == y); } -// compare optional to non-optional with invalid types +// error +// backend=stage1 +// target=native // // :4:12: error: cannot compare types '?i32' and 'comptime_int' // :4:12: note: optional child type 'i32' must be the same as non-optional type 'comptime_int' diff --git a/test/compile_errors/stage1/obj/comparing_a_non-optional_pointer_against_null.zig b/test/compile_errors/stage1/obj/comparing_a_non-optional_pointer_against_null.zig index 69a5120135..62b5708034 100644 --- a/test/compile_errors/stage1/obj/comparing_a_non-optional_pointer_against_null.zig +++ b/test/compile_errors/stage1/obj/comparing_a_non-optional_pointer_against_null.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = &x == null; } -// comparing a non-optional pointer against null +// error +// backend=stage1 +// target=native // // tmp.zig:3:12: error: comparison of '*i32' with null diff --git a/test/compile_errors/stage1/obj/comparing_against_undefined_produces_undefined_value.zig b/test/compile_errors/stage1/obj/comparing_against_undefined_produces_undefined_value.zig index c329f51ef7..8bad61e6d1 100644 --- a/test/compile_errors/stage1/obj/comparing_against_undefined_produces_undefined_value.zig +++ b/test/compile_errors/stage1/obj/comparing_against_undefined_produces_undefined_value.zig @@ -2,6 +2,8 @@ export fn entry() void { if (2 == undefined) {} } -// comparing against undefined produces undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:2:11: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/comparison_operators_with_undefined_value.zig b/test/compile_errors/stage1/obj/comparison_operators_with_undefined_value.zig index 6021382fd4..818a575fc8 100644 --- a/test/compile_errors/stage1/obj/comparison_operators_with_undefined_value.zig +++ b/test/compile_errors/stage1/obj/comparison_operators_with_undefined_value.zig @@ -35,7 +35,9 @@ comptime { if (a <= a) x += 1; } -// comparison operators with undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:5:11: error: use of undefined value here causes undefined behavior // tmp.zig:11:11: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/comparison_with_error_union_and_error_value.zig b/test/compile_errors/stage1/obj/comparison_with_error_union_and_error_value.zig index 260ccc6f01..16f3b21c3d 100644 --- a/test/compile_errors/stage1/obj/comparison_with_error_union_and_error_value.zig +++ b/test/compile_errors/stage1/obj/comparison_with_error_union_and_error_value.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = number_or_error == error.SomethingAwful; } -// comparison with error union and error value +// error +// backend=stage1 +// target=native // // tmp.zig:3:25: error: operator not allowed for type 'anyerror!i32' diff --git a/test/compile_errors/stage1/obj/compile-time_division_by_zero.zig b/test/compile_errors/stage1/obj/compile-time_division_by_zero.zig index 578dbc7b4a..e16f5f8cf4 100644 --- a/test/compile_errors/stage1/obj/compile-time_division_by_zero.zig +++ b/test/compile_errors/stage1/obj/compile-time_division_by_zero.zig @@ -5,6 +5,8 @@ comptime { _ = c; } -// compile-time division by zero +// error +// backend=stage1 +// target=native // // tmp.zig:4:17: error: division by zero diff --git a/test/compile_errors/stage1/obj/compile-time_remainder_division_by_zero.zig b/test/compile_errors/stage1/obj/compile-time_remainder_division_by_zero.zig index 015d229110..63f0def52c 100644 --- a/test/compile_errors/stage1/obj/compile-time_remainder_division_by_zero.zig +++ b/test/compile_errors/stage1/obj/compile-time_remainder_division_by_zero.zig @@ -5,6 +5,8 @@ comptime { _ = c; } -// compile-time remainder division by zero +// error +// backend=stage1 +// target=native // // tmp.zig:4:17: error: division by zero diff --git a/test/compile_errors/stage1/obj/compileError_shows_traceback_of_references_that_caused_it.zig b/test/compile_errors/stage1/obj/compileError_shows_traceback_of_references_that_caused_it.zig index 4273741ad2..c58e9b7768 100644 --- a/test/compile_errors/stage1/obj/compileError_shows_traceback_of_references_that_caused_it.zig +++ b/test/compile_errors/stage1/obj/compileError_shows_traceback_of_references_that_caused_it.zig @@ -7,6 +7,8 @@ export fn entry() i32 { return bar; } -// @compileError shows traceback of references that caused it +// error +// backend=stage1 +// target=native // // tmp.zig:1:13: error: aoeu diff --git a/test/compile_errors/stage1/obj/compileLog_of_tagged_enum_doesnt_crash_the_compiler.zig b/test/compile_errors/stage1/obj/compileLog_of_tagged_enum_doesnt_crash_the_compiler.zig index 0770b3b6a4..36e1ee1118 100644 --- a/test/compile_errors/stage1/obj/compileLog_of_tagged_enum_doesnt_crash_the_compiler.zig +++ b/test/compile_errors/stage1/obj/compileLog_of_tagged_enum_doesnt_crash_the_compiler.zig @@ -10,6 +10,8 @@ pub fn main () void { comptime testCompileLog(Bar{.X = 123}); } -// compileLog of tagged enum doesn't crash the compiler +// error +// backend=stage1 +// target=native // // tmp.zig:6:5: error: found compile log statement diff --git a/test/compile_errors/stage1/obj/compile_error_in_struct_init_expression.zig b/test/compile_errors/stage1/obj/compile_error_in_struct_init_expression.zig index 6215c9ad76..041d09b002 100644 --- a/test/compile_errors/stage1/obj/compile_error_in_struct_init_expression.zig +++ b/test/compile_errors/stage1/obj/compile_error_in_struct_init_expression.zig @@ -9,6 +9,8 @@ export fn entry() void { _ = x; } -// compile error in struct init expression +// error +// backend=stage1 +// target=native // // tmp.zig:2:14: error: use of undeclared identifier 'crap' diff --git a/test/compile_errors/stage1/obj/compile_error_when_evaluating_return_type_of_inferred_error_set.zig b/test/compile_errors/stage1/obj/compile_error_when_evaluating_return_type_of_inferred_error_set.zig index 44d5b6a389..7b1d11b0a4 100644 --- a/test/compile_errors/stage1/obj/compile_error_when_evaluating_return_type_of_inferred_error_set.zig +++ b/test/compile_errors/stage1/obj/compile_error_when_evaluating_return_type_of_inferred_error_set.zig @@ -7,6 +7,8 @@ export fn entry() void { _ = car; } -// compile error when evaluating return type of inferred error set +// error +// backend=stage1 +// target=native // // tmp.zig:2:11: error: use of undeclared identifier 'SymbolThatDoesNotExist' diff --git a/test/compile_errors/stage1/obj/compile_log.zig b/test/compile_errors/stage1/obj/compile_log.zig index ef1cba4502..7f5d522407 100644 --- a/test/compile_errors/stage1/obj/compile_log.zig +++ b/test/compile_errors/stage1/obj/compile_log.zig @@ -7,7 +7,9 @@ fn bar(a: i32, b: []const u8) void { @compileLog("end",); } -// compile log +// error +// backend=stage1 +// target=native // // tmp.zig:5:5: error: found compile log statement // tmp.zig:6:5: error: found compile log statement diff --git a/test/compile_errors/stage1/obj/compile_log_a_pointer_to_an_opaque_value.zig b/test/compile_errors/stage1/obj/compile_log_a_pointer_to_an_opaque_value.zig index 15b7825a91..d585712b8a 100644 --- a/test/compile_errors/stage1/obj/compile_log_a_pointer_to_an_opaque_value.zig +++ b/test/compile_errors/stage1/obj/compile_log_a_pointer_to_an_opaque_value.zig @@ -2,6 +2,8 @@ export fn entry() void { @compileLog(@ptrCast(*const anyopaque, &entry)); } -// compile log a pointer to an opaque value +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: found compile log statement diff --git a/test/compile_errors/stage1/obj/compile_log_statement_inside_function_which_must_be_comptime_evaluated.zig b/test/compile_errors/stage1/obj/compile_log_statement_inside_function_which_must_be_comptime_evaluated.zig index f848ed7c7c..19b96048cb 100644 --- a/test/compile_errors/stage1/obj/compile_log_statement_inside_function_which_must_be_comptime_evaluated.zig +++ b/test/compile_errors/stage1/obj/compile_log_statement_inside_function_which_must_be_comptime_evaluated.zig @@ -7,6 +7,8 @@ export fn entry() void { _ = @typeName(Foo(i32)); } -// compile log statement inside function which must be comptime evaluated +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: found compile log statement diff --git a/test/compile_errors/stage1/obj/compile_log_statement_warning_deduplication_in_generic_fn.zig b/test/compile_errors/stage1/obj/compile_log_statement_warning_deduplication_in_generic_fn.zig index 05ac76724c..991021932d 100644 --- a/test/compile_errors/stage1/obj/compile_log_statement_warning_deduplication_in_generic_fn.zig +++ b/test/compile_errors/stage1/obj/compile_log_statement_warning_deduplication_in_generic_fn.zig @@ -7,6 +7,8 @@ fn inner(comptime n: usize) void { inline while (i < n) : (i += 1) { @compileLog("!@#$"); } } -// compile log statement warning deduplication in generic fn +// error +// backend=stage1 +// target=native // // tmp.zig:7:39: error: found compile log statement diff --git a/test/compile_errors/stage1/obj/compile_time_division_by_zero.zig b/test/compile_errors/stage1/obj/compile_time_division_by_zero.zig index 17187c47bf..7f7e168f02 100644 --- a/test/compile_errors/stage1/obj/compile_time_division_by_zero.zig +++ b/test/compile_errors/stage1/obj/compile_time_division_by_zero.zig @@ -5,6 +5,8 @@ fn foo(x: u32) u32 { export fn entry() usize { return @sizeOf(@TypeOf(y)); } -// compile time division by zero +// error +// backend=stage1 +// target=native // // tmp.zig:3:14: error: division by zero diff --git a/test/compile_errors/stage1/obj/comptime_cast_enum_to_union_but_field_has_payload.zig b/test/compile_errors/stage1/obj/comptime_cast_enum_to_union_but_field_has_payload.zig index 36a2079a01..c3cf9e76e5 100644 --- a/test/compile_errors/stage1/obj/comptime_cast_enum_to_union_but_field_has_payload.zig +++ b/test/compile_errors/stage1/obj/comptime_cast_enum_to_union_but_field_has_payload.zig @@ -9,7 +9,9 @@ export fn entry() void { _ = x; } -// comptime cast enum to union but field has payload +// error +// backend=stage1 +// target=native // // tmp.zig:8:26: error: cast to union 'Value' must initialize 'i32' field 'A' // tmp.zig:3:5: note: field 'A' declared here diff --git a/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_catch.zig b/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_catch.zig index 18c78c858c..7eefeb80b4 100644 --- a/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_catch.zig +++ b/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_catch.zig @@ -8,7 +8,9 @@ fn bad() !void { return error.Bad; } -// comptime continue inside runtime catch +// error +// backend=stage1 +// target=native // // tmp.zig:4:21: error: comptime control flow inside runtime block // tmp.zig:4:15: note: runtime block created here diff --git a/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_if_bool.zig b/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_if_bool.zig index f6ec1b98b1..9ace5ddceb 100644 --- a/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_if_bool.zig +++ b/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_if_bool.zig @@ -7,7 +7,9 @@ export fn entry() void { } } -// comptime continue inside runtime if bool +// error +// backend=stage1 +// target=native // // tmp.zig:5:22: error: comptime control flow inside runtime block // tmp.zig:5:9: note: runtime block created here diff --git a/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_if_error.zig b/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_if_error.zig index 556a8769a5..554ba3c43e 100644 --- a/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_if_error.zig +++ b/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_if_error.zig @@ -7,7 +7,9 @@ export fn entry() void { } } -// comptime continue inside runtime if error +// error +// backend=stage1 +// target=native // // tmp.zig:5:20: error: comptime control flow inside runtime block // tmp.zig:5:9: note: runtime block created here diff --git a/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_if_optional.zig b/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_if_optional.zig index 4f35398a2b..32c71e5c77 100644 --- a/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_if_optional.zig +++ b/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_if_optional.zig @@ -7,7 +7,9 @@ export fn entry() void { } } -// comptime continue inside runtime if optional +// error +// backend=stage1 +// target=native // // tmp.zig:5:20: error: comptime control flow inside runtime block // tmp.zig:5:9: note: runtime block created here diff --git a/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_switch.zig b/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_switch.zig index 259cbd602e..d145897b41 100644 --- a/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_switch.zig +++ b/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_switch.zig @@ -10,7 +10,9 @@ export fn entry() void { } } -// comptime continue inside runtime switch +// error +// backend=stage1 +// target=native // // tmp.zig:6:19: error: comptime control flow inside runtime block // tmp.zig:5:9: note: runtime block created here diff --git a/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_while_bool.zig b/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_while_bool.zig index 5d86394815..8e57854728 100644 --- a/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_while_bool.zig +++ b/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_while_bool.zig @@ -7,7 +7,9 @@ export fn entry() void { } } -// comptime continue inside runtime while bool +// error +// backend=stage1 +// target=native // // tmp.zig:5:25: error: comptime control flow inside runtime block // tmp.zig:5:9: note: runtime block created here diff --git a/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_while_error.zig b/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_while_error.zig index 0ba49cb3ca..818455c354 100644 --- a/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_while_error.zig +++ b/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_while_error.zig @@ -9,7 +9,9 @@ export fn entry() void { } } -// comptime continue inside runtime while error +// error +// backend=stage1 +// target=native // // tmp.zig:6:13: error: comptime control flow inside runtime block // tmp.zig:5:9: note: runtime block created here diff --git a/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_while_optional.zig b/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_while_optional.zig index b2cfd2f69d..ed22cc2cac 100644 --- a/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_while_optional.zig +++ b/test/compile_errors/stage1/obj/comptime_continue_inside_runtime_while_optional.zig @@ -7,7 +7,9 @@ export fn entry() void { } } -// comptime continue inside runtime while optional +// error +// backend=stage1 +// target=native // // tmp.zig:5:23: error: comptime control flow inside runtime block // tmp.zig:5:9: note: runtime block created here diff --git a/test/compile_errors/stage1/obj/comptime_float_in_asm_input.zig b/test/compile_errors/stage1/obj/comptime_float_in_asm_input.zig index c2333586b4..92ffadc4f7 100644 --- a/test/compile_errors/stage1/obj/comptime_float_in_asm_input.zig +++ b/test/compile_errors/stage1/obj/comptime_float_in_asm_input.zig @@ -2,6 +2,8 @@ export fn foo() void { asm volatile ("" : : [bar]"r"(3.17) : ""); } -// comptime_float in asm input +// error +// backend=stage1 +// target=native // // tmp.zig:2:35: error: expected sized integer or sized float, found comptime_float diff --git a/test/compile_errors/stage1/obj/comptime_implicit_cast_f64_to_f32.zig b/test/compile_errors/stage1/obj/comptime_implicit_cast_f64_to_f32.zig index f98c45a348..af5d49c7cb 100644 --- a/test/compile_errors/stage1/obj/comptime_implicit_cast_f64_to_f32.zig +++ b/test/compile_errors/stage1/obj/comptime_implicit_cast_f64_to_f32.zig @@ -4,6 +4,8 @@ export fn entry() void { _ = y; } -// comptime implicit cast f64 to f32 +// error +// backend=stage1 +// target=native // // tmp.zig:3:20: error: cast of value 16777217.000000 to type 'f32' loses information diff --git a/test/compile_errors/stage1/obj/comptime_int_in_asm_input.zig b/test/compile_errors/stage1/obj/comptime_int_in_asm_input.zig index 5a587e5a77..3e3ccf8c27 100644 --- a/test/compile_errors/stage1/obj/comptime_int_in_asm_input.zig +++ b/test/compile_errors/stage1/obj/comptime_int_in_asm_input.zig @@ -2,6 +2,8 @@ export fn foo() void { asm volatile ("" : : [bar]"r"(3) : ""); } -// comptime_int in asm input +// error +// backend=stage1 +// target=native // // tmp.zig:2:35: error: expected sized integer or sized float, found comptime_int diff --git a/test/compile_errors/stage1/obj/comptime_ptrcast_of_zero-sized_type.zig b/test/compile_errors/stage1/obj/comptime_ptrcast_of_zero-sized_type.zig index 1d3f91fe91..231e735cfa 100644 --- a/test/compile_errors/stage1/obj/comptime_ptrcast_of_zero-sized_type.zig +++ b/test/compile_errors/stage1/obj/comptime_ptrcast_of_zero-sized_type.zig @@ -5,6 +5,8 @@ fn foo() void { } comptime { foo(); } -// comptime ptrcast of zero-sized type +// error +// backend=stage1 +// target=native // // tmp.zig:3:21: error: '*const struct:2:17' and '[*]const u8' do not have the same in-memory representation diff --git a/test/compile_errors/stage1/obj/comptime_slice-sentinel_does_not_match_memory_at_target_index_terminated.zig b/test/compile_errors/stage1/obj/comptime_slice-sentinel_does_not_match_memory_at_target_index_terminated.zig index 622e0cf76b..598d23a305 100644 --- a/test/compile_errors/stage1/obj/comptime_slice-sentinel_does_not_match_memory_at_target_index_terminated.zig +++ b/test/compile_errors/stage1/obj/comptime_slice-sentinel_does_not_match_memory_at_target_index_terminated.zig @@ -54,7 +54,9 @@ export fn foo_slice() void { } } -// comptime slice-sentinel does not match memory at target index (terminated) +// error +// backend=stage1 +// target=native // // :4:29: error: slice-sentinel does not match memory at target index // :12:29: error: slice-sentinel does not match memory at target index diff --git a/test/compile_errors/stage1/obj/comptime_slice-sentinel_does_not_match_memory_at_target_index_unterminated.zig b/test/compile_errors/stage1/obj/comptime_slice-sentinel_does_not_match_memory_at_target_index_unterminated.zig index e9451cf9aa..d6b469aaf1 100644 --- a/test/compile_errors/stage1/obj/comptime_slice-sentinel_does_not_match_memory_at_target_index_unterminated.zig +++ b/test/compile_errors/stage1/obj/comptime_slice-sentinel_does_not_match_memory_at_target_index_unterminated.zig @@ -54,7 +54,9 @@ export fn foo_slice() void { } } -// comptime slice-sentinel does not match memory at target index (unterminated) +// error +// backend=stage1 +// target=native // // :4:29: error: slice-sentinel does not match memory at target index // :12:29: error: slice-sentinel does not match memory at target index diff --git a/test/compile_errors/stage1/obj/comptime_slice-sentinel_does_not_match_target-sentinel.zig b/test/compile_errors/stage1/obj/comptime_slice-sentinel_does_not_match_target-sentinel.zig index 597a493705..b204cfc684 100644 --- a/test/compile_errors/stage1/obj/comptime_slice-sentinel_does_not_match_target-sentinel.zig +++ b/test/compile_errors/stage1/obj/comptime_slice-sentinel_does_not_match_target-sentinel.zig @@ -54,7 +54,9 @@ export fn foo_slice() void { } } -// comptime slice-sentinel does not match target-sentinel +// error +// backend=stage1 +// target=native // // :4:29: error: slice-sentinel does not match target-sentinel // :12:29: error: slice-sentinel does not match target-sentinel diff --git a/test/compile_errors/stage1/obj/comptime_slice-sentinel_is_out_of_bounds_terminated.zig b/test/compile_errors/stage1/obj/comptime_slice-sentinel_is_out_of_bounds_terminated.zig index d5fc64ea84..82c19126c0 100644 --- a/test/compile_errors/stage1/obj/comptime_slice-sentinel_is_out_of_bounds_terminated.zig +++ b/test/compile_errors/stage1/obj/comptime_slice-sentinel_is_out_of_bounds_terminated.zig @@ -54,7 +54,9 @@ export fn foo_slice() void { } } -// comptime slice-sentinel is out of bounds (terminated) +// error +// backend=stage1 +// target=native // // :4:29: error: out of bounds slice // :12:29: error: out of bounds slice diff --git a/test/compile_errors/stage1/obj/comptime_slice-sentinel_is_out_of_bounds_unterminated.zig b/test/compile_errors/stage1/obj/comptime_slice-sentinel_is_out_of_bounds_unterminated.zig index 05a499ca8a..952b17600a 100644 --- a/test/compile_errors/stage1/obj/comptime_slice-sentinel_is_out_of_bounds_unterminated.zig +++ b/test/compile_errors/stage1/obj/comptime_slice-sentinel_is_out_of_bounds_unterminated.zig @@ -54,7 +54,9 @@ export fn foo_slice() void { } } -// comptime slice-sentinel is out of bounds (unterminated) +// error +// backend=stage1 +// target=native // // :4:29: error: slice-sentinel is out of bounds // :12:29: error: slice-sentinel is out of bounds diff --git a/test/compile_errors/stage1/obj/comptime_slice_of_an_undefined_slice.zig b/test/compile_errors/stage1/obj/comptime_slice_of_an_undefined_slice.zig index b56feddc02..4aa519f41e 100644 --- a/test/compile_errors/stage1/obj/comptime_slice_of_an_undefined_slice.zig +++ b/test/compile_errors/stage1/obj/comptime_slice_of_an_undefined_slice.zig @@ -4,6 +4,8 @@ comptime { _ = b; } -// comptime slice of an undefined slice +// error +// backend=stage1 +// target=native // // tmp.zig:3:14: error: slice of undefined diff --git a/test/compile_errors/stage1/obj/comptime_slice_of_undefined_pointer_non-zero_len.zig b/test/compile_errors/stage1/obj/comptime_slice_of_undefined_pointer_non-zero_len.zig index bcddd1d866..ec7fbdc6e2 100644 --- a/test/compile_errors/stage1/obj/comptime_slice_of_undefined_pointer_non-zero_len.zig +++ b/test/compile_errors/stage1/obj/comptime_slice_of_undefined_pointer_non-zero_len.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = slice; } -// comptime slice of undefined pointer non-zero len +// error +// backend=stage1 +// target=native // // tmp.zig:2:41: error: non-zero length slice of undefined pointer diff --git a/test/compile_errors/stage1/obj/comptime_struct_field_no_init_value.zig b/test/compile_errors/stage1/obj/comptime_struct_field_no_init_value.zig index c3de76a794..b889911a4d 100644 --- a/test/compile_errors/stage1/obj/comptime_struct_field_no_init_value.zig +++ b/test/compile_errors/stage1/obj/comptime_struct_field_no_init_value.zig @@ -6,6 +6,8 @@ export fn entry() void { _ = f; } -// comptime struct field, no init value +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: comptime field without default initialization value diff --git a/test/compile_errors/stage1/obj/const_frame_cast_to_anyframe.zig b/test/compile_errors/stage1/obj/const_frame_cast_to_anyframe.zig index 1e6cdba507..affdb953d7 100644 --- a/test/compile_errors/stage1/obj/const_frame_cast_to_anyframe.zig +++ b/test/compile_errors/stage1/obj/const_frame_cast_to_anyframe.zig @@ -11,7 +11,9 @@ fn func() void { suspend {} } -// const frame cast to anyframe +// error +// backend=stage1 +// target=native // // tmp.zig:3:12: error: expected type 'anyframe', found '*const @Frame(func)' // tmp.zig:7:24: error: expected type 'anyframe', found '*const @Frame(func)' diff --git a/test/compile_errors/stage1/obj/const_is_a_statement_not_an_expression.zig b/test/compile_errors/stage1/obj/const_is_a_statement_not_an_expression.zig index 4396407dd1..b90878abeb 100644 --- a/test/compile_errors/stage1/obj/const_is_a_statement_not_an_expression.zig +++ b/test/compile_errors/stage1/obj/const_is_a_statement_not_an_expression.zig @@ -2,6 +2,8 @@ export fn f() void { (const a = 0); } -// const is a statement, not an expression +// error +// backend=stage1 +// target=native // // tmp.zig:2:6: error: expected expression, found 'const' diff --git a/test/compile_errors/stage1/obj/container_init_with_non-type.zig b/test/compile_errors/stage1/obj/container_init_with_non-type.zig index 6464555df5..3364b2f5b6 100644 --- a/test/compile_errors/stage1/obj/container_init_with_non-type.zig +++ b/test/compile_errors/stage1/obj/container_init_with_non-type.zig @@ -3,6 +3,8 @@ const a = zero{1}; export fn entry() usize { return @sizeOf(@TypeOf(a)); } -// container init with non-type +// error +// backend=stage1 +// target=native // // tmp.zig:2:11: error: expected type 'type', found 'i32' diff --git a/test/compile_errors/stage1/obj/control_flow_uses_comptime_var_at_runtime.zig b/test/compile_errors/stage1/obj/control_flow_uses_comptime_var_at_runtime.zig index ee2c0234c3..cb2c3e9f6e 100644 --- a/test/compile_errors/stage1/obj/control_flow_uses_comptime_var_at_runtime.zig +++ b/test/compile_errors/stage1/obj/control_flow_uses_comptime_var_at_runtime.zig @@ -7,7 +7,9 @@ export fn foo() void { fn bar() void { } -// control flow uses comptime var at runtime +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: control flow attempts to use compile-time variable at runtime // tmp.zig:3:24: note: compile-time variable assigned here diff --git a/test/compile_errors/stage1/obj/control_reaches_end_of_non-void_function.zig b/test/compile_errors/stage1/obj/control_reaches_end_of_non-void_function.zig index 13d2876823..e15c1bd40b 100644 --- a/test/compile_errors/stage1/obj/control_reaches_end_of_non-void_function.zig +++ b/test/compile_errors/stage1/obj/control_reaches_end_of_non-void_function.zig @@ -1,6 +1,8 @@ fn a() i32 {} export fn entry() void { _ = a(); } -// control reaches end of non-void function +// error +// backend=stage1 +// target=native // // tmp.zig:1:12: error: expected type 'i32', found 'void' diff --git a/test/compile_errors/stage1/obj/declaration_between_fields.zig b/test/compile_errors/stage1/obj/declaration_between_fields.zig index 6e6b60f2e4..25a1ff5abc 100644 --- a/test/compile_errors/stage1/obj/declaration_between_fields.zig +++ b/test/compile_errors/stage1/obj/declaration_between_fields.zig @@ -15,7 +15,9 @@ comptime { _ = S; } -// declaration between fields +// error +// backend=stage1 +// target=native // // tmp.zig:9:5: error: declarations are not allowed between container fields // tmp.zig:5:5: note: field before declarations here diff --git a/test/compile_errors/stage1/obj/declaration_with_same_name_as_primitive_must_use_special_syntax.zig b/test/compile_errors/stage1/obj/declaration_with_same_name_as_primitive_must_use_special_syntax.zig index c10f397da4..46b0257ed5 100644 --- a/test/compile_errors/stage1/obj/declaration_with_same_name_as_primitive_must_use_special_syntax.zig +++ b/test/compile_errors/stage1/obj/declaration_with_same_name_as_primitive_must_use_special_syntax.zig @@ -4,7 +4,9 @@ export fn entry() void { _ = a; } -// declaration with same name as primitive must use special syntax +// error +// backend=stage1 +// target=native // // tmp.zig:1:7: error: name shadows primitive 'u8' // tmp.zig:1:7: note: consider using @"u8" to disambiguate diff --git a/test/compile_errors/stage1/obj/deduplicate_undeclared_identifier.zig b/test/compile_errors/stage1/obj/deduplicate_undeclared_identifier.zig index 1c9d6c3d31..1e3b3bf6db 100644 --- a/test/compile_errors/stage1/obj/deduplicate_undeclared_identifier.zig +++ b/test/compile_errors/stage1/obj/deduplicate_undeclared_identifier.zig @@ -5,6 +5,8 @@ export fn b() void { x += 1; } -// deduplicate undeclared identifier +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: use of undeclared identifier 'x' diff --git a/test/compile_errors/stage1/obj/deref_on_undefined_value.zig b/test/compile_errors/stage1/obj/deref_on_undefined_value.zig index 607f6ea5e0..f64d567a26 100644 --- a/test/compile_errors/stage1/obj/deref_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/deref_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = a.*; } -// deref on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: attempt to dereference undefined value diff --git a/test/compile_errors/stage1/obj/deref_slice_and_get_len_field.zig b/test/compile_errors/stage1/obj/deref_slice_and_get_len_field.zig index 2fa5ff6133..98097597cc 100644 --- a/test/compile_errors/stage1/obj/deref_slice_and_get_len_field.zig +++ b/test/compile_errors/stage1/obj/deref_slice_and_get_len_field.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = a.*.len; } -// deref slice and get len field +// error +// backend=stage1 +// target=native // // tmp.zig:3:10: error: attempt to dereference non-pointer type '[]u8' diff --git a/test/compile_errors/stage1/obj/dereference_an_array.zig b/test/compile_errors/stage1/obj/dereference_an_array.zig index 713c655784..0dd91f70e5 100644 --- a/test/compile_errors/stage1/obj/dereference_an_array.zig +++ b/test/compile_errors/stage1/obj/dereference_an_array.zig @@ -7,6 +7,8 @@ pub fn pass(in: []u8) []u8 { export fn entry() usize { return @sizeOf(@TypeOf(pass)); } -// dereference an array +// error +// backend=stage1 +// target=native // // tmp.zig:4:10: error: attempt to dereference non-pointer type '[10]u8' diff --git a/test/compile_errors/stage1/obj/dereference_unknown_length_pointer.zig b/test/compile_errors/stage1/obj/dereference_unknown_length_pointer.zig index 22ad181fb2..c305e4bc98 100644 --- a/test/compile_errors/stage1/obj/dereference_unknown_length_pointer.zig +++ b/test/compile_errors/stage1/obj/dereference_unknown_length_pointer.zig @@ -2,6 +2,8 @@ export fn entry(x: [*]i32) i32 { return x.*; } -// dereference unknown length pointer +// error +// backend=stage1 +// target=native // // tmp.zig:2:13: error: index syntax required for unknown-length pointer type '[*]i32' diff --git a/test/compile_errors/stage1/obj/direct_struct_loop.zig b/test/compile_errors/stage1/obj/direct_struct_loop.zig index 25b3c724c3..3062e617d6 100644 --- a/test/compile_errors/stage1/obj/direct_struct_loop.zig +++ b/test/compile_errors/stage1/obj/direct_struct_loop.zig @@ -1,6 +1,8 @@ const A = struct { a : A, }; export fn entry() usize { return @sizeOf(A); } -// direct struct loop +// error +// backend=stage1 +// target=native // // tmp.zig:1:11: error: struct 'A' depends on itself diff --git a/test/compile_errors/stage1/obj/directly_embedding_opaque_type_in_struct_and_union.zig b/test/compile_errors/stage1/obj/directly_embedding_opaque_type_in_struct_and_union.zig index 811fc00f50..8b8d84ad2a 100644 --- a/test/compile_errors/stage1/obj/directly_embedding_opaque_type_in_struct_and_union.zig +++ b/test/compile_errors/stage1/obj/directly_embedding_opaque_type_in_struct_and_union.zig @@ -20,7 +20,9 @@ export fn c() void { _ = qux; } -// directly embedding opaque type in struct and union +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: opaque types have unknown size and therefore cannot be directly embedded in structs // tmp.zig:7:5: error: opaque types have unknown size and therefore cannot be directly embedded in unions diff --git a/test/compile_errors/stage1/obj/disallow_coercion_from_non-null-terminated_pointer_to_null-terminated_pointer.zig b/test/compile_errors/stage1/obj/disallow_coercion_from_non-null-terminated_pointer_to_null-terminated_pointer.zig index a8467ddc87..1d0a6216dd 100644 --- a/test/compile_errors/stage1/obj/disallow_coercion_from_non-null-terminated_pointer_to_null-terminated_pointer.zig +++ b/test/compile_errors/stage1/obj/disallow_coercion_from_non-null-terminated_pointer_to_null-terminated_pointer.zig @@ -5,6 +5,8 @@ pub fn main() void { _ = puts(no_zero_ptr); } -// disallow coercion from non-null-terminated pointer to null-terminated pointer +// error +// backend=stage1 +// target=native // // tmp.zig:5:14: error: expected type '[*:0]const u8', found '[*]const u8' diff --git a/test/compile_errors/stage1/obj/discarding_error_value.zig b/test/compile_errors/stage1/obj/discarding_error_value.zig index 966a43a47c..dcfa22e8cb 100644 --- a/test/compile_errors/stage1/obj/discarding_error_value.zig +++ b/test/compile_errors/stage1/obj/discarding_error_value.zig @@ -5,6 +5,8 @@ fn foo() !void { return error.OutOfMemory; } -// discarding error value +// error +// backend=stage1 +// target=native // // tmp.zig:2:12: error: error is discarded. consider using `try`, `catch`, or `if` diff --git a/test/compile_errors/stage1/obj/div_assign_on_undefined_value.zig b/test/compile_errors/stage1/obj/div_assign_on_undefined_value.zig index 40c31649fb..5f18e6286a 100644 --- a/test/compile_errors/stage1/obj/div_assign_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/div_assign_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { a /= a; } -// div assign on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/div_on_undefined_value.zig b/test/compile_errors/stage1/obj/div_on_undefined_value.zig index 17af3fa221..9857b1c779 100644 --- a/test/compile_errors/stage1/obj/div_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/div_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = a / a; } -// div on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/division_by_zero.zig b/test/compile_errors/stage1/obj/division_by_zero.zig index 178d1d935b..3023f0c6f3 100644 --- a/test/compile_errors/stage1/obj/division_by_zero.zig +++ b/test/compile_errors/stage1/obj/division_by_zero.zig @@ -8,7 +8,9 @@ export fn entry2() usize { return @sizeOf(@TypeOf(lit_float_x)); } export fn entry3() usize { return @sizeOf(@TypeOf(int_x)); } export fn entry4() usize { return @sizeOf(@TypeOf(float_x)); } -// division by zero +// error +// backend=stage1 +// target=native // // tmp.zig:1:21: error: division by zero // tmp.zig:2:25: error: division by zero diff --git a/test/compile_errors/stage1/obj/dont_implicit_cast_double_pointer_to_anyopaque.zig b/test/compile_errors/stage1/obj/dont_implicit_cast_double_pointer_to_anyopaque.zig index 5894103f1c..f61dec2ee0 100644 --- a/test/compile_errors/stage1/obj/dont_implicit_cast_double_pointer_to_anyopaque.zig +++ b/test/compile_errors/stage1/obj/dont_implicit_cast_double_pointer_to_anyopaque.zig @@ -6,6 +6,8 @@ export fn entry() void { _ = ptr2; } -// don't implicit cast double pointer to *anyopaque +// error +// backend=stage1 +// target=native // // tmp.zig:5:29: error: expected type '*anyopaque', found '**u32' diff --git a/test/compile_errors/stage1/obj/double_optional_on_main_return_value.zig b/test/compile_errors/stage1/obj/double_optional_on_main_return_value.zig index c85706bc87..c61ac400ba 100644 --- a/test/compile_errors/stage1/obj/double_optional_on_main_return_value.zig +++ b/test/compile_errors/stage1/obj/double_optional_on_main_return_value.zig @@ -1,6 +1,8 @@ pub fn main() ??void { } -// double ?? on main return value +// error +// backend=stage1 +// target=native // // error: expected return type of main to be 'void', '!void', 'noreturn', 'u8', or '!u8' diff --git a/test/compile_errors/stage1/obj/duplicate_boolean_switch_value.zig b/test/compile_errors/stage1/obj/duplicate_boolean_switch_value.zig index 8c496d5e19..5b85c0a2eb 100644 --- a/test/compile_errors/stage1/obj/duplicate_boolean_switch_value.zig +++ b/test/compile_errors/stage1/obj/duplicate_boolean_switch_value.zig @@ -15,7 +15,9 @@ comptime { _ = x; } -// duplicate boolean switch value +// error +// backend=stage1 +// target=native // // tmp.zig:5:9: error: duplicate switch value // tmp.zig:13:9: error: duplicate switch value diff --git a/test/compile_errors/stage1/obj/duplicate_enum_field.zig b/test/compile_errors/stage1/obj/duplicate_enum_field.zig index 2aee3cc2dc..cd024270bd 100644 --- a/test/compile_errors/stage1/obj/duplicate_enum_field.zig +++ b/test/compile_errors/stage1/obj/duplicate_enum_field.zig @@ -8,7 +8,9 @@ export fn entry() void { _ = a; } -// duplicate enum field +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: duplicate enum field: 'Bar' // tmp.zig:2:5: note: other field here diff --git a/test/compile_errors/stage1/obj/duplicate_error_in_switch.zig b/test/compile_errors/stage1/obj/duplicate_error_in_switch.zig index bca59056c3..140a14ec81 100644 --- a/test/compile_errors/stage1/obj/duplicate_error_in_switch.zig +++ b/test/compile_errors/stage1/obj/duplicate_error_in_switch.zig @@ -14,7 +14,9 @@ fn foo(x: i32) !void { } } -// duplicate error in switch +// error +// backend=stage1 +// target=native // // tmp.zig:5:14: error: duplicate switch value: '@typeInfo(@typeInfo(@TypeOf(foo)).Fn.return_type.?).ErrorUnion.error_set.Foo' // tmp.zig:3:14: note: other value here diff --git a/test/compile_errors/stage1/obj/duplicate_error_value_in_error_set.zig b/test/compile_errors/stage1/obj/duplicate_error_value_in_error_set.zig index 90457562b2..30d3bee8ab 100644 --- a/test/compile_errors/stage1/obj/duplicate_error_value_in_error_set.zig +++ b/test/compile_errors/stage1/obj/duplicate_error_value_in_error_set.zig @@ -7,7 +7,9 @@ export fn entry() void { _ = a; } -// duplicate error value in error set +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: duplicate error set field 'Bar' // tmp.zig:2:5: note: previous declaration here diff --git a/test/compile_errors/stage1/obj/duplicate_field_in_struct_value_expression.zig b/test/compile_errors/stage1/obj/duplicate_field_in_struct_value_expression.zig index 6df71430d9..1c0bac75e2 100644 --- a/test/compile_errors/stage1/obj/duplicate_field_in_struct_value_expression.zig +++ b/test/compile_errors/stage1/obj/duplicate_field_in_struct_value_expression.zig @@ -13,6 +13,8 @@ export fn f() void { _ = a; } -// duplicate field in struct value expression +// error +// backend=stage1 +// target=native // // tmp.zig:11:9: error: duplicate field diff --git a/test/compile_errors/stage1/obj/duplicate_struct_field.zig b/test/compile_errors/stage1/obj/duplicate_struct_field.zig index d1fd05aacc..93afdef70e 100644 --- a/test/compile_errors/stage1/obj/duplicate_struct_field.zig +++ b/test/compile_errors/stage1/obj/duplicate_struct_field.zig @@ -7,7 +7,9 @@ export fn entry() void { _ = a; } -// duplicate struct field +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: duplicate struct field: 'Bar' // tmp.zig:2:5: note: other field here diff --git a/test/compile_errors/stage1/obj/duplicate_union_field.zig b/test/compile_errors/stage1/obj/duplicate_union_field.zig index a8bff106c6..5cbdcb7820 100644 --- a/test/compile_errors/stage1/obj/duplicate_union_field.zig +++ b/test/compile_errors/stage1/obj/duplicate_union_field.zig @@ -7,7 +7,9 @@ export fn entry() void { _ = a; } -// duplicate union field +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: duplicate union field: 'Bar' // tmp.zig:2:5: note: other field here diff --git a/test/compile_errors/stage1/obj/embedFile_with_bogus_file.zig b/test/compile_errors/stage1/obj/embedFile_with_bogus_file.zig index e50e091909..a03949b40a 100644 --- a/test/compile_errors/stage1/obj/embedFile_with_bogus_file.zig +++ b/test/compile_errors/stage1/obj/embedFile_with_bogus_file.zig @@ -2,6 +2,8 @@ const resource = @embedFile("bogus.txt",); export fn entry() usize { return @sizeOf(@TypeOf(resource)); } -// @embedFile with bogus file +// error +// backend=stage1 +// target=native // // tmp.zig:1:29: error: unable to find ' diff --git a/test/compile_errors/stage1/obj/empty_for_loop_body.zig b/test/compile_errors/stage1/obj/empty_for_loop_body.zig index 6e042f71e4..b824c93131 100644 --- a/test/compile_errors/stage1/obj/empty_for_loop_body.zig +++ b/test/compile_errors/stage1/obj/empty_for_loop_body.zig @@ -2,6 +2,8 @@ export fn a() void { for(undefined) |x|; } -// empty for loop body +// error +// backend=stage1 +// target=native // // tmp.zig:2:23: error: expected block or assignment, found ';' diff --git a/test/compile_errors/stage1/obj/empty_if_body.zig b/test/compile_errors/stage1/obj/empty_if_body.zig index a81973396f..0a7b5b1b8b 100644 --- a/test/compile_errors/stage1/obj/empty_if_body.zig +++ b/test/compile_errors/stage1/obj/empty_if_body.zig @@ -2,6 +2,8 @@ export fn a() void { if(true); } -// empty if body +// error +// backend=stage1 +// target=native // // tmp.zig:2:13: error: expected block or assignment, found ';' diff --git a/test/compile_errors/stage1/obj/empty_switch_on_an_integer.zig b/test/compile_errors/stage1/obj/empty_switch_on_an_integer.zig index eb0bdbab19..a7b8e2a81b 100644 --- a/test/compile_errors/stage1/obj/empty_switch_on_an_integer.zig +++ b/test/compile_errors/stage1/obj/empty_switch_on_an_integer.zig @@ -3,6 +3,8 @@ export fn entry() void { switch(x) {} } -// empty switch on an integer +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: switch must handle all possibilities diff --git a/test/compile_errors/stage1/obj/empty_while_loop_body.zig b/test/compile_errors/stage1/obj/empty_while_loop_body.zig index 3a186f1a2b..01b2132518 100644 --- a/test/compile_errors/stage1/obj/empty_while_loop_body.zig +++ b/test/compile_errors/stage1/obj/empty_while_loop_body.zig @@ -2,6 +2,8 @@ export fn a() void { while(true); } -// empty while loop body +// error +// backend=stage1 +// target=native // // tmp.zig:2:16: error: expected block or assignment, found ';' diff --git a/test/compile_errors/stage1/obj/endless_loop_in_function_evaluation.zig b/test/compile_errors/stage1/obj/endless_loop_in_function_evaluation.zig index fa422ba588..302ee242e0 100644 --- a/test/compile_errors/stage1/obj/endless_loop_in_function_evaluation.zig +++ b/test/compile_errors/stage1/obj/endless_loop_in_function_evaluation.zig @@ -5,6 +5,8 @@ fn fibonacci(x: i32) i32 { export fn entry() usize { return @sizeOf(@TypeOf(seventh_fib_number)); } -// endless loop in function evaluation +// error +// backend=stage1 +// target=native // // tmp.zig:3:21: error: evaluation exceeded 1000 backwards branches diff --git a/test/compile_errors/stage1/obj/enum_field_value_references_enum.zig b/test/compile_errors/stage1/obj/enum_field_value_references_enum.zig index 02dcfc1f9d..ebf32db5e0 100644 --- a/test/compile_errors/stage1/obj/enum_field_value_references_enum.zig +++ b/test/compile_errors/stage1/obj/enum_field_value_references_enum.zig @@ -8,6 +8,8 @@ export fn entry() void { } const D = 1; -// enum field value references enum +// error +// backend=stage1 +// target=native // // tmp.zig:1:17: error: enum 'Foo' depends on itself diff --git a/test/compile_errors/stage1/obj/enum_in_field_count_range_but_not_matching_tag.zig b/test/compile_errors/stage1/obj/enum_in_field_count_range_but_not_matching_tag.zig index dc90c467df..e783cbee52 100644 --- a/test/compile_errors/stage1/obj/enum_in_field_count_range_but_not_matching_tag.zig +++ b/test/compile_errors/stage1/obj/enum_in_field_count_range_but_not_matching_tag.zig @@ -7,7 +7,9 @@ export fn entry() void { _ = x; } -// enum in field count range but not matching tag +// error +// backend=stage1 +// target=native // // tmp.zig:6:13: error: enum 'Foo' has no tag matching integer value 0 // tmp.zig:1:13: note: 'Foo' declared here diff --git a/test/compile_errors/stage1/obj/enum_value_already_taken.zig b/test/compile_errors/stage1/obj/enum_value_already_taken.zig index 9939553c41..60e88f0062 100644 --- a/test/compile_errors/stage1/obj/enum_value_already_taken.zig +++ b/test/compile_errors/stage1/obj/enum_value_already_taken.zig @@ -10,7 +10,9 @@ export fn entry() void { _ = x; } -// enum value already taken +// error +// backend=stage1 +// target=native // // tmp.zig:6:5: error: enum tag value 60 already taken // tmp.zig:4:5: note: other occurrence here diff --git a/test/compile_errors/stage1/obj/enum_with_0_fields.zig b/test/compile_errors/stage1/obj/enum_with_0_fields.zig index 10559d15b3..9ee18f51ca 100644 --- a/test/compile_errors/stage1/obj/enum_with_0_fields.zig +++ b/test/compile_errors/stage1/obj/enum_with_0_fields.zig @@ -1,5 +1,7 @@ const Foo = enum {}; -// enum with 0 fields +// error +// backend=stage1 +// target=native // // tmp.zig:1:13: error: enum declarations must have at least one tag diff --git a/test/compile_errors/stage1/obj/enum_with_declarations_unavailable_for_reify_type.zig b/test/compile_errors/stage1/obj/enum_with_declarations_unavailable_for_reify_type.zig index 4a27caab3d..ffe9a2a78a 100644 --- a/test/compile_errors/stage1/obj/enum_with_declarations_unavailable_for_reify_type.zig +++ b/test/compile_errors/stage1/obj/enum_with_declarations_unavailable_for_reify_type.zig @@ -2,6 +2,8 @@ export fn entry() void { _ = @Type(@typeInfo(enum { foo, const bar = 1; })); } -// enum with declarations unavailable for @Type +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: Type.Enum.decls must be empty for @Type diff --git a/test/compile_errors/stage1/obj/error_equality_but_sets_have_no_common_members.zig b/test/compile_errors/stage1/obj/error_equality_but_sets_have_no_common_members.zig index 433f6d50e3..d42169b503 100644 --- a/test/compile_errors/stage1/obj/error_equality_but_sets_have_no_common_members.zig +++ b/test/compile_errors/stage1/obj/error_equality_but_sets_have_no_common_members.zig @@ -9,6 +9,8 @@ fn foo(x: Set1) void { } } -// error equality but sets have no common members +// error +// backend=stage1 +// target=native // // tmp.zig:7:11: error: error sets 'Set1' and 'Set2' have no common errors diff --git a/test/compile_errors/stage1/obj/error_not_handled_in_switch.zig b/test/compile_errors/stage1/obj/error_not_handled_in_switch.zig index a69c538eac..12ee35daef 100644 --- a/test/compile_errors/stage1/obj/error_not_handled_in_switch.zig +++ b/test/compile_errors/stage1/obj/error_not_handled_in_switch.zig @@ -12,7 +12,9 @@ fn foo(x: i32) !void { } } -// error not handled in switch +// error +// backend=stage1 +// target=native // // tmp.zig:2:26: error: error.Baz not handled in switch // tmp.zig:2:26: error: error.Bar not handled in switch diff --git a/test/compile_errors/stage1/obj/error_note_for_function_parameter_incompatibility.zig b/test/compile_errors/stage1/obj/error_note_for_function_parameter_incompatibility.zig index 5014d01a3d..edc421d8f4 100644 --- a/test/compile_errors/stage1/obj/error_note_for_function_parameter_incompatibility.zig +++ b/test/compile_errors/stage1/obj/error_note_for_function_parameter_incompatibility.zig @@ -4,7 +4,9 @@ export fn entry() void { do_the_thing(bar); } -// error note for function parameter incompatibility +// error +// backend=stage1 +// target=native // // tmp.zig:4:18: error: expected type 'fn(i32) void', found 'fn(bool) void // tmp.zig:4:18: note: parameter 0: 'bool' cannot cast into 'i32' diff --git a/test/compile_errors/stage1/obj/error_union_operator_with_non_error_set_LHS.zig b/test/compile_errors/stage1/obj/error_union_operator_with_non_error_set_LHS.zig index 40b5872fc8..785e42fb9b 100644 --- a/test/compile_errors/stage1/obj/error_union_operator_with_non_error_set_LHS.zig +++ b/test/compile_errors/stage1/obj/error_union_operator_with_non_error_set_LHS.zig @@ -4,6 +4,8 @@ comptime { _ = x; } -// error union operator with non error set LHS +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: expected error set type, found type 'i32' diff --git a/test/compile_errors/stage1/obj/error_when_evaluating_return_type.zig b/test/compile_errors/stage1/obj/error_when_evaluating_return_type.zig index 60baa1c5b4..60731740b7 100644 --- a/test/compile_errors/stage1/obj/error_when_evaluating_return_type.zig +++ b/test/compile_errors/stage1/obj/error_when_evaluating_return_type.zig @@ -10,6 +10,8 @@ export fn entry() void { _ = rule_set; } -// error when evaluating return type +// error +// backend=stage1 +// target=native // // tmp.zig:2:19: error: expected type 'i32', found 'type' diff --git a/test/compile_errors/stage1/obj/exceeded_maximum_bit_width_of_integer.zig b/test/compile_errors/stage1/obj/exceeded_maximum_bit_width_of_integer.zig index e1784de63e..2a3c795f81 100644 --- a/test/compile_errors/stage1/obj/exceeded_maximum_bit_width_of_integer.zig +++ b/test/compile_errors/stage1/obj/exceeded_maximum_bit_width_of_integer.zig @@ -7,7 +7,9 @@ export fn entry2() void { _ = x; } -// exceeded maximum bit width of integer +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: primitive integer type 'u65536' exceeds maximum bit width of 65535 // tmp.zig:6:12: error: primitive integer type 'i65536' exceeds maximum bit width of 65535 diff --git a/test/compile_errors/stage1/obj/explicit_cast_float_literal_to_integer_when_there_is_a_fraction_component.zig b/test/compile_errors/stage1/obj/explicit_cast_float_literal_to_integer_when_there_is_a_fraction_component.zig index eaa2be84c7..696fef57fa 100644 --- a/test/compile_errors/stage1/obj/explicit_cast_float_literal_to_integer_when_there_is_a_fraction_component.zig +++ b/test/compile_errors/stage1/obj/explicit_cast_float_literal_to_integer_when_there_is_a_fraction_component.zig @@ -2,6 +2,8 @@ export fn entry() i32 { return @as(i32, 12.34); } -// explicit cast float literal to integer when there is a fraction component +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: fractional component prevents float value 12.340000 from being casted to type 'i32' diff --git a/test/compile_errors/stage1/obj/explicit_error_set_cast_known_at_comptime_violates_error_sets.zig b/test/compile_errors/stage1/obj/explicit_error_set_cast_known_at_comptime_violates_error_sets.zig index 68d78e0f92..4a41920107 100644 --- a/test/compile_errors/stage1/obj/explicit_error_set_cast_known_at_comptime_violates_error_sets.zig +++ b/test/compile_errors/stage1/obj/explicit_error_set_cast_known_at_comptime_violates_error_sets.zig @@ -6,6 +6,8 @@ comptime { _ = y; } -// explicit error set cast known at comptime violates error sets +// error +// backend=stage1 +// target=native // // tmp.zig:5:13: error: error.B not a member of error set 'Set2' diff --git a/test/compile_errors/stage1/obj/explicitly_casting_non_tag_type_to_enum.zig b/test/compile_errors/stage1/obj/explicitly_casting_non_tag_type_to_enum.zig index e7c4d5f5d9..1999fd70a7 100644 --- a/test/compile_errors/stage1/obj/explicitly_casting_non_tag_type_to_enum.zig +++ b/test/compile_errors/stage1/obj/explicitly_casting_non_tag_type_to_enum.zig @@ -11,6 +11,8 @@ export fn entry() void { _ = x; } -// explicitly casting non tag type to enum +// error +// backend=stage1 +// target=native // // tmp.zig:10:31: error: expected integer type, found 'f32' diff --git a/test/compile_errors/stage1/obj/export_function_with_comptime_parameter.zig b/test/compile_errors/stage1/obj/export_function_with_comptime_parameter.zig index 0f300f324b..ccfda1ba67 100644 --- a/test/compile_errors/stage1/obj/export_function_with_comptime_parameter.zig +++ b/test/compile_errors/stage1/obj/export_function_with_comptime_parameter.zig @@ -2,6 +2,8 @@ export fn foo(comptime x: i32, y: i32) i32{ return x + y; } -// export function with comptime parameter +// error +// backend=stage1 +// target=native // // tmp.zig:1:15: error: comptime parameter not allowed in function with calling convention 'C' diff --git a/test/compile_errors/stage1/obj/export_generic_function.zig b/test/compile_errors/stage1/obj/export_generic_function.zig index 3fb4375ed4..9f6bcd4cf4 100644 --- a/test/compile_errors/stage1/obj/export_generic_function.zig +++ b/test/compile_errors/stage1/obj/export_generic_function.zig @@ -3,6 +3,8 @@ export fn foo(num: anytype) i32 { return 0; } -// export generic function +// error +// backend=stage1 +// target=native // // tmp.zig:1:15: error: parameter of type 'anytype' not allowed in function with calling convention 'C' diff --git a/test/compile_errors/stage1/obj/exported_async_function.zig b/test/compile_errors/stage1/obj/exported_async_function.zig index 296a5950e9..b9ac591227 100644 --- a/test/compile_errors/stage1/obj/exported_async_function.zig +++ b/test/compile_errors/stage1/obj/exported_async_function.zig @@ -1,5 +1,7 @@ export fn foo() callconv(.Async) void {} -// exported async function +// error +// backend=stage1 +// target=native // // tmp.zig:1:1: error: exported function cannot be async diff --git a/test/compile_errors/stage1/obj/exported_enum_without_explicit_integer_tag_type.zig b/test/compile_errors/stage1/obj/exported_enum_without_explicit_integer_tag_type.zig index 3d6e63db43..c432bedd6b 100644 --- a/test/compile_errors/stage1/obj/exported_enum_without_explicit_integer_tag_type.zig +++ b/test/compile_errors/stage1/obj/exported_enum_without_explicit_integer_tag_type.zig @@ -7,7 +7,9 @@ comptime { @export(e, .{ .name = "e" }); } -// exported enum without explicit integer tag type +// error +// backend=stage1 +// target=native // // tmp.zig:3:13: error: exported enum without explicit integer tag type // tmp.zig:7:13: error: exported enum value without explicit integer tag type diff --git a/test/compile_errors/stage1/obj/extern_function_pointer_mismatch.zig b/test/compile_errors/stage1/obj/extern_function_pointer_mismatch.zig index f93a24db34..888b59a626 100644 --- a/test/compile_errors/stage1/obj/extern_function_pointer_mismatch.zig +++ b/test/compile_errors/stage1/obj/extern_function_pointer_mismatch.zig @@ -5,6 +5,8 @@ export fn c(x: i32) i32 {return x + 2;} export fn entry() usize { return @sizeOf(@TypeOf(fns)); } -// extern function pointer mismatch +// error +// backend=stage1 +// target=native // // tmp.zig:1:37: error: expected type 'fn(i32) i32', found 'fn(i32) callconv(.C) i32' diff --git a/test/compile_errors/stage1/obj/extern_function_with_comptime_parameter.zig b/test/compile_errors/stage1/obj/extern_function_with_comptime_parameter.zig index 3dfdfe663e..93e26b9543 100644 --- a/test/compile_errors/stage1/obj/extern_function_with_comptime_parameter.zig +++ b/test/compile_errors/stage1/obj/extern_function_with_comptime_parameter.zig @@ -4,6 +4,8 @@ fn f() i32 { } export fn entry() usize { return @sizeOf(@TypeOf(f)); } -// extern function with comptime parameter +// error +// backend=stage1 +// target=native // // tmp.zig:1:15: error: comptime parameter not allowed in function with calling convention 'C' diff --git a/test/compile_errors/stage1/obj/extern_struct_with_extern-compatible_but_inferred_integer_tag_type.zig b/test/compile_errors/stage1/obj/extern_struct_with_extern-compatible_but_inferred_integer_tag_type.zig index e65c438da3..8f45a0e5dc 100644 --- a/test/compile_errors/stage1/obj/extern_struct_with_extern-compatible_but_inferred_integer_tag_type.zig +++ b/test/compile_errors/stage1/obj/extern_struct_with_extern-compatible_but_inferred_integer_tag_type.zig @@ -36,6 +36,8 @@ export fn entry() void { _ = s; } -// extern struct with extern-compatible but inferred integer tag type +// error +// backend=stage1 +// target=native // // tmp.zig:31:5: error: extern structs cannot contain fields of type 'E' diff --git a/test/compile_errors/stage1/obj/extern_struct_with_non-extern-compatible_integer_tag_type.zig b/test/compile_errors/stage1/obj/extern_struct_with_non-extern-compatible_integer_tag_type.zig index 6d698ce8e3..aa508056a1 100644 --- a/test/compile_errors/stage1/obj/extern_struct_with_non-extern-compatible_integer_tag_type.zig +++ b/test/compile_errors/stage1/obj/extern_struct_with_non-extern-compatible_integer_tag_type.zig @@ -7,6 +7,8 @@ export fn entry() void { _ = s; } -// extern struct with non-extern-compatible integer tag type +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: extern structs cannot contain fields of type 'E' diff --git a/test/compile_errors/stage1/obj/extern_union_field_missing_type.zig b/test/compile_errors/stage1/obj/extern_union_field_missing_type.zig index 1287ce0159..9d8532f8a1 100644 --- a/test/compile_errors/stage1/obj/extern_union_field_missing_type.zig +++ b/test/compile_errors/stage1/obj/extern_union_field_missing_type.zig @@ -6,6 +6,8 @@ export fn entry() void { _ = a; } -// extern union field missing type +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: union field missing type diff --git a/test/compile_errors/stage1/obj/extern_union_given_enum_tag_type.zig b/test/compile_errors/stage1/obj/extern_union_given_enum_tag_type.zig index 5b38d77eb6..86ac42cccf 100644 --- a/test/compile_errors/stage1/obj/extern_union_given_enum_tag_type.zig +++ b/test/compile_errors/stage1/obj/extern_union_given_enum_tag_type.zig @@ -13,6 +13,8 @@ export fn entry() void { _ = a; } -// extern union given enum tag type +// error +// backend=stage1 +// target=native // // tmp.zig:6:30: error: extern union does not support enum tag type diff --git a/test/compile_errors/stage1/obj/extern_variable_has_no_type.zig b/test/compile_errors/stage1/obj/extern_variable_has_no_type.zig index f9d3952275..58d67f14e1 100644 --- a/test/compile_errors/stage1/obj/extern_variable_has_no_type.zig +++ b/test/compile_errors/stage1/obj/extern_variable_has_no_type.zig @@ -3,6 +3,8 @@ pub export fn entry() void { foo; } -// extern variable has no type +// error +// backend=stage1 +// target=native // // tmp.zig:1:8: error: unable to infer variable type diff --git a/test/compile_errors/stage1/obj/fieldParentPtr-bad_field_name.zig b/test/compile_errors/stage1/obj/fieldParentPtr-bad_field_name.zig index 8c40641113..73022167f5 100644 --- a/test/compile_errors/stage1/obj/fieldParentPtr-bad_field_name.zig +++ b/test/compile_errors/stage1/obj/fieldParentPtr-bad_field_name.zig @@ -5,6 +5,8 @@ export fn foo(a: *i32) *Foo { return @fieldParentPtr(Foo, "a", a); } -// @fieldParentPtr - bad field name +// error +// backend=stage1 +// target=native // // tmp.zig:5:33: error: struct 'Foo' has no field 'a' diff --git a/test/compile_errors/stage1/obj/fieldParentPtr-comptime_field_ptr_not_based_on_struct.zig b/test/compile_errors/stage1/obj/fieldParentPtr-comptime_field_ptr_not_based_on_struct.zig index a8a5431352..9375f4639a 100644 --- a/test/compile_errors/stage1/obj/fieldParentPtr-comptime_field_ptr_not_based_on_struct.zig +++ b/test/compile_errors/stage1/obj/fieldParentPtr-comptime_field_ptr_not_based_on_struct.zig @@ -10,6 +10,8 @@ comptime { _ = another_foo_ptr; } -// @fieldParentPtr - comptime field ptr not based on struct +// error +// backend=stage1 +// target=native // // tmp.zig:9:55: error: pointer value not based on parent struct diff --git a/test/compile_errors/stage1/obj/fieldParentPtr-comptime_wrong_field_index.zig b/test/compile_errors/stage1/obj/fieldParentPtr-comptime_wrong_field_index.zig index 11bb7282fc..c322543dc0 100644 --- a/test/compile_errors/stage1/obj/fieldParentPtr-comptime_wrong_field_index.zig +++ b/test/compile_errors/stage1/obj/fieldParentPtr-comptime_wrong_field_index.zig @@ -9,6 +9,8 @@ comptime { _ = another_foo_ptr; } -// @fieldParentPtr - comptime wrong field index +// error +// backend=stage1 +// target=native // // tmp.zig:8:29: error: field 'b' has index 1 but pointer value is index 0 of struct 'Foo' diff --git a/test/compile_errors/stage1/obj/fieldParentPtr-field_pointer_is_not_pointer.zig b/test/compile_errors/stage1/obj/fieldParentPtr-field_pointer_is_not_pointer.zig index 8db9075b7b..71360e5681 100644 --- a/test/compile_errors/stage1/obj/fieldParentPtr-field_pointer_is_not_pointer.zig +++ b/test/compile_errors/stage1/obj/fieldParentPtr-field_pointer_is_not_pointer.zig @@ -5,6 +5,8 @@ export fn foo(a: i32) *Foo { return @fieldParentPtr(Foo, "a", a); } -// @fieldParentPtr - field pointer is not pointer +// error +// backend=stage1 +// target=native // // tmp.zig:5:38: error: expected pointer, found 'i32' diff --git a/test/compile_errors/stage1/obj/fieldParentPtr-non_struct.zig b/test/compile_errors/stage1/obj/fieldParentPtr-non_struct.zig index 325fbe5b3b..16b9a9b332 100644 --- a/test/compile_errors/stage1/obj/fieldParentPtr-non_struct.zig +++ b/test/compile_errors/stage1/obj/fieldParentPtr-non_struct.zig @@ -3,6 +3,8 @@ export fn foo(a: *i32) *Foo { return @fieldParentPtr(Foo, "a", a); } -// @fieldParentPtr - non struct +// error +// backend=stage1 +// target=native // // tmp.zig:3:28: error: expected struct type, found 'i32' diff --git a/test/compile_errors/stage1/obj/field_access_of_opaque_type.zig b/test/compile_errors/stage1/obj/field_access_of_opaque_type.zig index 3354c0f471..963c89dafe 100644 --- a/test/compile_errors/stage1/obj/field_access_of_opaque_type.zig +++ b/test/compile_errors/stage1/obj/field_access_of_opaque_type.zig @@ -9,6 +9,8 @@ fn bar(x: *MyType) bool { return x.blah; } -// field access of opaque type +// error +// backend=stage1 +// target=native // // tmp.zig:9:13: error: no member named 'blah' in opaque type 'MyType' diff --git a/test/compile_errors/stage1/obj/field_access_of_slices.zig b/test/compile_errors/stage1/obj/field_access_of_slices.zig index 3e79e1f0e0..45ca711367 100644 --- a/test/compile_errors/stage1/obj/field_access_of_slices.zig +++ b/test/compile_errors/stage1/obj/field_access_of_slices.zig @@ -4,6 +4,8 @@ export fn entry() void { _ = info; } -// field access of slices +// error +// backend=stage1 +// target=native // // tmp.zig:3:32: error: type 'type' does not support field access diff --git a/test/compile_errors/stage1/obj/field_access_of_unknown_length_pointer.zig b/test/compile_errors/stage1/obj/field_access_of_unknown_length_pointer.zig index 7097c13605..f9a37cabcc 100644 --- a/test/compile_errors/stage1/obj/field_access_of_unknown_length_pointer.zig +++ b/test/compile_errors/stage1/obj/field_access_of_unknown_length_pointer.zig @@ -6,6 +6,8 @@ export fn entry(foo: [*]Foo) void { foo.a += 1; } -// field access of unknown length pointer +// error +// backend=stage1 +// target=native // // tmp.zig:6:8: error: type '[*]Foo' does not support field access diff --git a/test/compile_errors/stage1/obj/field_type_supplied_in_an_enum.zig b/test/compile_errors/stage1/obj/field_type_supplied_in_an_enum.zig index cb308307bb..d6ba214c0c 100644 --- a/test/compile_errors/stage1/obj/field_type_supplied_in_an_enum.zig +++ b/test/compile_errors/stage1/obj/field_type_supplied_in_an_enum.zig @@ -4,7 +4,9 @@ const Letter = enum { C, }; -// field type supplied in an enum +// error +// backend=stage1 +// target=native // // tmp.zig:2:8: error: enum fields do not have types // tmp.zig:1:16: note: consider 'union(enum)' here to make it a tagged union diff --git a/test/compile_errors/stage1/obj/floatToInt_comptime_safety.zig b/test/compile_errors/stage1/obj/floatToInt_comptime_safety.zig index e54047fb2f..1e5fa746a1 100644 --- a/test/compile_errors/stage1/obj/floatToInt_comptime_safety.zig +++ b/test/compile_errors/stage1/obj/floatToInt_comptime_safety.zig @@ -8,7 +8,9 @@ comptime { _ = @floatToInt(u8, @as(f32, 256.1)); } -// @floatToInt comptime safety +// error +// backend=stage1 +// target=native // // tmp.zig:2:9: error: integer value '-129' cannot be stored in type 'i8' // tmp.zig:5:9: error: integer value '-1' cannot be stored in type 'u8' diff --git a/test/compile_errors/stage1/obj/float_literal_too_large_error.zig b/test/compile_errors/stage1/obj/float_literal_too_large_error.zig index d7be9874ac..c3865c3110 100644 --- a/test/compile_errors/stage1/obj/float_literal_too_large_error.zig +++ b/test/compile_errors/stage1/obj/float_literal_too_large_error.zig @@ -3,6 +3,8 @@ comptime { _ = a; } -// float literal too large error +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: float literal out of range of any type diff --git a/test/compile_errors/stage1/obj/float_literal_too_small_error_denormal.zig b/test/compile_errors/stage1/obj/float_literal_too_small_error_denormal.zig index 2657775be0..0b0bfee1de 100644 --- a/test/compile_errors/stage1/obj/float_literal_too_small_error_denormal.zig +++ b/test/compile_errors/stage1/obj/float_literal_too_small_error_denormal.zig @@ -3,6 +3,8 @@ comptime { _ = a; } -// float literal too small error (denormal) +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: float literal out of range of any type diff --git a/test/compile_errors/stage1/obj/for_loop_body_expression_ignored.zig b/test/compile_errors/stage1/obj/for_loop_body_expression_ignored.zig index fffbb13604..6281d4b276 100644 --- a/test/compile_errors/stage1/obj/for_loop_body_expression_ignored.zig +++ b/test/compile_errors/stage1/obj/for_loop_body_expression_ignored.zig @@ -10,7 +10,9 @@ export fn f2() void { _ = x; } -// for loop body expression ignored +// error +// backend=stage1 +// target=native // // tmp.zig:5:30: error: expression value is ignored // tmp.zig:9:30: error: expression value is ignored diff --git a/test/compile_errors/stage1/obj/frame_called_outside_of_function_definition.zig b/test/compile_errors/stage1/obj/frame_called_outside_of_function_definition.zig index a76fff93a8..d140998152 100644 --- a/test/compile_errors/stage1/obj/frame_called_outside_of_function_definition.zig +++ b/test/compile_errors/stage1/obj/frame_called_outside_of_function_definition.zig @@ -4,6 +4,8 @@ export fn entry() bool { return handle_undef == handle_dummy; } -// @frame() called outside of function definition +// error +// backend=stage1 +// target=native // // tmp.zig:2:30: error: @frame() called outside of function definition diff --git a/test/compile_errors/stage1/obj/frame_causes_function_to_be_async.zig b/test/compile_errors/stage1/obj/frame_causes_function_to_be_async.zig index b45ff6965e..f8493b08b2 100644 --- a/test/compile_errors/stage1/obj/frame_causes_function_to_be_async.zig +++ b/test/compile_errors/stage1/obj/frame_causes_function_to_be_async.zig @@ -5,7 +5,9 @@ fn func() void { _ = @frame(); } -// @frame() causes function to be async +// error +// backend=stage1 +// target=native // // tmp.zig:1:1: error: function with calling convention 'C' cannot be async // tmp.zig:5:9: note: @frame() causes function to be async diff --git a/test/compile_errors/stage1/obj/function_alignment_non_power_of_2.zig b/test/compile_errors/stage1/obj/function_alignment_non_power_of_2.zig index 949e11c115..617939a120 100644 --- a/test/compile_errors/stage1/obj/function_alignment_non_power_of_2.zig +++ b/test/compile_errors/stage1/obj/function_alignment_non_power_of_2.zig @@ -1,6 +1,8 @@ extern fn foo() align(3) void; export fn entry() void { return foo(); } -// function alignment non power of 2 +// error +// backend=stage1 +// target=native // // tmp.zig:1:23: error: alignment value 3 is not a power of 2 diff --git a/test/compile_errors/stage1/obj/function_call_assigned_to_incorrect_type.zig b/test/compile_errors/stage1/obj/function_call_assigned_to_incorrect_type.zig index 4257b802c1..51bc82ffb8 100644 --- a/test/compile_errors/stage1/obj/function_call_assigned_to_incorrect_type.zig +++ b/test/compile_errors/stage1/obj/function_call_assigned_to_incorrect_type.zig @@ -6,6 +6,8 @@ fn concat() [16]f32 { return [1]f32{0}**16; } -// function call assigned to incorrect type +// error +// backend=stage1 +// target=native // // tmp.zig:3:17: error: expected type '[4]f32', found '[16]f32' diff --git a/test/compile_errors/stage1/obj/function_parameter_is_opaque.zig b/test/compile_errors/stage1/obj/function_parameter_is_opaque.zig index 12e50ca59b..5b52370d86 100644 --- a/test/compile_errors/stage1/obj/function_parameter_is_opaque.zig +++ b/test/compile_errors/stage1/obj/function_parameter_is_opaque.zig @@ -19,7 +19,9 @@ export fn entry4() void { _ = bar; } -// function parameter is opaque +// error +// backend=stage1 +// target=native // // tmp.zig:3:28: error: parameter of opaque type 'FooType' not allowed // tmp.zig:8:28: error: parameter of type '@Type(.Null)' not allowed diff --git a/test/compile_errors/stage1/obj/function_prototype_with_no_body.zig b/test/compile_errors/stage1/obj/function_prototype_with_no_body.zig index 07597af015..7926faaa44 100644 --- a/test/compile_errors/stage1/obj/function_prototype_with_no_body.zig +++ b/test/compile_errors/stage1/obj/function_prototype_with_no_body.zig @@ -3,6 +3,8 @@ export fn entry() void { foo(); } -// function prototype with no body +// error +// backend=stage1 +// target=native // // tmp.zig:1:1: error: non-extern function has no body diff --git a/test/compile_errors/stage1/obj/function_returning_opaque_type.zig b/test/compile_errors/stage1/obj/function_returning_opaque_type.zig index 956a4ed224..e2c084b517 100644 --- a/test/compile_errors/stage1/obj/function_returning_opaque_type.zig +++ b/test/compile_errors/stage1/obj/function_returning_opaque_type.zig @@ -9,7 +9,9 @@ export fn baz() !@TypeOf(undefined) { return error.InvalidValue; } -// function returning opaque type +// error +// backend=stage1 +// target=native // // tmp.zig:2:18: error: Opaque return type 'FooType' not allowed // tmp.zig:1:1: note: type declared here diff --git a/test/compile_errors/stage1/obj/function_with_ccc_indirectly_calling_async_function.zig b/test/compile_errors/stage1/obj/function_with_ccc_indirectly_calling_async_function.zig index 1ccf486be6..9fadb992b4 100644 --- a/test/compile_errors/stage1/obj/function_with_ccc_indirectly_calling_async_function.zig +++ b/test/compile_errors/stage1/obj/function_with_ccc_indirectly_calling_async_function.zig @@ -8,7 +8,9 @@ fn bar() void { suspend {} } -// function with ccc indirectly calling async function +// error +// backend=stage1 +// target=native // // tmp.zig:1:1: error: function with calling convention 'C' cannot be async // tmp.zig:2:8: note: async function call here diff --git a/test/compile_errors/stage1/obj/function_with_invalid_return_type.zig b/test/compile_errors/stage1/obj/function_with_invalid_return_type.zig index acedbac7d1..897b298a3d 100644 --- a/test/compile_errors/stage1/obj/function_with_invalid_return_type.zig +++ b/test/compile_errors/stage1/obj/function_with_invalid_return_type.zig @@ -1,5 +1,7 @@ export fn foo() boid {} -// function with invalid return type +// error +// backend=stage1 +// target=native // // tmp.zig:1:17: error: use of undeclared identifier 'boid' diff --git a/test/compile_errors/stage1/obj/function_with_non-extern_non-packed_enum_parameter.zig b/test/compile_errors/stage1/obj/function_with_non-extern_non-packed_enum_parameter.zig index 9c1913305d..8de26c08b8 100644 --- a/test/compile_errors/stage1/obj/function_with_non-extern_non-packed_enum_parameter.zig +++ b/test/compile_errors/stage1/obj/function_with_non-extern_non-packed_enum_parameter.zig @@ -1,6 +1,8 @@ const Foo = enum { A, B, C }; export fn entry(foo: Foo) void { _ = foo; } -// function with non-extern non-packed enum parameter +// error +// backend=stage1 +// target=native // // tmp.zig:2:22: error: parameter of type 'Foo' not allowed in function with calling convention 'C' diff --git a/test/compile_errors/stage1/obj/function_with_non-extern_non-packed_struct_parameter.zig b/test/compile_errors/stage1/obj/function_with_non-extern_non-packed_struct_parameter.zig index eb2617f279..ecb4a36267 100644 --- a/test/compile_errors/stage1/obj/function_with_non-extern_non-packed_struct_parameter.zig +++ b/test/compile_errors/stage1/obj/function_with_non-extern_non-packed_struct_parameter.zig @@ -5,6 +5,8 @@ const Foo = struct { }; export fn entry(foo: Foo) void { _ = foo; } -// function with non-extern non-packed struct parameter +// error +// backend=stage1 +// target=native // // tmp.zig:6:22: error: parameter of type 'Foo' not allowed in function with calling convention 'C' diff --git a/test/compile_errors/stage1/obj/function_with_non-extern_non-packed_union_parameter.zig b/test/compile_errors/stage1/obj/function_with_non-extern_non-packed_union_parameter.zig index 662ffd349b..bfe2dc6cfa 100644 --- a/test/compile_errors/stage1/obj/function_with_non-extern_non-packed_union_parameter.zig +++ b/test/compile_errors/stage1/obj/function_with_non-extern_non-packed_union_parameter.zig @@ -5,6 +5,8 @@ const Foo = union { }; export fn entry(foo: Foo) void { _ = foo; } -// function with non-extern non-packed union parameter +// error +// backend=stage1 +// target=native // // tmp.zig:6:22: error: parameter of type 'Foo' not allowed in function with calling convention 'C' diff --git a/test/compile_errors/stage1/obj/generic_fn_as_parameter_without_comptime_keyword.zig b/test/compile_errors/stage1/obj/generic_fn_as_parameter_without_comptime_keyword.zig index fceea0961b..72e27e3a0d 100644 --- a/test/compile_errors/stage1/obj/generic_fn_as_parameter_without_comptime_keyword.zig +++ b/test/compile_errors/stage1/obj/generic_fn_as_parameter_without_comptime_keyword.zig @@ -4,6 +4,8 @@ export fn entry() void { f(g); } -// generic fn as parameter without comptime keyword +// error +// backend=stage1 +// target=native // // tmp.zig:1:9: error: parameter of type 'fn(anytype) anytype' must be declared comptime diff --git a/test/compile_errors/stage1/obj/generic_function_call_assigned_to_incorrect_type.zig b/test/compile_errors/stage1/obj/generic_function_call_assigned_to_incorrect_type.zig index b48d5def57..72ed66b20a 100644 --- a/test/compile_errors/stage1/obj/generic_function_call_assigned_to_incorrect_type.zig +++ b/test/compile_errors/stage1/obj/generic_function_call_assigned_to_incorrect_type.zig @@ -6,6 +6,8 @@ fn myAlloc(comptime arg: type) anyerror!arg{ unreachable; } -// generic function call assigned to incorrect type +// error +// backend=stage1 +// target=native // // tmp.zig:3:18: error: expected type '[]i32', found 'anyerror!i32 diff --git a/test/compile_errors/stage1/obj/generic_function_instance_with_non-constant_expression.zig b/test/compile_errors/stage1/obj/generic_function_instance_with_non-constant_expression.zig index 3698370b57..9cdd653766 100644 --- a/test/compile_errors/stage1/obj/generic_function_instance_with_non-constant_expression.zig +++ b/test/compile_errors/stage1/obj/generic_function_instance_with_non-constant_expression.zig @@ -5,6 +5,8 @@ fn test1(a: i32, b: i32) i32 { export fn entry() usize { return @sizeOf(@TypeOf(test1)); } -// generic function instance with non-constant expression +// error +// backend=stage1 +// target=native // // tmp.zig:3:16: error: runtime value cannot be passed to comptime arg diff --git a/test/compile_errors/stage1/obj/generic_function_returning_opaque_type.zig b/test/compile_errors/stage1/obj/generic_function_returning_opaque_type.zig index c109a5ce7c..247c1a49bf 100644 --- a/test/compile_errors/stage1/obj/generic_function_returning_opaque_type.zig +++ b/test/compile_errors/stage1/obj/generic_function_returning_opaque_type.zig @@ -12,7 +12,9 @@ export fn baz() void { _ = generic(@TypeOf(undefined)); } -// generic function returning opaque type +// error +// backend=stage1 +// target=native // // tmp.zig:6:16: error: call to generic function with Opaque return type 'FooType' not allowed // tmp.zig:2:1: note: function declared here diff --git a/test/compile_errors/stage1/obj/generic_function_where_return_type_is_self-referenced.zig b/test/compile_errors/stage1/obj/generic_function_where_return_type_is_self-referenced.zig index 18237a5023..c8d31ec8df 100644 --- a/test/compile_errors/stage1/obj/generic_function_where_return_type_is_self-referenced.zig +++ b/test/compile_errors/stage1/obj/generic_function_where_return_type_is_self-referenced.zig @@ -8,6 +8,8 @@ export fn entry() void { _ = t; } -// generic function where return type is self-referenced +// error +// backend=stage1 +// target=native // // tmp.zig:1:29: error: evaluation exceeded 1000 backwards branches diff --git a/test/compile_errors/stage1/obj/global_variable_alignment_non_power_of_2.zig b/test/compile_errors/stage1/obj/global_variable_alignment_non_power_of_2.zig index a6c4ccaa98..f23f340b16 100644 --- a/test/compile_errors/stage1/obj/global_variable_alignment_non_power_of_2.zig +++ b/test/compile_errors/stage1/obj/global_variable_alignment_non_power_of_2.zig @@ -1,6 +1,8 @@ const some_data: [100]u8 align(3) = undefined; export fn entry() usize { return @sizeOf(@TypeOf(some_data)); } -// global variable alignment non power of 2 +// error +// backend=stage1 +// target=native // // tmp.zig:1:32: error: alignment value 3 is not a power of 2 diff --git a/test/compile_errors/stage1/obj/global_variable_initializer_must_be_constant_expression.zig b/test/compile_errors/stage1/obj/global_variable_initializer_must_be_constant_expression.zig index 1d6c20f3af..d01e828da6 100644 --- a/test/compile_errors/stage1/obj/global_variable_initializer_must_be_constant_expression.zig +++ b/test/compile_errors/stage1/obj/global_variable_initializer_must_be_constant_expression.zig @@ -2,6 +2,8 @@ extern fn foo() i32; const x = foo(); export fn entry() i32 { return x; } -// global variable initializer must be constant expression +// error +// backend=stage1 +// target=native // // tmp.zig:2:11: error: unable to evaluate constant expression diff --git a/test/compile_errors/stage1/obj/hasDecl_with_non-container.zig b/test/compile_errors/stage1/obj/hasDecl_with_non-container.zig index 50f1231997..e9aeacdd4e 100644 --- a/test/compile_errors/stage1/obj/hasDecl_with_non-container.zig +++ b/test/compile_errors/stage1/obj/hasDecl_with_non-container.zig @@ -2,6 +2,8 @@ export fn entry() void { _ = @hasDecl(i32, "hi"); } -// @hasDecl with non-container +// error +// backend=stage1 +// target=native // // tmp.zig:2:18: error: expected struct, enum, or union; found 'i32' diff --git a/test/compile_errors/stage1/obj/if_condition_is_bool_not_int.zig b/test/compile_errors/stage1/obj/if_condition_is_bool_not_int.zig index e8b7c61417..53afb2792a 100644 --- a/test/compile_errors/stage1/obj/if_condition_is_bool_not_int.zig +++ b/test/compile_errors/stage1/obj/if_condition_is_bool_not_int.zig @@ -2,6 +2,8 @@ export fn f() void { if (0) {} } -// if condition is bool, not int +// error +// backend=stage1 +// target=native // // tmp.zig:2:9: error: expected type 'bool', found 'comptime_int' diff --git a/test/compile_errors/stage1/obj/ignored_assert-err-ok_return_value.zig b/test/compile_errors/stage1/obj/ignored_assert-err-ok_return_value.zig index 53fbcaa8b5..4d45ae1304 100644 --- a/test/compile_errors/stage1/obj/ignored_assert-err-ok_return_value.zig +++ b/test/compile_errors/stage1/obj/ignored_assert-err-ok_return_value.zig @@ -3,6 +3,8 @@ export fn foo() void { } fn bar() anyerror!i32 { return 0; } -// ignored assert-err-ok return value +// error +// backend=stage1 +// target=native // // tmp.zig:2:11: error: expression value is ignored diff --git a/test/compile_errors/stage1/obj/ignored_comptime_statement_value.zig b/test/compile_errors/stage1/obj/ignored_comptime_statement_value.zig index 80925d6c84..0e82c9ae3e 100644 --- a/test/compile_errors/stage1/obj/ignored_comptime_statement_value.zig +++ b/test/compile_errors/stage1/obj/ignored_comptime_statement_value.zig @@ -2,6 +2,8 @@ export fn foo() void { comptime {1;} } -// ignored comptime statement value +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: expression value is ignored diff --git a/test/compile_errors/stage1/obj/ignored_comptime_value.zig b/test/compile_errors/stage1/obj/ignored_comptime_value.zig index 375a5d242c..0306ea72ff 100644 --- a/test/compile_errors/stage1/obj/ignored_comptime_value.zig +++ b/test/compile_errors/stage1/obj/ignored_comptime_value.zig @@ -2,6 +2,8 @@ export fn foo() void { comptime 1; } -// ignored comptime value +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: expression value is ignored diff --git a/test/compile_errors/stage1/obj/ignored_deferred_function_call.zig b/test/compile_errors/stage1/obj/ignored_deferred_function_call.zig index 58b85da985..41812bfda9 100644 --- a/test/compile_errors/stage1/obj/ignored_deferred_function_call.zig +++ b/test/compile_errors/stage1/obj/ignored_deferred_function_call.zig @@ -3,6 +3,8 @@ export fn foo() void { } fn bar() anyerror!i32 { return 0; } -// ignored deferred function call +// error +// backend=stage1 +// target=native // // tmp.zig:2:14: error: error is ignored. consider using `try`, `catch`, or `if` diff --git a/test/compile_errors/stage1/obj/ignored_deferred_statement_value.zig b/test/compile_errors/stage1/obj/ignored_deferred_statement_value.zig index effc79b039..1042c4f40a 100644 --- a/test/compile_errors/stage1/obj/ignored_deferred_statement_value.zig +++ b/test/compile_errors/stage1/obj/ignored_deferred_statement_value.zig @@ -2,6 +2,8 @@ export fn foo() void { defer {1;} } -// ignored deferred statement value +// error +// backend=stage1 +// target=native // // tmp.zig:2:12: error: expression value is ignored diff --git a/test/compile_errors/stage1/obj/ignored_expression_in_while_continuation.zig b/test/compile_errors/stage1/obj/ignored_expression_in_while_continuation.zig index fb205924e3..43f3713fc6 100644 --- a/test/compile_errors/stage1/obj/ignored_expression_in_while_continuation.zig +++ b/test/compile_errors/stage1/obj/ignored_expression_in_while_continuation.zig @@ -13,7 +13,9 @@ fn bad() anyerror!void { return error.Bad; } -// ignored expression in while continuation +// error +// backend=stage1 +// target=native // // tmp.zig:2:24: error: error is ignored. consider using `try`, `catch`, or `if` // tmp.zig:6:25: error: error is ignored. consider using `try`, `catch`, or `if` diff --git a/test/compile_errors/stage1/obj/ignored_return_value.zig b/test/compile_errors/stage1/obj/ignored_return_value.zig index 9c8cfa0aa4..b918523b37 100644 --- a/test/compile_errors/stage1/obj/ignored_return_value.zig +++ b/test/compile_errors/stage1/obj/ignored_return_value.zig @@ -3,6 +3,8 @@ export fn foo() void { } fn bar() i32 { return 0; } -// ignored return value +// error +// backend=stage1 +// target=native // // tmp.zig:2:8: error: expression value is ignored diff --git a/test/compile_errors/stage1/obj/ignored_statement_value.zig b/test/compile_errors/stage1/obj/ignored_statement_value.zig index 7855cf584b..a0e540a92b 100644 --- a/test/compile_errors/stage1/obj/ignored_statement_value.zig +++ b/test/compile_errors/stage1/obj/ignored_statement_value.zig @@ -2,6 +2,8 @@ export fn foo() void { 1; } -// ignored statement value +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: expression value is ignored diff --git a/test/compile_errors/stage1/obj/illegal_comparison_of_types.zig b/test/compile_errors/stage1/obj/illegal_comparison_of_types.zig index 462664a400..d04eaec3b5 100644 --- a/test/compile_errors/stage1/obj/illegal_comparison_of_types.zig +++ b/test/compile_errors/stage1/obj/illegal_comparison_of_types.zig @@ -12,7 +12,9 @@ fn bad_eql_2(a: *const EnumWithData, b: *const EnumWithData) bool { export fn entry1() usize { return @sizeOf(@TypeOf(bad_eql_1)); } export fn entry2() usize { return @sizeOf(@TypeOf(bad_eql_2)); } -// illegal comparison of types +// error +// backend=stage1 +// target=native // // tmp.zig:2:14: error: operator not allowed for type '[]u8' // tmp.zig:9:16: error: operator not allowed for type 'EnumWithData' diff --git a/test/compile_errors/stage1/obj/implicit_cast_between_C_pointer_and_Zig_pointer-bad_const-align-child.zig b/test/compile_errors/stage1/obj/implicit_cast_between_C_pointer_and_Zig_pointer-bad_const-align-child.zig index 1dd751f989..6ff155b591 100644 --- a/test/compile_errors/stage1/obj/implicit_cast_between_C_pointer_and_Zig_pointer-bad_const-align-child.zig +++ b/test/compile_errors/stage1/obj/implicit_cast_between_C_pointer_and_Zig_pointer-bad_const-align-child.zig @@ -29,7 +29,9 @@ export fn f() void { _ = x; } -// implicit cast between C pointer and Zig pointer - bad const/align/child +// error +// backend=stage1 +// target=native // // tmp.zig:3:27: error: cast increases pointer alignment // tmp.zig:8:18: error: cast discards const qualifier diff --git a/test/compile_errors/stage1/obj/implicit_cast_const_array_to_mutable_slice.zig b/test/compile_errors/stage1/obj/implicit_cast_const_array_to_mutable_slice.zig index f38c2c9fe1..3f22cbed6b 100644 --- a/test/compile_errors/stage1/obj/implicit_cast_const_array_to_mutable_slice.zig +++ b/test/compile_errors/stage1/obj/implicit_cast_const_array_to_mutable_slice.zig @@ -4,7 +4,9 @@ export fn entry() void { _ = sliceA; } -// implicit cast const array to mutable slice +// error +// backend=stage1 +// target=native // // tmp.zig:3:27: error: cannot cast pointer to array literal to slice type '[]u8' // tmp.zig:3:27: note: cast discards const qualifier diff --git a/test/compile_errors/stage1/obj/implicit_cast_from_array_to_mutable_slice.zig b/test/compile_errors/stage1/obj/implicit_cast_from_array_to_mutable_slice.zig index 60fc5baf1f..012555928c 100644 --- a/test/compile_errors/stage1/obj/implicit_cast_from_array_to_mutable_slice.zig +++ b/test/compile_errors/stage1/obj/implicit_cast_from_array_to_mutable_slice.zig @@ -4,6 +4,8 @@ export fn entry() void { foo(global_array); } -// implicit cast from array to mutable slice +// error +// backend=stage1 +// target=native // // tmp.zig:4:9: error: expected type '[]i32', found '[10]i32' diff --git a/test/compile_errors/stage1/obj/implicit_cast_from_f64_to_f32.zig b/test/compile_errors/stage1/obj/implicit_cast_from_f64_to_f32.zig index d1d4417f34..f18a46b7f5 100644 --- a/test/compile_errors/stage1/obj/implicit_cast_from_f64_to_f32.zig +++ b/test/compile_errors/stage1/obj/implicit_cast_from_f64_to_f32.zig @@ -3,6 +3,8 @@ var y: f32 = x; export fn entry() usize { return @sizeOf(@TypeOf(y)); } -// implicit cast from f64 to f32 +// error +// backend=stage1 +// target=native // // tmp.zig:2:14: error: expected type 'f32', found 'f64' diff --git a/test/compile_errors/stage1/obj/implicit_cast_of_error_set_not_a_subset.zig b/test/compile_errors/stage1/obj/implicit_cast_of_error_set_not_a_subset.zig index 9cfce6524f..5958a41639 100644 --- a/test/compile_errors/stage1/obj/implicit_cast_of_error_set_not_a_subset.zig +++ b/test/compile_errors/stage1/obj/implicit_cast_of_error_set_not_a_subset.zig @@ -8,7 +8,9 @@ fn foo(set1: Set1) void { _ = x; } -// implicit cast of error set not a subset +// error +// backend=stage1 +// target=native // // tmp.zig:7:19: error: expected type 'Set2', found 'Set1' // tmp.zig:1:23: note: 'error.B' not a member of destination error set diff --git a/test/compile_errors/stage1/obj/implicit_casting_C_pointers_which_would_mess_up_null_semantics.zig b/test/compile_errors/stage1/obj/implicit_casting_C_pointers_which_would_mess_up_null_semantics.zig index cdc35e3963..760bab41da 100644 --- a/test/compile_errors/stage1/obj/implicit_casting_C_pointers_which_would_mess_up_null_semantics.zig +++ b/test/compile_errors/stage1/obj/implicit_casting_C_pointers_which_would_mess_up_null_semantics.zig @@ -14,7 +14,9 @@ export fn entry2() void { _ = c_ptr; } -// implicit casting C pointers which would mess up null semantics +// error +// backend=stage1 +// target=native // // tmp.zig:6:24: error: expected type '*const [*]const u8', found '[*c]const [*c]const u8' // tmp.zig:6:24: note: pointer type child '[*c]const u8' cannot cast into pointer type child '[*]const u8' diff --git a/test/compile_errors/stage1/obj/implicit_casting_null_c_pointer_to_zig_pointer.zig b/test/compile_errors/stage1/obj/implicit_casting_null_c_pointer_to_zig_pointer.zig index 29dd6d06f9..0bd38d868b 100644 --- a/test/compile_errors/stage1/obj/implicit_casting_null_c_pointer_to_zig_pointer.zig +++ b/test/compile_errors/stage1/obj/implicit_casting_null_c_pointer_to_zig_pointer.zig @@ -4,6 +4,8 @@ comptime { _ = zig_ptr; } -// implicit casting null c pointer to zig pointer +// error +// backend=stage1 +// target=native // // tmp.zig:3:24: error: null pointer casted to type '*u8' diff --git a/test/compile_errors/stage1/obj/implicit_casting_too_big_integers_to_C_pointers.zig b/test/compile_errors/stage1/obj/implicit_casting_too_big_integers_to_C_pointers.zig index 3deb817b76..f142540ff6 100644 --- a/test/compile_errors/stage1/obj/implicit_casting_too_big_integers_to_C_pointers.zig +++ b/test/compile_errors/stage1/obj/implicit_casting_too_big_integers_to_C_pointers.zig @@ -8,7 +8,9 @@ export fn b() void { _ = ptr; } -// implicit casting too big integers to C pointers +// error +// backend=stage1 +// target=native // // tmp.zig:2:33: error: integer value 18446744073709551617 cannot be coerced to type 'usize' // tmp.zig:7:23: error: integer type 'u65' too big for implicit @intToPtr to type '[*c]u8' diff --git a/test/compile_errors/stage1/obj/implicit_casting_undefined_c_pointer_to_zig_pointer.zig b/test/compile_errors/stage1/obj/implicit_casting_undefined_c_pointer_to_zig_pointer.zig index 4c19f57442..5554146fa5 100644 --- a/test/compile_errors/stage1/obj/implicit_casting_undefined_c_pointer_to_zig_pointer.zig +++ b/test/compile_errors/stage1/obj/implicit_casting_undefined_c_pointer_to_zig_pointer.zig @@ -4,6 +4,8 @@ comptime { _ = zig_ptr; } -// implicit casting undefined c pointer to zig pointer +// error +// backend=stage1 +// target=native // // tmp.zig:3:24: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/implicit_dependency_on_libc.zig b/test/compile_errors/stage1/obj/implicit_dependency_on_libc.zig new file mode 100644 index 0000000000..f069f78551 --- /dev/null +++ b/test/compile_errors/stage1/obj/implicit_dependency_on_libc.zig @@ -0,0 +1,11 @@ +extern "c" fn exit(u8) void; +export fn entry() void { + exit(0); +} + +// error +// backend=stage1 +// target=native-linux +// is_test=1 +// +// tmp.zig:3:5: error: dependency on libc must be explicitly specified in the build command diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-block_expr.zig b/test/compile_errors/stage1/obj/implicit_semicolon-block_expr.zig index bacd484c0c..a57da8ac0b 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-block_expr.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-block_expr.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - block expr +// error +// backend=stage1 +// target=native // // tmp.zig:4:11: error: expected ';' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-block_statement.zig b/test/compile_errors/stage1/obj/implicit_semicolon-block_statement.zig index dca8998ee6..2d9d850e75 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-block_statement.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-block_statement.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - block statement +// error +// backend=stage1 +// target=native // // tmp.zig:4:9: error: expected ';' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-comptime_expression.zig b/test/compile_errors/stage1/obj/implicit_semicolon-comptime_expression.zig index a3f679a59a..b4cd4de849 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-comptime_expression.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-comptime_expression.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - comptime expression +// error +// backend=stage1 +// target=native // // tmp.zig:4:20: error: expected ';' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-comptime_statement.zig b/test/compile_errors/stage1/obj/implicit_semicolon-comptime_statement.zig index 299b081e4b..3b83ef92eb 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-comptime_statement.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-comptime_statement.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - comptime statement +// error +// backend=stage1 +// target=native // // tmp.zig:4:18: error: expected ';' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-defer.zig b/test/compile_errors/stage1/obj/implicit_semicolon-defer.zig index 7e58d930d6..0ded4fcf26 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-defer.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-defer.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - defer +// error +// backend=stage1 +// target=native // // tmp.zig:4:15: error: expected ';' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-for_expression.zig b/test/compile_errors/stage1/obj/implicit_semicolon-for_expression.zig index 3e332ef189..964a48d30b 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-for_expression.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-for_expression.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - for expression +// error +// backend=stage1 +// target=native // // tmp.zig:4:26: error: expected ';' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-for_statement.zig b/test/compile_errors/stage1/obj/implicit_semicolon-for_statement.zig index 092c28889f..1320e4cc46 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-for_statement.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-for_statement.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - for statement +// error +// backend=stage1 +// target=native // // tmp.zig:4:24: error: expected ';' or 'else' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-if-else-if-else_expression.zig b/test/compile_errors/stage1/obj/implicit_semicolon-if-else-if-else_expression.zig index fd55529a8f..40b1a33d78 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-if-else-if-else_expression.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-if-else-if-else_expression.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - if-else-if-else expression +// error +// backend=stage1 +// target=native // // tmp.zig:4:45: error: expected ';' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-if-else-if-else_statement.zig b/test/compile_errors/stage1/obj/implicit_semicolon-if-else-if-else_statement.zig index 3d59e38aa9..8444fe654d 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-if-else-if-else_statement.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-if-else-if-else_statement.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - if-else-if-else statement +// error +// backend=stage1 +// target=native // // tmp.zig:4:47: error: expected ';' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-if-else-if_expression.zig b/test/compile_errors/stage1/obj/implicit_semicolon-if-else-if_expression.zig index 2caaad52b8..7466d64691 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-if-else-if_expression.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-if-else-if_expression.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - if-else-if expression +// error +// backend=stage1 +// target=native // // tmp.zig:4:37: error: expected ';' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-if-else-if_statement.zig b/test/compile_errors/stage1/obj/implicit_semicolon-if-else-if_statement.zig index 263aa36da3..34e116b3f7 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-if-else-if_statement.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-if-else-if_statement.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - if-else-if statement +// error +// backend=stage1 +// target=native // // tmp.zig:4:37: error: expected ';' or 'else' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-if-else_expression.zig b/test/compile_errors/stage1/obj/implicit_semicolon-if-else_expression.zig index 12d993f6a7..3c1e0add62 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-if-else_expression.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-if-else_expression.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - if-else expression +// error +// backend=stage1 +// target=native // // tmp.zig:4:28: error: expected ';' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-if-else_statement.zig b/test/compile_errors/stage1/obj/implicit_semicolon-if-else_statement.zig index 401fc46a51..e9c52fb6bb 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-if-else_statement.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-if-else_statement.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - if-else statement +// error +// backend=stage1 +// target=native // // tmp.zig:4:28: error: expected ';' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-if_expression.zig b/test/compile_errors/stage1/obj/implicit_semicolon-if_expression.zig index b3a81e9d36..2082588e0e 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-if_expression.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-if_expression.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - if expression +// error +// backend=stage1 +// target=native // // tmp.zig:4:20: error: expected ';' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-if_statement.zig b/test/compile_errors/stage1/obj/implicit_semicolon-if_statement.zig index e543925d78..26cefd0237 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-if_statement.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-if_statement.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - if statement +// error +// backend=stage1 +// target=native // // tmp.zig:4:18: error: expected ';' or 'else' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-test_expression.zig b/test/compile_errors/stage1/obj/implicit_semicolon-test_expression.zig index 1702bec048..c31f3520c1 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-test_expression.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-test_expression.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - test expression +// error +// backend=stage1 +// target=native // // tmp.zig:4:26: error: expected ';' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-test_statement.zig b/test/compile_errors/stage1/obj/implicit_semicolon-test_statement.zig index 8715ca9ac0..8abb1cbcb1 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-test_statement.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-test_statement.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - test statement +// error +// backend=stage1 +// target=native // // tmp.zig:4:24: error: expected ';' or 'else' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-while-continue_expression.zig b/test/compile_errors/stage1/obj/implicit_semicolon-while-continue_expression.zig index b1a7bdbab8..4d3219eb66 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-while-continue_expression.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-while-continue_expression.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - while-continue expression +// error +// backend=stage1 +// target=native // // tmp.zig:4:28: error: expected ';' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-while-continue_statement.zig b/test/compile_errors/stage1/obj/implicit_semicolon-while-continue_statement.zig index 601f1f0318..c0b3370357 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-while-continue_statement.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-while-continue_statement.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - while-continue statement +// error +// backend=stage1 +// target=native // // tmp.zig:4:26: error: expected ';' or 'else' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-while_expression.zig b/test/compile_errors/stage1/obj/implicit_semicolon-while_expression.zig index 9580889bd7..39f49319d5 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-while_expression.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-while_expression.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - while expression +// error +// backend=stage1 +// target=native // // tmp.zig:4:23: error: expected ';' after statement diff --git a/test/compile_errors/stage1/obj/implicit_semicolon-while_statement.zig b/test/compile_errors/stage1/obj/implicit_semicolon-while_statement.zig index ab64dd991d..6c253ecf56 100644 --- a/test/compile_errors/stage1/obj/implicit_semicolon-while_statement.zig +++ b/test/compile_errors/stage1/obj/implicit_semicolon-while_statement.zig @@ -5,6 +5,8 @@ export fn entry() void { var bad = {}; } -// implicit semicolon - while statement +// error +// backend=stage1 +// target=native // // tmp.zig:4:18: error: expected ';' or 'else' after statement diff --git a/test/compile_errors/stage1/obj/implicitly_casting_enum_to_tag_type.zig b/test/compile_errors/stage1/obj/implicitly_casting_enum_to_tag_type.zig index 26806a3914..a40615f99b 100644 --- a/test/compile_errors/stage1/obj/implicitly_casting_enum_to_tag_type.zig +++ b/test/compile_errors/stage1/obj/implicitly_casting_enum_to_tag_type.zig @@ -10,6 +10,8 @@ export fn entry() void { _ = x; } -// implicitly casting enum to tag type +// error +// backend=stage1 +// target=native // // tmp.zig:9:22: error: expected type 'u2', found 'Small' diff --git a/test/compile_errors/stage1/obj/implicitly_increasing_pointer_alignment.zig b/test/compile_errors/stage1/obj/implicitly_increasing_pointer_alignment.zig index 8f743a3b59..3743eef0b2 100644 --- a/test/compile_errors/stage1/obj/implicitly_increasing_pointer_alignment.zig +++ b/test/compile_errors/stage1/obj/implicitly_increasing_pointer_alignment.zig @@ -12,6 +12,8 @@ fn bar(x: *u32) void { x.* += 1; } -// implicitly increasing pointer alignment +// error +// backend=stage1 +// target=native // // tmp.zig:8:13: error: expected type '*u32', found '*align(1) u32' diff --git a/test/compile_errors/stage1/obj/implicitly_increasing_slice_alignment.zig b/test/compile_errors/stage1/obj/implicitly_increasing_slice_alignment.zig index c1d4ec2a0f..2e5c201b5d 100644 --- a/test/compile_errors/stage1/obj/implicitly_increasing_slice_alignment.zig +++ b/test/compile_errors/stage1/obj/implicitly_increasing_slice_alignment.zig @@ -13,7 +13,9 @@ fn bar(x: []u32) void { x[0] += 1; } -// implicitly increasing slice alignment +// error +// backend=stage1 +// target=native // // tmp.zig:9:26: error: cast increases pointer alignment // tmp.zig:9:26: note: '*align(1) u32' has alignment 1 diff --git a/test/compile_errors/stage1/obj/import_outside_package_path.zig b/test/compile_errors/stage1/obj/import_outside_package_path.zig index 843de67b63..5a712c2e01 100644 --- a/test/compile_errors/stage1/obj/import_outside_package_path.zig +++ b/test/compile_errors/stage1/obj/import_outside_package_path.zig @@ -2,6 +2,8 @@ comptime{ _ = @import("../a.zig"); } -// import outside package path +// error +// backend=stage1 +// target=native // // tmp.zig:2:9: error: import of file outside package path: '../a.zig' diff --git a/test/compile_errors/stage1/obj/incompatible_sentinels.zig b/test/compile_errors/stage1/obj/incompatible_sentinels.zig new file mode 100644 index 0000000000..a292ae3d7c --- /dev/null +++ b/test/compile_errors/stage1/obj/incompatible_sentinels.zig @@ -0,0 +1,29 @@ +// Note: One of the error messages here is backwards. It would be nice to fix, but that's not +// going to stop me from merging this branch which fixes a bunch of other stuff. +export fn entry1(ptr: [*:255]u8) [*:0]u8 { + return ptr; +} +export fn entry2(ptr: [*]u8) [*:0]u8 { + return ptr; +} +export fn entry3() void { + var array: [2:0]u8 = [_:255]u8{ 1, 2 }; + _ = array; +} +export fn entry4() void { + var array: [2:0]u8 = [_]u8{ 1, 2 }; + _ = array; +} + +// error +// backend=stage1 +// target=native +// +// tmp.zig:4:12: error: expected type '[*:0]u8', found '[*:255]u8' +// tmp.zig:4:12: note: destination pointer requires a terminating '0' sentinel, but source pointer has a terminating '255' sentinel +// tmp.zig:7:12: error: expected type '[*:0]u8', found '[*]u8' +// tmp.zig:7:12: note: destination pointer requires a terminating '0' sentinel +// tmp.zig:10:35: error: expected type '[2:255]u8', found '[2:0]u8' +// tmp.zig:10:35: note: destination array requires a terminating '255' sentinel, but source array has a terminating '0' sentinel +// tmp.zig:14:31: error: expected type '[2:0]u8', found '[2]u8' +// tmp.zig:14:31: note: destination array requires a terminating '0' sentinel diff --git a/test/compile_errors/stage1/obj/incorrect_return_type.zig b/test/compile_errors/stage1/obj/incorrect_return_type.zig index 86c5f23dc3..b25e2a8ea4 100644 --- a/test/compile_errors/stage1/obj/incorrect_return_type.zig +++ b/test/compile_errors/stage1/obj/incorrect_return_type.zig @@ -14,6 +14,8 @@ unreachable; } -// incorrect return type +// error +// backend=stage1 +// target=native // // tmp.zig:8:16: error: expected type 'A', found 'B' diff --git a/test/compile_errors/stage1/obj/increase_pointer_alignment_in_ptrCast.zig b/test/compile_errors/stage1/obj/increase_pointer_alignment_in_ptrCast.zig index 01d8ac821e..f3f67ca4c6 100644 --- a/test/compile_errors/stage1/obj/increase_pointer_alignment_in_ptrCast.zig +++ b/test/compile_errors/stage1/obj/increase_pointer_alignment_in_ptrCast.zig @@ -4,7 +4,9 @@ export fn entry() u32 { return ptr.*; } -// increase pointer alignment in @ptrCast +// error +// backend=stage1 +// target=native // // tmp.zig:3:17: error: cast increases pointer alignment // tmp.zig:3:38: note: '*u8' has alignment 1 diff --git a/test/compile_errors/stage1/obj/indexing_a_undefined_slice_at_comptime.zig b/test/compile_errors/stage1/obj/indexing_a_undefined_slice_at_comptime.zig index 4653d8668e..70b0c68658 100644 --- a/test/compile_errors/stage1/obj/indexing_a_undefined_slice_at_comptime.zig +++ b/test/compile_errors/stage1/obj/indexing_a_undefined_slice_at_comptime.zig @@ -3,6 +3,8 @@ comptime { slice[0] = 2; } -// indexing a undefined slice at comptime +// error +// backend=stage1 +// target=native // // tmp.zig:3:10: error: index 0 outside slice of size 0 diff --git a/test/compile_errors/stage1/obj/indexing_an_array_of_size_zero.zig b/test/compile_errors/stage1/obj/indexing_an_array_of_size_zero.zig index 9066985de5..dfb2e7c1c3 100644 --- a/test/compile_errors/stage1/obj/indexing_an_array_of_size_zero.zig +++ b/test/compile_errors/stage1/obj/indexing_an_array_of_size_zero.zig @@ -4,6 +4,8 @@ export fn foo() void { _ = pointer; } -// indexing an array of size zero +// error +// backend=stage1 +// target=native // // tmp.zig:3:27: error: accessing a zero length array is not allowed diff --git a/test/compile_errors/stage1/obj/indexing_an_array_of_size_zero_with_runtime_index.zig b/test/compile_errors/stage1/obj/indexing_an_array_of_size_zero_with_runtime_index.zig index c5f3acb3cc..f50931312e 100644 --- a/test/compile_errors/stage1/obj/indexing_an_array_of_size_zero_with_runtime_index.zig +++ b/test/compile_errors/stage1/obj/indexing_an_array_of_size_zero_with_runtime_index.zig @@ -5,6 +5,8 @@ export fn foo() void { _ = pointer; } -// indexing an array of size zero with runtime index +// error +// backend=stage1 +// target=native // // tmp.zig:4:27: error: accessing a zero length array is not allowed diff --git a/test/compile_errors/stage1/obj/indexing_single-item_pointer.zig b/test/compile_errors/stage1/obj/indexing_single-item_pointer.zig index e228083964..bc7951ec96 100644 --- a/test/compile_errors/stage1/obj/indexing_single-item_pointer.zig +++ b/test/compile_errors/stage1/obj/indexing_single-item_pointer.zig @@ -2,6 +2,8 @@ export fn entry(ptr: *i32) i32 { return ptr[1]; } -// indexing single-item pointer +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: index of single-item pointer diff --git a/test/compile_errors/stage1/obj/indirect_recursion_of_async_functions_detected.zig b/test/compile_errors/stage1/obj/indirect_recursion_of_async_functions_detected.zig index 5765f7aae1..d845dc7930 100644 --- a/test/compile_errors/stage1/obj/indirect_recursion_of_async_functions_detected.zig +++ b/test/compile_errors/stage1/obj/indirect_recursion_of_async_functions_detected.zig @@ -27,7 +27,9 @@ fn rangeSumIndirect(x: i32) i32 { return child + 1; } -// indirect recursion of async functions detected +// error +// backend=stage1 +// target=native // // tmp.zig:8:1: error: '@Frame(rangeSum)' depends on itself // tmp.zig:15:33: note: when analyzing type '@Frame(rangeSum)' here diff --git a/test/compile_errors/stage1/obj/indirect_struct_loop.zig b/test/compile_errors/stage1/obj/indirect_struct_loop.zig index 903a1bda39..12214923d0 100644 --- a/test/compile_errors/stage1/obj/indirect_struct_loop.zig +++ b/test/compile_errors/stage1/obj/indirect_struct_loop.zig @@ -3,6 +3,8 @@ const B = struct { c : C, }; const C = struct { a : A, }; export fn entry() usize { return @sizeOf(A); } -// indirect struct loop +// error +// backend=stage1 +// target=native // // tmp.zig:1:11: error: struct 'A' depends on itself diff --git a/test/compile_errors/stage1/obj/inferred_array_size_invalid_here.zig b/test/compile_errors/stage1/obj/inferred_array_size_invalid_here.zig index a45b6aa027..2b2d944eab 100644 --- a/test/compile_errors/stage1/obj/inferred_array_size_invalid_here.zig +++ b/test/compile_errors/stage1/obj/inferred_array_size_invalid_here.zig @@ -8,7 +8,9 @@ export fn entry2() void { _ = a; } -// inferred array size invalid here +// error +// backend=stage1 +// target=native // // tmp.zig:2:16: error: unable to infer array size // tmp.zig:6:35: error: unable to infer array size diff --git a/test/compile_errors/stage1/obj/inferring_error_set_of_function_pointer.zig b/test/compile_errors/stage1/obj/inferring_error_set_of_function_pointer.zig index ead5afd248..b91242322d 100644 --- a/test/compile_errors/stage1/obj/inferring_error_set_of_function_pointer.zig +++ b/test/compile_errors/stage1/obj/inferring_error_set_of_function_pointer.zig @@ -2,6 +2,8 @@ comptime { const z: ?fn()!void = null; } -// inferring error set of function pointer +// error +// backend=stage1 +// target=native // // tmp.zig:2:19: error: function prototype may not have inferred error set diff --git a/test/compile_errors/stage1/obj/initializing_array_with_struct_syntax.zig b/test/compile_errors/stage1/obj/initializing_array_with_struct_syntax.zig index 15412ac5ab..2884c6193e 100644 --- a/test/compile_errors/stage1/obj/initializing_array_with_struct_syntax.zig +++ b/test/compile_errors/stage1/obj/initializing_array_with_struct_syntax.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = x; } -// initializing array with struct syntax +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: initializing array with struct syntax diff --git a/test/compile_errors/stage1/obj/instantiating_an_undefined_value_for_an_invalid_struct_that_contains_itself.zig b/test/compile_errors/stage1/obj/instantiating_an_undefined_value_for_an_invalid_struct_that_contains_itself.zig index c39908c9b5..dd6909b1c2 100644 --- a/test/compile_errors/stage1/obj/instantiating_an_undefined_value_for_an_invalid_struct_that_contains_itself.zig +++ b/test/compile_errors/stage1/obj/instantiating_an_undefined_value_for_an_invalid_struct_that_contains_itself.zig @@ -8,6 +8,8 @@ export fn entry() usize { return @sizeOf(@TypeOf(foo.x)); } -// instantiating an undefined value for an invalid struct that contains itself +// error +// backend=stage1 +// target=native // // tmp.zig:1:13: error: struct 'Foo' depends on itself diff --git a/test/compile_errors/stage1/obj/intToPtr_with_misaligned_address.zig b/test/compile_errors/stage1/obj/intToPtr_with_misaligned_address.zig index a04f318f0c..16b6bf565e 100644 --- a/test/compile_errors/stage1/obj/intToPtr_with_misaligned_address.zig +++ b/test/compile_errors/stage1/obj/intToPtr_with_misaligned_address.zig @@ -3,6 +3,8 @@ pub fn main() void { _ = y; } -// intToPtr with misaligned address +// error +// backend=stage1 +// target=native // // tmp.zig:2:13: error: pointer type '[*]align(4) u8' requires aligned address diff --git a/test/compile_errors/stage1/obj/int_to_err_global_invalid_number.zig b/test/compile_errors/stage1/obj/int_to_err_global_invalid_number.zig index 180da60ab2..5c078a751c 100644 --- a/test/compile_errors/stage1/obj/int_to_err_global_invalid_number.zig +++ b/test/compile_errors/stage1/obj/int_to_err_global_invalid_number.zig @@ -8,6 +8,8 @@ comptime { _ = y; } -// int to err global invalid number +// error +// backend=stage1 +// target=native // // tmp.zig:7:13: error: integer value 3 represents no error diff --git a/test/compile_errors/stage1/obj/int_to_err_non_global_invalid_number.zig b/test/compile_errors/stage1/obj/int_to_err_non_global_invalid_number.zig index a6627891d0..8c1e547746 100644 --- a/test/compile_errors/stage1/obj/int_to_err_non_global_invalid_number.zig +++ b/test/compile_errors/stage1/obj/int_to_err_non_global_invalid_number.zig @@ -12,6 +12,8 @@ comptime { _ = y; } -// int to err non global invalid number +// error +// backend=stage1 +// target=native // // tmp.zig:11:13: error: error.B not a member of error set 'Set2' diff --git a/test/compile_errors/stage1/obj/int_to_ptr_of_0_bits.zig b/test/compile_errors/stage1/obj/int_to_ptr_of_0_bits.zig index 7047600c1b..7b65cdf836 100644 --- a/test/compile_errors/stage1/obj/int_to_ptr_of_0_bits.zig +++ b/test/compile_errors/stage1/obj/int_to_ptr_of_0_bits.zig @@ -4,6 +4,8 @@ export fn foo() void { _ = y; } -// int to ptr of 0 bits +// error +// backend=stage1 +// target=native // // tmp.zig:3:30: error: type '*void' has 0 bits and cannot store information diff --git a/test/compile_errors/stage1/obj/integer_cast_truncates_bits.zig b/test/compile_errors/stage1/obj/integer_cast_truncates_bits.zig index a5c8036152..e8ef418624 100644 --- a/test/compile_errors/stage1/obj/integer_cast_truncates_bits.zig +++ b/test/compile_errors/stage1/obj/integer_cast_truncates_bits.zig @@ -19,7 +19,9 @@ export fn entry4() void { _ = unsigned; } -// integer cast truncates bits +// error +// backend=stage1 +// target=native // // tmp.zig:3:18: error: cast from 'u16' to 'u8' truncates bits // tmp.zig:8:22: error: integer value 300 cannot be coerced to type 'u8' diff --git a/test/compile_errors/stage1/obj/integer_overflow_error.zig b/test/compile_errors/stage1/obj/integer_overflow_error.zig index 568cc5034b..117d77ed93 100644 --- a/test/compile_errors/stage1/obj/integer_overflow_error.zig +++ b/test/compile_errors/stage1/obj/integer_overflow_error.zig @@ -1,6 +1,8 @@ const x : u8 = 300; export fn entry() usize { return @sizeOf(@TypeOf(x)); } -// integer overflow error +// error +// backend=stage1 +// target=native // // tmp.zig:1:16: error: integer value 300 cannot be coerced to type 'u8' diff --git a/test/compile_errors/stage1/obj/integer_underflow_error.zig b/test/compile_errors/stage1/obj/integer_underflow_error.zig index 01171589d9..15bd4c472b 100644 --- a/test/compile_errors/stage1/obj/integer_underflow_error.zig +++ b/test/compile_errors/stage1/obj/integer_underflow_error.zig @@ -2,6 +2,8 @@ export fn entry() void { _ = @intToPtr(*anyopaque, ~@as(usize, @import("std").math.maxInt(usize)) - 1); } -// integer underflow error +// error +// backend=stage1 +// target=native // // :2:78: error: operation caused overflow diff --git a/test/compile_errors/stage1/obj/invalid_break_expression.zig b/test/compile_errors/stage1/obj/invalid_break_expression.zig index b6d27d6ea5..efb76a34f7 100644 --- a/test/compile_errors/stage1/obj/invalid_break_expression.zig +++ b/test/compile_errors/stage1/obj/invalid_break_expression.zig @@ -2,6 +2,8 @@ export fn f() void { break; } -// invalid break expression +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: break expression outside loop diff --git a/test/compile_errors/stage1/obj/invalid_builtin_fn.zig b/test/compile_errors/stage1/obj/invalid_builtin_fn.zig index e10baf5965..8f0e3633bb 100644 --- a/test/compile_errors/stage1/obj/invalid_builtin_fn.zig +++ b/test/compile_errors/stage1/obj/invalid_builtin_fn.zig @@ -2,6 +2,8 @@ fn f() @bogus(foo) { } export fn entry() void { _ = f(); } -// invalid builtin fn +// error +// backend=stage1 +// target=native // // tmp.zig:1:8: error: invalid builtin function: '@bogus' diff --git a/test/compile_errors/stage1/obj/invalid_cast_from_integral_type_to_enum.zig b/test/compile_errors/stage1/obj/invalid_cast_from_integral_type_to_enum.zig index 476a4929ef..81dbd88e3b 100644 --- a/test/compile_errors/stage1/obj/invalid_cast_from_integral_type_to_enum.zig +++ b/test/compile_errors/stage1/obj/invalid_cast_from_integral_type_to_enum.zig @@ -10,6 +10,8 @@ fn foo(x: usize) void { } } -// invalid cast from integral type to enum +// error +// backend=stage1 +// target=native // // tmp.zig:9:10: error: expected type 'usize', found 'E' diff --git a/test/compile_errors/stage1/obj/invalid_comparison_for_function_pointers.zig b/test/compile_errors/stage1/obj/invalid_comparison_for_function_pointers.zig index f7827ed0e9..6d64b6cdaf 100644 --- a/test/compile_errors/stage1/obj/invalid_comparison_for_function_pointers.zig +++ b/test/compile_errors/stage1/obj/invalid_comparison_for_function_pointers.zig @@ -3,6 +3,8 @@ const invalid = foo > foo; export fn entry() usize { return @sizeOf(@TypeOf(invalid)); } -// invalid comparison for function pointers +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: operator not allowed for type 'fn() void' diff --git a/test/compile_errors/stage1/obj/invalid_continue_expression.zig b/test/compile_errors/stage1/obj/invalid_continue_expression.zig index 9bd40c516a..00f3c5a3d5 100644 --- a/test/compile_errors/stage1/obj/invalid_continue_expression.zig +++ b/test/compile_errors/stage1/obj/invalid_continue_expression.zig @@ -2,6 +2,8 @@ export fn f() void { continue; } -// invalid continue expression +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: continue expression outside loop diff --git a/test/compile_errors/stage1/obj/invalid_deref_on_switch_target.zig b/test/compile_errors/stage1/obj/invalid_deref_on_switch_target.zig index 47dc0a52c1..966a881543 100644 --- a/test/compile_errors/stage1/obj/invalid_deref_on_switch_target.zig +++ b/test/compile_errors/stage1/obj/invalid_deref_on_switch_target.zig @@ -10,6 +10,8 @@ const Tile = enum { Filled, }; -// invalid deref on switch target +// error +// backend=stage1 +// target=native // // tmp.zig:3:17: error: attempt to dereference non-pointer type 'Tile' diff --git a/test/compile_errors/stage1/obj/invalid_empty_unicode_escape.zig b/test/compile_errors/stage1/obj/invalid_empty_unicode_escape.zig index d8853110a4..57dd16a63d 100644 --- a/test/compile_errors/stage1/obj/invalid_empty_unicode_escape.zig +++ b/test/compile_errors/stage1/obj/invalid_empty_unicode_escape.zig @@ -2,6 +2,8 @@ export fn entry() void { const a = '\u{}'; } -// invalid empty unicode escape +// error +// backend=stage1 +// target=native // // tmp.zig:2:19: error: empty unicode escape sequence diff --git a/test/compile_errors/stage1/obj/invalid_exponent_in_float_literal-1.zig b/test/compile_errors/stage1/obj/invalid_exponent_in_float_literal-1.zig index 4f13de2a62..431401c534 100644 --- a/test/compile_errors/stage1/obj/invalid_exponent_in_float_literal-1.zig +++ b/test/compile_errors/stage1/obj/invalid_exponent_in_float_literal-1.zig @@ -3,7 +3,9 @@ fn main() void { _ = bad; } -// invalid exponent in float literal - 1 +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected expression, found 'invalid bytes' // tmp.zig:2:28: note: invalid byte: 'a' diff --git a/test/compile_errors/stage1/obj/invalid_exponent_in_float_literal-2.zig b/test/compile_errors/stage1/obj/invalid_exponent_in_float_literal-2.zig index f612d8c510..088b43546c 100644 --- a/test/compile_errors/stage1/obj/invalid_exponent_in_float_literal-2.zig +++ b/test/compile_errors/stage1/obj/invalid_exponent_in_float_literal-2.zig @@ -3,7 +3,9 @@ fn main() void { _ = bad; } -// invalid exponent in float literal - 2 +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected expression, found 'invalid bytes' // tmp.zig:2:29: note: invalid byte: 'F' diff --git a/test/compile_errors/stage1/obj/invalid_field_access_in_comptime.zig b/test/compile_errors/stage1/obj/invalid_field_access_in_comptime.zig index e8395b5e7a..2630a704ed 100644 --- a/test/compile_errors/stage1/obj/invalid_field_access_in_comptime.zig +++ b/test/compile_errors/stage1/obj/invalid_field_access_in_comptime.zig @@ -1,5 +1,7 @@ comptime { var x = doesnt_exist.whatever; _ = x; } -// invalid field access in comptime +// error +// backend=stage1 +// target=native // // tmp.zig:1:20: error: use of undeclared identifier 'doesnt_exist' diff --git a/test/compile_errors/stage1/obj/invalid_field_in_struct_value_expression.zig b/test/compile_errors/stage1/obj/invalid_field_in_struct_value_expression.zig index 41511f0d0a..fae0a90b51 100644 --- a/test/compile_errors/stage1/obj/invalid_field_in_struct_value_expression.zig +++ b/test/compile_errors/stage1/obj/invalid_field_in_struct_value_expression.zig @@ -12,6 +12,8 @@ export fn f() void { _ = a; } -// invalid field in struct value expression +// error +// backend=stage1 +// target=native // // tmp.zig:10:9: error: no member named 'foo' in struct 'A' diff --git a/test/compile_errors/stage1/obj/invalid_float_literal.zig b/test/compile_errors/stage1/obj/invalid_float_literal.zig index 5d9a26032f..709609a027 100644 --- a/test/compile_errors/stage1/obj/invalid_float_literal.zig +++ b/test/compile_errors/stage1/obj/invalid_float_literal.zig @@ -6,6 +6,8 @@ pub fn main() void { std.debug.assert(bad_float < 1.0); } -// invalid float literal +// error +// backend=stage1 +// target=native // // tmp.zig:5:29: error: expected expression, found '.' diff --git a/test/compile_errors/stage1/obj/invalid_legacy_unicode_escape.zig b/test/compile_errors/stage1/obj/invalid_legacy_unicode_escape.zig index 58e1390345..b81a814a60 100644 --- a/test/compile_errors/stage1/obj/invalid_legacy_unicode_escape.zig +++ b/test/compile_errors/stage1/obj/invalid_legacy_unicode_escape.zig @@ -2,7 +2,9 @@ export fn entry() void { const a = '\U1234'; } -// invalid legacy unicode escape +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: expected expression, found 'invalid bytes' // tmp.zig:2:18: note: invalid byte: '1' diff --git a/test/compile_errors/stage1/obj/invalid_maybe_type.zig b/test/compile_errors/stage1/obj/invalid_maybe_type.zig index 9edc313526..cb075c36b7 100644 --- a/test/compile_errors/stage1/obj/invalid_maybe_type.zig +++ b/test/compile_errors/stage1/obj/invalid_maybe_type.zig @@ -2,6 +2,8 @@ export fn f() void { if (true) |x| { _ = x; } } -// invalid maybe type +// error +// backend=stage1 +// target=native // // tmp.zig:2:9: error: expected optional type, found 'bool' diff --git a/test/compile_errors/stage1/obj/invalid_member_of_builtin_enum.zig b/test/compile_errors/stage1/obj/invalid_member_of_builtin_enum.zig index 32888ff84b..166ebfc782 100644 --- a/test/compile_errors/stage1/obj/invalid_member_of_builtin_enum.zig +++ b/test/compile_errors/stage1/obj/invalid_member_of_builtin_enum.zig @@ -4,6 +4,8 @@ export fn entry() void { _ = foo; } -// invalid member of builtin enum +// error +// backend=stage1 +// target=native // // tmp.zig:3:29: error: container 'std.builtin.Mode' has no member called 'x86' diff --git a/test/compile_errors/stage1/obj/invalid_multiple_dereferences.zig b/test/compile_errors/stage1/obj/invalid_multiple_dereferences.zig index bdf5ccb228..f8a0b8013f 100644 --- a/test/compile_errors/stage1/obj/invalid_multiple_dereferences.zig +++ b/test/compile_errors/stage1/obj/invalid_multiple_dereferences.zig @@ -11,7 +11,9 @@ pub const Box = struct { field: i32, }; -// invalid multiple dereferences +// error +// backend=stage1 +// target=native // // tmp.zig:3:8: error: attempt to dereference non-pointer type 'Box' // tmp.zig:8:13: error: attempt to dereference non-pointer type 'Box' diff --git a/test/compile_errors/stage1/obj/invalid_optional_type_in_extern_struct.zig b/test/compile_errors/stage1/obj/invalid_optional_type_in_extern_struct.zig index 17d9477abf..dc2e2690b8 100644 --- a/test/compile_errors/stage1/obj/invalid_optional_type_in_extern_struct.zig +++ b/test/compile_errors/stage1/obj/invalid_optional_type_in_extern_struct.zig @@ -3,6 +3,8 @@ const stroo = extern struct { }; export fn testf(fluff: *stroo) void { _ = fluff; } -// invalid optional type in extern struct +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: extern structs cannot contain fields of type '?[*c]u8' diff --git a/test/compile_errors/stage1/obj/invalid_pointer_for_var_type.zig b/test/compile_errors/stage1/obj/invalid_pointer_for_var_type.zig index 599aef54f2..caf8c70797 100644 --- a/test/compile_errors/stage1/obj/invalid_pointer_for_var_type.zig +++ b/test/compile_errors/stage1/obj/invalid_pointer_for_var_type.zig @@ -6,6 +6,8 @@ export fn f() void { } } -// invalid pointer for var type +// error +// backend=stage1 +// target=native // // tmp.zig:2:13: error: unable to evaluate constant expression diff --git a/test/compile_errors/stage1/obj/invalid_pointer_syntax.zig b/test/compile_errors/stage1/obj/invalid_pointer_syntax.zig index d4b68200b6..a4c823bde1 100644 --- a/test/compile_errors/stage1/obj/invalid_pointer_syntax.zig +++ b/test/compile_errors/stage1/obj/invalid_pointer_syntax.zig @@ -2,6 +2,8 @@ export fn foo() void { var guid: *:0 const u8 = undefined; } -// invalid pointer syntax +// error +// backend=stage1 +// target=native // // tmp.zig:2:16: error: expected type expression, found ':' diff --git a/test/compile_errors/stage1/obj/invalid_shift_amount_error.zig b/test/compile_errors/stage1/obj/invalid_shift_amount_error.zig index f4fe1cb2ff..7c84f2db38 100644 --- a/test/compile_errors/stage1/obj/invalid_shift_amount_error.zig +++ b/test/compile_errors/stage1/obj/invalid_shift_amount_error.zig @@ -4,6 +4,8 @@ fn f() u16 { } export fn entry() u16 { return f(); } -// invalid shift amount error +// error +// backend=stage1 +// target=native // // tmp.zig:3:17: error: integer value 8 cannot be coerced to type 'u3' diff --git a/test/compile_errors/stage1/obj/invalid_struct_field.zig b/test/compile_errors/stage1/obj/invalid_struct_field.zig index 2d85914907..6264125bca 100644 --- a/test/compile_errors/stage1/obj/invalid_struct_field.zig +++ b/test/compile_errors/stage1/obj/invalid_struct_field.zig @@ -11,7 +11,9 @@ export fn g() void { _ = y; } -// invalid struct field +// error +// backend=stage1 +// target=native // // tmp.zig:4:6: error: no member named 'foo' in struct 'A' // tmp.zig:10:16: error: no member named 'bar' in struct 'A' diff --git a/test/compile_errors/stage1/obj/invalid_suspend_in_exported_function.zig b/test/compile_errors/stage1/obj/invalid_suspend_in_exported_function.zig index da808563a5..cfcbfba889 100644 --- a/test/compile_errors/stage1/obj/invalid_suspend_in_exported_function.zig +++ b/test/compile_errors/stage1/obj/invalid_suspend_in_exported_function.zig @@ -7,7 +7,9 @@ fn func() void { suspend {} } -// invalid suspend in exported function +// error +// backend=stage1 +// target=native // // tmp.zig:1:1: error: function with calling convention 'C' cannot be async // tmp.zig:3:18: note: await here is a suspend point diff --git a/test/compile_errors/stage1/obj/invalid_type.zig b/test/compile_errors/stage1/obj/invalid_type.zig index 0307300517..8a2952e5f2 100644 --- a/test/compile_errors/stage1/obj/invalid_type.zig +++ b/test/compile_errors/stage1/obj/invalid_type.zig @@ -1,6 +1,8 @@ fn a() bogus {} export fn entry() void { _ = a(); } -// invalid type +// error +// backend=stage1 +// target=native // // tmp.zig:1:8: error: use of undeclared identifier 'bogus' diff --git a/test/compile_errors/stage1/obj/invalid_type_used_in_array_type.zig b/test/compile_errors/stage1/obj/invalid_type_used_in_array_type.zig index 26f0e6a7db..3a7bc4272c 100644 --- a/test/compile_errors/stage1/obj/invalid_type_used_in_array_type.zig +++ b/test/compile_errors/stage1/obj/invalid_type_used_in_array_type.zig @@ -7,6 +7,8 @@ export fn entry() void { _ = a; } -// invalid type used in array type +// error +// backend=stage1 +// target=native // // tmp.zig:2:12: error: use of undeclared identifier 'SomeNonexistentType' diff --git a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-1.zig b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-1.zig index 5cea540104..a3e2827f31 100644 --- a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-1.zig +++ b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-1.zig @@ -3,7 +3,9 @@ fn main() void { _ = bad; } -// invalid underscore placement in float literal - 1 +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected expression, found 'invalid bytes' // tmp.zig:2:23: note: invalid byte: '_' diff --git a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-10.zig b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-10.zig index d789579a2b..7d33244483 100644 --- a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-10.zig +++ b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-10.zig @@ -3,7 +3,9 @@ fn main() void { _ = bad; } -// invalid underscore placement in float literal - 10 +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected expression, found 'invalid bytes' // tmp.zig:2:25: note: invalid byte: '_' diff --git a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-11.zig b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-11.zig index 197b114090..fa4f5b8975 100644 --- a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-11.zig +++ b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-11.zig @@ -3,7 +3,9 @@ fn main() void { _ = bad; } -// invalid underscore placement in float literal - 11 +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected expression, found 'invalid bytes' // tmp.zig:2:28: note: invalid byte: '_' diff --git a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-12.zig b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-12.zig index 1d25c9f4b4..2d36187711 100644 --- a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-12.zig +++ b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-12.zig @@ -3,7 +3,9 @@ fn main() void { _ = bad; } -// invalid underscore placement in float literal - 12 +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected expression, found 'invalid bytes' // tmp.zig:2:23: note: invalid byte: 'x' diff --git a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-13.zig b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-13.zig index c3de75ed32..21b044121c 100644 --- a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-13.zig +++ b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-13.zig @@ -3,7 +3,9 @@ fn main() void { _ = bad; } -// invalid underscore placement in float literal - 13 +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected expression, found 'invalid bytes' // tmp.zig:2:23: note: invalid byte: '_' diff --git a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-14.zig b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-14.zig index cbb967e926..adb0727eba 100644 --- a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-14.zig +++ b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-14.zig @@ -3,7 +3,9 @@ fn main() void { _ = bad; } -// invalid underscore placement in float literal - 14 +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected expression, found 'invalid bytes' // tmp.zig:2:27: note: invalid byte: 'p' diff --git a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-2.zig b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-2.zig index e83c1b420b..16618c6a18 100644 --- a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-2.zig +++ b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-2.zig @@ -3,7 +3,9 @@ fn main() void { _ = bad; } -// invalid underscore placement in float literal - 2 +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected expression, found 'invalid bytes' // tmp.zig:2:23: note: invalid byte: '.' diff --git a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-3.zig b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-3.zig index f9ca8e0d7c..09e9e20b4b 100644 --- a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-3.zig +++ b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-3.zig @@ -3,7 +3,9 @@ fn main() void { _ = bad; } -// invalid underscore placement in float literal - 3 +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected expression, found 'invalid bytes' // tmp.zig:2:25: note: invalid byte: ';' diff --git a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-4.zig b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-4.zig index 20e8d3692e..278ee35f5f 100644 --- a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-4.zig +++ b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-4.zig @@ -3,7 +3,9 @@ fn main() void { _ = bad; } -// invalid underscore placement in float literal - 4 +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected expression, found 'invalid bytes' // tmp.zig:2:25: note: invalid byte: '_' diff --git a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-5.zig b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-5.zig index 3719f54e06..4912c15e50 100644 --- a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-5.zig +++ b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-5.zig @@ -3,7 +3,9 @@ fn main() void { _ = bad; } -// invalid underscore placement in float literal - 5 +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected expression, found 'invalid bytes' // tmp.zig:2:26: note: invalid byte: '_' diff --git a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-6.zig b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-6.zig index 64a439538a..3386c860b9 100644 --- a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-6.zig +++ b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-6.zig @@ -3,7 +3,9 @@ fn main() void { _ = bad; } -// invalid underscore placement in float literal - 6 +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected expression, found 'invalid bytes' // tmp.zig:2:26: note: invalid byte: '_' diff --git a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-7.zig b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-7.zig index 311b27339a..c0e57424a9 100644 --- a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-7.zig +++ b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-7.zig @@ -3,7 +3,9 @@ fn main() void { _ = bad; } -// invalid underscore placement in float literal - 7 +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected expression, found 'invalid bytes' // tmp.zig:2:28: note: invalid byte: ';' diff --git a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-9.zig b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-9.zig index ecd1149f22..f7475332c1 100644 --- a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-9.zig +++ b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_float_literal-9.zig @@ -3,7 +3,9 @@ fn main() void { _ = bad; } -// invalid underscore placement in float literal - 9 +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected expression, found 'invalid bytes' // tmp.zig:2:23: note: invalid byte: '_' diff --git a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-1.zig b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-1.zig index 47da090745..9cea337db4 100644 --- a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-1.zig +++ b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-1.zig @@ -3,7 +3,9 @@ fn main() void { _ = bad; } -// invalid underscore placement in int literal - 1 +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected expression, found 'invalid bytes' // tmp.zig:2:26: note: invalid byte: ';' diff --git a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-2.zig b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-2.zig index bb230daa9e..5f02479f2e 100644 --- a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-2.zig +++ b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-2.zig @@ -3,7 +3,9 @@ fn main() void { _ = bad; } -// invalid underscore placement in int literal - 2 +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected expression, found 'invalid bytes' // tmp.zig:2:28: note: invalid byte: ';' diff --git a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-3.zig b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-3.zig index 7808b6ee4d..aed4cb9068 100644 --- a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-3.zig +++ b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-3.zig @@ -3,7 +3,9 @@ fn main() void { _ = bad; } -// invalid underscore placement in int literal - 3 +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected expression, found 'invalid bytes' // tmp.zig:2:28: note: invalid byte: ';' diff --git a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-4.zig b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-4.zig index 51ddb3d061..dce2771048 100644 --- a/test/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-4.zig +++ b/test/compile_errors/stage1/obj/invalid_underscore_placement_in_int_literal-4.zig @@ -3,7 +3,9 @@ fn main() void { _ = bad; } -// invalid underscore placement in int literal - 4 +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected expression, found 'invalid bytes' // tmp.zig:2:28: note: invalid byte: ';' diff --git a/test/compile_errors/stage1/obj/invalid_union_field_access_in_comptime.zig b/test/compile_errors/stage1/obj/invalid_union_field_access_in_comptime.zig index d570dca0b9..6d55f3b04f 100644 --- a/test/compile_errors/stage1/obj/invalid_union_field_access_in_comptime.zig +++ b/test/compile_errors/stage1/obj/invalid_union_field_access_in_comptime.zig @@ -8,6 +8,8 @@ comptime { _ = bar_val; } -// invalid union field access in comptime +// error +// backend=stage1 +// target=native // // tmp.zig:7:24: error: accessing union field 'Bar' while field 'Baz' is set diff --git a/test/compile_errors/stage1/obj/issue_2032_compile_diagnostic_string_for_top_level_decl_type.zig b/test/compile_errors/stage1/obj/issue_2032_compile_diagnostic_string_for_top_level_decl_type.zig index 9e353a4d38..c742cb9b77 100644 --- a/test/compile_errors/stage1/obj/issue_2032_compile_diagnostic_string_for_top_level_decl_type.zig +++ b/test/compile_errors/stage1/obj/issue_2032_compile_diagnostic_string_for_top_level_decl_type.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = foo; } -// compile diagnostic string for top level decl type (issue 2032) +// error +// backend=stage1 +// target=native // // tmp.zig:2:27: error: type 'u32' does not support array initialization diff --git a/test/compile_errors/stage1/obj/issue_2687_coerce_from_undefined_array_pointer_to_slice.zig b/test/compile_errors/stage1/obj/issue_2687_coerce_from_undefined_array_pointer_to_slice.zig index 7c125b85ce..21fbb6b4fe 100644 --- a/test/compile_errors/stage1/obj/issue_2687_coerce_from_undefined_array_pointer_to_slice.zig +++ b/test/compile_errors/stage1/obj/issue_2687_coerce_from_undefined_array_pointer_to_slice.zig @@ -18,7 +18,9 @@ export fn foo3() void { } } -// issue #2687: coerce from undefined array pointer to slice +// error +// backend=stage1 +// target=native // // tmp.zig:3:19: error: use of undefined value here causes undefined behavior // tmp.zig:9:23: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/issue_3818_bitcast_from_parray-slice_to_u16.zig b/test/compile_errors/stage1/obj/issue_3818_bitcast_from_parray-slice_to_u16.zig index 1c9d9cd1b1..cdc1def677 100644 --- a/test/compile_errors/stage1/obj/issue_3818_bitcast_from_parray-slice_to_u16.zig +++ b/test/compile_errors/stage1/obj/issue_3818_bitcast_from_parray-slice_to_u16.zig @@ -9,7 +9,9 @@ export fn foo2() void { _ = word; } -// issue #3818: bitcast from parray/slice to u16 +// error +// backend=stage1 +// target=native // // tmp.zig:3:42: error: unable to @bitCast from pointer type '*[2]u8' // tmp.zig:8:32: error: destination type 'u16' has size 2 but source type '[]const u8' has size 16 diff --git a/test/compile_errors/stage1/obj/issue_4207_coerce_from_non-terminated-slice_to_terminated-pointer.zig b/test/compile_errors/stage1/obj/issue_4207_coerce_from_non-terminated-slice_to_terminated-pointer.zig index bfb0595cce..d53f7731a0 100644 --- a/test/compile_errors/stage1/obj/issue_4207_coerce_from_non-terminated-slice_to_terminated-pointer.zig +++ b/test/compile_errors/stage1/obj/issue_4207_coerce_from_non-terminated-slice_to_terminated-pointer.zig @@ -3,7 +3,9 @@ export fn foo() [*:0]const u8 { return buffer[0..]; } -// issue #4207: coerce from non-terminated-slice to terminated-pointer +// error +// backend=stage1 +// target=native // // :3:18: error: expected type '[*:0]const u8', found '*[64]u8' // :3:18: note: destination pointer requires a terminating '0' sentinel diff --git a/test/compile_errors/stage1/obj/issue_5221_invalid_struct_init_type_referenced_by_typeInfo_and_passed_into_function.zig b/test/compile_errors/stage1/obj/issue_5221_invalid_struct_init_type_referenced_by_typeInfo_and_passed_into_function.zig index aa839bc72c..a622ceb44e 100644 --- a/test/compile_errors/stage1/obj/issue_5221_invalid_struct_init_type_referenced_by_typeInfo_and_passed_into_function.zig +++ b/test/compile_errors/stage1/obj/issue_5221_invalid_struct_init_type_referenced_by_typeInfo_and_passed_into_function.zig @@ -8,7 +8,9 @@ export fn foo() void { comptime ignore(@typeInfo(MyStruct).Struct.fields[0]); } -// issue #5221: invalid struct init type referenced by @typeInfo and passed into function +// error +// backend=stage1 +// target=native // // :5:28: error: cannot cast pointer to array literal to slice type '[]u8' // :5:28: note: cast discards const qualifier diff --git a/test/compile_errors/stage1/obj/issue_5618_coercion_of_optional_anyopaque_to_anyopaque_must_fail.zig b/test/compile_errors/stage1/obj/issue_5618_coercion_of_optional_anyopaque_to_anyopaque_must_fail.zig index daa8a91f40..9ba9910838 100644 --- a/test/compile_errors/stage1/obj/issue_5618_coercion_of_optional_anyopaque_to_anyopaque_must_fail.zig +++ b/test/compile_errors/stage1/obj/issue_5618_coercion_of_optional_anyopaque_to_anyopaque_must_fail.zig @@ -4,6 +4,8 @@ export fn foo() void { v = u; } -// Issue #5618: coercion of ?*anyopaque to *anyopaque must fail. +// error +// backend=stage1 +// target=native // // tmp.zig:4:9: error: cannot convert optional to payload type. consider using `.?`, `orelse`, or `if`. expected type '*anyopaque', found '?*anyopaque' diff --git a/test/compile_errors/stage1/obj/issue_7810-comptime_slice-len_increment_beyond_bounds.zig b/test/compile_errors/stage1/obj/issue_7810-comptime_slice-len_increment_beyond_bounds.zig index 533ac928b4..c8b2f0b09e 100644 --- a/test/compile_errors/stage1/obj/issue_7810-comptime_slice-len_increment_beyond_bounds.zig +++ b/test/compile_errors/stage1/obj/issue_7810-comptime_slice-len_increment_beyond_bounds.zig @@ -7,6 +7,8 @@ export fn foo_slice_len_increment_beyond_bounds() void { } } -// comptime slice-len increment beyond bounds +// error +// backend=stage1 +// target=native // // :6:12: error: out of bounds slice diff --git a/test/compile_errors/stage1/obj/issue_9346_return_outside_of_function_scope.zig b/test/compile_errors/stage1/obj/issue_9346_return_outside_of_function_scope.zig index 6be92e2ee8..d12bff2b49 100644 --- a/test/compile_errors/stage1/obj/issue_9346_return_outside_of_function_scope.zig +++ b/test/compile_errors/stage1/obj/issue_9346_return_outside_of_function_scope.zig @@ -1,5 +1,7 @@ pub const empty = return 1; -// issue #9346: return outside of function scope +// error +// backend=stage1 +// target=native // // tmp.zig:1:19: error: 'return' outside function scope diff --git a/test/compile_errors/stage1/obj/labeled_break_not_found.zig b/test/compile_errors/stage1/obj/labeled_break_not_found.zig index 0f4632d74d..754e1864b0 100644 --- a/test/compile_errors/stage1/obj/labeled_break_not_found.zig +++ b/test/compile_errors/stage1/obj/labeled_break_not_found.zig @@ -6,6 +6,8 @@ export fn entry() void { } } -// labeled break not found +// error +// backend=stage1 +// target=native // // tmp.zig:4:20: error: label not found: 'outer' diff --git a/test/compile_errors/stage1/obj/labeled_continue_not_found.zig b/test/compile_errors/stage1/obj/labeled_continue_not_found.zig index 8f95a0fce1..b112e9b355 100644 --- a/test/compile_errors/stage1/obj/labeled_continue_not_found.zig +++ b/test/compile_errors/stage1/obj/labeled_continue_not_found.zig @@ -7,6 +7,8 @@ export fn entry() void { } } -// labeled continue not found +// error +// backend=stage1 +// target=native // // tmp.zig:5:23: error: label not found: 'outer' diff --git a/test/compile_errors/stage1/obj/lazy_pointer_with_undefined_element_type.zig b/test/compile_errors/stage1/obj/lazy_pointer_with_undefined_element_type.zig index 47b271a05e..733a3ca2dd 100644 --- a/test/compile_errors/stage1/obj/lazy_pointer_with_undefined_element_type.zig +++ b/test/compile_errors/stage1/obj/lazy_pointer_with_undefined_element_type.zig @@ -5,6 +5,8 @@ export fn foo() void { _ = I; } -// lazy pointer with undefined element type +// error +// backend=stage1 +// target=native // // :3:28: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/libc_headers_note.zig b/test/compile_errors/stage1/obj/libc_headers_note.zig new file mode 100644 index 0000000000..c8d9a9cbf3 --- /dev/null +++ b/test/compile_errors/stage1/obj/libc_headers_note.zig @@ -0,0 +1,12 @@ +const c = @cImport(@cInclude("stdio.h")); +export fn entry() void { + _ = c.printf("hello, world!\n"); +} + +// error +// backend=stage1 +// is_test=1 +// target=native-linux +// +// tmp.zig:1:11: error: C import failed +// tmp.zig:1:11: note: libc headers not available; compilation does not link against libc diff --git a/test/compile_errors/stage1/obj/load_too_many_bytes_from_comptime_reinterpreted_pointer.zig b/test/compile_errors/stage1/obj/load_too_many_bytes_from_comptime_reinterpreted_pointer.zig index 2c5e1c7327..b275dbbeed 100644 --- a/test/compile_errors/stage1/obj/load_too_many_bytes_from_comptime_reinterpreted_pointer.zig +++ b/test/compile_errors/stage1/obj/load_too_many_bytes_from_comptime_reinterpreted_pointer.zig @@ -6,6 +6,8 @@ export fn entry() void { _ = int_val; } -// load too many bytes from comptime reinterpreted pointer +// error +// backend=stage1 +// target=native // // tmp.zig:5:28: error: attempt to read 8 bytes from pointer to f32 which is 4 bytes diff --git a/test/compile_errors/stage1/obj/load_vector_pointer_with_unknown_runtime_index.zig b/test/compile_errors/stage1/obj/load_vector_pointer_with_unknown_runtime_index.zig index fe28fa9102..8d703b09e6 100644 --- a/test/compile_errors/stage1/obj/load_vector_pointer_with_unknown_runtime_index.zig +++ b/test/compile_errors/stage1/obj/load_vector_pointer_with_unknown_runtime_index.zig @@ -10,6 +10,8 @@ fn loadv(ptr: anytype) i32 { return ptr.*; } -// load vector pointer with unknown runtime index +// error +// backend=stage1 +// target=native // // tmp.zig:10:12: error: unable to determine vector element index of type '*align(16:0:4:?) i32 diff --git a/test/compile_errors/stage1/obj/local_shadows_global_that_occurs_later.zig b/test/compile_errors/stage1/obj/local_shadows_global_that_occurs_later.zig index 2265a34f18..4b9b58871f 100644 --- a/test/compile_errors/stage1/obj/local_shadows_global_that_occurs_later.zig +++ b/test/compile_errors/stage1/obj/local_shadows_global_that_occurs_later.zig @@ -4,7 +4,9 @@ pub fn main() void { } fn foo() void {} -// local shadows global that occurs later +// error +// backend=stage1 +// target=native // // tmp.zig:2:9: error: local shadows declaration of 'foo' // tmp.zig:5:1: note: declared here diff --git a/test/compile_errors/stage1/obj/local_variable_redeclaration.zig b/test/compile_errors/stage1/obj/local_variable_redeclaration.zig index 2367963edb..79eba0d428 100644 --- a/test/compile_errors/stage1/obj/local_variable_redeclaration.zig +++ b/test/compile_errors/stage1/obj/local_variable_redeclaration.zig @@ -3,7 +3,9 @@ export fn f() void { var a = 0; } -// local variable redeclaration +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: redeclaration of local constant 'a' // tmp.zig:2:11: note: previous declaration here diff --git a/test/compile_errors/stage1/obj/local_variable_redeclares_parameter.zig b/test/compile_errors/stage1/obj/local_variable_redeclares_parameter.zig index e624e14e31..854ef080c5 100644 --- a/test/compile_errors/stage1/obj/local_variable_redeclares_parameter.zig +++ b/test/compile_errors/stage1/obj/local_variable_redeclares_parameter.zig @@ -3,7 +3,9 @@ fn f(a : i32) void { } export fn entry() void { f(1); } -// local variable redeclares parameter +// error +// backend=stage1 +// target=native // // tmp.zig:2:11: error: redeclaration of function parameter 'a' // tmp.zig:1:6: note: previous declaration here diff --git a/test/compile_errors/stage1/obj/local_variable_shadowing_global.zig b/test/compile_errors/stage1/obj/local_variable_shadowing_global.zig index c824cb3df7..3f1af3a4cb 100644 --- a/test/compile_errors/stage1/obj/local_variable_shadowing_global.zig +++ b/test/compile_errors/stage1/obj/local_variable_shadowing_global.zig @@ -6,7 +6,9 @@ export fn entry() void { _ = Bar; } -// local variable shadowing global +// error +// backend=stage1 +// target=native // // tmp.zig:5:9: error: local shadows declaration of 'Bar' // tmp.zig:2:1: note: declared here diff --git a/test/compile_errors/stage1/obj/locally_shadowing_a_primitive_type.zig b/test/compile_errors/stage1/obj/locally_shadowing_a_primitive_type.zig index 457cea418c..e66a2082ea 100644 --- a/test/compile_errors/stage1/obj/locally_shadowing_a_primitive_type.zig +++ b/test/compile_errors/stage1/obj/locally_shadowing_a_primitive_type.zig @@ -4,7 +4,9 @@ export fn foo() void { _ = a; } -// locally shadowing a primitive type +// error +// backend=stage1 +// target=native // // tmp.zig:2:11: error: name shadows primitive 'u8' // tmp.zig:2:11: note: consider using @"u8" to disambiguate diff --git a/test/compile_errors/stage1/obj/main_function_with_bogus_args_type.zig b/test/compile_errors/stage1/obj/main_function_with_bogus_args_type.zig index 3954c4b846..5808ab90ec 100644 --- a/test/compile_errors/stage1/obj/main_function_with_bogus_args_type.zig +++ b/test/compile_errors/stage1/obj/main_function_with_bogus_args_type.zig @@ -1,5 +1,7 @@ pub fn main(args: [][]bogus) !void {_ = args;} -// main function with bogus args type +// error +// backend=stage1 +// target=native // // tmp.zig:1:23: error: use of undeclared identifier 'bogus' diff --git a/test/compile_errors/stage1/obj/method_call_with_first_arg_type_primitive.zig b/test/compile_errors/stage1/obj/method_call_with_first_arg_type_primitive.zig index 9763e84fba..316be2d899 100644 --- a/test/compile_errors/stage1/obj/method_call_with_first_arg_type_primitive.zig +++ b/test/compile_errors/stage1/obj/method_call_with_first_arg_type_primitive.zig @@ -14,6 +14,8 @@ export fn f() void { derp.init(); } -// method call with first arg type primitive +// error +// backend=stage1 +// target=native // // tmp.zig:14:5: error: expected type 'i32', found 'Foo' diff --git a/test/compile_errors/stage1/obj/method_call_with_first_arg_type_wrong_container.zig b/test/compile_errors/stage1/obj/method_call_with_first_arg_type_wrong_container.zig index ccbc7e32e3..04ab89fb6c 100644 --- a/test/compile_errors/stage1/obj/method_call_with_first_arg_type_wrong_container.zig +++ b/test/compile_errors/stage1/obj/method_call_with_first_arg_type_wrong_container.zig @@ -23,6 +23,8 @@ export fn foo() void { x.init(); } -// method call with first arg type wrong container +// error +// backend=stage1 +// target=native // // tmp.zig:23:5: error: expected type '*Allocator', found '*List' diff --git a/test/compile_errors/stage1/obj/missing_boolean_switch_value.zig b/test/compile_errors/stage1/obj/missing_boolean_switch_value.zig index 63a12c4e6f..2e9d4b48ce 100644 --- a/test/compile_errors/stage1/obj/missing_boolean_switch_value.zig +++ b/test/compile_errors/stage1/obj/missing_boolean_switch_value.zig @@ -11,7 +11,9 @@ comptime { _ = x; } -// missing boolean switch value +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: switch must handle all possibilities // tmp.zig:8:15: error: switch must handle all possibilities diff --git a/test/compile_errors/stage1/obj/missing_const_in_slice_with_nested_array_type.zig b/test/compile_errors/stage1/obj/missing_const_in_slice_with_nested_array_type.zig index 4f552284d7..af9d690d43 100644 --- a/test/compile_errors/stage1/obj/missing_const_in_slice_with_nested_array_type.zig +++ b/test/compile_errors/stage1/obj/missing_const_in_slice_with_nested_array_type.zig @@ -11,6 +11,8 @@ export fn entry() void { _ = geo_data; } -// missing const in slice with nested array type +// error +// backend=stage1 +// target=native // // tmp.zig:4:30: error: array literal requires address-of operator (&) to coerce to slice type '[][2]f32' diff --git a/test/compile_errors/stage1/obj/missing_else_clause.zig b/test/compile_errors/stage1/obj/missing_else_clause.zig index 28adfd21e8..f331933437 100644 --- a/test/compile_errors/stage1/obj/missing_else_clause.zig +++ b/test/compile_errors/stage1/obj/missing_else_clause.zig @@ -8,7 +8,9 @@ fn g(b: bool) void { } export fn entry() void { f(true); g(true); } -// missing else clause +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected type 'i32', found 'void' // tmp.zig:6:15: error: incompatible types: 'i32' and 'void' diff --git a/test/compile_errors/stage1/obj/missing_field_in_struct_value_expression.zig b/test/compile_errors/stage1/obj/missing_field_in_struct_value_expression.zig index bea4021a5a..9eb4246c8f 100644 --- a/test/compile_errors/stage1/obj/missing_field_in_struct_value_expression.zig +++ b/test/compile_errors/stage1/obj/missing_field_in_struct_value_expression.zig @@ -13,6 +13,8 @@ export fn f() void { _ = a; } -// missing field in struct value expression +// error +// backend=stage1 +// target=native // // tmp.zig:9:17: error: missing field: 'x' diff --git a/test/compile_errors/stage1/obj/missing_function_call_param.zig b/test/compile_errors/stage1/obj/missing_function_call_param.zig index 45a7259814..9e08ed7140 100644 --- a/test/compile_errors/stage1/obj/missing_function_call_param.zig +++ b/test/compile_errors/stage1/obj/missing_function_call_param.zig @@ -24,6 +24,8 @@ fn f(foo: *const Foo, index: usize) void { export fn entry() usize { return @sizeOf(@TypeOf(f)); } -// missing function call param +// error +// backend=stage1 +// target=native // // tmp.zig:20:34: error: expected 1 argument(s), found 0 diff --git a/test/compile_errors/stage1/obj/missing_function_name.zig b/test/compile_errors/stage1/obj/missing_function_name.zig index 194f5eb6a8..cd9a3ca7ee 100644 --- a/test/compile_errors/stage1/obj/missing_function_name.zig +++ b/test/compile_errors/stage1/obj/missing_function_name.zig @@ -1,6 +1,8 @@ fn () void {} export fn entry() usize { return @sizeOf(@TypeOf(f)); } -// missing function name +// error +// backend=stage1 +// target=native // // tmp.zig:1:1: error: missing function name diff --git a/test/compile_errors/stage1/obj/missing_param_name.zig b/test/compile_errors/stage1/obj/missing_param_name.zig index 1c379dd245..febb16d2ca 100644 --- a/test/compile_errors/stage1/obj/missing_param_name.zig +++ b/test/compile_errors/stage1/obj/missing_param_name.zig @@ -1,6 +1,8 @@ fn f(i32) void {} export fn entry() usize { return @sizeOf(@TypeOf(f)); } -// missing param name +// error +// backend=stage1 +// target=native // // tmp.zig:1:6: error: missing parameter name diff --git a/test/compile_errors/stage1/obj/missing_parameter_name_of_generic_function.zig b/test/compile_errors/stage1/obj/missing_parameter_name_of_generic_function.zig index 3a3ccd28a8..041c0c4a47 100644 --- a/test/compile_errors/stage1/obj/missing_parameter_name_of_generic_function.zig +++ b/test/compile_errors/stage1/obj/missing_parameter_name_of_generic_function.zig @@ -4,6 +4,8 @@ export fn entry() void { dump(a); } -// missing parameter name of generic function +// error +// backend=stage1 +// target=native // // tmp.zig:1:9: error: missing parameter name diff --git a/test/compile_errors/stage1/obj/missing_result_type_for_phi_node.zig b/test/compile_errors/stage1/obj/missing_result_type_for_phi_node.zig index 3ef99e0859..33bc1d0d9c 100644 --- a/test/compile_errors/stage1/obj/missing_result_type_for_phi_node.zig +++ b/test/compile_errors/stage1/obj/missing_result_type_for_phi_node.zig @@ -5,6 +5,8 @@ export fn entry() void { foo() catch 0; } -// missing result type for phi node +// error +// backend=stage1 +// target=native // // tmp.zig:5:17: error: integer value 0 cannot be coerced to type 'void' diff --git a/test/compile_errors/stage1/obj/misspelled_type_with_pointer_only_reference.zig b/test/compile_errors/stage1/obj/misspelled_type_with_pointer_only_reference.zig index 6b3f647c02..8e2055a829 100644 --- a/test/compile_errors/stage1/obj/misspelled_type_with_pointer_only_reference.zig +++ b/test/compile_errors/stage1/obj/misspelled_type_with_pointer_only_reference.zig @@ -30,6 +30,8 @@ fn foo() void { export fn entry() usize { return @sizeOf(@TypeOf(foo)); } -// misspelled type with pointer only reference +// error +// backend=stage1 +// target=native // // tmp.zig:5:16: error: use of undeclared identifier 'JsonList' diff --git a/test/compile_errors/stage1/obj/mod_assign_on_undefined_value.zig b/test/compile_errors/stage1/obj/mod_assign_on_undefined_value.zig index 3165970d44..c127e256e8 100644 --- a/test/compile_errors/stage1/obj/mod_assign_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/mod_assign_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { a %= a; } -// mod assign on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/mod_on_undefined_value.zig b/test/compile_errors/stage1/obj/mod_on_undefined_value.zig index 3b33f6ed82..8bd7774a46 100644 --- a/test/compile_errors/stage1/obj/mod_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/mod_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = a % a; } -// mod on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/mul_overflow_in_function_evaluation.zig b/test/compile_errors/stage1/obj/mul_overflow_in_function_evaluation.zig index ea8eea5ab5..8209b33f94 100644 --- a/test/compile_errors/stage1/obj/mul_overflow_in_function_evaluation.zig +++ b/test/compile_errors/stage1/obj/mul_overflow_in_function_evaluation.zig @@ -5,6 +5,8 @@ fn mul(a: u16, b: u16) u16 { export fn entry() usize { return @sizeOf(@TypeOf(y)); } -// mul overflow in function evaluation +// error +// backend=stage1 +// target=native // // tmp.zig:3:14: error: operation caused overflow diff --git a/test/compile_errors/stage1/obj/mult_assign_on_undefined_value.zig b/test/compile_errors/stage1/obj/mult_assign_on_undefined_value.zig index 4617c5f62b..04040b9756 100644 --- a/test/compile_errors/stage1/obj/mult_assign_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/mult_assign_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { a *= a; } -// mult assign on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/mult_on_undefined_value.zig b/test/compile_errors/stage1/obj/mult_on_undefined_value.zig index 836b59e19d..0dcd2b02f2 100644 --- a/test/compile_errors/stage1/obj/mult_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/mult_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = a * a; } -// mult on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/mult_wrap_assign_on_undefined_value.zig b/test/compile_errors/stage1/obj/mult_wrap_assign_on_undefined_value.zig index 38bd38bf79..db54af9f0b 100644 --- a/test/compile_errors/stage1/obj/mult_wrap_assign_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/mult_wrap_assign_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { a *%= a; } -// mult wrap assign on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/mult_wrap_on_undefined_value.zig b/test/compile_errors/stage1/obj/mult_wrap_on_undefined_value.zig index 0c0ca46540..9ad09f7e93 100644 --- a/test/compile_errors/stage1/obj/mult_wrap_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/mult_wrap_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = a *% a; } -// mult wrap on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/multiple_function_definitions.zig b/test/compile_errors/stage1/obj/multiple_function_definitions.zig index c4efefce8d..baa4a43048 100644 --- a/test/compile_errors/stage1/obj/multiple_function_definitions.zig +++ b/test/compile_errors/stage1/obj/multiple_function_definitions.zig @@ -2,7 +2,9 @@ fn a() void {} fn a() void {} export fn entry() void { a(); } -// multiple function definitions +// error +// backend=stage1 +// target=native // // tmp.zig:2:1: error: redeclaration of 'a' // tmp.zig:1:1: note: other declaration here diff --git a/test/compile_errors/stage1/obj/negate_on_undefined_value.zig b/test/compile_errors/stage1/obj/negate_on_undefined_value.zig index 7e7e392104..f8d5f6128d 100644 --- a/test/compile_errors/stage1/obj/negate_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/negate_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = -a; } -// negate on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:10: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/negate_wrap_on_undefined_value.zig b/test/compile_errors/stage1/obj/negate_wrap_on_undefined_value.zig index f49c6eac34..4ca32956de 100644 --- a/test/compile_errors/stage1/obj/negate_wrap_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/negate_wrap_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = -%a; } -// negate wrap on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:11: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/negation_overflow_in_function_evaluation.zig b/test/compile_errors/stage1/obj/negation_overflow_in_function_evaluation.zig index ca69b6fb5d..f83e0de6ae 100644 --- a/test/compile_errors/stage1/obj/negation_overflow_in_function_evaluation.zig +++ b/test/compile_errors/stage1/obj/negation_overflow_in_function_evaluation.zig @@ -5,6 +5,8 @@ fn neg(x: i8) i8 { export fn entry() usize { return @sizeOf(@TypeOf(y)); } -// negation overflow in function evaluation +// error +// backend=stage1 +// target=native // // tmp.zig:3:12: error: negation caused overflow diff --git a/test/compile_errors/stage1/obj/nested_error_set_mismatch.zig b/test/compile_errors/stage1/obj/nested_error_set_mismatch.zig index 6c677049df..cd037635bc 100644 --- a/test/compile_errors/stage1/obj/nested_error_set_mismatch.zig +++ b/test/compile_errors/stage1/obj/nested_error_set_mismatch.zig @@ -10,7 +10,9 @@ fn foo() ?OtherError!i32 { return null; } -// nested error set mismatch +// error +// backend=stage1 +// target=native // // tmp.zig:5:34: error: expected type '?NextError!i32', found '?OtherError!i32' // tmp.zig:5:34: note: optional type child 'OtherError!i32' cannot cast into optional type child 'NextError!i32' diff --git a/test/compile_errors/stage1/obj/no_else_prong_on_switch_on_global_error_set.zig b/test/compile_errors/stage1/obj/no_else_prong_on_switch_on_global_error_set.zig index 7de3f189f0..39f4399caf 100644 --- a/test/compile_errors/stage1/obj/no_else_prong_on_switch_on_global_error_set.zig +++ b/test/compile_errors/stage1/obj/no_else_prong_on_switch_on_global_error_set.zig @@ -7,6 +7,8 @@ fn foo(a: anyerror) void { } } -// no else prong on switch on global error set +// error +// backend=stage1 +// target=native // // tmp.zig:5:5: error: else prong required when switching on type 'anyerror' diff --git a/test/compile_errors/stage1/obj/noalias_on_non_pointer_param.zig b/test/compile_errors/stage1/obj/noalias_on_non_pointer_param.zig index 3419dc8c99..ca84aca73f 100644 --- a/test/compile_errors/stage1/obj/noalias_on_non_pointer_param.zig +++ b/test/compile_errors/stage1/obj/noalias_on_non_pointer_param.zig @@ -1,6 +1,8 @@ fn f(noalias x: i32) void { _ = x; } export fn entry() void { f(1234); } -// noalias on non pointer param +// error +// backend=stage1 +// target=native // // tmp.zig:1:6: error: noalias on non-pointer parameter diff --git a/test/compile_errors/stage1/obj/non-async_function_pointer_eventually_is_inferred_to_become_async.zig b/test/compile_errors/stage1/obj/non-async_function_pointer_eventually_is_inferred_to_become_async.zig index 93391daaef..e18b420028 100644 --- a/test/compile_errors/stage1/obj/non-async_function_pointer_eventually_is_inferred_to_become_async.zig +++ b/test/compile_errors/stage1/obj/non-async_function_pointer_eventually_is_inferred_to_become_async.zig @@ -6,7 +6,9 @@ fn func() void { suspend {} } -// non-async function pointer eventually is inferred to become async +// error +// backend=stage1 +// target=native // // tmp.zig:5:1: error: 'func' cannot be async // tmp.zig:3:20: note: required to be non-async here diff --git a/test/compile_errors/stage1/obj/non-const_expression_function_call_with_struct_return_value_outside_function.zig b/test/compile_errors/stage1/obj/non-const_expression_function_call_with_struct_return_value_outside_function.zig index d6a463e71f..25e33d1435 100644 --- a/test/compile_errors/stage1/obj/non-const_expression_function_call_with_struct_return_value_outside_function.zig +++ b/test/compile_errors/stage1/obj/non-const_expression_function_call_with_struct_return_value_outside_function.zig @@ -10,6 +10,8 @@ var global_side_effect = false; export fn entry() usize { return @sizeOf(@TypeOf(a)); } -// non-const expression function call with struct return value outside function +// error +// backend=stage1 +// target=native // // tmp.zig:6:26: error: unable to evaluate constant expression diff --git a/test/compile_errors/stage1/obj/non-const_expression_in_struct_literal_outside_function.zig b/test/compile_errors/stage1/obj/non-const_expression_in_struct_literal_outside_function.zig index ef7b1309c3..46b94f1f96 100644 --- a/test/compile_errors/stage1/obj/non-const_expression_in_struct_literal_outside_function.zig +++ b/test/compile_errors/stage1/obj/non-const_expression_in_struct_literal_outside_function.zig @@ -6,6 +6,8 @@ extern fn get_it() i32; export fn entry() usize { return @sizeOf(@TypeOf(a)); } -// non-const expression in struct literal outside function +// error +// backend=stage1 +// target=native // // tmp.zig:4:21: error: unable to evaluate constant expression diff --git a/test/compile_errors/stage1/obj/non-const_switch_number_literal.zig b/test/compile_errors/stage1/obj/non-const_switch_number_literal.zig index aecaa7dcb6..005db548ed 100644 --- a/test/compile_errors/stage1/obj/non-const_switch_number_literal.zig +++ b/test/compile_errors/stage1/obj/non-const_switch_number_literal.zig @@ -10,6 +10,8 @@ fn bar() i32 { return 2; } -// non-const switch number literal +// error +// backend=stage1 +// target=native // // tmp.zig:5:17: error: cannot store runtime value in type 'comptime_int' diff --git a/test/compile_errors/stage1/obj/non-const_variables_of_things_that_require_const_variables.zig b/test/compile_errors/stage1/obj/non-const_variables_of_things_that_require_const_variables.zig index 0598e04e4b..73ef29aa54 100644 --- a/test/compile_errors/stage1/obj/non-const_variables_of_things_that_require_const_variables.zig +++ b/test/compile_errors/stage1/obj/non-const_variables_of_things_that_require_const_variables.zig @@ -35,7 +35,9 @@ const Foo = struct { fn bar(self: *const Foo) void {_ = self;} }; -// non-const variables of things that require const variables +// error +// backend=stage1 +// target=native // // tmp.zig:2:4: error: variable of type '*const comptime_int' must be const or comptime // tmp.zig:6:4: error: variable of type '@Type(.Undefined)' must be const or comptime diff --git a/test/compile_errors/stage1/obj/non-enum_tag_type_passed_to_union.zig b/test/compile_errors/stage1/obj/non-enum_tag_type_passed_to_union.zig index 3161f16b28..e188a3f819 100644 --- a/test/compile_errors/stage1/obj/non-enum_tag_type_passed_to_union.zig +++ b/test/compile_errors/stage1/obj/non-enum_tag_type_passed_to_union.zig @@ -6,6 +6,8 @@ export fn entry() void { _ = x; } -// non-enum tag type passed to union +// error +// backend=stage1 +// target=native // // tmp.zig:1:19: error: expected enum tag type, found 'u32' diff --git a/test/compile_errors/stage1/obj/non-extern_function_with_var_args.zig b/test/compile_errors/stage1/obj/non-extern_function_with_var_args.zig index 02b99383c1..9e5463d451 100644 --- a/test/compile_errors/stage1/obj/non-extern_function_with_var_args.zig +++ b/test/compile_errors/stage1/obj/non-extern_function_with_var_args.zig @@ -3,6 +3,8 @@ export fn entry() void { foo(); } -// non-extern function with var args +// error +// backend=stage1 +// target=native // // tmp.zig:1:14: error: expected type expression, found '...' diff --git a/test/compile_errors/stage1/obj/non-inline_for_loop_on_a_type_that_requires_comptime.zig b/test/compile_errors/stage1/obj/non-inline_for_loop_on_a_type_that_requires_comptime.zig index 9190e7cea8..d2b4e28ea6 100644 --- a/test/compile_errors/stage1/obj/non-inline_for_loop_on_a_type_that_requires_comptime.zig +++ b/test/compile_errors/stage1/obj/non-inline_for_loop_on_a_type_that_requires_comptime.zig @@ -7,6 +7,8 @@ export fn entry() void { for (xx) |f| { _ = f;} } -// non-inline for loop on a type that requires comptime +// error +// backend=stage1 +// target=native // // tmp.zig:7:5: error: values of type 'Foo' must be comptime known, but index value is runtime known diff --git a/test/compile_errors/stage1/obj/non-integer_tag_type_to_automatic_union_enum.zig b/test/compile_errors/stage1/obj/non-integer_tag_type_to_automatic_union_enum.zig index a84ca36f6c..41d5e14163 100644 --- a/test/compile_errors/stage1/obj/non-integer_tag_type_to_automatic_union_enum.zig +++ b/test/compile_errors/stage1/obj/non-integer_tag_type_to_automatic_union_enum.zig @@ -6,6 +6,8 @@ export fn entry() void { _ = x; } -// non-integer tag type to automatic union enum +// error +// backend=stage1 +// target=native // // tmp.zig:1:24: error: expected integer tag type, found 'f32' diff --git a/test/compile_errors/stage1/obj/non-pure_function_returns_type.zig b/test/compile_errors/stage1/obj/non-pure_function_returns_type.zig index 0925207b9f..9d1c642273 100644 --- a/test/compile_errors/stage1/obj/non-pure_function_returns_type.zig +++ b/test/compile_errors/stage1/obj/non-pure_function_returns_type.zig @@ -17,6 +17,8 @@ export fn function_with_return_type_type() void { list.length = 10; } -// non-pure function returns type +// error +// backend=stage1 +// target=native // // tmp.zig:3:7: error: unable to evaluate constant expression diff --git a/test/compile_errors/stage1/obj/non_async_function_pointer_passed_to_asyncCall.zig b/test/compile_errors/stage1/obj/non_async_function_pointer_passed_to_asyncCall.zig index 73c4fd96ca..d8ab4087e0 100644 --- a/test/compile_errors/stage1/obj/non_async_function_pointer_passed_to_asyncCall.zig +++ b/test/compile_errors/stage1/obj/non_async_function_pointer_passed_to_asyncCall.zig @@ -5,6 +5,8 @@ export fn entry() void { } fn afunc() void { } -// non async function pointer passed to @asyncCall +// error +// backend=stage1 +// target=native // // tmp.zig:4:32: error: expected async function, found 'fn() void' diff --git a/test/compile_errors/stage1/obj/non_compile_time_array_concatenation.zig b/test/compile_errors/stage1/obj/non_compile_time_array_concatenation.zig index c119cc03f7..e70e6daf32 100644 --- a/test/compile_errors/stage1/obj/non_compile_time_array_concatenation.zig +++ b/test/compile_errors/stage1/obj/non_compile_time_array_concatenation.zig @@ -4,6 +4,8 @@ fn f() []u8 { var s: [10]u8 = undefined; export fn entry() usize { return @sizeOf(@TypeOf(f)); } -// non compile time array concatenation +// error +// backend=stage1 +// target=native // // tmp.zig:2:12: error: unable to evaluate constant expression diff --git a/test/compile_errors/stage1/obj/non_constant_expression_in_array_size.zig b/test/compile_errors/stage1/obj/non_constant_expression_in_array_size.zig index fe28921265..a0cb8e8ce1 100644 --- a/test/compile_errors/stage1/obj/non_constant_expression_in_array_size.zig +++ b/test/compile_errors/stage1/obj/non_constant_expression_in_array_size.zig @@ -6,7 +6,9 @@ fn get() usize { return global_var; } export fn entry() usize { return @sizeOf(@TypeOf(Foo)); } -// non constant expression in array size +// error +// backend=stage1 +// target=native // // tmp.zig:5:25: error: cannot store runtime value in compile time variable // tmp.zig:2:12: note: called from here diff --git a/test/compile_errors/stage1/obj/non_error_sets_used_in_merge_error_sets_operator.zig b/test/compile_errors/stage1/obj/non_error_sets_used_in_merge_error_sets_operator.zig index c600bea8b0..fc3431820c 100644 --- a/test/compile_errors/stage1/obj/non_error_sets_used_in_merge_error_sets_operator.zig +++ b/test/compile_errors/stage1/obj/non_error_sets_used_in_merge_error_sets_operator.zig @@ -7,7 +7,9 @@ export fn bar() void { _ = Errors; } -// non error sets used in merge error sets operator +// error +// backend=stage1 +// target=native // // tmp.zig:2:20: error: expected error set type, found type 'u8' // tmp.zig:2:23: note: `||` merges error sets; `or` performs boolean OR diff --git a/test/compile_errors/stage1/obj/non_float_passed_to_floatToInt.zig b/test/compile_errors/stage1/obj/non_float_passed_to_floatToInt.zig index cad658ba5a..c91025906a 100644 --- a/test/compile_errors/stage1/obj/non_float_passed_to_floatToInt.zig +++ b/test/compile_errors/stage1/obj/non_float_passed_to_floatToInt.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = x; } -// non float passed to @floatToInt +// error +// backend=stage1 +// target=native // // tmp.zig:2:32: error: expected float type, found 'i32' diff --git a/test/compile_errors/stage1/obj/non_int_passed_to_intToFloat.zig b/test/compile_errors/stage1/obj/non_int_passed_to_intToFloat.zig index 8b985c2b0b..8f6acca51e 100644 --- a/test/compile_errors/stage1/obj/non_int_passed_to_intToFloat.zig +++ b/test/compile_errors/stage1/obj/non_int_passed_to_intToFloat.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = x; } -// non int passed to @intToFloat +// error +// backend=stage1 +// target=native // // tmp.zig:2:32: error: expected int type, found 'comptime_float' diff --git a/test/compile_errors/stage1/obj/non_pointer_given_to_ptrToInt.zig b/test/compile_errors/stage1/obj/non_pointer_given_to_ptrToInt.zig index 1d4d3087da..7824c0f796 100644 --- a/test/compile_errors/stage1/obj/non_pointer_given_to_ptrToInt.zig +++ b/test/compile_errors/stage1/obj/non_pointer_given_to_ptrToInt.zig @@ -2,6 +2,8 @@ export fn entry(x: i32) usize { return @ptrToInt(x); } -// non pointer given to @ptrToInt +// error +// backend=stage1 +// target=native // // tmp.zig:2:22: error: expected pointer, found 'i32' diff --git a/test/compile_errors/stage1/obj/normal_string_with_newline.zig b/test/compile_errors/stage1/obj/normal_string_with_newline.zig index dafc041744..f6c1d1b1b9 100644 --- a/test/compile_errors/stage1/obj/normal_string_with_newline.zig +++ b/test/compile_errors/stage1/obj/normal_string_with_newline.zig @@ -1,7 +1,9 @@ const foo = "a b"; -// normal string with newline +// error +// backend=stage1 +// target=native // // tmp.zig:1:13: error: expected expression, found 'invalid bytes' // tmp.zig:1:15: note: invalid byte: '\n' diff --git a/test/compile_errors/stage1/obj/offsetOf-bad_field_name.zig b/test/compile_errors/stage1/obj/offsetOf-bad_field_name.zig index 3b301e2677..de5b82c22c 100644 --- a/test/compile_errors/stage1/obj/offsetOf-bad_field_name.zig +++ b/test/compile_errors/stage1/obj/offsetOf-bad_field_name.zig @@ -5,6 +5,8 @@ export fn foo() usize { return @offsetOf(Foo, "a",); } -// @offsetOf - bad field name +// error +// backend=stage1 +// target=native // // tmp.zig:5:27: error: struct 'Foo' has no field 'a' diff --git a/test/compile_errors/stage1/obj/offsetOf-non_struct.zig b/test/compile_errors/stage1/obj/offsetOf-non_struct.zig index 173119407a..15275b827b 100644 --- a/test/compile_errors/stage1/obj/offsetOf-non_struct.zig +++ b/test/compile_errors/stage1/obj/offsetOf-non_struct.zig @@ -3,6 +3,8 @@ export fn foo() usize { return @offsetOf(Foo, "a",); } -// @offsetOf - non struct +// error +// backend=stage1 +// target=native // // tmp.zig:3:22: error: expected struct type, found 'i32' diff --git a/test/compile_errors/stage1/obj/only_equality_binary_operator_allowed_for_error_sets.zig b/test/compile_errors/stage1/obj/only_equality_binary_operator_allowed_for_error_sets.zig index 58512ef2a6..ff9c4d18a2 100644 --- a/test/compile_errors/stage1/obj/only_equality_binary_operator_allowed_for_error_sets.zig +++ b/test/compile_errors/stage1/obj/only_equality_binary_operator_allowed_for_error_sets.zig @@ -3,6 +3,8 @@ comptime { _ = z; } -// only equality binary operator allowed for error sets +// error +// backend=stage1 +// target=native // // tmp.zig:2:23: error: operator not allowed for errors diff --git a/test/compile_errors/stage1/obj/opaque_type_with_field.zig b/test/compile_errors/stage1/obj/opaque_type_with_field.zig index 748d5c0736..0b87091de9 100644 --- a/test/compile_errors/stage1/obj/opaque_type_with_field.zig +++ b/test/compile_errors/stage1/obj/opaque_type_with_field.zig @@ -4,6 +4,8 @@ export fn entry() void { _ = foo; } -// opaque type with field +// error +// backend=stage1 +// target=native // // tmp.zig:1:25: error: opaque types cannot have fields diff --git a/test/compile_errors/stage1/obj/optional_pointer_to_void_in_extern_struct.zig b/test/compile_errors/stage1/obj/optional_pointer_to_void_in_extern_struct.zig index f4ebb577d9..552f672ad6 100644 --- a/test/compile_errors/stage1/obj/optional_pointer_to_void_in_extern_struct.zig +++ b/test/compile_errors/stage1/obj/optional_pointer_to_void_in_extern_struct.zig @@ -7,6 +7,8 @@ const Bar = extern struct { }; export fn entry(bar: *Bar) void {_ = bar;} -// optional pointer to void in extern struct +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: extern structs cannot contain fields of type '?*const void' diff --git a/test/compile_errors/stage1/obj/or_on_undefined_value.zig b/test/compile_errors/stage1/obj/or_on_undefined_value.zig index ac636bff9e..11e6c41dea 100644 --- a/test/compile_errors/stage1/obj/or_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/or_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = a or a; } -// or on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/orelse_on_undefined_value.zig b/test/compile_errors/stage1/obj/orelse_on_undefined_value.zig index 28e7c4b425..3042c208eb 100644 --- a/test/compile_errors/stage1/obj/orelse_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/orelse_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = a orelse false; } -// orelse on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:11: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/out_of_range_comptime_int_passed_to_floatToInt.zig b/test/compile_errors/stage1/obj/out_of_range_comptime_int_passed_to_floatToInt.zig index 581bb58ffd..1a1dd541c9 100644 --- a/test/compile_errors/stage1/obj/out_of_range_comptime_int_passed_to_floatToInt.zig +++ b/test/compile_errors/stage1/obj/out_of_range_comptime_int_passed_to_floatToInt.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = x; } -// out of range comptime_int passed to @floatToInt +// error +// backend=stage1 +// target=native // // tmp.zig:2:31: error: integer value 200 cannot be coerced to type 'i8' diff --git a/test/compile_errors/stage1/obj/overflow_in_enum_value_allocation.zig b/test/compile_errors/stage1/obj/overflow_in_enum_value_allocation.zig index 5c737e06a2..c5dc5c1dcf 100644 --- a/test/compile_errors/stage1/obj/overflow_in_enum_value_allocation.zig +++ b/test/compile_errors/stage1/obj/overflow_in_enum_value_allocation.zig @@ -7,6 +7,8 @@ pub fn main() void { _ = y; } -// overflow in enum value allocation +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: enumeration value 256 too large for type 'u8' diff --git a/test/compile_errors/stage1/obj/packed_union_given_enum_tag_type.zig b/test/compile_errors/stage1/obj/packed_union_given_enum_tag_type.zig index f0bc445295..fceb7af65c 100644 --- a/test/compile_errors/stage1/obj/packed_union_given_enum_tag_type.zig +++ b/test/compile_errors/stage1/obj/packed_union_given_enum_tag_type.zig @@ -13,6 +13,8 @@ export fn entry() void { _ = a; } -// packed union given enum tag type +// error +// backend=stage1 +// target=native // // tmp.zig:6:30: error: packed union does not support enum tag type diff --git a/test/compile_errors/stage1/obj/packed_union_with_automatic_layout_field.zig b/test/compile_errors/stage1/obj/packed_union_with_automatic_layout_field.zig index 4450531a5b..99ad6ca306 100644 --- a/test/compile_errors/stage1/obj/packed_union_with_automatic_layout_field.zig +++ b/test/compile_errors/stage1/obj/packed_union_with_automatic_layout_field.zig @@ -11,6 +11,8 @@ export fn entry() void { _ = a; } -// packed union with automatic layout field +// error +// backend=stage1 +// target=native // // tmp.zig:6:5: error: non-packed, non-extern struct 'Foo' not allowed in packed union; no guaranteed in-memory representation diff --git a/test/compile_errors/stage1/obj/panic_called_at_compile_time.zig b/test/compile_errors/stage1/obj/panic_called_at_compile_time.zig index 6dd32cdf59..7c16932913 100644 --- a/test/compile_errors/stage1/obj/panic_called_at_compile_time.zig +++ b/test/compile_errors/stage1/obj/panic_called_at_compile_time.zig @@ -4,6 +4,8 @@ export fn entry() void { } } -// @panic called at compile time +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: encountered @panic at compile-time diff --git a/test/compile_errors/stage1/obj/parameter_redeclaration.zig b/test/compile_errors/stage1/obj/parameter_redeclaration.zig index 01fc507afc..528eee8374 100644 --- a/test/compile_errors/stage1/obj/parameter_redeclaration.zig +++ b/test/compile_errors/stage1/obj/parameter_redeclaration.zig @@ -2,7 +2,9 @@ fn f(a : i32, a : i32) void { } export fn entry() void { f(1, 2); } -// parameter redeclaration +// error +// backend=stage1 +// target=native // // tmp.zig:1:15: error: redeclaration of function parameter 'a' // tmp.zig:1:6: note: previous declaration here diff --git a/test/compile_errors/stage1/obj/parameter_shadowing_global.zig b/test/compile_errors/stage1/obj/parameter_shadowing_global.zig index a58a0b93ce..ce417d7188 100644 --- a/test/compile_errors/stage1/obj/parameter_shadowing_global.zig +++ b/test/compile_errors/stage1/obj/parameter_shadowing_global.zig @@ -4,7 +4,9 @@ export fn entry() void { f(1234); } -// parameter shadowing global +// error +// backend=stage1 +// target=native // // tmp.zig:2:6: error: local shadows declaration of 'Foo' // tmp.zig:1:1: note: declared here diff --git a/test/compile_errors/stage1/obj/pass_const_ptr_to_mutable_ptr_fn.zig b/test/compile_errors/stage1/obj/pass_const_ptr_to_mutable_ptr_fn.zig index ff0057bb48..3209bb7321 100644 --- a/test/compile_errors/stage1/obj/pass_const_ptr_to_mutable_ptr_fn.zig +++ b/test/compile_errors/stage1/obj/pass_const_ptr_to_mutable_ptr_fn.zig @@ -10,6 +10,8 @@ fn ptrEql(a: *[]const u8, b: *[]const u8) bool { export fn entry() usize { return @sizeOf(@TypeOf(foo)); } -// pass const ptr to mutable ptr fn +// error +// backend=stage1 +// target=native // // tmp.zig:4:19: error: expected type '*[]const u8', found '*const []const u8' diff --git a/test/compile_errors/stage1/obj/passing_a_not-aligned-enough_pointer_to_cmpxchg.zig b/test/compile_errors/stage1/obj/passing_a_not-aligned-enough_pointer_to_cmpxchg.zig index 40564998b7..c1725f1ee8 100644 --- a/test/compile_errors/stage1/obj/passing_a_not-aligned-enough_pointer_to_cmpxchg.zig +++ b/test/compile_errors/stage1/obj/passing_a_not-aligned-enough_pointer_to_cmpxchg.zig @@ -5,6 +5,8 @@ export fn entry() bool { return x == 5678; } -// passing a not-aligned-enough pointer to cmpxchg +// error +// backend=stage1 +// target=native // // tmp.zig:4:32: error: expected type '*i32', found '*align(1) i32' diff --git a/test/compile_errors/stage1/obj/passing_an_under-aligned_function_pointer.zig b/test/compile_errors/stage1/obj/passing_an_under-aligned_function_pointer.zig index f6c0e52cc0..d67bd42a72 100644 --- a/test/compile_errors/stage1/obj/passing_an_under-aligned_function_pointer.zig +++ b/test/compile_errors/stage1/obj/passing_an_under-aligned_function_pointer.zig @@ -6,6 +6,8 @@ fn testImplicitlyDecreaseFnAlign(ptr: fn () align(8) i32, answer: i32) void { } fn alignedSmall() align(4) i32 { return 1234; } -// passing an under-aligned function pointer +// error +// backend=stage1 +// target=native // // tmp.zig:2:35: error: expected type 'fn() align(8) i32', found 'fn() align(4) i32' diff --git a/test/compile_errors/stage1/obj/peer_cast_then_implicit_cast_const_pointer_to_mutable_C_pointer.zig b/test/compile_errors/stage1/obj/peer_cast_then_implicit_cast_const_pointer_to_mutable_C_pointer.zig index 78f072c0d0..7d18e760c3 100644 --- a/test/compile_errors/stage1/obj/peer_cast_then_implicit_cast_const_pointer_to_mutable_C_pointer.zig +++ b/test/compile_errors/stage1/obj/peer_cast_then_implicit_cast_const_pointer_to_mutable_C_pointer.zig @@ -3,7 +3,9 @@ export fn func() void { strValue = strValue orelse ""; } -// peer cast then implicit cast const pointer to mutable C pointer +// error +// backend=stage1 +// target=native // // tmp.zig:3:32: error: expected type '[*c]u8', found '*const [0:0]u8' // tmp.zig:3:32: note: cast discards const qualifier diff --git a/test/compile_errors/stage1/obj/pointer_arithmetic_on_pointer-to-array.zig b/test/compile_errors/stage1/obj/pointer_arithmetic_on_pointer-to-array.zig index b293ae2b32..6542aa6968 100644 --- a/test/compile_errors/stage1/obj/pointer_arithmetic_on_pointer-to-array.zig +++ b/test/compile_errors/stage1/obj/pointer_arithmetic_on_pointer-to-array.zig @@ -5,6 +5,8 @@ export fn foo() void { _ = z; } -// pointer arithmetic on pointer-to-array +// error +// backend=stage1 +// target=native // // tmp.zig:4:17: error: integer value 1 cannot be coerced to type '*[10]u8' diff --git a/test/compile_errors/stage1/obj/pointer_attributes_checked_when_coercing_pointer_to_anon_literal.zig b/test/compile_errors/stage1/obj/pointer_attributes_checked_when_coercing_pointer_to_anon_literal.zig index 079844ac7f..8456c8afcb 100644 --- a/test/compile_errors/stage1/obj/pointer_attributes_checked_when_coercing_pointer_to_anon_literal.zig +++ b/test/compile_errors/stage1/obj/pointer_attributes_checked_when_coercing_pointer_to_anon_literal.zig @@ -12,7 +12,9 @@ comptime { _ = c; } -// pointer attributes checked when coercing pointer to anon literal +// error +// backend=stage1 +// target=native // // tmp.zig:2:31: error: cannot cast pointer to array literal to slice type '[][]const u8' // tmp.zig:2:31: note: cast discards const qualifier diff --git a/test/compile_errors/stage1/obj/pointer_to_noreturn.zig b/test/compile_errors/stage1/obj/pointer_to_noreturn.zig index 3b945919fc..5afcaacaad 100644 --- a/test/compile_errors/stage1/obj/pointer_to_noreturn.zig +++ b/test/compile_errors/stage1/obj/pointer_to_noreturn.zig @@ -1,6 +1,8 @@ fn a() *noreturn {} export fn entry() void { _ = a(); } -// pointer to noreturn +// error +// backend=stage1 +// target=native // // tmp.zig:1:9: error: pointer to noreturn not allowed diff --git a/test/compile_errors/stage1/obj/popCount-non-integer.zig b/test/compile_errors/stage1/obj/popCount-non-integer.zig index 694b794927..a58a98faa3 100644 --- a/test/compile_errors/stage1/obj/popCount-non-integer.zig +++ b/test/compile_errors/stage1/obj/popCount-non-integer.zig @@ -2,6 +2,8 @@ export fn entry(x: f32) u32 { return @popCount(f32, x); } -// @popCount - non-integer +// error +// backend=stage1 +// target=native // // tmp.zig:2:22: error: expected integer type, found 'f32' diff --git a/test/compile_errors/stage1/obj/prevent_bad_implicit_casting_of_anyframe_types.zig b/test/compile_errors/stage1/obj/prevent_bad_implicit_casting_of_anyframe_types.zig index 14bdb9cb11..2e21d45c12 100644 --- a/test/compile_errors/stage1/obj/prevent_bad_implicit_casting_of_anyframe_types.zig +++ b/test/compile_errors/stage1/obj/prevent_bad_implicit_casting_of_anyframe_types.zig @@ -15,7 +15,9 @@ export fn c() void { } fn func() void {} -// prevent bad implicit casting of anyframe types +// error +// backend=stage1 +// target=native // // tmp.zig:3:28: error: expected type 'anyframe->i32', found 'anyframe' // tmp.zig:8:28: error: expected type 'anyframe->i32', found 'i32' diff --git a/test/compile_errors/stage1/obj/primitives_take_precedence_over_declarations.zig b/test/compile_errors/stage1/obj/primitives_take_precedence_over_declarations.zig index 3517c07917..6f6107e88c 100644 --- a/test/compile_errors/stage1/obj/primitives_take_precedence_over_declarations.zig +++ b/test/compile_errors/stage1/obj/primitives_take_precedence_over_declarations.zig @@ -4,6 +4,8 @@ export fn entry() void { _ = a; } -// primitives take precedence over declarations +// error +// backend=stage1 +// target=native // // tmp.zig:3:19: error: integer value 300 cannot be coerced to type 'u8' diff --git a/test/compile_errors/stage1/obj/ptrCast_a_0_bit_type_to_a_non-_0_bit_type.zig b/test/compile_errors/stage1/obj/ptrCast_a_0_bit_type_to_a_non-_0_bit_type.zig index 63d0656f21..2fc30d4a32 100644 --- a/test/compile_errors/stage1/obj/ptrCast_a_0_bit_type_to_a_non-_0_bit_type.zig +++ b/test/compile_errors/stage1/obj/ptrCast_a_0_bit_type_to_a_non-_0_bit_type.zig @@ -4,7 +4,9 @@ export fn entry() bool { return p == null; } -// @ptrCast a 0 bit type to a non- 0 bit type +// error +// backend=stage1 +// target=native // // tmp.zig:3:15: error: '*u0' and '?*u0' do not have the same in-memory representation // tmp.zig:3:31: note: '*u0' has no in-memory bits diff --git a/test/compile_errors/stage1/obj/ptrCast_discards_const_qualifier.zig b/test/compile_errors/stage1/obj/ptrCast_discards_const_qualifier.zig index 1517fd4bd8..1a90ff73f8 100644 --- a/test/compile_errors/stage1/obj/ptrCast_discards_const_qualifier.zig +++ b/test/compile_errors/stage1/obj/ptrCast_discards_const_qualifier.zig @@ -4,6 +4,8 @@ export fn entry() void { _ = y; } -// @ptrCast discards const qualifier +// error +// backend=stage1 +// target=native // // tmp.zig:3:15: error: cast discards const qualifier diff --git a/test/compile_errors/stage1/obj/ptrToInt_0_to_non_optional_pointer.zig b/test/compile_errors/stage1/obj/ptrToInt_0_to_non_optional_pointer.zig index fde1e53c1a..b8a5d1b0aa 100644 --- a/test/compile_errors/stage1/obj/ptrToInt_0_to_non_optional_pointer.zig +++ b/test/compile_errors/stage1/obj/ptrToInt_0_to_non_optional_pointer.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = b; } -// @ptrToInt 0 to non optional pointer +// error +// backend=stage1 +// target=native // // tmp.zig:2:13: error: pointer type '*i32' does not allow address zero diff --git a/test/compile_errors/stage1/obj/ptrToInt_on_void.zig b/test/compile_errors/stage1/obj/ptrToInt_on_void.zig index fd43053103..5012be65e0 100644 --- a/test/compile_errors/stage1/obj/ptrToInt_on_void.zig +++ b/test/compile_errors/stage1/obj/ptrToInt_on_void.zig @@ -2,6 +2,8 @@ export fn entry() bool { return @ptrToInt(&{}) == @ptrToInt(&{}); } -// @ptrToInt on *void +// error +// backend=stage1 +// target=native // // tmp.zig:2:23: error: pointer to size 0 type has no address diff --git a/test/compile_errors/stage1/obj/ptrcast_to_non-pointer.zig b/test/compile_errors/stage1/obj/ptrcast_to_non-pointer.zig index 74894d5e8a..7e9e9a99b7 100644 --- a/test/compile_errors/stage1/obj/ptrcast_to_non-pointer.zig +++ b/test/compile_errors/stage1/obj/ptrcast_to_non-pointer.zig @@ -2,6 +2,8 @@ export fn entry(a: *i32) usize { return @ptrCast(usize, a); } -// ptrcast to non-pointer +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: expected pointer, found 'usize' diff --git a/test/compile_errors/stage1/obj/range_operator_in_switch_used_on_error_set.zig b/test/compile_errors/stage1/obj/range_operator_in_switch_used_on_error_set.zig index 4f2949c50c..8108f42979 100644 --- a/test/compile_errors/stage1/obj/range_operator_in_switch_used_on_error_set.zig +++ b/test/compile_errors/stage1/obj/range_operator_in_switch_used_on_error_set.zig @@ -12,6 +12,8 @@ fn foo(x: i32) !void { } } -// range operator in switch used on error set +// error +// backend=stage1 +// target=native // // tmp.zig:3:17: error: operator not allowed for errors diff --git a/test/compile_errors/stage1/obj/reading_past_end_of_pointer_casted_array.zig b/test/compile_errors/stage1/obj/reading_past_end_of_pointer_casted_array.zig index 558797d69b..cece3345c3 100644 --- a/test/compile_errors/stage1/obj/reading_past_end_of_pointer_casted_array.zig +++ b/test/compile_errors/stage1/obj/reading_past_end_of_pointer_casted_array.zig @@ -6,6 +6,8 @@ comptime { _ = deref; } -// reading past end of pointer casted array +// error +// backend=stage1 +// target=native // // tmp.zig:5:26: error: attempt to read 4 bytes from [4]u8 at index 1 which is 3 bytes diff --git a/test/compile_errors/stage1/obj/recursive_inferred_error_set.zig b/test/compile_errors/stage1/obj/recursive_inferred_error_set.zig index 8059833923..89a2a54cfa 100644 --- a/test/compile_errors/stage1/obj/recursive_inferred_error_set.zig +++ b/test/compile_errors/stage1/obj/recursive_inferred_error_set.zig @@ -5,6 +5,8 @@ fn foo() !void { try foo(); } -// recursive inferred error set +// error +// backend=stage1 +// target=native // // tmp.zig:5:5: error: cannot resolve inferred error set '@typeInfo(@typeInfo(@TypeOf(foo)).Fn.return_type.?).ErrorUnion.error_set': function 'foo' not fully analyzed yet diff --git a/test/compile_errors/stage1/obj/redefinition_of_enums.zig b/test/compile_errors/stage1/obj/redefinition_of_enums.zig index b4033536c3..a95eb88935 100644 --- a/test/compile_errors/stage1/obj/redefinition_of_enums.zig +++ b/test/compile_errors/stage1/obj/redefinition_of_enums.zig @@ -1,7 +1,9 @@ const A = enum {x}; const A = enum {x}; -// redefinition of enums +// error +// backend=stage1 +// target=native // // tmp.zig:2:1: error: redeclaration of 'A' // tmp.zig:1:1: note: other declaration here diff --git a/test/compile_errors/stage1/obj/redefinition_of_global_variables.zig b/test/compile_errors/stage1/obj/redefinition_of_global_variables.zig index b2267423b0..3651946ffe 100644 --- a/test/compile_errors/stage1/obj/redefinition_of_global_variables.zig +++ b/test/compile_errors/stage1/obj/redefinition_of_global_variables.zig @@ -1,7 +1,9 @@ var a : i32 = 1; var a : i32 = 2; -// redefinition of global variables +// error +// backend=stage1 +// target=native // // tmp.zig:2:1: error: redeclaration of 'a' // tmp.zig:1:1: note: other declaration here diff --git a/test/compile_errors/stage1/obj/redefinition_of_struct.zig b/test/compile_errors/stage1/obj/redefinition_of_struct.zig index 8c169356c9..8367a05e43 100644 --- a/test/compile_errors/stage1/obj/redefinition_of_struct.zig +++ b/test/compile_errors/stage1/obj/redefinition_of_struct.zig @@ -1,7 +1,9 @@ const A = struct { x : i32, }; const A = struct { y : i32, }; -// redefinition of struct +// error +// backend=stage1 +// target=native // // tmp.zig:2:1: error: redeclaration of 'A' // tmp.zig:1:1: note: other declaration here diff --git a/test/compile_errors/stage1/obj/refer_to_the_type_of_a_generic_function.zig b/test/compile_errors/stage1/obj/refer_to_the_type_of_a_generic_function.zig index 6e23854cd6..99ab1da8a3 100644 --- a/test/compile_errors/stage1/obj/refer_to_the_type_of_a_generic_function.zig +++ b/test/compile_errors/stage1/obj/refer_to_the_type_of_a_generic_function.zig @@ -4,6 +4,8 @@ export fn entry() void { f(i32); } -// refer to the type of a generic function +// error +// backend=stage1 +// target=native // // tmp.zig:4:5: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/referring_to_a_struct_that_is_invalid.zig b/test/compile_errors/stage1/obj/referring_to_a_struct_that_is_invalid.zig index 5f646461d8..433650cddb 100644 --- a/test/compile_errors/stage1/obj/referring_to_a_struct_that_is_invalid.zig +++ b/test/compile_errors/stage1/obj/referring_to_a_struct_that_is_invalid.zig @@ -10,6 +10,8 @@ fn assert(ok: bool) void { if (!ok) unreachable; } -// referring to a struct that is invalid +// error +// backend=stage1 +// target=native // // tmp.zig:10:14: error: reached unreachable code diff --git a/test/compile_errors/stage1/obj/regression_test_2980_base_type_u32_is_not_type_checked_properly_when_assigning_a_value_within_a_struct.zig b/test/compile_errors/stage1/obj/regression_test_2980_base_type_u32_is_not_type_checked_properly_when_assigning_a_value_within_a_struct.zig index a714b10ef6..8be44fbe05 100644 --- a/test/compile_errors/stage1/obj/regression_test_2980_base_type_u32_is_not_type_checked_properly_when_assigning_a_value_within_a_struct.zig +++ b/test/compile_errors/stage1/obj/regression_test_2980_base_type_u32_is_not_type_checked_properly_when_assigning_a_value_within_a_struct.zig @@ -14,6 +14,8 @@ export fn entry() void { _ = afoo; } -// regression test #2980: base type u32 is not type checked properly when assigning a value within a struct +// error +// backend=stage1 +// target=native // // tmp.zig:12:25: error: cannot convert error union to payload type. consider using `try`, `catch`, or `if`. expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(get_uval)).Fn.return_type.?).ErrorUnion.error_set!u32' diff --git a/test/compile_errors/stage1/obj/reify_type.Fn_with_is_generic_true.zig b/test/compile_errors/stage1/obj/reify_type.Fn_with_is_generic_true.zig index ed33158649..f2849b5eb4 100644 --- a/test/compile_errors/stage1/obj/reify_type.Fn_with_is_generic_true.zig +++ b/test/compile_errors/stage1/obj/reify_type.Fn_with_is_generic_true.zig @@ -10,6 +10,8 @@ const Foo = @Type(.{ }); comptime { _ = Foo; } -// @Type(.Fn) with is_generic = true +// error +// backend=stage1 +// target=native // // tmp.zig:1:20: error: Type.Fn.is_generic must be false for @Type diff --git a/test/compile_errors/stage1/obj/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig b/test/compile_errors/stage1/obj/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig index a57484075f..4d449e9eb9 100644 --- a/test/compile_errors/stage1/obj/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig +++ b/test/compile_errors/stage1/obj/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig @@ -10,6 +10,8 @@ const Foo = @Type(.{ }); comptime { _ = Foo; } -// @Type(.Fn) with is_var_args = true and non-C callconv +// error +// backend=stage1 +// target=native // // tmp.zig:1:20: error: varargs functions must have C calling convention diff --git a/test/compile_errors/stage1/obj/reify_type.Fn_with_return_type_null.zig b/test/compile_errors/stage1/obj/reify_type.Fn_with_return_type_null.zig index f8ddea52cf..98cbc37d41 100644 --- a/test/compile_errors/stage1/obj/reify_type.Fn_with_return_type_null.zig +++ b/test/compile_errors/stage1/obj/reify_type.Fn_with_return_type_null.zig @@ -10,6 +10,8 @@ const Foo = @Type(.{ }); comptime { _ = Foo; } -// @Type(.Fn) with return_type = null +// error +// backend=stage1 +// target=native // // tmp.zig:1:20: error: Type.Fn.return_type must be non-null for @Type diff --git a/test/compile_errors/stage1/obj/reify_type.Pointer_with_invalid_address_space.zig b/test/compile_errors/stage1/obj/reify_type.Pointer_with_invalid_address_space.zig index 78160fae58..1ca97ce250 100644 --- a/test/compile_errors/stage1/obj/reify_type.Pointer_with_invalid_address_space.zig +++ b/test/compile_errors/stage1/obj/reify_type.Pointer_with_invalid_address_space.zig @@ -11,6 +11,8 @@ export fn entry() void { }}); } -// @Type(.Pointer) with invalid address space +// error +// backend=stage1 +// target=native // // tmp.zig:2:16: error: address space 'gs' not available in stage 1 compiler, must be .generic diff --git a/test/compile_errors/stage1/obj/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig b/test/compile_errors/stage1/obj/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig index e77c2eb627..56d05578be 100644 --- a/test/compile_errors/stage1/obj/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig +++ b/test/compile_errors/stage1/obj/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig @@ -11,6 +11,8 @@ export fn entry() void { _ = @intToEnum(Tag, 0); } -// @Type for exhaustive enum with non-integer tag type +// error +// backend=stage1 +// target=native // // tmp.zig:1:20: error: Type.Enum.tag_type must be an integer type, not 'bool' diff --git a/test/compile_errors/stage1/obj/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig b/test/compile_errors/stage1/obj/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig index 6a00516387..e6454d2ee5 100644 --- a/test/compile_errors/stage1/obj/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig +++ b/test/compile_errors/stage1/obj/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig @@ -11,6 +11,8 @@ export fn entry() void { _ = @intToEnum(Tag, 0); } -// @Type for exhaustive enum with undefined tag type +// error +// backend=stage1 +// target=native // // tmp.zig:1:20: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/reify_type_for_exhaustive_enum_with_zero_fields.zig b/test/compile_errors/stage1/obj/reify_type_for_exhaustive_enum_with_zero_fields.zig index 87689247aa..d3ce70c1b0 100644 --- a/test/compile_errors/stage1/obj/reify_type_for_exhaustive_enum_with_zero_fields.zig +++ b/test/compile_errors/stage1/obj/reify_type_for_exhaustive_enum_with_zero_fields.zig @@ -11,6 +11,8 @@ export fn entry() void { _ = @intToEnum(Tag, 0); } -// @Type for exhaustive enum with zero fields +// error +// backend=stage1 +// target=native // // tmp.zig:1:20: error: enums must have 1 or more fields diff --git a/test/compile_errors/stage1/obj/reify_type_for_tagged_union_with_extra_enum_field.zig b/test/compile_errors/stage1/obj/reify_type_for_tagged_union_with_extra_enum_field.zig index f9155d7161..0c56cb91ea 100644 --- a/test/compile_errors/stage1/obj/reify_type_for_tagged_union_with_extra_enum_field.zig +++ b/test/compile_errors/stage1/obj/reify_type_for_tagged_union_with_extra_enum_field.zig @@ -27,6 +27,8 @@ export fn entry() void { tagged = .{ .unsigned = 1 }; } -// @Type for tagged union with extra enum field +// error +// backend=stage1 +// target=native // // tmp.zig:14:23: error: enum field missing: 'arst' diff --git a/test/compile_errors/stage1/obj/reify_type_for_tagged_union_with_extra_union_field.zig b/test/compile_errors/stage1/obj/reify_type_for_tagged_union_with_extra_union_field.zig index 9cd82213df..63cf1f178e 100644 --- a/test/compile_errors/stage1/obj/reify_type_for_tagged_union_with_extra_union_field.zig +++ b/test/compile_errors/stage1/obj/reify_type_for_tagged_union_with_extra_union_field.zig @@ -27,7 +27,9 @@ export fn entry() void { tagged = .{ .unsigned = 1 }; } -// @Type for tagged union with extra union field +// error +// backend=stage1 +// target=native // // tmp.zig:13:23: error: enum field not found: 'arst' // tmp.zig:1:20: note: enum declared here diff --git a/test/compile_errors/stage1/obj/reify_type_for_union_with_opaque_field.zig b/test/compile_errors/stage1/obj/reify_type_for_union_with_opaque_field.zig index 374ccb544b..d3f4f6da4b 100644 --- a/test/compile_errors/stage1/obj/reify_type_for_union_with_opaque_field.zig +++ b/test/compile_errors/stage1/obj/reify_type_for_union_with_opaque_field.zig @@ -12,6 +12,8 @@ export fn entry() void { _ = Untagged{}; } -// @Type for union with opaque field +// error +// backend=stage1 +// target=native // // tmp.zig:1:25: error: opaque types have unknown size and therefore cannot be directly embedded in unions diff --git a/test/compile_errors/stage1/obj/reify_type_for_union_with_zero_fields.zig b/test/compile_errors/stage1/obj/reify_type_for_union_with_zero_fields.zig index 8243ff3292..578f902697 100644 --- a/test/compile_errors/stage1/obj/reify_type_for_union_with_zero_fields.zig +++ b/test/compile_errors/stage1/obj/reify_type_for_union_with_zero_fields.zig @@ -10,6 +10,8 @@ export fn entry() void { _ = Untagged{}; } -// @Type for union with zero fields +// error +// backend=stage1 +// target=native // // tmp.zig:1:25: error: unions must have 1 or more fields diff --git a/test/compile_errors/stage1/obj/reify_type_union_payload_is_undefined.zig b/test/compile_errors/stage1/obj/reify_type_union_payload_is_undefined.zig index 43261dc32f..47be31c711 100644 --- a/test/compile_errors/stage1/obj/reify_type_union_payload_is_undefined.zig +++ b/test/compile_errors/stage1/obj/reify_type_union_payload_is_undefined.zig @@ -3,6 +3,8 @@ const Foo = @Type(.{ }); comptime { _ = Foo; } -// @Type() union payload is undefined +// error +// backend=stage1 +// target=native // // tmp.zig:1:20: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/reify_type_with_Type.Int.zig b/test/compile_errors/stage1/obj/reify_type_with_Type.Int.zig index cea09d3f19..116bd86e0f 100644 --- a/test/compile_errors/stage1/obj/reify_type_with_Type.Int.zig +++ b/test/compile_errors/stage1/obj/reify_type_with_Type.Int.zig @@ -6,6 +6,8 @@ export fn entry() void { }); } -// @Type with Type.Int +// error +// backend=stage1 +// target=native // // tmp.zig:3:31: error: expected type 'std.builtin.Type', found 'std.builtin.Type.Int' diff --git a/test/compile_errors/stage1/obj/reify_type_with_non-constant_expression.zig b/test/compile_errors/stage1/obj/reify_type_with_non-constant_expression.zig index a58b2a6b33..7eec6b395a 100644 --- a/test/compile_errors/stage1/obj/reify_type_with_non-constant_expression.zig +++ b/test/compile_errors/stage1/obj/reify_type_with_non-constant_expression.zig @@ -4,6 +4,8 @@ export fn entry() void { _ = @Type(globalTypeInfo); } -// @Type with non-constant expression +// error +// backend=stage1 +// target=native // // tmp.zig:4:15: error: unable to evaluate constant expression diff --git a/test/compile_errors/stage1/obj/reify_type_with_undefined.zig b/test/compile_errors/stage1/obj/reify_type_with_undefined.zig index 984c9ac555..1de93ccdf6 100644 --- a/test/compile_errors/stage1/obj/reify_type_with_undefined.zig +++ b/test/compile_errors/stage1/obj/reify_type_with_undefined.zig @@ -12,7 +12,9 @@ comptime { }); } -// @Type with undefined +// error +// backend=stage1 +// target=native // // tmp.zig:2:16: error: use of undefined value here causes undefined behavior // tmp.zig:5:16: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/result_location_incompatibility_mismatching_handle_is_ptr.zig b/test/compile_errors/stage1/obj/result_location_incompatibility_mismatching_handle_is_ptr.zig index a45fd9f41a..18dd6382fc 100644 --- a/test/compile_errors/stage1/obj/result_location_incompatibility_mismatching_handle_is_ptr.zig +++ b/test/compile_errors/stage1/obj/result_location_incompatibility_mismatching_handle_is_ptr.zig @@ -11,6 +11,8 @@ pub const Container = struct { not_optional: i32, }; -// result location incompatibility mismatching handle_is_ptr +// error +// backend=stage1 +// target=native // // tmp.zig:3:36: error: cannot convert optional to payload type. consider using `.?`, `orelse`, or `if`. expected type 'i32', found '?i32' diff --git a/test/compile_errors/stage1/obj/result_location_incompatibility_mismatching_handle_is_ptr_generic_call.zig b/test/compile_errors/stage1/obj/result_location_incompatibility_mismatching_handle_is_ptr_generic_call.zig index 8b913bd15c..75811c58e1 100644 --- a/test/compile_errors/stage1/obj/result_location_incompatibility_mismatching_handle_is_ptr_generic_call.zig +++ b/test/compile_errors/stage1/obj/result_location_incompatibility_mismatching_handle_is_ptr_generic_call.zig @@ -11,6 +11,8 @@ pub const Container = struct { not_optional: i32, }; -// result location incompatibility mismatching handle_is_ptr (generic call) +// error +// backend=stage1 +// target=native // // tmp.zig:3:36: error: cannot convert optional to payload type. consider using `.?`, `orelse`, or `if`. expected type 'i32', found '?i32' diff --git a/test/compile_errors/stage1/obj/return_from_defer_expression.zig b/test/compile_errors/stage1/obj/return_from_defer_expression.zig index 0f4ac8e071..cbe9542176 100644 --- a/test/compile_errors/stage1/obj/return_from_defer_expression.zig +++ b/test/compile_errors/stage1/obj/return_from_defer_expression.zig @@ -14,6 +14,8 @@ pub fn maybeInt() ?i32 { export fn entry() usize { return @sizeOf(@TypeOf(testTrickyDefer)); } -// return from defer expression +// error +// backend=stage1 +// target=native // // tmp.zig:4:11: error: 'try' not allowed inside defer expression diff --git a/test/compile_errors/stage1/obj/returning_error_from_void_async_function.zig b/test/compile_errors/stage1/obj/returning_error_from_void_async_function.zig index a00422dd12..691c89a347 100644 --- a/test/compile_errors/stage1/obj/returning_error_from_void_async_function.zig +++ b/test/compile_errors/stage1/obj/returning_error_from_void_async_function.zig @@ -5,6 +5,8 @@ fn amain() callconv(.Async) void { return error.ShouldBeCompileError; } -// returning error from void async function +// error +// backend=stage1 +// target=native // // tmp.zig:5:17: error: expected type 'void', found 'error{ShouldBeCompileError}' diff --git a/test/compile_errors/stage1/obj/runtime-known_async_function_called.zig b/test/compile_errors/stage1/obj/runtime-known_async_function_called.zig index 52afd83a11..90685ce566 100644 --- a/test/compile_errors/stage1/obj/runtime-known_async_function_called.zig +++ b/test/compile_errors/stage1/obj/runtime-known_async_function_called.zig @@ -7,6 +7,8 @@ fn amain() void { } fn afunc() callconv(.Async) void {} -// runtime-known async function called +// error +// backend=stage1 +// target=native // // tmp.zig:6:12: error: function is not comptime-known; @asyncCall required diff --git a/test/compile_errors/stage1/obj/runtime-known_function_called_with_async_keyword.zig b/test/compile_errors/stage1/obj/runtime-known_function_called_with_async_keyword.zig index 79f0420a83..c66d0f9cbb 100644 --- a/test/compile_errors/stage1/obj/runtime-known_function_called_with_async_keyword.zig +++ b/test/compile_errors/stage1/obj/runtime-known_function_called_with_async_keyword.zig @@ -5,6 +5,8 @@ export fn entry() void { fn afunc() callconv(.Async) void { } -// runtime-known function called with async keyword +// error +// backend=stage1 +// target=native // // tmp.zig:3:15: error: function is not comptime-known; @asyncCall required diff --git a/test/compile_errors/stage1/obj/runtime_assignment_to_comptime_struct_type.zig b/test/compile_errors/stage1/obj/runtime_assignment_to_comptime_struct_type.zig index f8a3fd3ba1..62b09673eb 100644 --- a/test/compile_errors/stage1/obj/runtime_assignment_to_comptime_struct_type.zig +++ b/test/compile_errors/stage1/obj/runtime_assignment_to_comptime_struct_type.zig @@ -8,6 +8,8 @@ export fn f() void { _ = foo; } -// runtime assignment to comptime struct type +// error +// backend=stage1 +// target=native // // tmp.zig:7:23: error: unable to evaluate constant expression diff --git a/test/compile_errors/stage1/obj/runtime_assignment_to_comptime_union_type.zig b/test/compile_errors/stage1/obj/runtime_assignment_to_comptime_union_type.zig index bc4f093b0d..af13f8b8ce 100644 --- a/test/compile_errors/stage1/obj/runtime_assignment_to_comptime_union_type.zig +++ b/test/compile_errors/stage1/obj/runtime_assignment_to_comptime_union_type.zig @@ -8,6 +8,8 @@ export fn f() void { _ = foo; } -// runtime assignment to comptime union type +// error +// backend=stage1 +// target=native // // tmp.zig:7:23: error: unable to evaluate constant expression diff --git a/test/compile_errors/stage1/obj/runtime_cast_to_union_which_has_non-void_fields.zig b/test/compile_errors/stage1/obj/runtime_cast_to_union_which_has_non-void_fields.zig index 8be361f2fe..d25c815c7e 100644 --- a/test/compile_errors/stage1/obj/runtime_cast_to_union_which_has_non-void_fields.zig +++ b/test/compile_errors/stage1/obj/runtime_cast_to_union_which_has_non-void_fields.zig @@ -12,7 +12,9 @@ fn foo(l: Letter) void { _ = x; } -// runtime cast to union which has non-void fields +// error +// backend=stage1 +// target=native // // tmp.zig:11:20: error: runtime cast to union 'Value' which has non-void fields // tmp.zig:3:5: note: field 'A' has type 'i32' diff --git a/test/compile_errors/stage1/obj/runtime_index_into_comptime_type_slice.zig b/test/compile_errors/stage1/obj/runtime_index_into_comptime_type_slice.zig index 4b9538c1a1..379767c7f3 100644 --- a/test/compile_errors/stage1/obj/runtime_index_into_comptime_type_slice.zig +++ b/test/compile_errors/stage1/obj/runtime_index_into_comptime_type_slice.zig @@ -10,6 +10,8 @@ export fn entry() void { _ = field; } -// runtime index into comptime type slice +// error +// backend=stage1 +// target=native // // tmp.zig:9:51: error: values of type 'std.builtin.Type.StructField' must be comptime known, but index value is runtime known diff --git a/test/compile_errors/stage1/obj/saturating_arithmetic_does_not_allow_floats.zig b/test/compile_errors/stage1/obj/saturating_arithmetic_does_not_allow_floats.zig index 57ee724e74..7bda134af6 100644 --- a/test/compile_errors/stage1/obj/saturating_arithmetic_does_not_allow_floats.zig +++ b/test/compile_errors/stage1/obj/saturating_arithmetic_does_not_allow_floats.zig @@ -2,6 +2,8 @@ export fn a() void { _ = @as(f32, 1.0) +| @as(f32, 1.0); } -// saturating arithmetic does not allow floats +// error +// backend=stage1 +// target=native // // error: invalid operands to binary expression: 'f32' and 'f32' diff --git a/test/compile_errors/stage1/obj/saturating_shl_assign_does_not_allow_negative_rhs_at_comptime.zig b/test/compile_errors/stage1/obj/saturating_shl_assign_does_not_allow_negative_rhs_at_comptime.zig index 9a46367ae5..7b94f8e832 100644 --- a/test/compile_errors/stage1/obj/saturating_shl_assign_does_not_allow_negative_rhs_at_comptime.zig +++ b/test/compile_errors/stage1/obj/saturating_shl_assign_does_not_allow_negative_rhs_at_comptime.zig @@ -5,6 +5,8 @@ export fn a() void { } } -// saturating shl assign does not allow negative rhs at comptime +// error +// backend=stage1 +// target=native // // error: shift by negative value -2 diff --git a/test/compile_errors/stage1/obj/saturating_shl_does_not_allow_negative_rhs_at_comptime.zig b/test/compile_errors/stage1/obj/saturating_shl_does_not_allow_negative_rhs_at_comptime.zig index ffe715a8e3..ac1ce7d3a0 100644 --- a/test/compile_errors/stage1/obj/saturating_shl_does_not_allow_negative_rhs_at_comptime.zig +++ b/test/compile_errors/stage1/obj/saturating_shl_does_not_allow_negative_rhs_at_comptime.zig @@ -2,6 +2,8 @@ export fn a() void { _ = @as(i32, 1) <<| @as(i32, -2); } -// saturating shl does not allow negative rhs at comptime +// error +// backend=stage1 +// target=native // // error: shift by negative value -2 diff --git a/test/compile_errors/stage1/obj/setAlignStack_in_inline_function.zig b/test/compile_errors/stage1/obj/setAlignStack_in_inline_function.zig index 9261ecdb18..8490298aa3 100644 --- a/test/compile_errors/stage1/obj/setAlignStack_in_inline_function.zig +++ b/test/compile_errors/stage1/obj/setAlignStack_in_inline_function.zig @@ -5,6 +5,8 @@ fn foo() callconv(.Inline) void { @setAlignStack(16); } -// @setAlignStack in inline function +// error +// backend=stage1 +// target=native // // tmp.zig:5:5: error: @setAlignStack in inline function diff --git a/test/compile_errors/stage1/obj/setAlignStack_in_naked_function.zig b/test/compile_errors/stage1/obj/setAlignStack_in_naked_function.zig index d7146625c5..b9adc84ed5 100644 --- a/test/compile_errors/stage1/obj/setAlignStack_in_naked_function.zig +++ b/test/compile_errors/stage1/obj/setAlignStack_in_naked_function.zig @@ -2,6 +2,8 @@ export fn entry() callconv(.Naked) void { @setAlignStack(16); } -// @setAlignStack in naked function +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: @setAlignStack in naked function diff --git a/test/compile_errors/stage1/obj/setAlignStack_outside_function.zig b/test/compile_errors/stage1/obj/setAlignStack_outside_function.zig index c9ac12e6e0..754756012b 100644 --- a/test/compile_errors/stage1/obj/setAlignStack_outside_function.zig +++ b/test/compile_errors/stage1/obj/setAlignStack_outside_function.zig @@ -2,6 +2,8 @@ comptime { @setAlignStack(16); } -// @setAlignStack outside function +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: @setAlignStack outside function diff --git a/test/compile_errors/stage1/obj/setAlignStack_set_twice.zig b/test/compile_errors/stage1/obj/setAlignStack_set_twice.zig index de8cde7c01..244db9d962 100644 --- a/test/compile_errors/stage1/obj/setAlignStack_set_twice.zig +++ b/test/compile_errors/stage1/obj/setAlignStack_set_twice.zig @@ -3,7 +3,9 @@ export fn entry() void { @setAlignStack(16); } -// @setAlignStack set twice +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: alignstack set twice // tmp.zig:2:5: note: first set here diff --git a/test/compile_errors/stage1/obj/setAlignStack_too_big.zig b/test/compile_errors/stage1/obj/setAlignStack_too_big.zig index 669ec45204..601631e158 100644 --- a/test/compile_errors/stage1/obj/setAlignStack_too_big.zig +++ b/test/compile_errors/stage1/obj/setAlignStack_too_big.zig @@ -2,6 +2,8 @@ export fn entry() void { @setAlignStack(511 + 1); } -// @setAlignStack too big +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: attempt to @setAlignStack(512); maximum is 256 diff --git a/test/compile_errors/stage1/obj/setFloatMode_twice_for_same_scope.zig b/test/compile_errors/stage1/obj/setFloatMode_twice_for_same_scope.zig index 3e55604030..41fe6d4d6c 100644 --- a/test/compile_errors/stage1/obj/setFloatMode_twice_for_same_scope.zig +++ b/test/compile_errors/stage1/obj/setFloatMode_twice_for_same_scope.zig @@ -3,7 +3,9 @@ export fn foo() void { @setFloatMode(@import("std").builtin.FloatMode.Optimized); } -// @setFloatMode twice for same scope +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: float mode set twice for same scope // tmp.zig:2:5: note: first set here diff --git a/test/compile_errors/stage1/obj/setRuntimeSafety_twice_for_same_scope.zig b/test/compile_errors/stage1/obj/setRuntimeSafety_twice_for_same_scope.zig index 741a214cde..03a93b68d5 100644 --- a/test/compile_errors/stage1/obj/setRuntimeSafety_twice_for_same_scope.zig +++ b/test/compile_errors/stage1/obj/setRuntimeSafety_twice_for_same_scope.zig @@ -3,7 +3,9 @@ export fn foo() void { @setRuntimeSafety(false); } -// @setRuntimeSafety twice for same scope +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: runtime safety set twice for same scope // tmp.zig:2:5: note: first set here diff --git a/test/compile_errors/stage1/obj/setting_a_section_on_a_local_variable.zig b/test/compile_errors/stage1/obj/setting_a_section_on_a_local_variable.zig index eb3df0e214..90d605dc40 100644 --- a/test/compile_errors/stage1/obj/setting_a_section_on_a_local_variable.zig +++ b/test/compile_errors/stage1/obj/setting_a_section_on_a_local_variable.zig @@ -3,6 +3,8 @@ export fn entry() i32 { return foo; } -// setting a section on a local variable +// error +// backend=stage1 +// target=native // // tmp.zig:2:30: error: cannot set section of local variable 'foo' diff --git a/test/compile_errors/stage1/obj/shift_amount_has_to_be_an_integer_type.zig b/test/compile_errors/stage1/obj/shift_amount_has_to_be_an_integer_type.zig index 6e54405619..53794dba1b 100644 --- a/test/compile_errors/stage1/obj/shift_amount_has_to_be_an_integer_type.zig +++ b/test/compile_errors/stage1/obj/shift_amount_has_to_be_an_integer_type.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = x; } -// shift amount has to be an integer type +// error +// backend=stage1 +// target=native // // tmp.zig:2:21: error: shift amount has to be an integer type, but found '*const u8' diff --git a/test/compile_errors/stage1/obj/shift_by_negative_comptime_integer.zig b/test/compile_errors/stage1/obj/shift_by_negative_comptime_integer.zig index 41f0ff80aa..3425cf565e 100644 --- a/test/compile_errors/stage1/obj/shift_by_negative_comptime_integer.zig +++ b/test/compile_errors/stage1/obj/shift_by_negative_comptime_integer.zig @@ -3,6 +3,8 @@ comptime { _ = a; } -// shift by negative comptime integer +// error +// backend=stage1 +// target=native // // tmp.zig:2:18: error: shift by negative value -1 diff --git a/test/compile_errors/stage1/obj/shift_left_assign_on_undefined_value.zig b/test/compile_errors/stage1/obj/shift_left_assign_on_undefined_value.zig index a23d0e190c..575bf0ee6b 100644 --- a/test/compile_errors/stage1/obj/shift_left_assign_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/shift_left_assign_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { a >>= 2; } -// shift left assign on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/shift_left_on_undefined_value.zig b/test/compile_errors/stage1/obj/shift_left_on_undefined_value.zig index aa0891133b..abd06fbbab 100644 --- a/test/compile_errors/stage1/obj/shift_left_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/shift_left_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = a << 2; } -// shift left on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/shift_right_assign_on_undefined_value.zig b/test/compile_errors/stage1/obj/shift_right_assign_on_undefined_value.zig index 65f4fe50b8..575bf0ee6b 100644 --- a/test/compile_errors/stage1/obj/shift_right_assign_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/shift_right_assign_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { a >>= 2; } -// shift right assign on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/shift_right_on_undefined_value.zig b/test/compile_errors/stage1/obj/shift_right_on_undefined_value.zig index ccd2563c84..e24cbe473a 100644 --- a/test/compile_errors/stage1/obj/shift_right_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/shift_right_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = a >> 2; } -// shift right on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/shifting_RHS_is_log2_of_LHS_int_bit_width.zig b/test/compile_errors/stage1/obj/shifting_RHS_is_log2_of_LHS_int_bit_width.zig index 8a5d6cfee4..d9b9bbfce3 100644 --- a/test/compile_errors/stage1/obj/shifting_RHS_is_log2_of_LHS_int_bit_width.zig +++ b/test/compile_errors/stage1/obj/shifting_RHS_is_log2_of_LHS_int_bit_width.zig @@ -2,6 +2,8 @@ export fn entry(x: u8, y: u8) u8 { return x << y; } -// shifting RHS is log2 of LHS int bit width +// error +// backend=stage1 +// target=native // // tmp.zig:2:17: error: expected type 'u3', found 'u8' diff --git a/test/compile_errors/stage1/obj/shifting_without_int_type_or_comptime_known.zig b/test/compile_errors/stage1/obj/shifting_without_int_type_or_comptime_known.zig index 380a08a95c..4d875575d0 100644 --- a/test/compile_errors/stage1/obj/shifting_without_int_type_or_comptime_known.zig +++ b/test/compile_errors/stage1/obj/shifting_without_int_type_or_comptime_known.zig @@ -2,6 +2,8 @@ export fn entry(x: u8) u8 { return 0x11 << x; } -// shifting without int type or comptime known +// error +// backend=stage1 +// target=native // // tmp.zig:2:17: error: LHS of shift must be a fixed-width integer type, or RHS must be compile-time known diff --git a/test/compile_errors/stage1/obj/shlExact_shifts_out_1_bits.zig b/test/compile_errors/stage1/obj/shlExact_shifts_out_1_bits.zig index bd6e48f25c..953c5fec50 100644 --- a/test/compile_errors/stage1/obj/shlExact_shifts_out_1_bits.zig +++ b/test/compile_errors/stage1/obj/shlExact_shifts_out_1_bits.zig @@ -3,6 +3,8 @@ comptime { _ = x; } -// @shlExact shifts out 1 bits +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: operation caused overflow diff --git a/test/compile_errors/stage1/obj/shrExact_shifts_out_1_bits.zig b/test/compile_errors/stage1/obj/shrExact_shifts_out_1_bits.zig index 004bf0c1c3..223db76630 100644 --- a/test/compile_errors/stage1/obj/shrExact_shifts_out_1_bits.zig +++ b/test/compile_errors/stage1/obj/shrExact_shifts_out_1_bits.zig @@ -3,6 +3,8 @@ comptime { _ = x; } -// @shrExact shifts out 1 bits +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: exact shift shifted out 1 bits diff --git a/test/compile_errors/stage1/obj/signed_integer_division.zig b/test/compile_errors/stage1/obj/signed_integer_division.zig index 524f9fe1db..3eebbf2248 100644 --- a/test/compile_errors/stage1/obj/signed_integer_division.zig +++ b/test/compile_errors/stage1/obj/signed_integer_division.zig @@ -2,6 +2,8 @@ export fn foo(a: i32, b: i32) i32 { return a / b; } -// signed integer division +// error +// backend=stage1 +// target=native // // tmp.zig:2:14: error: division with 'i32' and 'i32': signed integers must use @divTrunc, @divFloor, or @divExact diff --git a/test/compile_errors/stage1/obj/signed_integer_remainder_division.zig b/test/compile_errors/stage1/obj/signed_integer_remainder_division.zig index e060b780d0..5877672954 100644 --- a/test/compile_errors/stage1/obj/signed_integer_remainder_division.zig +++ b/test/compile_errors/stage1/obj/signed_integer_remainder_division.zig @@ -2,6 +2,8 @@ export fn foo(a: i32, b: i32) i32 { return a % b; } -// signed integer remainder division +// error +// backend=stage1 +// target=native // // tmp.zig:2:14: error: remainder division with 'i32' and 'i32': signed integers and floats must use @rem or @mod diff --git a/test/compile_errors/stage1/obj/sizeOf_bad_type.zig b/test/compile_errors/stage1/obj/sizeOf_bad_type.zig index 1b336cf657..f8c397f768 100644 --- a/test/compile_errors/stage1/obj/sizeOf_bad_type.zig +++ b/test/compile_errors/stage1/obj/sizeOf_bad_type.zig @@ -2,6 +2,8 @@ export fn entry() usize { return @sizeOf(@TypeOf(null)); } -// @sizeOf bad type +// error +// backend=stage1 +// target=native // // tmp.zig:2:20: error: no size available for type '@Type(.Null)' diff --git a/test/compile_errors/stage1/obj/slice_cannot_have_its_bytes_reinterpreted.zig b/test/compile_errors/stage1/obj/slice_cannot_have_its_bytes_reinterpreted.zig index 4f7670ba74..8fcf4f505c 100644 --- a/test/compile_errors/stage1/obj/slice_cannot_have_its_bytes_reinterpreted.zig +++ b/test/compile_errors/stage1/obj/slice_cannot_have_its_bytes_reinterpreted.zig @@ -4,6 +4,8 @@ export fn foo() void { _ = value; } -// slice cannot have its bytes reinterpreted +// error +// backend=stage1 +// target=native // // :3:52: error: slice '[]const u8' cannot have its bytes reinterpreted diff --git a/test/compile_errors/stage1/obj/slice_passed_as_array_init_type.zig b/test/compile_errors/stage1/obj/slice_passed_as_array_init_type.zig index 0d29120ca4..7ad29b1900 100644 --- a/test/compile_errors/stage1/obj/slice_passed_as_array_init_type.zig +++ b/test/compile_errors/stage1/obj/slice_passed_as_array_init_type.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = x; } -// slice passed as array init type +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: array literal requires address-of operator (&) to coerce to slice type '[]u8' diff --git a/test/compile_errors/stage1/obj/slice_passed_as_array_init_type_with_elems.zig b/test/compile_errors/stage1/obj/slice_passed_as_array_init_type_with_elems.zig index 375ed55a72..0da4b3fc9d 100644 --- a/test/compile_errors/stage1/obj/slice_passed_as_array_init_type_with_elems.zig +++ b/test/compile_errors/stage1/obj/slice_passed_as_array_init_type_with_elems.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = x; } -// slice passed as array init type with elems +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: array literal requires address-of operator (&) to coerce to slice type '[]u8' diff --git a/test/compile_errors/stage1/obj/slice_sentinel_mismatch-1.zig b/test/compile_errors/stage1/obj/slice_sentinel_mismatch-1.zig index 1e3c2450cb..d0c47097da 100644 --- a/test/compile_errors/stage1/obj/slice_sentinel_mismatch-1.zig +++ b/test/compile_errors/stage1/obj/slice_sentinel_mismatch-1.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = y; } -// slice sentinel mismatch - 1 +// error +// backend=stage1 +// target=native // // tmp.zig:2:37: error: expected type '[:1]const u8', found '*const [2:2]u8' diff --git a/test/compile_errors/stage1/obj/slice_sentinel_mismatch-2.zig b/test/compile_errors/stage1/obj/slice_sentinel_mismatch-2.zig index f1d73eb9df..5f8d312a3c 100644 --- a/test/compile_errors/stage1/obj/slice_sentinel_mismatch-2.zig +++ b/test/compile_errors/stage1/obj/slice_sentinel_mismatch-2.zig @@ -4,7 +4,9 @@ fn foo() [:0]u8 { } comptime { _ = foo; } -// slice sentinel mismatch - 2 +// error +// backend=stage1 +// target=native // // tmp.zig:3:12: error: expected type '[:0]u8', found '[]u8' // tmp.zig:3:12: note: destination pointer requires a terminating '0' sentinel diff --git a/test/compile_errors/stage1/obj/slicing_of_global_undefined_pointer.zig b/test/compile_errors/stage1/obj/slicing_of_global_undefined_pointer.zig index d52bfdf6a5..8bbc0f85eb 100644 --- a/test/compile_errors/stage1/obj/slicing_of_global_undefined_pointer.zig +++ b/test/compile_errors/stage1/obj/slicing_of_global_undefined_pointer.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = buf[0..1]; } -// slicing of global undefined pointer +// error +// backend=stage1 +// target=native // // tmp.zig:3:12: error: non-zero length slice of undefined pointer diff --git a/test/compile_errors/stage1/obj/slicing_single-item_pointer.zig b/test/compile_errors/stage1/obj/slicing_single-item_pointer.zig index f6bbe752b1..d8c82fa3af 100644 --- a/test/compile_errors/stage1/obj/slicing_single-item_pointer.zig +++ b/test/compile_errors/stage1/obj/slicing_single-item_pointer.zig @@ -3,6 +3,8 @@ export fn entry(ptr: *i32) void { _ = slice; } -// slicing single-item pointer +// error +// backend=stage1 +// target=native // // tmp.zig:2:22: error: slice of single-item pointer diff --git a/test/compile_errors/stage1/obj/specify_enum_tag_type_that_is_too_small.zig b/test/compile_errors/stage1/obj/specify_enum_tag_type_that_is_too_small.zig index ca7c305d38..dc7077c8f8 100644 --- a/test/compile_errors/stage1/obj/specify_enum_tag_type_that_is_too_small.zig +++ b/test/compile_errors/stage1/obj/specify_enum_tag_type_that_is_too_small.zig @@ -11,6 +11,8 @@ export fn entry() void { _ = x; } -// specify enum tag type that is too small +// error +// backend=stage1 +// target=native // // tmp.zig:6:5: error: enumeration value 4 too large for type 'u2' diff --git a/test/compile_errors/stage1/obj/specify_non-integer_enum_tag_type.zig b/test/compile_errors/stage1/obj/specify_non-integer_enum_tag_type.zig index 095a0812c1..333647e1e3 100644 --- a/test/compile_errors/stage1/obj/specify_non-integer_enum_tag_type.zig +++ b/test/compile_errors/stage1/obj/specify_non-integer_enum_tag_type.zig @@ -9,6 +9,8 @@ export fn entry() void { _ = x; } -// specify non-integer enum tag type +// error +// backend=stage1 +// target=native // // tmp.zig:1:21: error: expected integer, found 'f32' diff --git a/test/compile_errors/stage1/obj/src_outside_function.zig b/test/compile_errors/stage1/obj/src_outside_function.zig index 5359135066..7f8c7ae72f 100644 --- a/test/compile_errors/stage1/obj/src_outside_function.zig +++ b/test/compile_errors/stage1/obj/src_outside_function.zig @@ -2,6 +2,8 @@ comptime { @src(); } -// @src outside function +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: @src outside function diff --git a/test/compile_errors/stage1/obj/std.fmt_error_for_unused_arguments.zig b/test/compile_errors/stage1/obj/std.fmt_error_for_unused_arguments.zig index 68299c2177..21603ab3d3 100644 --- a/test/compile_errors/stage1/obj/std.fmt_error_for_unused_arguments.zig +++ b/test/compile_errors/stage1/obj/std.fmt_error_for_unused_arguments.zig @@ -2,6 +2,8 @@ export fn entry() void { @import("std").debug.print("{d} {d} {d} {d} {d}", .{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}); } -// std.fmt error for unused arguments +// error +// backend=stage1 +// target=native // // ?:?:?: error: 10 unused arguments in '{d} {d} {d} {d} {d}' diff --git a/test/compile_errors/stage1/obj/store_vector_pointer_with_unknown_runtime_index.zig b/test/compile_errors/stage1/obj/store_vector_pointer_with_unknown_runtime_index.zig index 6ef71c863a..57e91631b1 100644 --- a/test/compile_errors/stage1/obj/store_vector_pointer_with_unknown_runtime_index.zig +++ b/test/compile_errors/stage1/obj/store_vector_pointer_with_unknown_runtime_index.zig @@ -9,6 +9,8 @@ fn storev(ptr: anytype, val: i32) void { ptr.* = val; } -// store vector pointer with unknown runtime index +// error +// backend=stage1 +// target=native // // tmp.zig:9:8: error: unable to determine vector element index of type '*align(16:0:4:?) i32 diff --git a/test/compile_errors/stage1/obj/storing_runtime_value_in_compile_time_variable_then_using_it.zig b/test/compile_errors/stage1/obj/storing_runtime_value_in_compile_time_variable_then_using_it.zig index 318db771d5..2d85209358 100644 --- a/test/compile_errors/stage1/obj/storing_runtime_value_in_compile_time_variable_then_using_it.zig +++ b/test/compile_errors/stage1/obj/storing_runtime_value_in_compile_time_variable_then_using_it.zig @@ -42,6 +42,8 @@ export fn entry() void { } } -// storing runtime value in compile time variable then using it +// error +// backend=stage1 +// target=native // // tmp.zig:38:29: error: cannot store runtime value in compile time variable diff --git a/test/compile_errors/stage1/obj/struct_depends_on_itself_via_optional_field.zig b/test/compile_errors/stage1/obj/struct_depends_on_itself_via_optional_field.zig index 13ee95155d..46086172f7 100644 --- a/test/compile_errors/stage1/obj/struct_depends_on_itself_via_optional_field.zig +++ b/test/compile_errors/stage1/obj/struct_depends_on_itself_via_optional_field.zig @@ -10,7 +10,9 @@ export fn entry() void { _ = obj; } -// struct depends on itself via optional field +// error +// backend=stage1 +// target=native // // tmp.zig:1:17: error: struct 'LhsExpr' depends on itself // tmp.zig:5:5: note: while checking this field diff --git a/test/compile_errors/stage1/obj/struct_field_missing_type.zig b/test/compile_errors/stage1/obj/struct_field_missing_type.zig index 669718a3d4..175f1c7df7 100644 --- a/test/compile_errors/stage1/obj/struct_field_missing_type.zig +++ b/test/compile_errors/stage1/obj/struct_field_missing_type.zig @@ -6,6 +6,8 @@ export fn entry() void { _ = a; } -// struct field missing type +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: struct field missing type diff --git a/test/compile_errors/stage1/obj/struct_init_syntax_for_array.zig b/test/compile_errors/stage1/obj/struct_init_syntax_for_array.zig index 4eda9622ab..6362e05114 100644 --- a/test/compile_errors/stage1/obj/struct_init_syntax_for_array.zig +++ b/test/compile_errors/stage1/obj/struct_init_syntax_for_array.zig @@ -3,6 +3,8 @@ comptime { _ = foo; } -// struct init syntax for array +// error +// backend=stage1 +// target=native // // tmp.zig:1:13: error: initializing array with struct syntax diff --git a/test/compile_errors/stage1/obj/struct_with_declarations_unavailable_for_reify_type.zig b/test/compile_errors/stage1/obj/struct_with_declarations_unavailable_for_reify_type.zig index 656a9b9f62..409020ca25 100644 --- a/test/compile_errors/stage1/obj/struct_with_declarations_unavailable_for_reify_type.zig +++ b/test/compile_errors/stage1/obj/struct_with_declarations_unavailable_for_reify_type.zig @@ -2,6 +2,8 @@ export fn entry() void { _ = @Type(@typeInfo(struct { const foo = 1; })); } -// struct with declarations unavailable for @Type +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: Type.Struct.decls must be empty for @Type diff --git a/test/compile_errors/stage1/obj/struct_with_invalid_field.zig b/test/compile_errors/stage1/obj/struct_with_invalid_field.zig index a2a632fbd9..dcc9d26f65 100644 --- a/test/compile_errors/stage1/obj/struct_with_invalid_field.zig +++ b/test/compile_errors/stage1/obj/struct_with_invalid_field.zig @@ -23,6 +23,8 @@ export fn entry() void { _ = a; } -// struct with invalid field +// error +// backend=stage1 +// target=native // // tmp.zig:14:17: error: use of undeclared identifier 'HeaderValue' diff --git a/test/compile_errors/stage1/obj/sub_assign_on_undefined_value.zig b/test/compile_errors/stage1/obj/sub_assign_on_undefined_value.zig index 01ef9313e5..74b705a154 100644 --- a/test/compile_errors/stage1/obj/sub_assign_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/sub_assign_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { a -= a; } -// sub assign on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/sub_on_undefined_value.zig b/test/compile_errors/stage1/obj/sub_on_undefined_value.zig index 80746abf0e..08c590ee3f 100644 --- a/test/compile_errors/stage1/obj/sub_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/sub_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = a - a; } -// sub on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/sub_overflow_in_function_evaluation.zig b/test/compile_errors/stage1/obj/sub_overflow_in_function_evaluation.zig index 1084f1a111..dc259e6dcf 100644 --- a/test/compile_errors/stage1/obj/sub_overflow_in_function_evaluation.zig +++ b/test/compile_errors/stage1/obj/sub_overflow_in_function_evaluation.zig @@ -5,6 +5,8 @@ fn sub(a: u16, b: u16) u16 { export fn entry() usize { return @sizeOf(@TypeOf(y)); } -// sub overflow in function evaluation +// error +// backend=stage1 +// target=native // // tmp.zig:3:14: error: operation caused overflow diff --git a/test/compile_errors/stage1/obj/sub_wrap_assign_on_undefined_value.zig b/test/compile_errors/stage1/obj/sub_wrap_assign_on_undefined_value.zig index 3c7fd4faa5..41aa1ca14b 100644 --- a/test/compile_errors/stage1/obj/sub_wrap_assign_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/sub_wrap_assign_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { a -%= a; } -// sub wrap assign on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/sub_wrap_on_undefined_value.zig b/test/compile_errors/stage1/obj/sub_wrap_on_undefined_value.zig index 367b4c9c0e..68e4e78512 100644 --- a/test/compile_errors/stage1/obj/sub_wrap_on_undefined_value.zig +++ b/test/compile_errors/stage1/obj/sub_wrap_on_undefined_value.zig @@ -3,6 +3,8 @@ comptime { _ = a -% a; } -// sub wrap on undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/suspend_inside_suspend_block.zig b/test/compile_errors/stage1/obj/suspend_inside_suspend_block.zig index 2e807268ce..4adffd2f25 100644 --- a/test/compile_errors/stage1/obj/suspend_inside_suspend_block.zig +++ b/test/compile_errors/stage1/obj/suspend_inside_suspend_block.zig @@ -8,7 +8,9 @@ fn foo() void { } } -// suspend inside suspend block +// error +// backend=stage1 +// target=native // // tmp.zig:6:9: error: cannot suspend inside suspend block // tmp.zig:5:5: note: other suspend block here diff --git a/test/compile_errors/stage1/obj/switch_expression-duplicate_enumeration_prong.zig b/test/compile_errors/stage1/obj/switch_expression-duplicate_enumeration_prong.zig index c5db39f5b2..056aebe3dd 100644 --- a/test/compile_errors/stage1/obj/switch_expression-duplicate_enumeration_prong.zig +++ b/test/compile_errors/stage1/obj/switch_expression-duplicate_enumeration_prong.zig @@ -16,7 +16,9 @@ fn f(n: Number) i32 { export fn entry() usize { return @sizeOf(@TypeOf(f)); } -// switch expression - duplicate enumeration prong +// error +// backend=stage1 +// target=native // // tmp.zig:13:15: error: duplicate switch value // tmp.zig:10:15: note: other value here diff --git a/test/compile_errors/stage1/obj/switch_expression-duplicate_enumeration_prong_when_else_present.zig b/test/compile_errors/stage1/obj/switch_expression-duplicate_enumeration_prong_when_else_present.zig index 22a0c189c1..4d891c3917 100644 --- a/test/compile_errors/stage1/obj/switch_expression-duplicate_enumeration_prong_when_else_present.zig +++ b/test/compile_errors/stage1/obj/switch_expression-duplicate_enumeration_prong_when_else_present.zig @@ -17,7 +17,9 @@ fn f(n: Number) i32 { export fn entry() usize { return @sizeOf(@TypeOf(f)); } -// switch expression - duplicate enumeration prong when else present +// error +// backend=stage1 +// target=native // // tmp.zig:13:15: error: duplicate switch value // tmp.zig:10:15: note: other value here diff --git a/test/compile_errors/stage1/obj/switch_expression-duplicate_or_overlapping_integer_value.zig b/test/compile_errors/stage1/obj/switch_expression-duplicate_or_overlapping_integer_value.zig index 06ef7de62e..2810bc13e1 100644 --- a/test/compile_errors/stage1/obj/switch_expression-duplicate_or_overlapping_integer_value.zig +++ b/test/compile_errors/stage1/obj/switch_expression-duplicate_or_overlapping_integer_value.zig @@ -8,7 +8,9 @@ fn foo(x: u8) u8 { } export fn entry() usize { return @sizeOf(@TypeOf(foo)); } -// switch expression - duplicate or overlapping integer value +// error +// backend=stage1 +// target=native // // tmp.zig:6:9: error: duplicate switch value // tmp.zig:5:14: note: previous value here diff --git a/test/compile_errors/stage1/obj/switch_expression-duplicate_type.zig b/test/compile_errors/stage1/obj/switch_expression-duplicate_type.zig index 9ac9feaeaf..b84c4622a2 100644 --- a/test/compile_errors/stage1/obj/switch_expression-duplicate_type.zig +++ b/test/compile_errors/stage1/obj/switch_expression-duplicate_type.zig @@ -9,7 +9,9 @@ fn foo(comptime T: type, x: T) u8 { } export fn entry() usize { return @sizeOf(@TypeOf(foo(u32, 0))); } -// switch expression - duplicate type +// error +// backend=stage1 +// target=native // // tmp.zig:6:9: error: duplicate switch value // tmp.zig:4:9: note: previous value here diff --git a/test/compile_errors/stage1/obj/switch_expression-duplicate_type_struct_alias.zig b/test/compile_errors/stage1/obj/switch_expression-duplicate_type_struct_alias.zig index b92336cac5..057e674e5a 100644 --- a/test/compile_errors/stage1/obj/switch_expression-duplicate_type_struct_alias.zig +++ b/test/compile_errors/stage1/obj/switch_expression-duplicate_type_struct_alias.zig @@ -13,7 +13,9 @@ fn foo(comptime T: type, x: T) u8 { } export fn entry() usize { return @sizeOf(@TypeOf(foo(u32, 0))); } -// switch expression - duplicate type (struct alias) +// error +// backend=stage1 +// target=native // // tmp.zig:10:9: error: duplicate switch value // tmp.zig:8:9: note: previous value here diff --git a/test/compile_errors/stage1/obj/switch_expression-missing_enumeration_prong.zig b/test/compile_errors/stage1/obj/switch_expression-missing_enumeration_prong.zig index b6cd60c22b..1a13730223 100644 --- a/test/compile_errors/stage1/obj/switch_expression-missing_enumeration_prong.zig +++ b/test/compile_errors/stage1/obj/switch_expression-missing_enumeration_prong.zig @@ -14,6 +14,8 @@ fn f(n: Number) i32 { export fn entry() usize { return @sizeOf(@TypeOf(f)); } -// switch expression - missing enumeration prong +// error +// backend=stage1 +// target=native // // tmp.zig:8:5: error: enumeration value 'Number.Four' not handled in switch diff --git a/test/compile_errors/stage1/obj/switch_expression-multiple_else_prongs.zig b/test/compile_errors/stage1/obj/switch_expression-multiple_else_prongs.zig index 6a7e274b56..8267222092 100644 --- a/test/compile_errors/stage1/obj/switch_expression-multiple_else_prongs.zig +++ b/test/compile_errors/stage1/obj/switch_expression-multiple_else_prongs.zig @@ -9,6 +9,8 @@ export fn entry() void { f(1234); } -// switch expression - multiple else prongs +// error +// backend=stage1 +// target=native // // tmp.zig:5:9: error: multiple else prongs in switch expression diff --git a/test/compile_errors/stage1/obj/switch_expression-non_exhaustive_integer_prongs.zig b/test/compile_errors/stage1/obj/switch_expression-non_exhaustive_integer_prongs.zig index 88fb8548de..940338edb9 100644 --- a/test/compile_errors/stage1/obj/switch_expression-non_exhaustive_integer_prongs.zig +++ b/test/compile_errors/stage1/obj/switch_expression-non_exhaustive_integer_prongs.zig @@ -5,6 +5,8 @@ fn foo(x: u8) void { } export fn entry() usize { return @sizeOf(@TypeOf(foo)); } -// switch expression - non exhaustive integer prongs +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: switch must handle all possibilities diff --git a/test/compile_errors/stage1/obj/switch_expression-switch_on_pointer_type_with_no_else.zig b/test/compile_errors/stage1/obj/switch_expression-switch_on_pointer_type_with_no_else.zig index ec7565b882..6a357beabe 100644 --- a/test/compile_errors/stage1/obj/switch_expression-switch_on_pointer_type_with_no_else.zig +++ b/test/compile_errors/stage1/obj/switch_expression-switch_on_pointer_type_with_no_else.zig @@ -6,6 +6,8 @@ fn foo(x: *u8) void { const y: u8 = 100; export fn entry() usize { return @sizeOf(@TypeOf(foo)); } -// switch expression - switch on pointer type with no else +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: else prong required when switching on type '*u8' diff --git a/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_bool.zig b/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_bool.zig index 8c36a3c289..2ee39f1531 100644 --- a/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_bool.zig +++ b/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_bool.zig @@ -7,6 +7,8 @@ fn foo(x: bool) void { } export fn entry() usize { return @sizeOf(@TypeOf(foo)); } -// switch expression - unreachable else prong (bool) +// error +// backend=stage1 +// target=native // // tmp.zig:5:9: error: unreachable else prong, all cases already handled diff --git a/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_enum.zig b/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_enum.zig index 8207d05234..bcf840ab97 100644 --- a/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_enum.zig +++ b/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_enum.zig @@ -17,6 +17,8 @@ fn foo(x: u8) void { export fn entry() usize { return @sizeOf(@TypeOf(foo)); } -// switch expression - unreachable else prong (enum) +// error +// backend=stage1 +// target=native // // tmp.zig:14:9: error: unreachable else prong, all cases already handled diff --git a/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_range_i8.zig b/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_range_i8.zig index 8750e57fae..f0c9d7a08a 100644 --- a/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_range_i8.zig +++ b/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_range_i8.zig @@ -10,6 +10,8 @@ fn foo(x: i8) void { } export fn entry() usize { return @sizeOf(@TypeOf(foo)); } -// switch expression - unreachable else prong (range i8) +// error +// backend=stage1 +// target=native // // tmp.zig:8:9: error: unreachable else prong, all cases already handled diff --git a/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_range_u8.zig b/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_range_u8.zig index 280663ae51..9342ce8c32 100644 --- a/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_range_u8.zig +++ b/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_range_u8.zig @@ -10,6 +10,8 @@ fn foo(x: u8) void { } export fn entry() usize { return @sizeOf(@TypeOf(foo)); } -// switch expression - unreachable else prong (range u8) +// error +// backend=stage1 +// target=native // // tmp.zig:8:9: error: unreachable else prong, all cases already handled diff --git a/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_u1.zig b/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_u1.zig index 58c4f378bf..90abf5074b 100644 --- a/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_u1.zig +++ b/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_u1.zig @@ -7,6 +7,8 @@ fn foo(x: u1) void { } export fn entry() usize { return @sizeOf(@TypeOf(foo)); } -// switch expression - unreachable else prong (u1) +// error +// backend=stage1 +// target=native // // tmp.zig:5:9: error: unreachable else prong, all cases already handled diff --git a/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_u2.zig b/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_u2.zig index ec1804316e..a523046e16 100644 --- a/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_u2.zig +++ b/test/compile_errors/stage1/obj/switch_expression-unreachable_else_prong_u2.zig @@ -9,6 +9,8 @@ fn foo(x: u2) void { } export fn entry() usize { return @sizeOf(@TypeOf(foo)); } -// switch expression - unreachable else prong (u2) +// error +// backend=stage1 +// target=native // // tmp.zig:7:9: error: unreachable else prong, all cases already handled diff --git a/test/compile_errors/stage1/obj/switch_on_enum_with_1_field_with_no_prongs.zig b/test/compile_errors/stage1/obj/switch_on_enum_with_1_field_with_no_prongs.zig index fbfc039f59..97f7de121d 100644 --- a/test/compile_errors/stage1/obj/switch_on_enum_with_1_field_with_no_prongs.zig +++ b/test/compile_errors/stage1/obj/switch_on_enum_with_1_field_with_no_prongs.zig @@ -5,6 +5,8 @@ export fn entry() void { switch (f) {} } -// switch on enum with 1 field with no prongs +// error +// backend=stage1 +// target=native // // tmp.zig:5:5: error: enumeration value 'Foo.M' not handled in switch diff --git a/test/compile_errors/stage1/obj/switch_on_union_with_no_attached_enum.zig b/test/compile_errors/stage1/obj/switch_on_union_with_no_attached_enum.zig index f1ae750b4b..684861a898 100644 --- a/test/compile_errors/stage1/obj/switch_on_union_with_no_attached_enum.zig +++ b/test/compile_errors/stage1/obj/switch_on_union_with_no_attached_enum.zig @@ -14,7 +14,9 @@ fn foo(a: *const Payload) void { } } -// switch on union with no attached enum +// error +// backend=stage1 +// target=native // // tmp.zig:11:14: error: switch on union which has no attached enum // tmp.zig:1:17: note: consider 'union(enum)' here diff --git a/test/compile_errors/stage1/obj/switch_with_invalid_expression_parameter.zig b/test/compile_errors/stage1/obj/switch_with_invalid_expression_parameter.zig index f65879bc7a..1eb74519f5 100644 --- a/test/compile_errors/stage1/obj/switch_with_invalid_expression_parameter.zig +++ b/test/compile_errors/stage1/obj/switch_with_invalid_expression_parameter.zig @@ -10,6 +10,8 @@ fn Test(comptime T: type) void { _ = x; } -// switch with invalid expression parameter +// error +// backend=stage1 +// target=native // // tmp.zig:7:17: error: switch on type 'type' provides no expression parameter diff --git a/test/compile_errors/stage1/obj/switch_with_overlapping_case_ranges.zig b/test/compile_errors/stage1/obj/switch_with_overlapping_case_ranges.zig index 2818d766a7..1b03d3fe54 100644 --- a/test/compile_errors/stage1/obj/switch_with_overlapping_case_ranges.zig +++ b/test/compile_errors/stage1/obj/switch_with_overlapping_case_ranges.zig @@ -6,6 +6,8 @@ export fn entry() void { } } -// switch with overlapping case ranges +// error +// backend=stage1 +// target=native // // tmp.zig:5:9: error: duplicate switch value diff --git a/test/compile_errors/stage1/obj/tagName_used_on_union_with_no_associated_enum_tag.zig b/test/compile_errors/stage1/obj/tagName_used_on_union_with_no_associated_enum_tag.zig index bd03a97cfd..efd9b8ceef 100644 --- a/test/compile_errors/stage1/obj/tagName_used_on_union_with_no_associated_enum_tag.zig +++ b/test/compile_errors/stage1/obj/tagName_used_on_union_with_no_associated_enum_tag.zig @@ -8,7 +8,9 @@ export fn entry() void { _ = tagName; } -// @tagName used on union with no associated enum tag +// error +// backend=stage1 +// target=native // // tmp.zig:7:19: error: union has no associated enum // tmp.zig:1:18: note: declared here diff --git a/test/compile_errors/stage1/obj/take_slice_of_invalid_dereference.zig b/test/compile_errors/stage1/obj/take_slice_of_invalid_dereference.zig index 9beda30e2f..c039be3737 100644 --- a/test/compile_errors/stage1/obj/take_slice_of_invalid_dereference.zig +++ b/test/compile_errors/stage1/obj/take_slice_of_invalid_dereference.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = x; } -// take slice of invalid dereference +// error +// backend=stage1 +// target=native // // tmp.zig:2:18: error: attempt to dereference non-pointer type 'comptime_int' diff --git a/test/compile_errors/stage1/obj/taking_bit_offset_of_void_field_in_struct.zig b/test/compile_errors/stage1/obj/taking_bit_offset_of_void_field_in_struct.zig index 936a110a61..e404c3bdd6 100644 --- a/test/compile_errors/stage1/obj/taking_bit_offset_of_void_field_in_struct.zig +++ b/test/compile_errors/stage1/obj/taking_bit_offset_of_void_field_in_struct.zig @@ -6,6 +6,8 @@ export fn foo() void { _ = fieldOffset; } -// taking bit offset of void field in struct +// error +// backend=stage1 +// target=native // // tmp.zig:5:45: error: zero-bit field 'val' in struct 'Empty' has no offset diff --git a/test/compile_errors/stage1/obj/taking_byte_offset_of_void_field_in_struct.zig b/test/compile_errors/stage1/obj/taking_byte_offset_of_void_field_in_struct.zig index d71dbc1502..eb7d83efff 100644 --- a/test/compile_errors/stage1/obj/taking_byte_offset_of_void_field_in_struct.zig +++ b/test/compile_errors/stage1/obj/taking_byte_offset_of_void_field_in_struct.zig @@ -6,6 +6,8 @@ export fn foo() void { _ = fieldOffset; } -// taking byte offset of void field in struct +// error +// backend=stage1 +// target=native // // tmp.zig:5:42: error: zero-bit field 'val' in struct 'Empty' has no offset diff --git a/test/compile_errors/stage1/obj/threadlocal_qualifier_on_const.zig b/test/compile_errors/stage1/obj/threadlocal_qualifier_on_const.zig index fa99e592ae..d34ba06879 100644 --- a/test/compile_errors/stage1/obj/threadlocal_qualifier_on_const.zig +++ b/test/compile_errors/stage1/obj/threadlocal_qualifier_on_const.zig @@ -3,6 +3,8 @@ export fn entry() i32 { return x; } -// threadlocal qualifier on const +// error +// backend=stage1 +// target=native // // tmp.zig:1:1: error: threadlocal variable cannot be constant diff --git a/test/compile_errors/stage1/obj/top_level_decl_dependency_loop.zig b/test/compile_errors/stage1/obj/top_level_decl_dependency_loop.zig index 4ecdc6f67d..ac70285c9c 100644 --- a/test/compile_errors/stage1/obj/top_level_decl_dependency_loop.zig +++ b/test/compile_errors/stage1/obj/top_level_decl_dependency_loop.zig @@ -5,6 +5,8 @@ export fn entry() void { _ = c; } -// top level decl dependency loop +// error +// backend=stage1 +// target=native // // tmp.zig:2:19: error: dependency loop detected diff --git a/test/compile_errors/stage1/obj/truncate_sign_mismatch.zig b/test/compile_errors/stage1/obj/truncate_sign_mismatch.zig index a60ca4bc7a..8434d9ed16 100644 --- a/test/compile_errors/stage1/obj/truncate_sign_mismatch.zig +++ b/test/compile_errors/stage1/obj/truncate_sign_mismatch.zig @@ -15,7 +15,9 @@ export fn entry4() u8 { return @truncate(u8, x); } -// truncate sign mismatch +// error +// backend=stage1 +// target=native // // tmp.zig:3:26: error: expected signed integer type, found 'u32' // tmp.zig:7:26: error: expected unsigned integer type, found 'i32' diff --git a/test/compile_errors/stage1/obj/truncate_undefined_value.zig b/test/compile_errors/stage1/obj/truncate_undefined_value.zig index 9d3913f9c3..67a1f17ba7 100644 --- a/test/compile_errors/stage1/obj/truncate_undefined_value.zig +++ b/test/compile_errors/stage1/obj/truncate_undefined_value.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = z; } -// @truncate undefined value +// error +// backend=stage1 +// target=native // // tmp.zig:2:27: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/try_in_function_with_non_error_return_type.zig b/test/compile_errors/stage1/obj/try_in_function_with_non_error_return_type.zig index d799f769b6..c00fa2709f 100644 --- a/test/compile_errors/stage1/obj/try_in_function_with_non_error_return_type.zig +++ b/test/compile_errors/stage1/obj/try_in_function_with_non_error_return_type.zig @@ -3,6 +3,8 @@ export fn f() void { } fn something() anyerror!void { } -// try in function with non error return type +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: expected type 'void', found 'anyerror' diff --git a/test/compile_errors/stage1/obj/type_checking_function_pointers.zig b/test/compile_errors/stage1/obj/type_checking_function_pointers.zig index d9bcde6bab..b88b6bdb52 100644 --- a/test/compile_errors/stage1/obj/type_checking_function_pointers.zig +++ b/test/compile_errors/stage1/obj/type_checking_function_pointers.zig @@ -6,6 +6,8 @@ export fn entry() void { a(c); } -// type checking function pointers +// error +// backend=stage1 +// target=native // // tmp.zig:6:7: error: expected type 'fn(*const u8) void', found 'fn(u8) void' diff --git a/test/compile_errors/stage1/obj/type_variables_must_be_constant.zig b/test/compile_errors/stage1/obj/type_variables_must_be_constant.zig index 33846d6da8..f8cadf8520 100644 --- a/test/compile_errors/stage1/obj/type_variables_must_be_constant.zig +++ b/test/compile_errors/stage1/obj/type_variables_must_be_constant.zig @@ -3,6 +3,8 @@ export fn entry() foo { return 1; } -// type variables must be constant +// error +// backend=stage1 +// target=native // // tmp.zig:1:1: error: variable of type 'type' must be constant diff --git a/test/compile_errors/stage1/obj/undeclared_identifier.zig b/test/compile_errors/stage1/obj/undeclared_identifier.zig index 36f46a22f4..297a618eb8 100644 --- a/test/compile_errors/stage1/obj/undeclared_identifier.zig +++ b/test/compile_errors/stage1/obj/undeclared_identifier.zig @@ -4,6 +4,8 @@ export fn a() void { c; } -// undeclared identifier +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: use of undeclared identifier 'b' diff --git a/test/compile_errors/stage1/obj/undeclared_identifier_error_should_mark_fn_as_impure.zig b/test/compile_errors/stage1/obj/undeclared_identifier_error_should_mark_fn_as_impure.zig index fa629bdcb8..697b7ccb55 100644 --- a/test/compile_errors/stage1/obj/undeclared_identifier_error_should_mark_fn_as_impure.zig +++ b/test/compile_errors/stage1/obj/undeclared_identifier_error_should_mark_fn_as_impure.zig @@ -5,6 +5,8 @@ fn test_a_thing() void { bad_fn_call(); } -// undeclared identifier error should mark fn as impure +// error +// backend=stage1 +// target=native // // tmp.zig:5:5: error: use of undeclared identifier 'bad_fn_call' diff --git a/test/compile_errors/stage1/obj/undeclared_identifier_in_unanalyzed_branch.zig b/test/compile_errors/stage1/obj/undeclared_identifier_in_unanalyzed_branch.zig index 55d952e0fd..2efa8ca115 100644 --- a/test/compile_errors/stage1/obj/undeclared_identifier_in_unanalyzed_branch.zig +++ b/test/compile_errors/stage1/obj/undeclared_identifier_in_unanalyzed_branch.zig @@ -4,6 +4,8 @@ export fn a() void { } } -// undeclared identifier in unanalyzed branch +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: use of undeclared identifier 'lol_this_doesnt_exist' diff --git a/test/compile_errors/stage1/obj/undefined_as_field_type_is_rejected.zig b/test/compile_errors/stage1/obj/undefined_as_field_type_is_rejected.zig index 4035955387..b6eb059661 100644 --- a/test/compile_errors/stage1/obj/undefined_as_field_type_is_rejected.zig +++ b/test/compile_errors/stage1/obj/undefined_as_field_type_is_rejected.zig @@ -6,6 +6,8 @@ export fn entry1() void { _ = foo; } -// undefined as field type is rejected +// error +// backend=stage1 +// target=native // // tmp.zig:2:8: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/undefined_function_call.zig b/test/compile_errors/stage1/obj/undefined_function_call.zig index ebf76aafbd..a9627961fe 100644 --- a/test/compile_errors/stage1/obj/undefined_function_call.zig +++ b/test/compile_errors/stage1/obj/undefined_function_call.zig @@ -2,6 +2,8 @@ export fn a() void { b(); } -// undefined function call +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: use of undeclared identifier 'b' diff --git a/test/compile_errors/stage1/obj/underscore_is_not_a_declarable_symbol.zig b/test/compile_errors/stage1/obj/underscore_is_not_a_declarable_symbol.zig index bfcfbc3bcc..f4318af8fd 100644 --- a/test/compile_errors/stage1/obj/underscore_is_not_a_declarable_symbol.zig +++ b/test/compile_errors/stage1/obj/underscore_is_not_a_declarable_symbol.zig @@ -3,6 +3,8 @@ export fn f1() usize { return _; } -// `_` is not a declarable symbol +// error +// backend=stage1 +// target=native // // tmp.zig:2:9: error: '_' used as an identifier without @"_" syntax diff --git a/test/compile_errors/stage1/obj/underscore_should_not_be_usable_inside_for.zig b/test/compile_errors/stage1/obj/underscore_should_not_be_usable_inside_for.zig index be2ae559f3..fe89c8372d 100644 --- a/test/compile_errors/stage1/obj/underscore_should_not_be_usable_inside_for.zig +++ b/test/compile_errors/stage1/obj/underscore_should_not_be_usable_inside_for.zig @@ -6,6 +6,8 @@ export fn returns() void { } } -// `_` should not be usable inside for +// error +// backend=stage1 +// target=native // // tmp.zig:4:20: error: '_' used as an identifier without @"_" syntax diff --git a/test/compile_errors/stage1/obj/underscore_should_not_be_usable_inside_while.zig b/test/compile_errors/stage1/obj/underscore_should_not_be_usable_inside_while.zig index d93ed28c9e..7f694e0603 100644 --- a/test/compile_errors/stage1/obj/underscore_should_not_be_usable_inside_while.zig +++ b/test/compile_errors/stage1/obj/underscore_should_not_be_usable_inside_while.zig @@ -9,6 +9,8 @@ fn optionalReturn() ?u32 { return 1; } -// `_` should not be usable inside while +// error +// backend=stage1 +// target=native // // tmp.zig:4:20: error: '_' used as an identifier without @"_" syntax diff --git a/test/compile_errors/stage1/obj/underscore_should_not_be_usable_inside_while_else.zig b/test/compile_errors/stage1/obj/underscore_should_not_be_usable_inside_while_else.zig index e1e4c7b4c1..87a705ee69 100644 --- a/test/compile_errors/stage1/obj/underscore_should_not_be_usable_inside_while_else.zig +++ b/test/compile_errors/stage1/obj/underscore_should_not_be_usable_inside_while_else.zig @@ -11,6 +11,8 @@ fn optionalReturnError() !?u32 { return error.optionalReturnError; } -// `_` should not be usable inside while else +// error +// backend=stage1 +// target=native // // tmp.zig:6:17: error: '_' used as an identifier without @"_" syntax diff --git a/test/compile_errors/stage1/obj/union_auto-enum_value_already_taken.zig b/test/compile_errors/stage1/obj/union_auto-enum_value_already_taken.zig index 377290bd7e..3b00f95ff9 100644 --- a/test/compile_errors/stage1/obj/union_auto-enum_value_already_taken.zig +++ b/test/compile_errors/stage1/obj/union_auto-enum_value_already_taken.zig @@ -10,7 +10,9 @@ export fn entry() void { _ = x; } -// union auto-enum value already taken +// error +// backend=stage1 +// target=native // // tmp.zig:6:9: error: enum tag value 60 already taken // tmp.zig:4:9: note: other occurrence here diff --git a/test/compile_errors/stage1/obj/union_enum_field_does_not_match_enum.zig b/test/compile_errors/stage1/obj/union_enum_field_does_not_match_enum.zig index a924932c9f..38260091dc 100644 --- a/test/compile_errors/stage1/obj/union_enum_field_does_not_match_enum.zig +++ b/test/compile_errors/stage1/obj/union_enum_field_does_not_match_enum.zig @@ -14,7 +14,9 @@ export fn entry() void { _ = a; } -// union enum field does not match enum +// error +// backend=stage1 +// target=native // // tmp.zig:10:5: error: enum field not found: 'D' // tmp.zig:1:16: note: enum declared here diff --git a/test/compile_errors/stage1/obj/union_fields_with_value_assignments.zig b/test/compile_errors/stage1/obj/union_fields_with_value_assignments.zig index 0cf67a0eca..94568d55c3 100644 --- a/test/compile_errors/stage1/obj/union_fields_with_value_assignments.zig +++ b/test/compile_errors/stage1/obj/union_fields_with_value_assignments.zig @@ -6,7 +6,9 @@ export fn entry() void { _ = x; } -// union fields with value assignments +// error +// backend=stage1 +// target=native // // tmp.zig:1:24: error: explicitly valued tagged union missing integer tag type // tmp.zig:2:14: note: tag value specified here diff --git a/test/compile_errors/stage1/obj/union_with_0_fields.zig b/test/compile_errors/stage1/obj/union_with_0_fields.zig index 36086e8cce..a6f3d69faa 100644 --- a/test/compile_errors/stage1/obj/union_with_0_fields.zig +++ b/test/compile_errors/stage1/obj/union_with_0_fields.zig @@ -1,5 +1,7 @@ const Foo = union {}; -// union with 0 fields +// error +// backend=stage1 +// target=native // // tmp.zig:1:13: error: union declarations must have at least one tag diff --git a/test/compile_errors/stage1/obj/union_with_specified_enum_omits_field.zig b/test/compile_errors/stage1/obj/union_with_specified_enum_omits_field.zig index c1c1d38f02..0bb677a18c 100644 --- a/test/compile_errors/stage1/obj/union_with_specified_enum_omits_field.zig +++ b/test/compile_errors/stage1/obj/union_with_specified_enum_omits_field.zig @@ -11,7 +11,9 @@ export fn entry() usize { return @sizeOf(Payload); } -// union with specified enum omits field +// error +// backend=stage1 +// target=native // // tmp.zig:6:17: error: enum field missing: 'C' // tmp.zig:4:5: note: declared here diff --git a/test/compile_errors/stage1/obj/union_with_too_small_explicit_signed_tag_type.zig b/test/compile_errors/stage1/obj/union_with_too_small_explicit_signed_tag_type.zig index a3e75c25f6..97f4d48f6b 100644 --- a/test/compile_errors/stage1/obj/union_with_too_small_explicit_signed_tag_type.zig +++ b/test/compile_errors/stage1/obj/union_with_too_small_explicit_signed_tag_type.zig @@ -8,7 +8,9 @@ export fn entry() void { _ = U{ .D = 1 }; } -// union with too small explicit signed tag type +// error +// backend=stage1 +// target=native // // tmp.zig:1:22: error: specified integer tag type cannot represent every field // tmp.zig:1:22: note: type i2 cannot fit values in range 0...3 diff --git a/test/compile_errors/stage1/obj/union_with_too_small_explicit_unsigned_tag_type.zig b/test/compile_errors/stage1/obj/union_with_too_small_explicit_unsigned_tag_type.zig index 6f13dcda8a..c1496ade86 100644 --- a/test/compile_errors/stage1/obj/union_with_too_small_explicit_unsigned_tag_type.zig +++ b/test/compile_errors/stage1/obj/union_with_too_small_explicit_unsigned_tag_type.zig @@ -9,7 +9,9 @@ export fn entry() void { _ = U{ .E = 1 }; } -// union with too small explicit unsigned tag type +// error +// backend=stage1 +// target=native // // tmp.zig:1:22: error: specified integer tag type cannot represent every field // tmp.zig:1:22: note: type u2 cannot fit values in range 0...4 diff --git a/test/compile_errors/stage1/obj/unknown_length_pointer_to_opaque.zig b/test/compile_errors/stage1/obj/unknown_length_pointer_to_opaque.zig index a847bae599..d155b986d7 100644 --- a/test/compile_errors/stage1/obj/unknown_length_pointer_to_opaque.zig +++ b/test/compile_errors/stage1/obj/unknown_length_pointer_to_opaque.zig @@ -1,5 +1,7 @@ export const T = [*]opaque {}; -// unknown length pointer to opaque +// error +// backend=stage1 +// target=native // // tmp.zig:1:21: error: unknown-length pointer to opaque diff --git a/test/compile_errors/stage1/obj/unreachable_code-double_break.zig b/test/compile_errors/stage1/obj/unreachable_code-double_break.zig index b030c1d24d..0a19337af8 100644 --- a/test/compile_errors/stage1/obj/unreachable_code-double_break.zig +++ b/test/compile_errors/stage1/obj/unreachable_code-double_break.zig @@ -4,7 +4,9 @@ export fn a() void { }; } -// unreachable code - double break +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: unreachable code // tmp.zig:3:20: note: control flow is diverted here diff --git a/test/compile_errors/stage1/obj/unreachable_code-nested_returns.zig b/test/compile_errors/stage1/obj/unreachable_code-nested_returns.zig index 7bfa8eef64..8a80fcd161 100644 --- a/test/compile_errors/stage1/obj/unreachable_code-nested_returns.zig +++ b/test/compile_errors/stage1/obj/unreachable_code-nested_returns.zig @@ -2,7 +2,9 @@ export fn a() i32 { return return 1; } -// unreachable code - nested returns +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: unreachable code // tmp.zig:2:12: note: control flow is diverted here diff --git a/test/compile_errors/stage1/obj/unreachable_code.zig b/test/compile_errors/stage1/obj/unreachable_code.zig index 779cd90379..30a92d06bf 100644 --- a/test/compile_errors/stage1/obj/unreachable_code.zig +++ b/test/compile_errors/stage1/obj/unreachable_code.zig @@ -5,7 +5,9 @@ export fn a() void { fn b() void {} -// unreachable code +// error +// backend=stage1 +// target=native // // tmp.zig:3:6: error: unreachable code // tmp.zig:2:5: note: control flow is diverted here diff --git a/test/compile_errors/stage1/obj/unreachable_executed_at_comptime.zig b/test/compile_errors/stage1/obj/unreachable_executed_at_comptime.zig index 857ab0417f..34cb354e94 100644 --- a/test/compile_errors/stage1/obj/unreachable_executed_at_comptime.zig +++ b/test/compile_errors/stage1/obj/unreachable_executed_at_comptime.zig @@ -8,7 +8,9 @@ export fn entry() void { _ = foo(-42); } -// unreachable executed at comptime +// error +// backend=stage1 +// target=native // // tmp.zig:4:9: error: reached unreachable code // tmp.zig:8:12: note: called from here diff --git a/test/compile_errors/stage1/obj/unreachable_parameter.zig b/test/compile_errors/stage1/obj/unreachable_parameter.zig index 3feed62a1e..296194f7e3 100644 --- a/test/compile_errors/stage1/obj/unreachable_parameter.zig +++ b/test/compile_errors/stage1/obj/unreachable_parameter.zig @@ -1,6 +1,8 @@ fn f(a: noreturn) void { _ = a; } export fn entry() void { f(); } -// unreachable parameter +// error +// backend=stage1 +// target=native // // tmp.zig:1:9: error: parameter of type 'noreturn' not allowed diff --git a/test/compile_errors/stage1/obj/unreachable_variable.zig b/test/compile_errors/stage1/obj/unreachable_variable.zig index 8e053acd06..7f822a8bce 100644 --- a/test/compile_errors/stage1/obj/unreachable_variable.zig +++ b/test/compile_errors/stage1/obj/unreachable_variable.zig @@ -3,6 +3,8 @@ export fn f() void { _ = a; } -// unreachable variable +// error +// backend=stage1 +// target=native // // tmp.zig:2:25: error: expected type 'noreturn', found 'void' diff --git a/test/compile_errors/stage1/obj/unreachable_with_return.zig b/test/compile_errors/stage1/obj/unreachable_with_return.zig index ac9ecc93e3..6410d24913 100644 --- a/test/compile_errors/stage1/obj/unreachable_with_return.zig +++ b/test/compile_errors/stage1/obj/unreachable_with_return.zig @@ -1,6 +1,8 @@ fn a() noreturn {return;} export fn entry() void { a(); } -// unreachable with return +// error +// backend=stage1 +// target=native // // tmp.zig:1:18: error: expected type 'noreturn', found 'void' diff --git a/test/compile_errors/stage1/obj/unsupported_modifier_at_start_of_asm_output_constraint.zig b/test/compile_errors/stage1/obj/unsupported_modifier_at_start_of_asm_output_constraint.zig index c85850a61b..7c70fc5095 100644 --- a/test/compile_errors/stage1/obj/unsupported_modifier_at_start_of_asm_output_constraint.zig +++ b/test/compile_errors/stage1/obj/unsupported_modifier_at_start_of_asm_output_constraint.zig @@ -3,6 +3,8 @@ export fn foo() void { asm volatile ("" : [baz]"+r"(bar) : : ""); } -// unsupported modifier at start of asm output constraint +// error +// backend=stage1 +// target=native // // tmp.zig:3:5: error: invalid modifier starting output constraint for 'baz': '+', only '=' is supported. Compiler TODO: see https://github.com/ziglang/zig/issues/215 diff --git a/test/compile_errors/stage1/obj/unused_variable_error_on_errdefer.zig b/test/compile_errors/stage1/obj/unused_variable_error_on_errdefer.zig index eb92776938..b85d5729dc 100644 --- a/test/compile_errors/stage1/obj/unused_variable_error_on_errdefer.zig +++ b/test/compile_errors/stage1/obj/unused_variable_error_on_errdefer.zig @@ -6,6 +6,8 @@ export fn entry() void { foo() catch unreachable; } -// unused variable error on errdefer +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: unused variable: 'a' diff --git a/test/compile_errors/stage1/obj/use_anyopaque_as_return_type_of_fn_ptr.zig b/test/compile_errors/stage1/obj/use_anyopaque_as_return_type_of_fn_ptr.zig index f54bc14914..ef2787ca75 100644 --- a/test/compile_errors/stage1/obj/use_anyopaque_as_return_type_of_fn_ptr.zig +++ b/test/compile_errors/stage1/obj/use_anyopaque_as_return_type_of_fn_ptr.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = a; } -// use anyopaque as return type of fn ptr +// error +// backend=stage1 +// target=native // // tmp.zig:2:20: error: return type cannot be opaque diff --git a/test/compile_errors/stage1/obj/use_implicit_casts_to_assign_null_to_non-nullable_pointer.zig b/test/compile_errors/stage1/obj/use_implicit_casts_to_assign_null_to_non-nullable_pointer.zig index a8e01dbde0..4263f38e3e 100644 --- a/test/compile_errors/stage1/obj/use_implicit_casts_to_assign_null_to_non-nullable_pointer.zig +++ b/test/compile_errors/stage1/obj/use_implicit_casts_to_assign_null_to_non-nullable_pointer.zig @@ -7,6 +7,8 @@ export fn entry() void { _ = y; } -// use implicit casts to assign null to non-nullable pointer +// error +// backend=stage1 +// target=native // // tmp.zig:4:23: error: expected type '*?*i32', found '**i32' diff --git a/test/compile_errors/stage1/obj/use_invalid_number_literal_as_array_index.zig b/test/compile_errors/stage1/obj/use_invalid_number_literal_as_array_index.zig index 5ec655737e..b1d0aaa6f4 100644 --- a/test/compile_errors/stage1/obj/use_invalid_number_literal_as_array_index.zig +++ b/test/compile_errors/stage1/obj/use_invalid_number_literal_as_array_index.zig @@ -4,6 +4,8 @@ export fn entry() void { _ = arr; } -// use invalid number literal as array index +// error +// backend=stage1 +// target=native // // tmp.zig:1:1: error: unable to infer variable type diff --git a/test/compile_errors/stage1/obj/use_of_comptime-known_undefined_function_value.zig b/test/compile_errors/stage1/obj/use_of_comptime-known_undefined_function_value.zig index 5facc7e753..3500b13dfc 100644 --- a/test/compile_errors/stage1/obj/use_of_comptime-known_undefined_function_value.zig +++ b/test/compile_errors/stage1/obj/use_of_comptime-known_undefined_function_value.zig @@ -6,6 +6,8 @@ export fn entry() void { command.exec(); } -// use of comptime-known undefined function value +// error +// backend=stage1 +// target=native // // tmp.zig:6:12: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/use_of_undeclared_identifier.zig b/test/compile_errors/stage1/obj/use_of_undeclared_identifier.zig index e36453acc7..c1297731a3 100644 --- a/test/compile_errors/stage1/obj/use_of_undeclared_identifier.zig +++ b/test/compile_errors/stage1/obj/use_of_undeclared_identifier.zig @@ -2,6 +2,8 @@ export fn f() void { b = 3; } -// use of undeclared identifier +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: use of undeclared identifier 'b' diff --git a/test/compile_errors/stage1/obj/using_an_unknown_len_ptr_type_instead_of_array.zig b/test/compile_errors/stage1/obj/using_an_unknown_len_ptr_type_instead_of_array.zig index 983995b098..3124b057a8 100644 --- a/test/compile_errors/stage1/obj/using_an_unknown_len_ptr_type_instead_of_array.zig +++ b/test/compile_errors/stage1/obj/using_an_unknown_len_ptr_type_instead_of_array.zig @@ -6,6 +6,8 @@ comptime { _ = resolutions; } -// using an unknown len ptr type instead of array +// error +// backend=stage1 +// target=native // // tmp.zig:1:21: error: expected array type or [_], found '[*][*]const u8' diff --git a/test/compile_errors/stage1/obj/using_invalid_types_in_function_call_raises_an_error.zig b/test/compile_errors/stage1/obj/using_invalid_types_in_function_call_raises_an_error.zig index 182b5c59b0..f1fda15ea7 100644 --- a/test/compile_errors/stage1/obj/using_invalid_types_in_function_call_raises_an_error.zig +++ b/test/compile_errors/stage1/obj/using_invalid_types_in_function_call_raises_an_error.zig @@ -4,6 +4,8 @@ export fn entry() void { func(MenuEffect.ThisDoesNotExist); } -// using invalid types in function call raises an error +// error +// backend=stage1 +// target=native // // tmp.zig:1:20: error: enum declarations must have at least one tag diff --git a/test/compile_errors/stage1/obj/usingnamespace_with_wrong_type.zig b/test/compile_errors/stage1/obj/usingnamespace_with_wrong_type.zig index a74a8e6124..86b5f0dcfb 100644 --- a/test/compile_errors/stage1/obj/usingnamespace_with_wrong_type.zig +++ b/test/compile_errors/stage1/obj/usingnamespace_with_wrong_type.zig @@ -1,5 +1,7 @@ usingnamespace void; -// usingnamespace with wrong type +// error +// backend=stage1 +// target=native // // tmp.zig:1:1: error: expected struct, enum, or union; found 'void' diff --git a/test/compile_errors/stage1/obj/variable_has_wrong_type.zig b/test/compile_errors/stage1/obj/variable_has_wrong_type.zig index 1e20dde269..52dcf150de 100644 --- a/test/compile_errors/stage1/obj/variable_has_wrong_type.zig +++ b/test/compile_errors/stage1/obj/variable_has_wrong_type.zig @@ -3,6 +3,8 @@ export fn f() i32 { return a; } -// variable has wrong type +// error +// backend=stage1 +// target=native // // tmp.zig:3:12: error: expected type 'i32', found '*const [1:0]u8' diff --git a/test/compile_errors/stage1/obj/variable_in_inline_assembly_template_cannot_be_found.zig b/test/compile_errors/stage1/obj/variable_in_inline_assembly_template_cannot_be_found.zig new file mode 100644 index 0000000000..7636b501fd --- /dev/null +++ b/test/compile_errors/stage1/obj/variable_in_inline_assembly_template_cannot_be_found.zig @@ -0,0 +1,12 @@ +export fn entry() void { + var sp = asm volatile ("mov %[foo], sp" + : [bar] "=r" (-> usize), + ); + _ = sp; +} + +// error +// backend=stage1 +// target=x86_64-linux-gnu +// +// tmp.zig:2:14: error: could not find 'foo' in the inputs or outputs diff --git a/test/compile_errors/stage1/obj/variable_initialization_compile_error_then_referenced.zig b/test/compile_errors/stage1/obj/variable_initialization_compile_error_then_referenced.zig index d96b67bc3f..91b70481a1 100644 --- a/test/compile_errors/stage1/obj/variable_initialization_compile_error_then_referenced.zig +++ b/test/compile_errors/stage1/obj/variable_initialization_compile_error_then_referenced.zig @@ -12,6 +12,8 @@ export fn entry() void { _ = S; } -// variable initialization compile error then referenced +// error +// backend=stage1 +// target=native // // tmp.zig:2:12: error: use of undeclared identifier 'T' diff --git a/test/compile_errors/stage1/obj/variable_with_type_noreturn.zig b/test/compile_errors/stage1/obj/variable_with_type_noreturn.zig index b6cc65593b..e2ba9183be 100644 --- a/test/compile_errors/stage1/obj/variable_with_type_noreturn.zig +++ b/test/compile_errors/stage1/obj/variable_with_type_noreturn.zig @@ -2,7 +2,9 @@ export fn entry9() void { var z: noreturn = return; } -// variable with type 'noreturn' +// error +// backend=stage1 +// target=native // // tmp.zig:2:5: error: unreachable code // tmp.zig:2:23: note: control flow is diverted here diff --git a/test/compile_errors/stage1/obj/vector_index_out_of_bounds.zig b/test/compile_errors/stage1/obj/vector_index_out_of_bounds.zig index efdd8b5fe9..fdffd8b455 100644 --- a/test/compile_errors/stage1/obj/vector_index_out_of_bounds.zig +++ b/test/compile_errors/stage1/obj/vector_index_out_of_bounds.zig @@ -3,6 +3,8 @@ export fn entry() void { _ = x; } -// vector index out of bounds +// error +// backend=stage1 +// target=native // // tmp.zig:2:62: error: index 3 outside vector of size 3 diff --git a/test/compile_errors/stage1/obj/volatile_on_global_assembly.zig b/test/compile_errors/stage1/obj/volatile_on_global_assembly.zig index 8fc7ddfcc2..2157fe6a71 100644 --- a/test/compile_errors/stage1/obj/volatile_on_global_assembly.zig +++ b/test/compile_errors/stage1/obj/volatile_on_global_assembly.zig @@ -2,6 +2,8 @@ comptime { asm volatile (""); } -// volatile on global assembly +// error +// backend=stage1 +// target=native // // tmp.zig:2:9: error: volatile is meaningless on global assembly diff --git a/test/compile_errors/stage1/obj/wasmMemoryGrow_is_a_compile_error_in_non-Wasm_targets.zig b/test/compile_errors/stage1/obj/wasmMemoryGrow_is_a_compile_error_in_non-Wasm_targets.zig index 363b36a0af..6eda076f12 100644 --- a/test/compile_errors/stage1/obj/wasmMemoryGrow_is_a_compile_error_in_non-Wasm_targets.zig +++ b/test/compile_errors/stage1/obj/wasmMemoryGrow_is_a_compile_error_in_non-Wasm_targets.zig @@ -3,6 +3,8 @@ export fn foo() void { return; } -// wasmMemoryGrow is a compile error in non-Wasm targets +// error +// backend=stage1 +// target=native // // tmp.zig:2:9: error: @wasmMemoryGrow is a wasm32 feature only diff --git a/test/compile_errors/stage1/obj/wasmMemorySize_is_a_compile_error_in_non-Wasm_targets.zig b/test/compile_errors/stage1/obj/wasmMemorySize_is_a_compile_error_in_non-Wasm_targets.zig index 419173bd01..9bdf81073f 100644 --- a/test/compile_errors/stage1/obj/wasmMemorySize_is_a_compile_error_in_non-Wasm_targets.zig +++ b/test/compile_errors/stage1/obj/wasmMemorySize_is_a_compile_error_in_non-Wasm_targets.zig @@ -3,6 +3,8 @@ export fn foo() void { return; } -// wasmMemorySize is a compile error in non-Wasm targets +// error +// backend=stage1 +// target=native // // tmp.zig:2:9: error: @wasmMemorySize is a wasm32 feature only diff --git a/test/compile_errors/stage1/obj/while_expected_bool_got_error_union.zig b/test/compile_errors/stage1/obj/while_expected_bool_got_error_union.zig index e79296694d..9fc327e6c9 100644 --- a/test/compile_errors/stage1/obj/while_expected_bool_got_error_union.zig +++ b/test/compile_errors/stage1/obj/while_expected_bool_got_error_union.zig @@ -3,6 +3,8 @@ export fn foo() void { } fn bar() anyerror!i32 { return 1; } -// while expected bool, got error union +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: expected type 'bool', found 'anyerror!i32' diff --git a/test/compile_errors/stage1/obj/while_expected_bool_got_optional.zig b/test/compile_errors/stage1/obj/while_expected_bool_got_optional.zig index 7a3d184a1d..5948d62786 100644 --- a/test/compile_errors/stage1/obj/while_expected_bool_got_optional.zig +++ b/test/compile_errors/stage1/obj/while_expected_bool_got_optional.zig @@ -3,6 +3,8 @@ export fn foo() void { } fn bar() ?i32 { return 1; } -// while expected bool, got optional +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: expected type 'bool', found '?i32' diff --git a/test/compile_errors/stage1/obj/while_expected_error_union_got_bool.zig b/test/compile_errors/stage1/obj/while_expected_error_union_got_bool.zig index 8f92276af6..b8a72e9793 100644 --- a/test/compile_errors/stage1/obj/while_expected_error_union_got_bool.zig +++ b/test/compile_errors/stage1/obj/while_expected_error_union_got_bool.zig @@ -3,6 +3,8 @@ export fn foo() void { } fn bar() bool { return true; } -// while expected error union, got bool +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: expected error union type, found 'bool' diff --git a/test/compile_errors/stage1/obj/while_expected_error_union_got_optional.zig b/test/compile_errors/stage1/obj/while_expected_error_union_got_optional.zig index a67bf1ae16..c933dc9509 100644 --- a/test/compile_errors/stage1/obj/while_expected_error_union_got_optional.zig +++ b/test/compile_errors/stage1/obj/while_expected_error_union_got_optional.zig @@ -3,6 +3,8 @@ export fn foo() void { } fn bar() ?i32 { return 1; } -// while expected error union, got optional +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: expected error union type, found '?i32' diff --git a/test/compile_errors/stage1/obj/while_expected_optional_got_bool.zig b/test/compile_errors/stage1/obj/while_expected_optional_got_bool.zig index 6fc0d880ce..0458d1ba01 100644 --- a/test/compile_errors/stage1/obj/while_expected_optional_got_bool.zig +++ b/test/compile_errors/stage1/obj/while_expected_optional_got_bool.zig @@ -3,6 +3,8 @@ export fn foo() void { } fn bar() bool { return true; } -// while expected optional, got bool +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: expected optional type, found 'bool' diff --git a/test/compile_errors/stage1/obj/while_expected_optional_got_error_union.zig b/test/compile_errors/stage1/obj/while_expected_optional_got_error_union.zig index 472b3b81bc..7cdbd2cccf 100644 --- a/test/compile_errors/stage1/obj/while_expected_optional_got_error_union.zig +++ b/test/compile_errors/stage1/obj/while_expected_optional_got_error_union.zig @@ -3,6 +3,8 @@ export fn foo() void { } fn bar() anyerror!i32 { return 1; } -// while expected optional, got error union +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: expected optional type, found 'anyerror!i32' diff --git a/test/compile_errors/stage1/obj/while_loop_body_expression_ignored.zig b/test/compile_errors/stage1/obj/while_loop_body_expression_ignored.zig index 621c0d41d7..9542cbc62f 100644 --- a/test/compile_errors/stage1/obj/while_loop_body_expression_ignored.zig +++ b/test/compile_errors/stage1/obj/while_loop_body_expression_ignored.zig @@ -13,7 +13,9 @@ export fn f3() void { while (x) |_| returns() else |_| unreachable; } -// while loop body expression ignored +// error +// backend=stage1 +// target=native // // tmp.zig:5:25: error: expression value is ignored // tmp.zig:9:26: error: expression value is ignored diff --git a/test/compile_errors/stage1/obj/write_to_const_global_variable.zig b/test/compile_errors/stage1/obj/write_to_const_global_variable.zig index 327b3d02d0..4ce93e6b51 100644 --- a/test/compile_errors/stage1/obj/write_to_const_global_variable.zig +++ b/test/compile_errors/stage1/obj/write_to_const_global_variable.zig @@ -4,6 +4,8 @@ fn f() void { } export fn entry() void { f(); } -// write to const global variable +// error +// backend=stage1 +// target=native // // tmp.zig:3:9: error: cannot assign to constant diff --git a/test/compile_errors/stage1/obj/wrong_frame_type_used_for_async_call.zig b/test/compile_errors/stage1/obj/wrong_frame_type_used_for_async_call.zig index ba150c45cc..c02c20f495 100644 --- a/test/compile_errors/stage1/obj/wrong_frame_type_used_for_async_call.zig +++ b/test/compile_errors/stage1/obj/wrong_frame_type_used_for_async_call.zig @@ -9,6 +9,8 @@ fn bar() void { suspend {} } -// wrong frame type used for async call +// error +// backend=stage1 +// target=native // // tmp.zig:3:13: error: expected type '*@Frame(bar)', found '*@Frame(foo)' diff --git a/test/compile_errors/stage1/obj/wrong_function_type.zig b/test/compile_errors/stage1/obj/wrong_function_type.zig index c2238bb649..58f4477601 100644 --- a/test/compile_errors/stage1/obj/wrong_function_type.zig +++ b/test/compile_errors/stage1/obj/wrong_function_type.zig @@ -4,6 +4,8 @@ fn b() i32 {return 1;} fn c() i32 {return 2;} export fn entry() usize { return @sizeOf(@TypeOf(fns)); } -// wrong function type +// error +// backend=stage1 +// target=native // // tmp.zig:1:28: error: expected type 'fn() void', found 'fn() i32' diff --git a/test/compile_errors/stage1/obj/wrong_initializer_for_union_payload_of_type_type.zig b/test/compile_errors/stage1/obj/wrong_initializer_for_union_payload_of_type_type.zig index 1d56094b6d..2e7b8f2e40 100644 --- a/test/compile_errors/stage1/obj/wrong_initializer_for_union_payload_of_type_type.zig +++ b/test/compile_errors/stage1/obj/wrong_initializer_for_union_payload_of_type_type.zig @@ -9,6 +9,8 @@ export fn entry() void { v.u.A = U{ .A = i32 }; } -// wrong initializer for union payload of type 'type' +// error +// backend=stage1 +// target=native // // tmp.zig:9:8: error: use of undefined value here causes undefined behavior diff --git a/test/compile_errors/stage1/obj/wrong_number_of_arguments.zig b/test/compile_errors/stage1/obj/wrong_number_of_arguments.zig index 4cb13fdd12..f25c9dae08 100644 --- a/test/compile_errors/stage1/obj/wrong_number_of_arguments.zig +++ b/test/compile_errors/stage1/obj/wrong_number_of_arguments.zig @@ -3,6 +3,8 @@ export fn a() void { } fn c(d: i32, e: i32, f: i32) void { _ = d; _ = e; _ = f; } -// wrong number of arguments +// error +// backend=stage1 +// target=native // // tmp.zig:2:6: error: expected 3 argument(s), found 1 diff --git a/test/compile_errors/stage1/obj/wrong_number_of_arguments_for_method_fn_call.zig b/test/compile_errors/stage1/obj/wrong_number_of_arguments_for_method_fn_call.zig index 25449feb22..7371223863 100644 --- a/test/compile_errors/stage1/obj/wrong_number_of_arguments_for_method_fn_call.zig +++ b/test/compile_errors/stage1/obj/wrong_number_of_arguments_for_method_fn_call.zig @@ -7,6 +7,8 @@ fn f(foo: *const Foo) void { } export fn entry() usize { return @sizeOf(@TypeOf(f)); } -// wrong number of arguments for method fn call +// error +// backend=stage1 +// target=native // // tmp.zig:6:15: error: expected 2 argument(s), found 3 diff --git a/test/compile_errors/stage1/obj/wrong_panic_signature_generic_function.zig b/test/compile_errors/stage1/obj/wrong_panic_signature_generic_function.zig index faaa24ba60..45de2fc6cb 100644 --- a/test/compile_errors/stage1/obj/wrong_panic_signature_generic_function.zig +++ b/test/compile_errors/stage1/obj/wrong_panic_signature_generic_function.zig @@ -4,7 +4,9 @@ pub fn panic(comptime msg: []const u8, error_return_trace: ?*builtin.StackTrace) } const builtin = @import("std").builtin; -// wrong panic signature, generic function +// error +// backend=stage1 +// target=native // // error: expected type 'fn([]const u8, ?*std.builtin.StackTrace) noreturn', found 'fn([]const u8,anytype) anytype' // note: only one of the functions is generic diff --git a/test/compile_errors/stage1/obj/wrong_panic_signature_runtime_function.zig b/test/compile_errors/stage1/obj/wrong_panic_signature_runtime_function.zig index 92553c3104..5cf224c4a8 100644 --- a/test/compile_errors/stage1/obj/wrong_panic_signature_runtime_function.zig +++ b/test/compile_errors/stage1/obj/wrong_panic_signature_runtime_function.zig @@ -3,6 +3,8 @@ test "" {} pub fn panic() void {} -// wrong panic signature, runtime function +// error +// backend=stage1 +// target=native // // error: expected type 'fn([]const u8, ?*std.builtin.StackTrace) noreturn', found 'fn() void' diff --git a/test/compile_errors/stage1/obj/wrong_pointer_coerced_to_pointer_to_opaque_{}.zig b/test/compile_errors/stage1/obj/wrong_pointer_coerced_to_pointer_to_opaque_{}.zig index ed88e3be28..3f6b0e750b 100644 --- a/test/compile_errors/stage1/obj/wrong_pointer_coerced_to_pointer_to_opaque_{}.zig +++ b/test/compile_errors/stage1/obj/wrong_pointer_coerced_to_pointer_to_opaque_{}.zig @@ -5,6 +5,8 @@ export fn foo() void { bar(@ptrCast(*anyopaque, &x)); } -// wrong pointer coerced to pointer to opaque {} +// error +// backend=stage1 +// target=native // // tmp.zig:5:9: error: expected type '*Derp', found '*anyopaque' diff --git a/test/compile_errors/stage1/obj/wrong_return_type_for_main.zig b/test/compile_errors/stage1/obj/wrong_return_type_for_main.zig index bf335874db..218ef0b65d 100644 --- a/test/compile_errors/stage1/obj/wrong_return_type_for_main.zig +++ b/test/compile_errors/stage1/obj/wrong_return_type_for_main.zig @@ -1,5 +1,7 @@ pub fn main() f32 { } -// wrong return type for main +// error +// backend=stage1 +// target=native // // error: expected return type of main to be 'void', '!void', 'noreturn', 'u8', or '!u8' diff --git a/test/compile_errors/stage1/obj/wrong_size_to_an_array_literal.zig b/test/compile_errors/stage1/obj/wrong_size_to_an_array_literal.zig index 68cb263212..909d894587 100644 --- a/test/compile_errors/stage1/obj/wrong_size_to_an_array_literal.zig +++ b/test/compile_errors/stage1/obj/wrong_size_to_an_array_literal.zig @@ -3,6 +3,8 @@ comptime { _ = array; } -// wrong size to an array literal +// error +// backend=stage1 +// target=native // // tmp.zig:2:31: error: index 2 outside array of size 2 diff --git a/test/compile_errors/stage1/obj/wrong_type_for_argument_tuple_to_asyncCall.zig b/test/compile_errors/stage1/obj/wrong_type_for_argument_tuple_to_asyncCall.zig index d9e45a69b7..7a9be0a8cc 100644 --- a/test/compile_errors/stage1/obj/wrong_type_for_argument_tuple_to_asyncCall.zig +++ b/test/compile_errors/stage1/obj/wrong_type_for_argument_tuple_to_asyncCall.zig @@ -7,6 +7,8 @@ fn foo() i32 { return 0; } -// wrong type for argument tuple to @asyncCall +// error +// backend=stage1 +// target=native // // tmp.zig:3:33: error: expected tuple or struct, found 'void' diff --git a/test/compile_errors/stage1/obj/wrong_type_for_reify_type.zig b/test/compile_errors/stage1/obj/wrong_type_for_reify_type.zig index 2d8ea02326..b0c1d92659 100644 --- a/test/compile_errors/stage1/obj/wrong_type_for_reify_type.zig +++ b/test/compile_errors/stage1/obj/wrong_type_for_reify_type.zig @@ -2,6 +2,8 @@ export fn entry() void { _ = @Type(0); } -// wrong type for @Type +// error +// backend=stage1 +// target=native // // tmp.zig:2:15: error: expected type 'std.builtin.Type', found 'comptime_int' diff --git a/test/compile_errors/stage1/obj/wrong_type_for_result_ptr_to_asyncCall.zig b/test/compile_errors/stage1/obj/wrong_type_for_result_ptr_to_asyncCall.zig index 07c5ae8a0b..b4193d4de1 100644 --- a/test/compile_errors/stage1/obj/wrong_type_for_result_ptr_to_asyncCall.zig +++ b/test/compile_errors/stage1/obj/wrong_type_for_result_ptr_to_asyncCall.zig @@ -9,6 +9,8 @@ fn foo() i32 { return 1234; } -// wrong type for result ptr to @asyncCall +// error +// backend=stage1 +// target=native // // tmp.zig:6:37: error: expected type '*i32', found 'bool' diff --git a/test/compile_errors/stage1/obj/wrong_type_passed_to_panic.zig b/test/compile_errors/stage1/obj/wrong_type_passed_to_panic.zig index b16d563571..ed237f81df 100644 --- a/test/compile_errors/stage1/obj/wrong_type_passed_to_panic.zig +++ b/test/compile_errors/stage1/obj/wrong_type_passed_to_panic.zig @@ -3,6 +3,8 @@ export fn entry() void { @panic(e); } -// wrong type passed to @panic +// error +// backend=stage1 +// target=native // // tmp.zig:3:12: error: expected type '[]const u8', found 'error{Foo}' diff --git a/test/compile_errors/stage1/obj/wrong_type_to_hasField.zig b/test/compile_errors/stage1/obj/wrong_type_to_hasField.zig index a79fec2a21..680c19a6fb 100644 --- a/test/compile_errors/stage1/obj/wrong_type_to_hasField.zig +++ b/test/compile_errors/stage1/obj/wrong_type_to_hasField.zig @@ -2,6 +2,8 @@ export fn entry() bool { return @hasField(i32, "hi"); } -// wrong type to @hasField +// error +// backend=stage1 +// target=native // // tmp.zig:2:22: error: type 'i32' does not support @hasField diff --git a/test/compile_errors/stage1/obj/wrong_types_given_to_atomic_order_args_in_cmpxchg.zig b/test/compile_errors/stage1/obj/wrong_types_given_to_atomic_order_args_in_cmpxchg.zig index 47cdaa372f..b0f484e2fd 100644 --- a/test/compile_errors/stage1/obj/wrong_types_given_to_atomic_order_args_in_cmpxchg.zig +++ b/test/compile_errors/stage1/obj/wrong_types_given_to_atomic_order_args_in_cmpxchg.zig @@ -3,6 +3,8 @@ export fn entry() void { while (!@cmpxchgWeak(i32, &x, 1234, 5678, @as(u32, 1234), @as(u32, 1234))) {} } -// wrong types given to atomic order args in cmpxchg +// error +// backend=stage1 +// target=native // // tmp.zig:3:47: error: expected type 'std.builtin.AtomicOrder', found 'u32' diff --git a/test/compile_errors/stage1/obj/wrong_types_given_to_export.zig b/test/compile_errors/stage1/obj/wrong_types_given_to_export.zig index cdd7ab4631..c06116204f 100644 --- a/test/compile_errors/stage1/obj/wrong_types_given_to_export.zig +++ b/test/compile_errors/stage1/obj/wrong_types_given_to_export.zig @@ -3,6 +3,8 @@ comptime { @export(entry, .{.name = "entry", .linkage = @as(u32, 1234) }); } -// wrong types given to @export +// error +// backend=stage1 +// target=native // // tmp.zig:3:59: error: expected type 'std.builtin.GlobalLinkage', found 'comptime_int' diff --git a/test/compile_errors/stage1/test/access_invalid_typeInfo_decl.zig b/test/compile_errors/stage1/test/access_invalid_typeInfo_decl.zig index 2fc5730af0..40e31a0855 100644 --- a/test/compile_errors/stage1/test/access_invalid_typeInfo_decl.zig +++ b/test/compile_errors/stage1/test/access_invalid_typeInfo_decl.zig @@ -3,6 +3,9 @@ test "Crash" { _ = @typeInfo(@This()).Struct.decls[0]; } -// access invalid @typeInfo decl +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:1:11: error: use of undeclared identifier 'B' diff --git a/test/compile_errors/stage1/test/alignCast_of_zero_sized_types.zig b/test/compile_errors/stage1/test/alignCast_of_zero_sized_types.zig index 4c05571202..f83d22759c 100644 --- a/test/compile_errors/stage1/test/alignCast_of_zero_sized_types.zig +++ b/test/compile_errors/stage1/test/alignCast_of_zero_sized_types.zig @@ -17,7 +17,10 @@ export fn qux() void { _ = @alignCast(2, a); } -// @alignCast of zero sized types +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:3:23: error: cannot adjust alignment of zero sized type '*void' // tmp.zig:7:23: error: cannot adjust alignment of zero sized type '?*void' diff --git a/test/compile_errors/stage1/test/bad_splat_type.zig b/test/compile_errors/stage1/test/bad_splat_type.zig index 9a16bbc73d..94e3d052a6 100644 --- a/test/compile_errors/stage1/test/bad_splat_type.zig +++ b/test/compile_errors/stage1/test/bad_splat_type.zig @@ -4,6 +4,9 @@ export fn entry() void { _ = v; } -// bad @splat type +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:3:23: error: vector element type must be integer, float, bool, or pointer; 'comptime_int' is invalid diff --git a/test/compile_errors/stage1/test/binary_OR_operator_on_error_sets.zig b/test/compile_errors/stage1/test/binary_OR_operator_on_error_sets.zig index d9894a32a0..eb2d21c6ed 100644 --- a/test/compile_errors/stage1/test/binary_OR_operator_on_error_sets.zig +++ b/test/compile_errors/stage1/test/binary_OR_operator_on_error_sets.zig @@ -5,6 +5,9 @@ export fn entry() void { _ = x; } -// binary OR operator on error sets +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:2:18: error: invalid operands to binary expression: 'error{A}' and 'error{B}' diff --git a/test/compile_errors/stage1/test/call_rejects_non_comptime-known_fn-always_inline.zig b/test/compile_errors/stage1/test/call_rejects_non_comptime-known_fn-always_inline.zig index ea822f8d91..a010414a57 100644 --- a/test/compile_errors/stage1/test/call_rejects_non_comptime-known_fn-always_inline.zig +++ b/test/compile_errors/stage1/test/call_rejects_non_comptime-known_fn-always_inline.zig @@ -3,6 +3,9 @@ pub export fn entry() void { @call(.{ .modifier = .always_inline }, call_me, .{}); } -// @call rejects non comptime-known fn - always_inline +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:3:5: error: the specified modifier requires a comptime-known function diff --git a/test/compile_errors/stage1/test/call_rejects_non_comptime-known_fn-compile_time.zig b/test/compile_errors/stage1/test/call_rejects_non_comptime-known_fn-compile_time.zig index 3c50830787..b3ffcc6ec2 100644 --- a/test/compile_errors/stage1/test/call_rejects_non_comptime-known_fn-compile_time.zig +++ b/test/compile_errors/stage1/test/call_rejects_non_comptime-known_fn-compile_time.zig @@ -3,6 +3,9 @@ pub export fn entry() void { @call(.{ .modifier = .compile_time }, call_me, .{}); } -// @call rejects non comptime-known fn - compile_time +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:3:5: error: the specified modifier requires a comptime-known function diff --git a/test/compile_errors/stage1/test/cast_between_optional_T_where_T_is_not_a_pointer.zig b/test/compile_errors/stage1/test/cast_between_optional_T_where_T_is_not_a_pointer.zig index 8f5ca1c25d..b8392ff5db 100644 --- a/test/compile_errors/stage1/test/cast_between_optional_T_where_T_is_not_a_pointer.zig +++ b/test/compile_errors/stage1/test/cast_between_optional_T_where_T_is_not_a_pointer.zig @@ -6,7 +6,10 @@ export fn entry() void { a = b; } -// cast between ?T where T is not a pointer +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:6:9: error: expected type '?fn(i8) void', found '?fn(u64) void' // tmp.zig:6:9: note: optional type child 'fn(u64) void' cannot cast into optional type child 'fn(i8) void' diff --git a/test/compile_errors/stage1/test/combination_of_nosuspend_and_async.zig b/test/compile_errors/stage1/test/combination_of_nosuspend_and_async.zig index a164fb621b..43731c9648 100644 --- a/test/compile_errors/stage1/test/combination_of_nosuspend_and_async.zig +++ b/test/compile_errors/stage1/test/combination_of_nosuspend_and_async.zig @@ -7,7 +7,10 @@ export fn entry() void { } fn foo() void {} -// combination of nosuspend and async +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:4:9: error: suspend inside nosuspend block // tmp.zig:2:5: note: nosuspend block here diff --git a/test/compile_errors/stage1/test/comparison_of_non-tagged_union_and_enum_literal.zig b/test/compile_errors/stage1/test/comparison_of_non-tagged_union_and_enum_literal.zig index b3c1506705..4898ac744c 100644 --- a/test/compile_errors/stage1/test/comparison_of_non-tagged_union_and_enum_literal.zig +++ b/test/compile_errors/stage1/test/comparison_of_non-tagged_union_and_enum_literal.zig @@ -5,7 +5,10 @@ export fn entry() void { _ = ok; } -// comparison of non-tagged union and enum literal +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:4:16: error: comparison of union and enum literal is only valid for tagged union types // tmp.zig:2:15: note: type U is not a tagged union diff --git a/test/compile_errors/stage1/test/comptime_vector_overflow_shows_the_index.zig b/test/compile_errors/stage1/test/comptime_vector_overflow_shows_the_index.zig index a638c05b3b..a1f026ab70 100644 --- a/test/compile_errors/stage1/test/comptime_vector_overflow_shows_the_index.zig +++ b/test/compile_errors/stage1/test/comptime_vector_overflow_shows_the_index.zig @@ -5,7 +5,10 @@ comptime { _ = x; } -// comptime vector overflow shows the index +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:4:15: error: operation caused overflow // tmp.zig:4:15: note: when computing vector element at index 2 diff --git a/test/compile_errors/stage1/test/duplicate_field_in_anonymous_struct_literal.zig b/test/compile_errors/stage1/test/duplicate_field_in_anonymous_struct_literal.zig index 1b671d2ad3..7b6821d669 100644 --- a/test/compile_errors/stage1/test/duplicate_field_in_anonymous_struct_literal.zig +++ b/test/compile_errors/stage1/test/duplicate_field_in_anonymous_struct_literal.zig @@ -10,7 +10,10 @@ export fn entry() void { _ = anon; } -// duplicate field in anonymous struct literal +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:7:13: error: duplicate field // tmp.zig:4:13: note: other field here diff --git a/test/compile_errors/stage1/test/error_in_struct_initializer_doesnt_crash_the_compiler.zig b/test/compile_errors/stage1/test/error_in_struct_initializer_doesnt_crash_the_compiler.zig index e37b887121..2858fd6a01 100644 --- a/test/compile_errors/stage1/test/error_in_struct_initializer_doesnt_crash_the_compiler.zig +++ b/test/compile_errors/stage1/test/error_in_struct_initializer_doesnt_crash_the_compiler.zig @@ -7,6 +7,9 @@ pub export fn entry() void { _ = a; } -// error in struct initializer doesn't crash the compiler +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:4:9: error: duplicate struct field: 'e' diff --git a/test/compile_errors/stage1/test/errors_in_for_loop_bodies_are_propagated.zig b/test/compile_errors/stage1/test/errors_in_for_loop_bodies_are_propagated.zig index 32e99cf410..d8be29e39b 100644 --- a/test/compile_errors/stage1/test/errors_in_for_loop_bodies_are_propagated.zig +++ b/test/compile_errors/stage1/test/errors_in_for_loop_bodies_are_propagated.zig @@ -3,6 +3,9 @@ pub export fn entry() void { for (arr) |bits| _ = @popCount(bits); } -// errors in for loop bodies are propagated +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:3:26: error: expected 2 arguments, found 1 diff --git a/test/compile_errors/stage1/test/export_with_empty_name_string.zig b/test/compile_errors/stage1/test/export_with_empty_name_string.zig index 424ee6e4b5..b882d11723 100644 --- a/test/compile_errors/stage1/test/export_with_empty_name_string.zig +++ b/test/compile_errors/stage1/test/export_with_empty_name_string.zig @@ -3,6 +3,9 @@ comptime { @export(entry, .{ .name = "" }); } -// @export with empty name string +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:3:5: error: exported symbol name cannot be empty diff --git a/test/compile_errors/stage1/test/helpful_return_type_error_message.zig b/test/compile_errors/stage1/test/helpful_return_type_error_message.zig index 6f1f9639da..0e97c09de2 100644 --- a/test/compile_errors/stage1/test/helpful_return_type_error_message.zig +++ b/test/compile_errors/stage1/test/helpful_return_type_error_message.zig @@ -15,7 +15,10 @@ export fn quux() u32 { buf = bar(); } -// helpful return type error message +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:2:17: error: expected type 'u32', found 'error{Ohno}' // tmp.zig:1:17: note: function cannot return an error diff --git a/test/compile_errors/stage1/test/int-float_conversion_to_comptime_int-float.zig b/test/compile_errors/stage1/test/int-float_conversion_to_comptime_int-float.zig index eeb2e4798e..de439168ae 100644 --- a/test/compile_errors/stage1/test/int-float_conversion_to_comptime_int-float.zig +++ b/test/compile_errors/stage1/test/int-float_conversion_to_comptime_int-float.zig @@ -7,7 +7,10 @@ export fn bar() void { _ = @intToFloat(comptime_float, a); } -// int/float conversion to comptime_int/float +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:3:35: error: unable to evaluate constant expression // tmp.zig:7:37: error: unable to evaluate constant expression diff --git a/test/compile_errors/stage1/test/invalid_assignments.zig b/test/compile_errors/stage1/test/invalid_assignments.zig index 203784c554..75f45a8bcb 100644 --- a/test/compile_errors/stage1/test/invalid_assignments.zig +++ b/test/compile_errors/stage1/test/invalid_assignments.zig @@ -10,7 +10,10 @@ export fn entry4() void { 2 + 2 = 3; } -// invalid assignments +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:3:6: error: invalid left-hand side to assignment // tmp.zig:7:7: error: invalid left-hand side to assignment diff --git a/test/compile_errors/stage1/test/invalid_float_casts.zig b/test/compile_errors/stage1/test/invalid_float_casts.zig index 0e2509dcaf..2fe8003728 100644 --- a/test/compile_errors/stage1/test/invalid_float_casts.zig +++ b/test/compile_errors/stage1/test/invalid_float_casts.zig @@ -15,7 +15,10 @@ export fn qux() void { _ = @floatCast(f32, a); } -// invalid float casts +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:3:36: error: unable to evaluate constant expression // tmp.zig:7:21: error: expected integer type, found 'f32' diff --git a/test/compile_errors/stage1/test/invalid_int_casts.zig b/test/compile_errors/stage1/test/invalid_int_casts.zig index 6870ecc723..9945751ef5 100644 --- a/test/compile_errors/stage1/test/invalid_int_casts.zig +++ b/test/compile_errors/stage1/test/invalid_int_casts.zig @@ -15,7 +15,10 @@ export fn qux() void { _ = @intCast(u32, a); } -// invalid int casts +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:3:32: error: unable to evaluate constant expression // tmp.zig:7:21: error: expected float type, found 'u32' diff --git a/test/compile_errors/stage1/test/invalid_non-exhaustive_enum_to_union.zig b/test/compile_errors/stage1/test/invalid_non-exhaustive_enum_to_union.zig index f78a9e62ff..804e83a66a 100644 --- a/test/compile_errors/stage1/test/invalid_non-exhaustive_enum_to_union.zig +++ b/test/compile_errors/stage1/test/invalid_non-exhaustive_enum_to_union.zig @@ -18,7 +18,10 @@ export fn bar() void { _ = u; } -// invalid non-exhaustive enum to union +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:12:16: error: runtime cast to union 'U' from non-exhaustive enum // tmp.zig:17:16: error: no tag by value 15 diff --git a/test/compile_errors/stage1/test/invalid_pointer_with_reify_type.zig b/test/compile_errors/stage1/test/invalid_pointer_with_reify_type.zig index febf9685fd..bf1cf6bd6f 100644 --- a/test/compile_errors/stage1/test/invalid_pointer_with_reify_type.zig +++ b/test/compile_errors/stage1/test/invalid_pointer_with_reify_type.zig @@ -11,6 +11,9 @@ export fn entry() void { }}); } -// invalid pointer with @Type +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:2:16: error: sentinels are only allowed on slices and unknown-length pointers diff --git a/test/compile_errors/stage1/test/nested_vectors.zig b/test/compile_errors/stage1/test/nested_vectors.zig index a05e9b0c5b..9e87ac814b 100644 --- a/test/compile_errors/stage1/test/nested_vectors.zig +++ b/test/compile_errors/stage1/test/nested_vectors.zig @@ -5,6 +5,9 @@ export fn entry() void { _ = v; } -// nested vectors +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:3:23: error: vector element type must be integer, float, bool, or pointer; '@Vector(4, u8)' is invalid diff --git a/test/compile_errors/stage1/test/non-exhaustive_enum_marker_assigned_a_value.zig b/test/compile_errors/stage1/test/non-exhaustive_enum_marker_assigned_a_value.zig index 53037ff181..609af248df 100644 --- a/test/compile_errors/stage1/test/non-exhaustive_enum_marker_assigned_a_value.zig +++ b/test/compile_errors/stage1/test/non-exhaustive_enum_marker_assigned_a_value.zig @@ -10,7 +10,10 @@ const B = enum { }; comptime { _ = A; _ = B; } -// non-exhaustive enum marker assigned a value +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:4:9: error: '_' is used to mark an enum as non-exhaustive and cannot be assigned a value // tmp.zig:6:11: error: non-exhaustive enum missing integer tag type diff --git a/test/compile_errors/stage1/test/non-exhaustive_enums.zig b/test/compile_errors/stage1/test/non-exhaustive_enums.zig index 49ceff3178..3b5f8af7cb 100644 --- a/test/compile_errors/stage1/test/non-exhaustive_enums.zig +++ b/test/compile_errors/stage1/test/non-exhaustive_enums.zig @@ -13,7 +13,10 @@ pub export fn entry() void { _ = C; } -// non-exhaustive enums +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:3:5: error: '_' field of non-exhaustive enum must be last // tmp.zig:6:11: error: non-exhaustive enum specifies every value diff --git a/test/compile_errors/stage1/test/not_an_enum_type.zig b/test/compile_errors/stage1/test/not_an_enum_type.zig index f92c3d44e1..99c733b4d0 100644 --- a/test/compile_errors/stage1/test/not_an_enum_type.zig +++ b/test/compile_errors/stage1/test/not_an_enum_type.zig @@ -12,6 +12,9 @@ const Error = union(enum) { const InvalidToken = struct {}; const ExpectedVarDeclOrFn = struct {}; -// not an enum type +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:4:9: error: expected type '@typeInfo(Error).Union.tag_type.?', found 'type' diff --git a/test/compile_errors/stage1/test/packed_struct_with_fields_of_not_allowed_types.zig b/test/compile_errors/stage1/test/packed_struct_with_fields_of_not_allowed_types.zig index dc156342f4..2951d26c52 100644 --- a/test/compile_errors/stage1/test/packed_struct_with_fields_of_not_allowed_types.zig +++ b/test/compile_errors/stage1/test/packed_struct_with_fields_of_not_allowed_types.zig @@ -59,7 +59,10 @@ const Enum = enum { B, }; -// packed struct with fields of not allowed types +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:2:5: error: type 'anyerror' not allowed in packed struct; no guaranteed in-memory representation // tmp.zig:5:5: error: array of 'u24' not allowed in packed struct due to padding bits (must be padded from 48 to 64 bits) diff --git a/test/compile_errors/stage1/test/ptrToInt_with_pointer_to_zero-sized_type.zig b/test/compile_errors/stage1/test/ptrToInt_with_pointer_to_zero-sized_type.zig index 63ba217247..7c2ba184c4 100644 --- a/test/compile_errors/stage1/test/ptrToInt_with_pointer_to_zero-sized_type.zig +++ b/test/compile_errors/stage1/test/ptrToInt_with_pointer_to_zero-sized_type.zig @@ -4,6 +4,9 @@ export fn entry() void { _ = x; } -// @ptrToInt with pointer to zero-sized type +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:3:23: error: pointer to size 0 type has no address diff --git a/test/compile_errors/stage1/test/reassign_to_array_parameter.zig b/test/compile_errors/stage1/test/reassign_to_array_parameter.zig index a222150a2c..f3b51d2c0f 100644 --- a/test/compile_errors/stage1/test/reassign_to_array_parameter.zig +++ b/test/compile_errors/stage1/test/reassign_to_array_parameter.zig @@ -5,6 +5,9 @@ export fn entry() void { reassign(.{1, 2, 3}); } -// reassign to array parameter +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:2:15: error: cannot assign to constant diff --git a/test/compile_errors/stage1/test/reassign_to_slice_parameter.zig b/test/compile_errors/stage1/test/reassign_to_slice_parameter.zig index a8e555182a..34bd5541a1 100644 --- a/test/compile_errors/stage1/test/reassign_to_slice_parameter.zig +++ b/test/compile_errors/stage1/test/reassign_to_slice_parameter.zig @@ -5,6 +5,9 @@ export fn entry() void { reassign("foo"); } -// reassign to slice parameter +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:2:10: error: cannot assign to constant diff --git a/test/compile_errors/stage1/test/reassign_to_struct_parameter.zig b/test/compile_errors/stage1/test/reassign_to_struct_parameter.zig index 018548ab32..994833d989 100644 --- a/test/compile_errors/stage1/test/reassign_to_struct_parameter.zig +++ b/test/compile_errors/stage1/test/reassign_to_struct_parameter.zig @@ -8,6 +8,9 @@ export fn entry() void { reassign(S{.x = 3}); } -// reassign to struct parameter +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:5:10: error: cannot assign to constant diff --git a/test/compile_errors/stage1/test/reference_to_const_data.zig b/test/compile_errors/stage1/test/reference_to_const_data.zig index d785eb648e..6c98aefd7a 100644 --- a/test/compile_errors/stage1/test/reference_to_const_data.zig +++ b/test/compile_errors/stage1/test/reference_to_const_data.zig @@ -19,7 +19,10 @@ export fn qux() void { ptr.x = 2; } -// reference to const data +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:3:14: error: cannot assign to constant // tmp.zig:7:13: error: cannot assign to constant diff --git a/test/compile_errors/stage1/test/reify_typeOf_with_incompatible_arguments.zig b/test/compile_errors/stage1/test/reify_typeOf_with_incompatible_arguments.zig index 97ee7aaf1b..2013a07e53 100644 --- a/test/compile_errors/stage1/test/reify_typeOf_with_incompatible_arguments.zig +++ b/test/compile_errors/stage1/test/reify_typeOf_with_incompatible_arguments.zig @@ -4,6 +4,9 @@ export fn entry() void { _ = @TypeOf(var_1, var_2); } -// @TypeOf with incompatible arguments +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:4:9: error: incompatible types: 'f32' and 'u32' diff --git a/test/compile_errors/stage1/test/reify_typeOf_with_no_arguments.zig b/test/compile_errors/stage1/test/reify_typeOf_with_no_arguments.zig index e18b9e66b7..0626d45393 100644 --- a/test/compile_errors/stage1/test/reify_typeOf_with_no_arguments.zig +++ b/test/compile_errors/stage1/test/reify_typeOf_with_no_arguments.zig @@ -2,6 +2,9 @@ export fn entry() void { _ = @TypeOf(); } -// @TypeOf with no arguments +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:2:9: error: expected at least 1 argument, found 0 diff --git a/test/compile_errors/stage1/test/reject_extern_function_definitions_with_body.zig b/test/compile_errors/stage1/test/reject_extern_function_definitions_with_body.zig index 024080a6bc..a7b92e8399 100644 --- a/test/compile_errors/stage1/test/reject_extern_function_definitions_with_body.zig +++ b/test/compile_errors/stage1/test/reject_extern_function_definitions_with_body.zig @@ -2,6 +2,9 @@ extern "c" fn definitelyNotInLibC(a: i32, b: i32) i32 { return a + b; } -// reject extern function definitions with body +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:1:1: error: extern functions have no body diff --git a/test/compile_errors/stage1/test/reject_extern_variables_with_initializers.zig b/test/compile_errors/stage1/test/reject_extern_variables_with_initializers.zig index d3f65ff0cb..54239e0948 100644 --- a/test/compile_errors/stage1/test/reject_extern_variables_with_initializers.zig +++ b/test/compile_errors/stage1/test/reject_extern_variables_with_initializers.zig @@ -1,5 +1,8 @@ extern var foo: int = 2; -// reject extern variables with initializers +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:1:23: error: extern variables have no initializers diff --git a/test/compile_errors/stage1/test/repeated_invalid_field_access_to_generic_function_returning_type_crashes_compiler_2655.zig b/test/compile_errors/stage1/test/repeated_invalid_field_access_to_generic_function_returning_type_crashes_compiler_2655.zig index c419a6ae83..7499939b4a 100644 --- a/test/compile_errors/stage1/test/repeated_invalid_field_access_to_generic_function_returning_type_crashes_compiler_2655.zig +++ b/test/compile_errors/stage1/test/repeated_invalid_field_access_to_generic_function_returning_type_crashes_compiler_2655.zig @@ -6,6 +6,9 @@ test "1" { _ = A().a; } -// repeated invalid field access to generic function returning type crashes compiler. #2655 +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:2:12: error: use of undeclared identifier 'Q' diff --git a/test/compile_errors/stage1/test/return_invalid_type_from_test.zig b/test/compile_errors/stage1/test/return_invalid_type_from_test.zig index e7aeab3be7..590ac30918 100644 --- a/test/compile_errors/stage1/test/return_invalid_type_from_test.zig +++ b/test/compile_errors/stage1/test/return_invalid_type_from_test.zig @@ -1,5 +1,8 @@ test "example" { return 1; } -// return invalid type from test +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:1:25: error: expected type 'void', found 'comptime_int' diff --git a/test/compile_errors/stage1/test/shift_on_type_with_non-power-of-two_size.zig b/test/compile_errors/stage1/test/shift_on_type_with_non-power-of-two_size.zig index d76406223d..222cb22563 100644 --- a/test/compile_errors/stage1/test/shift_on_type_with_non-power-of-two_size.zig +++ b/test/compile_errors/stage1/test/shift_on_type_with_non-power-of-two_size.zig @@ -23,7 +23,10 @@ export fn entry() void { S.d(); } -// shift on type with non-power-of-two size +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:5:19: error: RHS of shift is too large for LHS type // tmp.zig:9:19: error: RHS of shift is too large for LHS type diff --git a/test/compile_errors/stage1/test/shuffle_with_selected_index_past_first_vector_length.zig b/test/compile_errors/stage1/test/shuffle_with_selected_index_past_first_vector_length.zig index c45eb4a0e2..8b0c5ba780 100644 --- a/test/compile_errors/stage1/test/shuffle_with_selected_index_past_first_vector_length.zig +++ b/test/compile_errors/stage1/test/shuffle_with_selected_index_past_first_vector_length.zig @@ -5,7 +5,10 @@ export fn entry() void { _ = z; } -// @shuffle with selected index past first vector length +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:4:39: error: mask index '4' has out-of-bounds selection // tmp.zig:4:27: note: selected index '7' out of bounds of @Vector(4, u32) diff --git a/test/compile_errors/stage1/test/switch_ranges_endpoints_are_validated.zig b/test/compile_errors/stage1/test/switch_ranges_endpoints_are_validated.zig index 4c0545ea92..a44d59feed 100644 --- a/test/compile_errors/stage1/test/switch_ranges_endpoints_are_validated.zig +++ b/test/compile_errors/stage1/test/switch_ranges_endpoints_are_validated.zig @@ -7,7 +7,10 @@ pub export fn entry() void { } } -// switch ranges endpoints are validated +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:4:9: error: range start value is greater than the end value // tmp.zig:5:9: error: range start value is greater than the end value diff --git a/test/compile_errors/stage1/test/switching_with_exhaustive_enum_has___prong_.zig b/test/compile_errors/stage1/test/switching_with_exhaustive_enum_has___prong_.zig index b132b7834e..0ca489bdb8 100644 --- a/test/compile_errors/stage1/test/switching_with_exhaustive_enum_has___prong_.zig +++ b/test/compile_errors/stage1/test/switching_with_exhaustive_enum_has___prong_.zig @@ -11,6 +11,9 @@ pub export fn entry() void { } } -// switching with exhaustive enum has '_' prong +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:7:5: error: switch on exhaustive enum has `_` prong diff --git a/test/compile_errors/stage1/test/switching_with_non-exhaustive_enums.zig b/test/compile_errors/stage1/test/switching_with_non-exhaustive_enums.zig index 53cd88e68c..ed46c5f2f1 100644 --- a/test/compile_errors/stage1/test/switching_with_non-exhaustive_enums.zig +++ b/test/compile_errors/stage1/test/switching_with_non-exhaustive_enums.zig @@ -25,7 +25,10 @@ pub export fn entry() void { } } -// switching with non-exhaustive enums +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:12:5: error: enumeration value 'E.b' not handled in switch // tmp.zig:16:5: error: switch on non-exhaustive enum must include `else` or `_` prong diff --git a/test/compile_errors/stage1/test/tagName_on_invalid_value_of_non-exhaustive_enum.zig b/test/compile_errors/stage1/test/tagName_on_invalid_value_of_non-exhaustive_enum.zig index 139c7c7a23..a98470b681 100644 --- a/test/compile_errors/stage1/test/tagName_on_invalid_value_of_non-exhaustive_enum.zig +++ b/test/compile_errors/stage1/test/tagName_on_invalid_value_of_non-exhaustive_enum.zig @@ -3,6 +3,9 @@ test "enum" { _ = @tagName(@intToEnum(E, 5)); } -// @tagName on invalid value of non-exhaustive enum +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:3:18: error: no tag by value 5 diff --git a/test/compile_errors/stage1/test/type_mismatch_in_C_prototype_with_varargs.zig b/test/compile_errors/stage1/test/type_mismatch_in_C_prototype_with_varargs.zig index 437cca8772..1f78ef3999 100644 --- a/test/compile_errors/stage1/test/type_mismatch_in_C_prototype_with_varargs.zig +++ b/test/compile_errors/stage1/test/type_mismatch_in_C_prototype_with_varargs.zig @@ -6,6 +6,9 @@ export fn main() void { _ = x; } -// type mismatch in C prototype with varargs +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:5:22: error: expected type 'fn([*c]u8, ...) callconv(.C) void', found 'fn([*:0]u8, ...) callconv(.C) void' diff --git a/test/compile_errors/stage1/test/type_mismatch_with_tuple_concatenation.zig b/test/compile_errors/stage1/test/type_mismatch_with_tuple_concatenation.zig index ce5e4d4629..5983224676 100644 --- a/test/compile_errors/stage1/test/type_mismatch_with_tuple_concatenation.zig +++ b/test/compile_errors/stage1/test/type_mismatch_with_tuple_concatenation.zig @@ -3,6 +3,9 @@ export fn entry() void { x = x ++ .{ 1, 2, 3 }; } -// type mismatch with tuple concatenation +// error +// backend=stage1 +// target=native +// is_test=1 // // tmp.zig:3:11: error: expected type 'struct:2:14', found 'struct:3:11' diff --git a/test/compile_errors/stage2/constant_inside_comptime_function_has_compile_error.zig b/test/compile_errors/stage2/constant_inside_comptime_function_has_compile_error.zig index 98d6104670..2b67390b05 100644 --- a/test/compile_errors/stage2/constant_inside_comptime_function_has_compile_error.zig +++ b/test/compile_errors/stage2/constant_inside_comptime_function_has_compile_error.zig @@ -15,6 +15,7 @@ export fn entry() void { } // error +// target=native // // :4:5: error: unreachable code // :4:25: note: control flow is diverted here diff --git a/test/compile_errors/stage2/duplicate-unused_labels.zig b/test/compile_errors/stage2/duplicate-unused_labels.zig index 44ab48480d..4bfc6c5960 100644 --- a/test/compile_errors/stage2/duplicate-unused_labels.zig +++ b/test/compile_errors/stage2/duplicate-unused_labels.zig @@ -18,6 +18,7 @@ comptime { } // error +// target=native // // :2:12: error: redefinition of label 'blk' // :2:5: note: previous definition here diff --git a/test/compile_errors/stage2/embed_outside_package.zig b/test/compile_errors/stage2/embed_outside_package.zig index 9cf1a8b905..2003adb061 100644 --- a/test/compile_errors/stage2/embed_outside_package.zig +++ b/test/compile_errors/stage2/embed_outside_package.zig @@ -3,5 +3,6 @@ export fn a() usize { } // error +// target=native // //:2:23: error: embed of file outside package path: '/root/foo' diff --git a/test/compile_errors/stage2/import_outside_package.zig b/test/compile_errors/stage2/import_outside_package.zig index 6b70778754..59a75e2745 100644 --- a/test/compile_errors/stage2/import_outside_package.zig +++ b/test/compile_errors/stage2/import_outside_package.zig @@ -3,5 +3,6 @@ export fn a() usize { } // error +// target=native // // :2:20: error: import of file outside package path: '../../above.zig' diff --git a/test/compile_errors/stage2/out_of_bounds_index.zig b/test/compile_errors/stage2/out_of_bounds_index.zig index 614c445d46..ea9bc6521d 100644 --- a/test/compile_errors/stage2/out_of_bounds_index.zig +++ b/test/compile_errors/stage2/out_of_bounds_index.zig @@ -21,6 +21,7 @@ comptime { } // error +// target=native // // :4:26: error: end index 6 out of bounds for slice of length 4 +1 (sentinel) // :9:22: error: end index 6 out of bounds for array of length 4 +1 (sentinel) diff --git a/test/compile_errors/stage2/slice_of_null_pointer.zig b/test/compile_errors/stage2/slice_of_null_pointer.zig index a33a904842..7f2c74a8a6 100644 --- a/test/compile_errors/stage2/slice_of_null_pointer.zig +++ b/test/compile_errors/stage2/slice_of_null_pointer.zig @@ -6,5 +6,6 @@ comptime { } // error +// target=native // // :4:14: error: slice of null pointer diff --git a/test/compile_errors/stage2/struct_duplicate_field_name.zig b/test/compile_errors/stage2/struct_duplicate_field_name.zig index e7bed78d06..7e4434f1d9 100644 --- a/test/compile_errors/stage2/struct_duplicate_field_name.zig +++ b/test/compile_errors/stage2/struct_duplicate_field_name.zig @@ -9,6 +9,7 @@ export fn entry() void { } // error +// target=native // // :3:5: error: duplicate struct field: 'foo' // :2:5: note: other field here diff --git a/test/compile_errors/stage2/union_access_of_inactive_field.zig b/test/compile_errors/stage2/union_access_of_inactive_field.zig index 881279e1c3..4f72914216 100644 --- a/test/compile_errors/stage2/union_access_of_inactive_field.zig +++ b/test/compile_errors/stage2/union_access_of_inactive_field.zig @@ -9,6 +9,7 @@ comptime { } // error +// target=native // // :7:16: error: access of union field 'b' while field 'a' is active // :1:11: note: union declared here diff --git a/test/compile_errors/stage2/union_duplicate_enum_field.zig b/test/compile_errors/stage2/union_duplicate_enum_field.zig index 5a08256edb..44eb58e014 100644 --- a/test/compile_errors/stage2/union_duplicate_enum_field.zig +++ b/test/compile_errors/stage2/union_duplicate_enum_field.zig @@ -10,6 +10,7 @@ export fn foo() void { } // error +// target=native // // :4:5: error: duplicate union field: 'a' // :3:5: note: other field here diff --git a/test/compile_errors/stage2/union_duplicate_field_definition.zig b/test/compile_errors/stage2/union_duplicate_field_definition.zig index 7aab7c4695..7993f27141 100644 --- a/test/compile_errors/stage2/union_duplicate_field_definition.zig +++ b/test/compile_errors/stage2/union_duplicate_field_definition.zig @@ -9,6 +9,7 @@ export fn entry() void { } // error +// target=native // // :3:5: error: duplicate union field: 'foo' // :2:5: note: other field here diff --git a/test/compile_errors/stage2/union_enum_field_missing.zig b/test/compile_errors/stage2/union_enum_field_missing.zig index 638c9fec26..25ec477894 100644 --- a/test/compile_errors/stage2/union_enum_field_missing.zig +++ b/test/compile_errors/stage2/union_enum_field_missing.zig @@ -14,6 +14,7 @@ export fn entry() usize { } // error +// target=native // // :7:1: error: enum field(s) missing in union // :4:5: note: field 'c' missing, declared here diff --git a/test/compile_errors/stage2/union_extra_field.zig b/test/compile_errors/stage2/union_extra_field.zig index cdfa482208..e3bc0deb33 100644 --- a/test/compile_errors/stage2/union_extra_field.zig +++ b/test/compile_errors/stage2/union_extra_field.zig @@ -14,6 +14,7 @@ export fn entry() usize { } // error +// target=native // // :6:1: error: enum 'tmp.E' has no field named 'd' // :1:11: note: enum declared here diff --git a/test/compile_errors/stage2/union_runtime_coercion_from_enum.zig b/test/compile_errors/stage2/union_runtime_coercion_from_enum.zig index 56cd2db83b..9020e9d5d7 100644 --- a/test/compile_errors/stage2/union_runtime_coercion_from_enum.zig +++ b/test/compile_errors/stage2/union_runtime_coercion_from_enum.zig @@ -15,6 +15,7 @@ export fn doTheTest() u64 { } // error +// target=native // // :13:19: error: runtime coercion from enum 'tmp.E' to union 'tmp.U' which has non-void fields // :6:5: note: field 'a' has type 'u32' From d25f06a71c058aa4ff8bf40749345028bda6e017 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Thu, 28 Apr 2022 18:22:57 +0200 Subject: [PATCH 26/26] test: remove redundant codepaths from test harness --- src/test.zig | 170 ++------------------------------------------------- 1 file changed, 4 insertions(+), 166 deletions(-) diff --git a/src/test.zig b/src/test.zig index adcfeb8dff..758347ac18 100644 --- a/src/test.zig +++ b/src/test.zig @@ -904,32 +904,12 @@ pub const TestContext = struct { incremental, }; - /// Adds a compile-error test for each file in the provided directory, using the - /// selected backend and output mode. If `one_test_case_per_file` is true, a new - /// test case is created for each file. Otherwise, a single test case is used for - /// all tests. + /// Adds a test for each file in the provided directory, using the selected strategy. + /// Recurses nested directories. /// /// Each file should include a test manifest as a contiguous block of comments at - /// the end of the file. The first line should be the test case name, followed by - /// a blank line, then one expected errors on each line in the form - /// `:line:column: error: message` - pub fn addErrorCasesFromDir( - ctx: *TestContext, - name: []const u8, - dir: std.fs.Dir, - backend: Backend, - output_mode: std.builtin.OutputMode, - is_test: bool, - strategy: Strategy, - ) void { - var current_file: []const u8 = "none"; - addErrorCasesFromDirInner(ctx, name, dir, backend, output_mode, is_test, strategy, ¤t_file) catch |err| { - std.debug.panic("test harness failed to process file '{s}': {s}\n", .{ - current_file, @errorName(err), - }); - }; - } - + /// the end of the file. The first line should be the test type, followed by a set of + /// key-value config values, followed by a blank line, then the expected output. pub fn addTestCasesFromDir(ctx: *TestContext, dir: std.fs.Dir, strategy: Strategy) void { var current_file: []const u8 = "none"; ctx.addTestCasesFromDirInner(dir, strategy, ¤t_file) catch |err| { @@ -1127,148 +1107,6 @@ pub const TestContext = struct { } } - fn addErrorCasesFromDirInner( - ctx: *TestContext, - name: []const u8, - dir: std.fs.Dir, - backend: Backend, - output_mode: std.builtin.OutputMode, - is_test: bool, - strategy: Strategy, - /// This is kept up to date with the currently being processed file so - /// that if any errors occur the caller knows it happened during this file. - current_file: *[]const u8, - ) !void { - var opt_case: ?*Case = null; - - var it = dir.iterate(); - var filenames = std.ArrayList([]const u8).init(ctx.arena); - defer filenames.deinit(); - - while (try it.next()) |entry| { - if (entry.kind != .File) continue; - - // Ignore stuff such as .swp files - switch (Compilation.classifyFileExt(entry.name)) { - .unknown => continue, - else => {}, - } - try filenames.append(try ctx.arena.dupe(u8, entry.name)); - } - - // Sort filenames, so that incremental tests are contiguous and in-order - sortTestFilenames(filenames.items); - - var prev_filename: []const u8 = ""; - for (filenames.items) |filename| { - current_file.* = filename; - - { // First, check if this file is part of an incremental update sequence - - // Split filename into ".." - const prev_parts = getTestFileNameParts(prev_filename); - const new_parts = getTestFileNameParts(filename); - - // If base_name and file_ext match, these files are in the same test sequence - // and the new one should be the incremented version of the previous test - if (std.mem.eql(u8, prev_parts.base_name, new_parts.base_name) and - std.mem.eql(u8, prev_parts.file_ext, new_parts.file_ext)) - { - - // This is "foo.X.zig" followed by "foo.Y.zig". Make sure that X = Y + 1 - if (prev_parts.test_index == null) return error.InvalidIncrementalTestIndex; - if (new_parts.test_index == null) return error.InvalidIncrementalTestIndex; - if (new_parts.test_index.? != prev_parts.test_index.? + 1) return error.InvalidIncrementalTestIndex; - } else { - - // This is not the same test sequence, so the new file must be the first file - // in a new sequence ("*.0.zig") or an independent test file ("*.zig") - if (new_parts.test_index != null and new_parts.test_index.? != 0) return error.InvalidIncrementalTestIndex; - - if (strategy == .independent) - opt_case = null; // Generate a new independent test case for this update - } - } - prev_filename = filename; - - const max_file_size = 10 * 1024 * 1024; - const src = try dir.readFileAllocOptions(ctx.arena, filename, max_file_size, null, 1, 0); - - // The manifest is the last contiguous block of comments in the file - // We scan for the beginning by searching backward for the first non-empty line that does not start with "//" - var manifest_start: ?usize = null; - var manifest_end: usize = src.len; - if (src.len > 0) { - var cursor: usize = src.len - 1; - while (true) { - // Move to beginning of line - while (cursor > 0 and src[cursor - 1] != '\n') cursor -= 1; - - if (std.mem.startsWith(u8, src[cursor..], "//")) { - manifest_start = cursor; // Contiguous comment line, include in manifest - } else { - if (manifest_start != null) break; // Encountered non-comment line, end of manifest - - // We ignore all-whitespace lines following the comment block, but anything else - // means that there is no manifest present. - if (std.mem.trim(u8, src[cursor..manifest_end], " \r\n\t").len == 0) { - manifest_end = cursor; - } else break; // If it's not whitespace, there is no manifest - } - - // Move to previous line - if (cursor != 0) cursor -= 1 else break; - } - } - - var errors = std.ArrayList([]const u8).init(ctx.arena); - - if (manifest_start) |start| { - // Due to the above processing, we know that this is a contiguous block of comments - // and do not need to re-validate the leading "//" on each line - var manifest_it = std.mem.tokenize(u8, src[start..manifest_end], "\r\n"); - - // First line is the test case name - const first_line = manifest_it.next() orelse return error.MissingTestCaseName; - const case_name = try std.mem.concat(ctx.arena, u8, &.{ name, ": ", std.mem.trim(u8, first_line[2..], " \t") }); - - // If the second line is present, it should be blank - if (manifest_it.next()) |second_line| { - if (std.mem.trim(u8, second_line[2..], " \t").len != 0) return error.SecondLineNotBlank; - } - - // All following lines are expected error messages - while (manifest_it.next()) |line| try errors.append(try ctx.arena.dupe(u8, std.mem.trim(u8, line[2..], " \t"))); - - const case = opt_case orelse case: { - ctx.cases.append(TestContext.Case{ - .name = name, - .target = .{}, - .backend = backend, - .updates = std.ArrayList(TestContext.Update).init(ctx.cases.allocator), - .is_test = is_test, - .output_mode = output_mode, - .files = std.ArrayList(TestContext.File).init(ctx.cases.allocator), - }) catch @panic("out of memory"); - const case = &ctx.cases.items[ctx.cases.items.len - 1]; - opt_case = case; - break :case case; - }; - switch (strategy) { - .independent => { - case.name = case_name; - case.addError(src, errors.items); - }, - .incremental => { - case.addErrorNamed(case_name, src, errors.items); - }, - } - } else { - return error.MissingManifest; - } - } - } - fn init(gpa: Allocator, arena: Allocator) TestContext { return .{ .cases = std.ArrayList(Case).init(gpa),