test: check compile errors when compilation has no errors

This commit is contained in:
dweiller 2023-11-19 01:35:59 +11:00 committed by Veikka Tuominen
parent 4e212f1650
commit 325e0f5f0e
12 changed files with 12 additions and 20 deletions

View File

@ -415,7 +415,7 @@ pub fn evalZigProcess(
.Exited => {
// Note that the exit code may be 0 in this case due to the
// compiler server protocol.
if (compile.expect_errors != null and s.result_error_bundle.errorMessageCount() > 0) {
if (compile.expect_errors != null) {
return error.NeedCompileErrorCheck;
}
},

View File

@ -162,6 +162,7 @@ pub fn renderToStdErr(eb: ErrorBundle, options: RenderOptions) void {
}
pub fn renderToWriter(eb: ErrorBundle, options: RenderOptions, writer: anytype) anyerror!void {
if (eb.extra.len == 0) return;
for (eb.getMessages()) |err_msg| {
try renderErrorMessageToWriter(eb, options, err_msg, writer, "error", .red, 0);
}

View File

@ -6173,6 +6173,7 @@ fn zirSetAlignStack(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst
};
return sema.failWithOwnedErrorMsg(block, msg);
}
sema.prev_stack_alignment_src = src;
const ip = &mod.intern_pool;
const a = ip.funcAnalysis(sema.func_index);

View File

@ -1,4 +1,4 @@
pub fn entry() void {
export fn entry() void {
comptime @trap();
}

View File

@ -1,4 +1,4 @@
const Foo = struct {};
const Foo = struct { a: u32 };
export fn a() void {
const T = [*c]Foo;
var t: T = undefined;

View File

@ -2,7 +2,7 @@ export fn entry(y: u8) void {
const Thing = struct {
y: u8 = y,
};
_ = @sizeOf(Thing);
_ = Thing{ .y = 1 };
}
// error

View File

@ -1,6 +1,6 @@
comptime {
var a: anyerror!bool = undefined;
_ = a catch false;
if (a catch false) {}
}
// error

View File

@ -1,7 +1,7 @@
export fn entry() void {
_ = @Type(@typeInfo(enum {
foo,
const bar = 1;
pub const bar = 1;
}));
}

View File

@ -2,7 +2,7 @@ const Foo = extern struct {
f: *const fn() void,
};
pub fn entry() void {
export fn entry() void {
_ = (Foo{}).f;
}

View File

@ -1,10 +1,10 @@
const x = @extern(*const fn() callconv(.C) void, .{ .name = "foo" });
pub fn entry0() void {
export fn entry0() void {
comptime x();
}
pub fn entry1() void {
export fn entry1() void {
@call(.always_inline, x, .{});
}

View File

@ -1,10 +0,0 @@
comptime {
var ptr: [*]u8 = undefined;
_ = ptr[0..];
}
// error
// backend=stage2
// target=native
//
// :3:12: error: slice of pointer must include end value

View File

@ -1,6 +1,6 @@
export fn entry() void {
_ = @Type(@typeInfo(struct {
const foo = 1;
pub const foo = 1;
}));
}