mirror of
https://github.com/ziglang/zig.git
synced 2024-11-26 23:22:44 +00:00
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:
parent
afba53f0f1
commit
9f4408d68b
@ -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
|
10
test/cases/compile_errors/div_assign_on_undefined_value.zig
Normal file
10
test/cases/compile_errors/div_assign_on_undefined_value.zig
Normal 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
|
10
test/cases/compile_errors/div_on_undefined_value.zig
Normal file
10
test/cases/compile_errors/div_on_undefined_value.zig
Normal 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
|
@ -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
|
18
test/cases/compile_errors/implicit_cast_from_f64_to_f32.zig
Normal file
18
test/cases/compile_errors/implicit_cast_from_f64_to_f32.zig
Normal 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'
|
10
test/cases/compile_errors/mod_assign_on_undefined_value.zig
Normal file
10
test/cases/compile_errors/mod_assign_on_undefined_value.zig
Normal 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
|
10
test/cases/compile_errors/mod_on_undefined_value.zig
Normal file
10
test/cases/compile_errors/mod_on_undefined_value.zig
Normal 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
|
10
test/cases/compile_errors/mult_assign_on_undefined_value.zig
Normal file
10
test/cases/compile_errors/mult_assign_on_undefined_value.zig
Normal 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
|
10
test/cases/compile_errors/mult_on_undefined_value.zig
Normal file
10
test/cases/compile_errors/mult_on_undefined_value.zig
Normal 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
|
10
test/cases/compile_errors/negate_on_undefined_value.zig
Normal file
10
test/cases/compile_errors/negate_on_undefined_value.zig
Normal 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
|
@ -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
|
@ -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
|
@ -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
|
@ -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'
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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'
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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'
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
10
test/cases/compile_errors/sub_assign_on_undefined_value.zig
Normal file
10
test/cases/compile_errors/sub_assign_on_undefined_value.zig
Normal 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
|
10
test/cases/compile_errors/sub_on_undefined_value.zig
Normal file
10
test/cases/compile_errors/sub_on_undefined_value.zig
Normal 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
|
Loading…
Reference in New Issue
Block a user