aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-02-14 20:04:13 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-02-14 20:04:13 -0500
commitd5bbd748711abc82272199869cf70faf1ea30f52 (patch)
treea3a15180a22228a4c38ccdcd79815349746aeaa4 /test
parentcc7060d0d934135d797bd2bc24288ecab095051a (diff)
downloadzig-d5bbd748711abc82272199869cf70faf1ea30f52.tar.gz
zig-d5bbd748711abc82272199869cf70faf1ea30f52.zip
allow C pointers to have alignment
clang/gcc support pointer alignment attribute: https://clang.llvm.org/docs/AttributeReference.html#align-value
Diffstat (limited to 'test')
-rw-r--r--test/compile_errors.zig4
-rw-r--r--test/stage1/behavior/type_info.zig4
2 files changed, 2 insertions, 6 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index ab9eda3f15..a2fd901197 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -123,12 +123,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\export fn a() void {
\\ const T = [*c]Foo;
\\}
- \\export fn b() void {
- \\ const T = [*c]align(4) u8;
- \\}
,
".tmp_source.zig:3:15: error: C pointers cannot point to non-C-ABI-compatible type 'Foo'",
- ".tmp_source.zig:6:15: error: [*c] pointers may not have align attribute",
);
cases.addTest(
diff --git a/test/stage1/behavior/type_info.zig b/test/stage1/behavior/type_info.zig
index 52e03c2d73..dc185cc960 100644
--- a/test/stage1/behavior/type_info.zig
+++ b/test/stage1/behavior/type_info.zig
@@ -67,12 +67,12 @@ test "type info: C pointer type info" {
}
fn testCPtr() void {
- const ptr_info = @typeInfo([*c]const i8);
+ const ptr_info = @typeInfo([*c]align(4) const i8);
expect(TypeId(ptr_info) == TypeId.Pointer);
expect(ptr_info.Pointer.size == TypeInfo.Pointer.Size.C);
expect(ptr_info.Pointer.is_const);
expect(!ptr_info.Pointer.is_volatile);
- expect(ptr_info.Pointer.alignment == 1);
+ expect(ptr_info.Pointer.alignment == 4);
expect(ptr_info.Pointer.child == i8);
}