diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-03-06 16:37:03 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-03-06 16:37:03 -0500 |
| commit | 07e47c058c480914d45ec0b1f9c61b76f59e6299 (patch) | |
| tree | ebbe6e0a1e2982de491708e3f538cad12a0eddda /test/compile_errors.zig | |
| parent | 46e258c9f76cee5b37042913c34b3a1a07cce0a6 (diff) | |
| download | zig-07e47c058c480914d45ec0b1f9c61b76f59e6299.tar.gz zig-07e47c058c480914d45ec0b1f9c61b76f59e6299.zip | |
ptrCast builtin now gives an error for removing const qualifier
closes #384
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index a3ac4e2344..be2750253c 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -1,6 +1,14 @@ const tests = @import("tests.zig"); pub fn addCases(cases: &tests.CompileErrorContext) void { + cases.add("@ptrCast discards const qualifier", + \\export fn entry() void { + \\ const x: i32 = 1234; + \\ const y = @ptrCast(&i32, &x); + \\} + , + ".tmp_source.zig:3:15: error: cast discards const qualifier"); + cases.add("comptime slice of undefined pointer non-zero len", \\export fn entry() void { \\ const slice = (&i32)(undefined)[0..1]; |
