| ... | @@ -2,6 +2,14 @@ const tests = @import("tests.zig"); | ... | @@ -2,6 +2,14 @@ const tests = @import("tests.zig"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | | 3 | |
| 4 | pub fn addCases(cases: *tests.CompileErrorContext) void { | 4 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| | 5 | cases.add("bitCast to enum type", |
| | 6 | \\export fn entry() void { |
| | 7 | \\ const y = @bitCast(enum(u32) { a, b }, @as(u32, 3)); |
| | 8 | \\} |
| | 9 | , &[_][]const u8{ |
| | 10 | "tmp.zig:2:24: error: cannot cast a value of type 'y'", |
| | 11 | }); |
| | 12 | |
| 5 | cases.add("comparing against undefined produces undefined value", | 13 | cases.add("comparing against undefined produces undefined value", |
| 6 | \\export fn entry() void { | 14 | \\export fn entry() void { |
| 7 | \\ if (2 == undefined) {} | 15 | \\ if (2 == undefined) {} |
| ... | @@ -31,8 +39,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -31,8 +39,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 31 | "tmp.zig:3:12: note: destination pointer requires a terminating '0' sentinel", | 39 | "tmp.zig:3:12: note: destination pointer requires a terminating '0' sentinel", |
| 32 | }); | 40 | }); |
| 33 | | 41 | |
| 34 | cases.add( | 42 | cases.add("cmpxchg with float", |
| 35 | "cmpxchg with float", | | |
| 36 | \\export fn entry() void { | 43 | \\export fn entry() void { |
| 37 | \\ var x: f32 = 0; | 44 | \\ var x: f32 = 0; |
| 38 | \\ _ = @cmpxchgWeak(f32, &x, 1, 2, .SeqCst, .SeqCst); | 45 | \\ _ = @cmpxchgWeak(f32, &x, 1, 2, .SeqCst, .SeqCst); |
| ... | @@ -41,8 +48,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -41,8 +48,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 41 | "tmp.zig:3:22: error: expected integer, enum or pointer type, found 'f32'", | 48 | "tmp.zig:3:22: error: expected integer, enum or pointer type, found 'f32'", |
| 42 | }); | 49 | }); |
| 43 | | 50 | |
| 44 | cases.add( | 51 | cases.add("atomicrmw with float op not .Xchg, .Add or .Sub", |
| 45 | "atomicrmw with float op not .Xchg, .Add or .Sub", | | |
| 46 | \\export fn entry() void { | 52 | \\export fn entry() void { |
| 47 | \\ var x: f32 = 0; | 53 | \\ var x: f32 = 0; |
| 48 | \\ _ = @atomicRmw(f32, &x, .And, 2, .SeqCst); | 54 | \\ _ = @atomicRmw(f32, &x, .And, 2, .SeqCst); |