From 4d8a6f6fea1b6922e7904b33c5b575249213fe53 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 17 Aug 2019 12:48:48 -0400 Subject: fix compiler not checking alignment of function frames closes #3086 --- test/compile_errors.zig | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'test/compile_errors.zig') diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 5eec78fa7f..2088b32d98 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -2,6 +2,28 @@ const tests = @import("tests.zig"); const builtin = @import("builtin"); pub fn addCases(cases: *tests.CompileErrorContext) void { + cases.add( + "bad alignment in @asyncCall", + \\export fn entry() void { + \\ var ptr: async fn () void = func; + \\ var bytes: [64]u8 = undefined; + \\ _ = @asyncCall(&bytes, {}, ptr); + \\} + \\async fn func() void {} + , + "tmp.zig:4:21: error: expected type '[]align(16) u8', found '*[64]u8'", + ); + + cases.add( + "bad alignment in implicit cast from array pointer to slice", + \\export fn a() void { + \\ var x: [10]u8 = undefined; + \\ var y: []align(16) u8 = &x; + \\} + , + "tmp.zig:3:30: error: expected type '[]align(16) u8', found '*[10]u8'", + ); + cases.add( "result location incompatibility mismatching handle_is_ptr (generic call)", \\export fn entry() void { @@ -164,7 +186,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { "non async function pointer passed to @asyncCall", \\export fn entry() void { \\ var ptr = afunc; - \\ var bytes: [100]u8 = undefined; + \\ var bytes: [100]u8 align(16) = undefined; \\ _ = @asyncCall(&bytes, {}, ptr); \\} \\fn afunc() void { } -- cgit v1.2.3