authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2021-08-30 03:11:22+02:00
committergravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2021-09-20 02:29:04+02:00
log7956eee1ab126cb6657f7b87e3fcf86794c141b0
tree631c18af42fd85e6a99ed4eac4f23ac87915c617
parentc5945467acfd580cb3413250ef52f13dc412a8cf

Address Spaces: Adapt compile error test cases to @Type with address spaces


1 files changed, 37 insertions(+), 3 deletions(-)

test/compile_errors.zig+37-3
......@@ -410,7 +410,7 @@ pub fn addCases(ctx: *TestContext) !void {
410410 \\ .Fn = .{
411411 \\ .calling_convention = .Unspecified,
412412 \\ .alignment = 0,
413 \\ .address_space = 0,
413 \\ .address_space = .generic,
414414 \\ .is_generic = true,
415415 \\ .is_var_args = false,
416416 \\ .return_type = u0,
......@@ -427,7 +427,7 @@ pub fn addCases(ctx: *TestContext) !void {
427427 \\ .Fn = .{
428428 \\ .calling_convention = .Unspecified,
429429 \\ .alignment = 0,
430 \\ .address_space = 0,
430 \\ .address_space = .generic,
431431 \\ .is_generic = false,
432432 \\ .is_var_args = true,
433433 \\ .return_type = u0,
......@@ -444,7 +444,7 @@ pub fn addCases(ctx: *TestContext) !void {
444444 \\ .Fn = .{
445445 \\ .calling_convention = .Unspecified,
446446 \\ .alignment = 0,
447 \\ .address_space = 0,
447 \\ .address_space = .generic,
448448 \\ .is_generic = false,
449449 \\ .is_var_args = false,
450450 \\ .return_type = null,
......@@ -456,6 +456,23 @@ pub fn addCases(ctx: *TestContext) !void {
456456 "tmp.zig:1:20: error: TypeInfo.Fn.return_type must be non-null for @Type",
457457 });
458458
459 ctx.objErrStage1("@Type(.Fn) with invalid address space ",
460 \\const Foo = @Type(.{
461 \\ .Fn = .{
462 \\ .calling_convention = .Unspecified,
463 \\ .alignment = 0,
464 \\ .address_space = .fs,
465 \\ .is_generic = false,
466 \\ .is_var_args = false,
467 \\ .return_type = u0,
468 \\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{},
469 \\ },
470 \\});
471 \\comptime { _ = Foo; }
472 , &[_][]const u8{
473 "tmp.zig:1:20: error: address space 'fs' not available in stage 1 compiler, must be .generic",
474 });
475
459476 ctx.objErrStage1("@Type for union with opaque field",
460477 \\const TypeInfo = @import("std").builtin.TypeInfo;
461478 \\const Untagged = @Type(.{
......@@ -724,6 +741,23 @@ pub fn addCases(ctx: *TestContext) !void {
724741 "tmp.zig:2:16: error: sentinels are only allowed on slices and unknown-length pointers",
725742 });
726743
744 ctx.objErrStage1("@Type(.Pointer) with invalid address space ",
745 \\export fn entry() void {
746 \\ _ = @Type(.{ .Pointer = .{
747 \\ .size = .One,
748 \\ .is_const = false,
749 \\ .is_volatile = false,
750 \\ .alignment = 1,
751 \\ .address_space = .gs,
752 \\ .child = u8,
753 \\ .is_allowzero = false,
754 \\ .sentinel = null,
755 \\ }});
756 \\}
757 , &[_][]const u8{
758 "tmp.zig:2:16: error: address space 'gs' not available in stage 1 compiler, must be .generic",
759 });
760
727761 ctx.testErrStage1("helpful return type error message",
728762 \\export fn foo() u32 {
729763 \\ return error.Ohno;