zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 7956eee1ab126cb6657f7b87e3fcf86794c141b0 (tree)
parent c5945467acfd580cb3413250ef52f13dc412a8cf
Author: Robin Voetter <robin@voetter.nl>
Date:   Mon, 30 Aug 2021 03:11:22 +0200

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

Diffstat:
Mtest/compile_errors.zig | 40+++++++++++++++++++++++++++++++++++++---
1 file changed, 37 insertions(+), 3 deletions(-)

diff --git a/test/compile_errors.zig b/test/compile_errors.zig @@ -410,7 +410,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ .Fn = .{ \\ .calling_convention = .Unspecified, \\ .alignment = 0, - \\ .address_space = 0, + \\ .address_space = .generic, \\ .is_generic = true, \\ .is_var_args = false, \\ .return_type = u0, @@ -427,7 +427,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ .Fn = .{ \\ .calling_convention = .Unspecified, \\ .alignment = 0, - \\ .address_space = 0, + \\ .address_space = .generic, \\ .is_generic = false, \\ .is_var_args = true, \\ .return_type = u0, @@ -444,7 +444,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ .Fn = .{ \\ .calling_convention = .Unspecified, \\ .alignment = 0, - \\ .address_space = 0, + \\ .address_space = .generic, \\ .is_generic = false, \\ .is_var_args = false, \\ .return_type = null, @@ -456,6 +456,23 @@ pub fn addCases(ctx: *TestContext) !void { "tmp.zig:1:20: error: TypeInfo.Fn.return_type must be non-null for @Type", }); + ctx.objErrStage1("@Type(.Fn) with invalid address space ", + \\const Foo = @Type(.{ + \\ .Fn = .{ + \\ .calling_convention = .Unspecified, + \\ .alignment = 0, + \\ .address_space = .fs, + \\ .is_generic = false, + \\ .is_var_args = false, + \\ .return_type = u0, + \\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{}, + \\ }, + \\}); + \\comptime { _ = Foo; } + , &[_][]const u8{ + "tmp.zig:1:20: error: address space 'fs' not available in stage 1 compiler, must be .generic", + }); + ctx.objErrStage1("@Type for union with opaque field", \\const TypeInfo = @import("std").builtin.TypeInfo; \\const Untagged = @Type(.{ @@ -724,6 +741,23 @@ pub fn addCases(ctx: *TestContext) !void { "tmp.zig:2:16: error: sentinels are only allowed on slices and unknown-length pointers", }); + ctx.objErrStage1("@Type(.Pointer) with invalid address space ", + \\export fn entry() void { + \\ _ = @Type(.{ .Pointer = .{ + \\ .size = .One, + \\ .is_const = false, + \\ .is_volatile = false, + \\ .alignment = 1, + \\ .address_space = .gs, + \\ .child = u8, + \\ .is_allowzero = false, + \\ .sentinel = null, + \\ }}); + \\} + , &[_][]const u8{ + "tmp.zig:2:16: error: address space 'gs' not available in stage 1 compiler, must be .generic", + }); + ctx.testErrStage1("helpful return type error message", \\export fn foo() u32 { \\ return error.Ohno;