diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-09-17 19:41:11 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-09-17 19:41:11 -0400 |
| commit | b16229da1de90295b4d173f1a0ddbca677e8cdf2 (patch) | |
| tree | ab8e9558ba662ab085eb35f3ec7365822db71cc4 /test/compile_errors.zig | |
| parent | 78a9a465a372d25ef6f9a1f6bb1018160b8c94e1 (diff) | |
| download | zig-b16229da1de90295b4d173f1a0ddbca677e8cdf2.tar.gz zig-b16229da1de90295b4d173f1a0ddbca677e8cdf2.zip | |
add compile error for @ptrCast 0 bit type to non-0 bit type
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index d1e9f6d03a..a1dd33fb43 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -2,6 +2,19 @@ const tests = @import("tests.zig"); pub fn addCases(cases: *tests.CompileErrorContext) void { cases.add( + "@ptrCast a 0 bit type to a non- 0 bit type", + \\export fn entry() bool { + \\ var x: u0 = 0; + \\ const p = @ptrCast(?*u0, &x); + \\ return p == null; + \\} + , + ".tmp_source.zig:3:15: error: '*u0' and '?*u0' do not have the same in-memory representation", + ".tmp_source.zig:3:31: note: '*u0' has no in-memory bits", + ".tmp_source.zig:3:24: note: '?*u0' has in-memory bits", + ); + + cases.add( "comparing a non-optional pointer against null", \\export fn entry() void { \\ var x: i32 = 1; |
