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 {...@@ -410,7 +410,7 @@ pub fn addCases(ctx: *TestContext) !void {
410 \\ .Fn = .{410 \\ .Fn = .{
411 \\ .calling_convention = .Unspecified,411 \\ .calling_convention = .Unspecified,
412 \\ .alignment = 0,412 \\ .alignment = 0,
413 \\ .address_space = 0,413 \\ .address_space = .generic,
414 \\ .is_generic = true,414 \\ .is_generic = true,
415 \\ .is_var_args = false,415 \\ .is_var_args = false,
416 \\ .return_type = u0,416 \\ .return_type = u0,
...@@ -427,7 +427,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -427,7 +427,7 @@ pub fn addCases(ctx: *TestContext) !void {
427 \\ .Fn = .{427 \\ .Fn = .{
428 \\ .calling_convention = .Unspecified,428 \\ .calling_convention = .Unspecified,
429 \\ .alignment = 0,429 \\ .alignment = 0,
430 \\ .address_space = 0,430 \\ .address_space = .generic,
431 \\ .is_generic = false,431 \\ .is_generic = false,
432 \\ .is_var_args = true,432 \\ .is_var_args = true,
433 \\ .return_type = u0,433 \\ .return_type = u0,
...@@ -444,7 +444,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -444,7 +444,7 @@ pub fn addCases(ctx: *TestContext) !void {
444 \\ .Fn = .{444 \\ .Fn = .{
445 \\ .calling_convention = .Unspecified,445 \\ .calling_convention = .Unspecified,
446 \\ .alignment = 0,446 \\ .alignment = 0,
447 \\ .address_space = 0,447 \\ .address_space = .generic,
448 \\ .is_generic = false,448 \\ .is_generic = false,
449 \\ .is_var_args = false,449 \\ .is_var_args = false,
450 \\ .return_type = null,450 \\ .return_type = null,
...@@ -456,6 +456,23 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -456,6 +456,23 @@ pub fn addCases(ctx: *TestContext) !void {
456 "tmp.zig:1:20: error: TypeInfo.Fn.return_type must be non-null for @Type",456 "tmp.zig:1:20: error: TypeInfo.Fn.return_type must be non-null for @Type",
457 });457 });
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
459 ctx.objErrStage1("@Type for union with opaque field",476 ctx.objErrStage1("@Type for union with opaque field",
460 \\const TypeInfo = @import("std").builtin.TypeInfo;477 \\const TypeInfo = @import("std").builtin.TypeInfo;
461 \\const Untagged = @Type(.{478 \\const Untagged = @Type(.{
...@@ -724,6 +741,23 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -724,6 +741,23 @@ pub fn addCases(ctx: *TestContext) !void {
724 "tmp.zig:2:16: error: sentinels are only allowed on slices and unknown-length pointers",741 "tmp.zig:2:16: error: sentinels are only allowed on slices and unknown-length pointers",
725 });742 });
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
727 ctx.testErrStage1("helpful return type error message",761 ctx.testErrStage1("helpful return type error message",
728 \\export fn foo() u32 {762 \\export fn foo() u32 {
729 \\ return error.Ohno;763 \\ return error.Ohno;