Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port some stage1 test cases to stage2 #14984

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export fn entry1() void {
}

// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:8: error: use of undefined value here causes undefined behavior
// :2:8: error: use of undefined value here causes undefined behavior
47 changes: 47 additions & 0 deletions test/compile_errors.zig
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,51 @@ pub fn addCases(ctx: *Cases) !void {
\\const dummy = 0;
);
}

{
const case = ctx.obj("wrong same named struct", .{});

case.addError(
\\const a = @import("a.zig");
\\const b = @import("b.zig");
\\
\\export fn entry() void {
\\ var a1: a.Foo = undefined;
\\ bar(&a1);
\\}
\\
\\fn bar(_: *b.Foo) void {}
, &[_][]const u8{
":6:9: error: expected type '*b.Foo', found '*a.Foo'",
":6:9: note: pointer type child 'a.Foo' cannot cast into pointer type child 'b.Foo'",
":1:17: note: struct declared here",
":1:17: note: struct declared here",
":9:11: note: parameter type declared here",
});

case.addSourceFile("a.zig",
\\pub const Foo = struct {
\\ x: i32,
\\};
);

case.addSourceFile("b.zig",
\\pub const Foo = struct {
\\ z: f64,
\\};
);
}

{
const case = ctx.obj("non-printable invalid character", .{});

case.addError("\xff\xfe" ++
\\export fn foo() bool {
\\ return true;
\\}
, &[_][]const u8{
":1:1: error: expected type expression, found 'invalid bytes'",
":1:1: note: invalid byte: '\\xff'",
});
}
}