aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-02-12 10:25:21 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-02-12 10:25:21 -0500
commit270933b1e997c91a9c2d28b6896d625c0ae1b163 (patch)
treee093841812f97af44544f318a70f74bfbb6b3737 /test/compile_errors.zig
parent6f05e8d1be083a429673e717e8b3c736c7ddb8d2 (diff)
downloadzig-270933b1e997c91a9c2d28b6896d625c0ae1b163.tar.gz
zig-270933b1e997c91a9c2d28b6896d625c0ae1b163.zip
compile error test for casting integer to c pointer
when the int has more bits than pointers See #1059
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 63850bb888..8f8e2a0bdf 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -2,6 +2,20 @@ const tests = @import("tests.zig");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.addTest(
+ "implicit casting too big integers to C pointers",
+ \\export fn a() void {
+ \\ var ptr: [*c]u8 = (1 << 64) + 1;
+ \\}
+ \\export fn b() void {
+ \\ var x: @IntType(false, 65) = 0x1234;
+ \\ var ptr: [*c]u8 = x;
+ \\}
+ ,
+ ".tmp_source.zig:2:33: error: integer value 71615590737044764481 cannot be implicitly casted to type 'usize'",
+ ".tmp_source.zig:6:23: error: integer type 'u65' too big for implicit @intToPtr to type '[*c]u8'",
+ );
+
+ cases.addTest(
"C pointer pointing to non C ABI compatible type",
\\const Foo = struct {};
\\export fn entry() [*c]Foo {