| 1 | const EnumInferred = enum {}; |
| 2 | const EnumExplicit = enum(noreturn) {}; |
| 3 | const EnumNonexhaustive = enum(u8) { _ }; |
| 4 | |
| 5 | const U0 = union {}; |
| 6 | const U1 = union(enum) {}; |
| 7 | const U2 = union(enum(noreturn)) {}; |
| 8 | const U3 = union(EnumInferred) {}; |
| 9 | const U4 = union(EnumExplicit) {}; |
| 10 | const U5 = union(EnumNonexhaustive) {}; |
| 11 | |
| 12 | export fn size0() void { |
| 13 | _ = @sizeOf(U0); |
| 14 | } |
| 15 | export fn size1() void { |
| 16 | _ = @sizeOf(U1); |
| 17 | } |
| 18 | export fn size2() void { |
| 19 | _ = @sizeOf(U2); |
| 20 | } |
| 21 | export fn size3() void { |
| 22 | _ = @sizeOf(U3); |
| 23 | } |
| 24 | export fn size4() void { |
| 25 | _ = @sizeOf(U4); |
| 26 | } |
| 27 | export fn size5() void { |
| 28 | _ = @sizeOf(U5); |
| 29 | } |
| 30 | |
| 31 | export fn align0() void { |
| 32 | _ = @alignOf(U0); |
| 33 | } |
| 34 | export fn align1() void { |
| 35 | _ = @alignOf(U1); |
| 36 | } |
| 37 | export fn align2() void { |
| 38 | _ = @alignOf(U2); |
| 39 | } |
| 40 | export fn align3() void { |
| 41 | _ = @alignOf(U3); |
| 42 | } |
| 43 | export fn align4() void { |
| 44 | _ = @alignOf(U4); |
| 45 | } |
| 46 | export fn align5() void { |
| 47 | _ = @alignOf(U5); |
| 48 | } |
| 49 | |
| 50 | // error |
| 51 | // |
| 52 | // :13:17: error: no size available for uninstantiable type 'tmp.U0' |
| 53 | // :5:12: note: union declared here |
| 54 | // :16:17: error: no size available for uninstantiable type 'tmp.U1' |
| 55 | // :6:12: note: union declared here |
| 56 | // :19:17: error: no size available for uninstantiable type 'tmp.U2' |
| 57 | // :7:12: note: union declared here |
| 58 | // :22:17: error: no size available for uninstantiable type 'tmp.U3' |
| 59 | // :8:12: note: union declared here |
| 60 | // :25:17: error: no size available for uninstantiable type 'tmp.U4' |
| 61 | // :9:12: note: union declared here |
| 62 | // :28:17: error: no size available for uninstantiable type 'tmp.U5' |
| 63 | // :10:12: note: union declared here |
| 64 | // :32:18: error: no align available for uninstantiable type 'tmp.U0' |
| 65 | // :5:12: note: union declared here |
| 66 | // :35:18: error: no align available for uninstantiable type 'tmp.U1' |
| 67 | // :6:12: note: union declared here |
| 68 | // :38:18: error: no align available for uninstantiable type 'tmp.U2' |
| 69 | // :7:12: note: union declared here |
| 70 | // :41:18: error: no align available for uninstantiable type 'tmp.U3' |
| 71 | // :8:12: note: union declared here |
| 72 | // :44:18: error: no align available for uninstantiable type 'tmp.U4' |
| 73 | // :9:12: note: union declared here |
| 74 | // :47:18: error: no align available for uninstantiable type 'tmp.U5' |
| 75 | // :10:12: note: union declared here |