diff options
| author | Isaac Freund <mail@isaacfreund.com> | 2022-08-08 18:39:14 +0200 |
|---|---|---|
| committer | Isaac Freund <mail@isaacfreund.com> | 2022-08-10 19:54:45 +0200 |
| commit | 0d32b73078aa4579187f7d5c67343a6036eed277 (patch) | |
| tree | 061cf1edf45d22198554159de00a7426748dad97 /test/cases/compile_errors/packed_struct_backing_int_wrong.zig | |
| parent | bb1c3e8b7e2be201221e14719d2d39e6298cc66c (diff) | |
| download | zig-0d32b73078aa4579187f7d5c67343a6036eed277.tar.gz zig-0d32b73078aa4579187f7d5c67343a6036eed277.zip | |
stage2: Implement explicit backing integers for packed structs
Now the backing integer of a packed struct type may be explicitly
specified with e.g. `packed struct(u32) { ... }`.
Diffstat (limited to 'test/cases/compile_errors/packed_struct_backing_int_wrong.zig')
| -rw-r--r-- | test/cases/compile_errors/packed_struct_backing_int_wrong.zig | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/cases/compile_errors/packed_struct_backing_int_wrong.zig b/test/cases/compile_errors/packed_struct_backing_int_wrong.zig new file mode 100644 index 0000000000..cd1b4ec11c --- /dev/null +++ b/test/cases/compile_errors/packed_struct_backing_int_wrong.zig @@ -0,0 +1,55 @@ +export fn entry1() void { + _ = @sizeOf(packed struct(u32) { + x: u1, + y: u24, + z: u4, + }); +} +export fn entry2() void { + _ = @sizeOf(packed struct(i31) { + x: u4, + y: u24, + z: u4, + }); +} + +export fn entry3() void { + _ = @sizeOf(packed struct(void) { + x: void, + }); +} + +export fn entry4() void { + _ = @sizeOf(packed struct(void) {}); +} + +export fn entry5() void { + _ = @sizeOf(packed struct(noreturn) {}); +} + +export fn entry6() void { + _ = @sizeOf(packed struct(f64) { + x: u32, + y: f32, + }); +} + +export fn entry7() void { + _ = @sizeOf(packed struct(*u32) { + x: u4, + y: u24, + z: u4, + }); +} + +// error +// backend=llvm +// target=native +// +// :2:31: error: backing integer type 'u32' has bit size 32 but the struct fields have a total bit size of 29 +// :9:31: error: backing integer type 'i31' has bit size 31 but the struct fields have a total bit size of 32 +// :17:31: error: expected backing integer type, found 'void' +// :23:31: error: expected backing integer type, found 'void' +// :27:31: error: expected backing integer type, found 'noreturn' +// :31:31: error: expected backing integer type, found 'f64' +// :38:31: error: expected backing integer type, found '*u32' |
