diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-07-09 11:13:29 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-07-09 11:13:29 -0400 |
| commit | 2ee67b7642cfeef36d8ebbc08080202b5b1d1958 (patch) | |
| tree | d031afb8e49237cf040b8fe4c2af72ab86239abd /test/compile_errors.zig | |
| parent | 9eb51e20ed1a040a617541303db760f80ffd3aa1 (diff) | |
| download | zig-2ee67b7642cfeef36d8ebbc08080202b5b1d1958.tar.gz zig-2ee67b7642cfeef36d8ebbc08080202b5b1d1958.zip | |
langref: docs for invalid error set cast and incorrect pointer alignment
also add detection of incorrect pointer alignment at compile-time
of pointers that were constructed with `@intToPtr`.
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 4ed65e449d..1b76c01564 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -2,6 +2,16 @@ const tests = @import("tests.zig"); pub fn addCases(cases: *tests.CompileErrorContext) void { cases.add( + "bad @alignCast at comptime", + \\comptime { + \\ const ptr = @intToPtr(*i32, 0x1); + \\ const aligned = @alignCast(4, ptr); + \\} + , + ".tmp_source.zig:3:35: error: pointer address 0x1 is not aligned to 4 bytes", + ); + + cases.add( "@ptrToInt on *void", \\export fn entry() bool { \\ return @ptrToInt(&{}) == @ptrToInt(&{}); |
