aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-08-29 23:33:25 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-08-29 23:33:25 -0400
commit898d65baa9198f2fb1c5df91fba51a58c3148626 (patch)
treefd4f7178f974b7be7236782aacde4981df03238b /test/compile_errors.zig
parent910a96f0468c635a135d9fccd39f139ba0775ef9 (diff)
downloadzig-898d65baa9198f2fb1c5df91fba51a58c3148626.tar.gz
zig-898d65baa9198f2fb1c5df91fba51a58c3148626.zip
more alignment improvements
* add alignment capability for fn protos * add @alignCast * fix some ast rendering code * fix some ir rendering code * add error for pointer cast increasing alignment * update allocators in std to correctly align See #37
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 21575bfc34..e21e56f4e8 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -2022,4 +2022,21 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
".tmp_source.zig:3:17: error: cast increases pointer alignment",
".tmp_source.zig:3:38: note: '&u8' has alignment 1",
".tmp_source.zig:3:27: note: '&u32' has alignment 4");
+
+ cases.add("increase pointer alignment in slice resize",
+ \\export fn entry() -> u32 {
+ \\ var bytes = []u8{0x01, 0x02, 0x03, 0x04};
+ \\ return ([]u32)(bytes[0..])[0];
+ \\}
+ ,
+ ".tmp_source.zig:3:19: error: cast increases pointer alignment",
+ ".tmp_source.zig:3:19: note: '[]u8' has alignment 1",
+ ".tmp_source.zig:3:19: note: '[]u32' has alignment 4");
+
+ cases.add("@alignCast expects pointer or slice",
+ \\export fn entry() {
+ \\ @alignCast(4, u32(3))
+ \\}
+ ,
+ ".tmp_source.zig:2:22: error: expected pointer or slice, found 'u32'");
}