organize some compile error tests

Many of these tests check for the incorrect behavior of stage1 whereas
self-hosted correctly does not emit an error, so they are simply
deleted.

The remaining number of test cases within the stage1/ subdirectory is
reduced from 143 to 103.
This commit is contained in:
Andrew Kelley 2022-09-14 18:12:15 -07:00
parent afba53f0f1
commit 9f4408d68b
50 changed files with 115 additions and 404 deletions

View File

@ -4,7 +4,7 @@ comptime {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:11: error: use of undefined value here causes undefined behavior
// :3:11: error: use of undefined value here causes undefined behavior

View File

@ -0,0 +1,10 @@
comptime {
var a: i64 = undefined;
a /= a;
}
// error
// backend=stage2
// target=native
//
// :3:10: error: use of undefined value here causes undefined behavior

View File

@ -0,0 +1,10 @@
comptime {
var a: i64 = undefined;
_ = a / a;
}
// error
// backend=stage2
// target=native
//
// :3:13: error: use of undefined value here causes undefined behavior

View File

@ -9,7 +9,8 @@ export fn entry() void {
const D = 1;
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:1:17: error: enum 'Foo' depends on itself
// :1:5: error: dependency loop detected
// :2:9: note: referenced here

View File

@ -0,0 +1,18 @@
var x: f64 = 1.0;
var y: f32 = x;
export fn entry() void {
_ = y;
}
export fn entry2() void {
var x1: f64 = 1.0;
var y2: f32 = x1;
_ = y2;
}
// error
// backend=llvm
// target=native
//
// :2:14: error: cannot load runtime value in comptime block
// :9:19: error: expected type 'f32', found 'f64'

View File

@ -0,0 +1,10 @@
comptime {
var a: i64 = undefined;
a %= a;
}
// error
// backend=stage2
// target=native
//
// :3:5: error: use of undefined value here causes undefined behavior

View File

@ -0,0 +1,10 @@
comptime {
var a: i64 = undefined;
_ = a % a;
}
// error
// backend=stage2
// target=native
//
// :3:9: error: use of undefined value here causes undefined behavior

View File

@ -0,0 +1,10 @@
comptime {
var a: i64 = undefined;
a *= a;
}
// error
// backend=stage2
// target=native
//
// :3:10: error: use of undefined value here causes undefined behavior

View File

@ -0,0 +1,10 @@
comptime {
var a: i64 = undefined;
_ = a * a;
}
// error
// backend=stage2
// target=native
//
// :3:13: error: use of undefined value here causes undefined behavior

View File

@ -0,0 +1,10 @@
comptime {
var a: i64 = undefined;
_ = -a;
}
// error
// backend=stage2
// target=native
//
// :3:10: error: use of undefined value here causes undefined behavior

View File

@ -4,7 +4,7 @@ comptime {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:11: error: use of undefined value here causes undefined behavior
// :3:11: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
a +%= a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:5: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
_ = a +% a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:9: error: use of undefined value here causes undefined behavior

View File

@ -1,27 +0,0 @@
export fn foo() void {
const a: *void = undefined;
_ = @alignCast(2, a);
}
export fn bar() void {
const a: ?*void = undefined;
_ = @alignCast(2, a);
}
export fn baz() void {
const a: []void = undefined;
_ = @alignCast(2, a);
}
export fn qux() void {
const a = struct {
fn a(comptime b: u32) void { _ = b; }
}.a;
_ = @alignCast(2, a);
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:23: error: cannot adjust alignment of zero sized type '*void'
// tmp.zig:7:23: error: cannot adjust alignment of zero sized type '?*void'
// tmp.zig:11:23: error: cannot adjust alignment of zero sized type '[]void'
// tmp.zig:17:23: error: cannot adjust alignment of zero sized type 'fn(u32) anytype'

View File

@ -1,10 +0,0 @@
export fn f() void {
var s: struct {} align(4) = undefined;
_ = s;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:2:5: error: variable 's' of zero-bit type 'struct:2:12' has no in-memory representation, it cannot be aligned

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
a &= a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:5: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
_ = a & a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:9: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
_ = ~a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:10: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
a |= a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:5: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
_ = a | a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:9: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
a ^= a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:5: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
_ = a ^ a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:9: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: bool = undefined;
_ = !a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:10: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
a /= a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:5: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
_ = a / a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:9: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
var x: f64 = 1.0;
var y: f32 = x;
export fn entry() usize { return @sizeOf(@TypeOf(y)); }
// error
// backend=stage1
// target=native
//
// tmp.zig:2:14: error: expected type 'f32', found 'f64'

View File

@ -1,11 +0,0 @@
export fn foo() void {
var x: usize = 0x1000;
var y: *void = @intToPtr(*void, x);
_ = y;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:30: error: type '*void' has 0 bits and cannot store information

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
a %= a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:5: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
_ = a % a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:9: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
a *= a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:5: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
_ = a * a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:9: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
a *%= a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:5: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
_ = a *% a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:9: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
_ = -a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:10: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
_ = -%a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:11: error: use of undefined value here causes undefined behavior

View File

@ -1,11 +0,0 @@
fn f() []u8 {
return s ++ "foo";
}
var s: [10]u8 = undefined;
export fn entry() usize { return @sizeOf(@TypeOf(f)); }
// error
// backend=stage1
// target=native
//
// tmp.zig:2:12: error: unable to evaluate constant expression

View File

@ -1,14 +0,0 @@
const Foo = extern struct {
x: ?*const void,
};
const Bar = extern struct {
foo: Foo,
y: i32,
};
export fn entry(bar: *Bar) void {_ = bar;}
// error
// backend=stage1
// target=native
//
// tmp.zig:2:5: error: extern structs cannot contain fields of type '?*const void'

View File

@ -1,13 +0,0 @@
export fn entry() bool {
var x: u0 = 0;
const p = @ptrCast(?*u0, &x);
return p == null;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:15: error: '*u0' and '?*u0' do not have the same in-memory representation
// tmp.zig:3:31: note: '*u0' has no in-memory bits
// tmp.zig:3:24: note: '?*u0' has in-memory bits

View File

@ -1,12 +0,0 @@
export fn entry() void {
foo() catch unreachable;
}
fn foo() !void {
try foo();
}
// error
// backend=stage1
// target=native
//
// tmp.zig:5:5: error: cannot resolve inferred error set '@typeInfo(@typeInfo(@TypeOf(foo)).Fn.return_type.?).ErrorUnion.error_set': function 'foo' not fully analyzed yet

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
a >>= 2;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:5: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
_ = a << 2;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:9: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
a >>= 2;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:5: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
_ = a >> 2;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:9: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
a -= a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:5: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
_ = a - a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:9: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
a -%= a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:5: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
comptime {
var a: i64 = undefined;
_ = a -% a;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:3:9: error: use of undefined value here causes undefined behavior

View File

@ -1,10 +0,0 @@
export fn entry() void {
var z = @truncate(u8, @as(u16, undefined));
_ = z;
}
// error
// backend=stage1
// target=native
//
// tmp.zig:2:27: error: use of undefined value here causes undefined behavior

View File

@ -0,0 +1,10 @@
comptime {
var a: i64 = undefined;
a -= a;
}
// error
// backend=stage2
// target=native
//
// :3:10: error: use of undefined value here causes undefined behavior

View File

@ -0,0 +1,10 @@
comptime {
var a: i64 = undefined;
_ = a - a;
}
// error
// backend=stage2
// target=native
//
// :3:13: error: use of undefined value here causes undefined behavior