authorgravatar for me@tadeo.caTadeo Kondrak <me@tadeo.ca> 2020-09-26 08:06:14-06:00
committergravatar for me@tadeo.caTadeo Kondrak <me@tadeo.ca> 2020-10-01 18:09:47-06:00
logcae49b1b9d40e106f52c8f80c00019138961bf89
tree04808670162592c286cbb91312790a9dc6649c0e
parent61ce72a38cedfcbd8450922cbf1cadc0c1682928
signature Commit is signed but in an unrecognized format.

Add tests for enums with explicit extern-allowed tag types in extern types


2 files changed, 19 insertions(+), 0 deletions(-)

test/compile_errors.zig+12
...@@ -20,6 +20,18 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -20,6 +20,18 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
20 "tmp.zig:2:20: error: use of undefined value here causes undefined behavior",20 "tmp.zig:2:20: error: use of undefined value here causes undefined behavior",
21 });21 });
2222
23 cases.add("extern struct with non-extern-compatible integer tag type",
24 \\pub const E = enum(u31) { A, B, C };
25 \\pub const S = extern struct {
26 \\ e: E,
27 \\};
28 \\export fn entry() void {
29 \\ const s: S = undefined;
30 \\}
31 , &[_][]const u8{
32 "tmp.zig:3:5: error: extern structs cannot contain fields of type 'E'",
33 });
34
23 cases.add("@Type for exhaustive enum with non-integer tag type",35 cases.add("@Type for exhaustive enum with non-integer tag type",
24 \\const TypeInfo = @import("builtin").TypeInfo;36 \\const TypeInfo = @import("builtin").TypeInfo;
25 \\const Tag = @Type(.{37 \\const Tag = @Type(.{
test/stage1/behavior/bugs/1467.zig created+7
...@@ -0,0 +1,7 @@
1pub const E = enum(u32) { A, B, C };
2pub const S = extern struct {
3 e: E,
4};
5test "bug 1467" {
6 const s: S = undefined;
7}