authorgravatar for 4678790+dweiller@users.noreply.github.comDominic <4678790+dweiller@users.noreply.github.com> 2023-11-19 01:35:59+11:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-11-19 00:12:43+02:00
log325e0f5f0e8a9ce2540ec3ec5b7cbbecac15257a
tree18e1e7532f65c60d8e245a81225cd5ab016f7a3b
parent4e212f16506b88d934d9a0c559fa6b2e0e88574e

test: check compile errors when compilation has no errors


12 files changed, 12 insertions(+), 20 deletions(-)

lib/std/Build/Step.zig+1-1
......@@ -415,7 +415,7 @@ pub fn evalZigProcess(
415415 .Exited => {
416416 // Note that the exit code may be 0 in this case due to the
417417 // compiler server protocol.
418 if (compile.expect_errors != null and s.result_error_bundle.errorMessageCount() > 0) {
418 if (compile.expect_errors != null) {
419419 return error.NeedCompileErrorCheck;
420420 }
421421 },
lib/std/zig/ErrorBundle.zig+1
......@@ -162,6 +162,7 @@ pub fn renderToStdErr(eb: ErrorBundle, options: RenderOptions) void {
162162}
163163
164164pub fn renderToWriter(eb: ErrorBundle, options: RenderOptions, writer: anytype) anyerror!void {
165 if (eb.extra.len == 0) return;
165166 for (eb.getMessages()) |err_msg| {
166167 try renderErrorMessageToWriter(eb, options, err_msg, writer, "error", .red, 0);
167168 }
src/Sema.zig+1
......@@ -6173,6 +6173,7 @@ fn zirSetAlignStack(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst
61736173 };
61746174 return sema.failWithOwnedErrorMsg(block, msg);
61756175 }
6176 sema.prev_stack_alignment_src = src;
61766177
61776178 const ip = &mod.intern_pool;
61786179 const a = ip.funcAnalysis(sema.func_index);
test/cases/compile_errors/@trap_comptime_call.zig+1-1
......@@ -1,4 +1,4 @@
1pub fn entry() void {
1export fn entry() void {
22 comptime @trap();
33}
44
test/cases/compile_errors/C_pointer_pointing_to_non_C_ABI_compatible_type_or_has_align_attr.zig+1-1
......@@ -1,4 +1,4 @@
1const Foo = struct {};
1const Foo = struct { a: u32 };
22export fn a() void {
33 const T = [*c]Foo;
44 var t: T = undefined;
test/cases/compile_errors/accessing_runtime_paramter_outside_function_scope.zig+1-1
......@@ -2,7 +2,7 @@ export fn entry(y: u8) void {
22 const Thing = struct {
33 y: u8 = y,
44 };
5 _ = @sizeOf(Thing);
5 _ = Thing{ .y = 1 };
66}
77
88// error
test/cases/compile_errors/catch_on_undefined_value.zig+1-1
......@@ -1,6 +1,6 @@
11comptime {
22 var a: anyerror!bool = undefined;
3 _ = a catch false;
3 if (a catch false) {}
44}
55
66// error
test/cases/compile_errors/enum_with_declarations_unavailable_for_reify_type.zig+1-1
......@@ -1,7 +1,7 @@
11export fn entry() void {
22 _ = @Type(@typeInfo(enum {
33 foo,
4 const bar = 1;
4 pub const bar = 1;
55 }));
66}
77
test/cases/compile_errors/extern_function_with_unspecified_calling_convention.zig+1-1
......@@ -2,7 +2,7 @@ const Foo = extern struct {
22 f: *const fn() void,
33};
44
5pub fn entry() void {
5export fn entry() void {
66 _ = (Foo{}).f;
77}
88
test/cases/compile_errors/invalid_extern_function_call.zig+2-2
......@@ -1,10 +1,10 @@
11const x = @extern(*const fn() callconv(.C) void, .{ .name = "foo" });
22
3pub fn entry0() void {
3export fn entry0() void {
44 comptime x();
55}
66
7pub fn entry1() void {
7export fn entry1() void {
88 @call(.always_inline, x, .{});
99}
1010
test/cases/compile_errors/slice_of_pointer_must_include_end_value.zig deleted-10
......@@ -1,10 +0,0 @@
1comptime {
2 var ptr: [*]u8 = undefined;
3 _ = ptr[0..];
4}
5
6// error
7// backend=stage2
8// target=native
9//
10// :3:12: error: slice of pointer must include end value
test/cases/compile_errors/struct_with_declarations_unavailable_for_reify_type.zig+1-1
......@@ -1,6 +1,6 @@
11export fn entry() void {
22 _ = @Type(@typeInfo(struct {
3 const foo = 1;
3 pub const foo = 1;
44 }));
55}
66