mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
test: check compile errors when compilation has no errors
This commit is contained in:
parent
4e212f1650
commit
325e0f5f0e
@ -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;
|
||||
}
|
||||
},
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
pub fn entry() void {
|
||||
export fn entry() void {
|
||||
comptime @trap();
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
const Foo = struct {};
|
||||
const Foo = struct { a: u32 };
|
||||
export fn a() void {
|
||||
const T = [*c]Foo;
|
||||
var t: T = undefined;
|
||||
|
||||
@ -2,7 +2,7 @@ export fn entry(y: u8) void {
|
||||
const Thing = struct {
|
||||
y: u8 = y,
|
||||
};
|
||||
_ = @sizeOf(Thing);
|
||||
_ = Thing{ .y = 1 };
|
||||
}
|
||||
|
||||
// error
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
comptime {
|
||||
var a: anyerror!bool = undefined;
|
||||
_ = a catch false;
|
||||
if (a catch false) {}
|
||||
}
|
||||
|
||||
// error
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
export fn entry() void {
|
||||
_ = @Type(@typeInfo(enum {
|
||||
foo,
|
||||
const bar = 1;
|
||||
pub const bar = 1;
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ const Foo = extern struct {
|
||||
f: *const fn() void,
|
||||
};
|
||||
|
||||
pub fn entry() void {
|
||||
export fn entry() void {
|
||||
_ = (Foo{}).f;
|
||||
}
|
||||
|
||||
|
||||
@ -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, .{});
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
@ -1,6 +1,6 @@
|
||||
export fn entry() void {
|
||||
_ = @Type(@typeInfo(struct {
|
||||
const foo = 1;
|
||||
pub const foo = 1;
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user