authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2023-03-17 12:27:19+00:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-20 19:55:50-04:00
log3a25f6a22e0f339fcaecc87efb0fa4e5f67bd73c
tree92858bf958239ef553a9e8a185b261c6f4136cf8
parent626a75bbc21453237f95c186d1fea790f233bc58

Port some stage1 test cases to stage2

There are now very few stage1 cases remaining: * `cases/compile_errors/stage1/obj/*` currently don't work correctly on stage2. There are 6 of these, and most of them are probably fairly simple to fix. * `cases/compile_errors/async/*` and all remaining `safety/*` depend on async; see #6025. Resolves: #14849

2 files changed, 49 insertions(+), 2 deletions(-)

test/cases/compile_errors/undefined_as_field_type_is_rejected.zig+2-2
......@@ -7,7 +7,7 @@ export fn entry1() void {
77}
88
99// error
10// backend=stage1
10// backend=stage2
1111// target=native
1212//
13// tmp.zig:2:8: error: use of undefined value here causes undefined behavior
13// :2:8: error: use of undefined value here causes undefined behavior
test/compile_errors.zig+47
......@@ -136,4 +136,51 @@ pub fn addCases(ctx: *Cases) !void {
136136 \\const dummy = 0;
137137 );
138138 }
139
140 {
141 const case = ctx.obj("wrong same named struct", .{});
142
143 case.addError(
144 \\const a = @import("a.zig");
145 \\const b = @import("b.zig");
146 \\
147 \\export fn entry() void {
148 \\ var a1: a.Foo = undefined;
149 \\ bar(&a1);
150 \\}
151 \\
152 \\fn bar(_: *b.Foo) void {}
153 , &[_][]const u8{
154 ":6:9: error: expected type '*b.Foo', found '*a.Foo'",
155 ":6:9: note: pointer type child 'a.Foo' cannot cast into pointer type child 'b.Foo'",
156 ":1:17: note: struct declared here",
157 ":1:17: note: struct declared here",
158 ":9:11: note: parameter type declared here",
159 });
160
161 case.addSourceFile("a.zig",
162 \\pub const Foo = struct {
163 \\ x: i32,
164 \\};
165 );
166
167 case.addSourceFile("b.zig",
168 \\pub const Foo = struct {
169 \\ z: f64,
170 \\};
171 );
172 }
173
174 {
175 const case = ctx.obj("non-printable invalid character", .{});
176
177 case.addError("\xff\xfe" ++
178 \\export fn foo() bool {
179 \\ return true;
180 \\}
181 , &[_][]const u8{
182 ":1:1: error: expected type expression, found 'invalid bytes'",
183 ":1:1: note: invalid byte: '\\xff'",
184 });
185 }
139186}