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(...@@ -415,7 +415,7 @@ pub fn evalZigProcess(
415 .Exited => {415 .Exited => {
416 // Note that the exit code may be 0 in this case due to the416 // Note that the exit code may be 0 in this case due to the
417 // compiler server protocol.417 // compiler server protocol.
418 if (compile.expect_errors != null and s.result_error_bundle.errorMessageCount() > 0) {418 if (compile.expect_errors != null) {
419 return error.NeedCompileErrorCheck;419 return error.NeedCompileErrorCheck;
420 }420 }
421 },421 },
lib/std/zig/ErrorBundle.zig+1
...@@ -162,6 +162,7 @@ pub fn renderToStdErr(eb: ErrorBundle, options: RenderOptions) void {...@@ -162,6 +162,7 @@ pub fn renderToStdErr(eb: ErrorBundle, options: RenderOptions) void {
162}162}
163163
164pub fn renderToWriter(eb: ErrorBundle, options: RenderOptions, writer: anytype) anyerror!void {164pub fn renderToWriter(eb: ErrorBundle, options: RenderOptions, writer: anytype) anyerror!void {
165 if (eb.extra.len == 0) return;
165 for (eb.getMessages()) |err_msg| {166 for (eb.getMessages()) |err_msg| {
166 try renderErrorMessageToWriter(eb, options, err_msg, writer, "error", .red, 0);167 try renderErrorMessageToWriter(eb, options, err_msg, writer, "error", .red, 0);
167 }168 }
src/Sema.zig+1
...@@ -6173,6 +6173,7 @@ fn zirSetAlignStack(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst...@@ -6173,6 +6173,7 @@ fn zirSetAlignStack(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst
6173 };6173 };
6174 return sema.failWithOwnedErrorMsg(block, msg);6174 return sema.failWithOwnedErrorMsg(block, msg);
6175 }6175 }
6176 sema.prev_stack_alignment_src = src;
61766177
6177 const ip = &mod.intern_pool;6178 const ip = &mod.intern_pool;
6178 const a = ip.funcAnalysis(sema.func_index);6179 const a = ip.funcAnalysis(sema.func_index);
test/cases/compile_errors/@trap_comptime_call.zig+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1pub fn entry() void {1export fn entry() void {
2 comptime @trap();2 comptime @trap();
3}3}
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 @@...@@ -1,4 +1,4 @@
1const Foo = struct {};1const Foo = struct { a: u32 };
2export fn a() void {2export fn a() void {
3 const T = [*c]Foo;3 const T = [*c]Foo;
4 var t: T = undefined;4 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 {...@@ -2,7 +2,7 @@ export fn entry(y: u8) void {
2 const Thing = struct {2 const Thing = struct {
3 y: u8 = y,3 y: u8 = y,
4 };4 };
5 _ = @sizeOf(Thing);5 _ = Thing{ .y = 1 };
6}6}
77
8// error8// error
test/cases/compile_errors/catch_on_undefined_value.zig+1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1comptime {1comptime {
2 var a: anyerror!bool = undefined;2 var a: anyerror!bool = undefined;
3 _ = a catch false;3 if (a catch false) {}
4}4}
55
6// error6// error
test/cases/compile_errors/enum_with_declarations_unavailable_for_reify_type.zig+1-1
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1export fn entry() void {1export fn entry() void {
2 _ = @Type(@typeInfo(enum {2 _ = @Type(@typeInfo(enum {
3 foo,3 foo,
4 const bar = 1;4 pub const bar = 1;
5 }));5 }));
6}6}
77
test/cases/compile_errors/extern_function_with_unspecified_calling_convention.zig+1-1
...@@ -2,7 +2,7 @@ const Foo = extern struct {...@@ -2,7 +2,7 @@ const Foo = extern struct {
2 f: *const fn() void,2 f: *const fn() void,
3};3};
44
5pub fn entry() void {5export fn entry() void {
6 _ = (Foo{}).f;6 _ = (Foo{}).f;
7}7}
88
test/cases/compile_errors/invalid_extern_function_call.zig+2-2
...@@ -1,10 +1,10 @@...@@ -1,10 +1,10 @@
1const x = @extern(*const fn() callconv(.C) void, .{ .name = "foo" });1const x = @extern(*const fn() callconv(.C) void, .{ .name = "foo" });
22
3pub fn entry0() void {3export fn entry0() void {
4 comptime x();4 comptime x();
5}5}
66
7pub fn entry1() void {7export fn entry1() void {
8 @call(.always_inline, x, .{});8 @call(.always_inline, x, .{});
9}9}
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 @@...@@ -1,6 +1,6 @@
1export fn entry() void {1export fn entry() void {
2 _ = @Type(@typeInfo(struct {2 _ = @Type(@typeInfo(struct {
3 const foo = 1;3 pub const foo = 1;
4 }));4 }));
5}5}
66