mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
Add tests for enums with explicit extern-allowed tag types in extern types
This commit is contained in:
parent
61ce72a38c
commit
cae49b1b9d
2 changed files with 19 additions and 0 deletions
|
|
@ -20,6 +20,18 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||||
"tmp.zig:2:20: error: use of undefined value here causes undefined behavior",
|
"tmp.zig:2:20: error: use of undefined value here causes undefined behavior",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
cases.add("extern struct with non-extern-compatible integer tag type",
|
||||||
|
\\pub const E = enum(u31) { A, B, C };
|
||||||
|
\\pub const S = extern struct {
|
||||||
|
\\ e: E,
|
||||||
|
\\};
|
||||||
|
\\export fn entry() void {
|
||||||
|
\\ const s: S = undefined;
|
||||||
|
\\}
|
||||||
|
, &[_][]const u8{
|
||||||
|
"tmp.zig:3:5: error: extern structs cannot contain fields of type 'E'",
|
||||||
|
});
|
||||||
|
|
||||||
cases.add("@Type for exhaustive enum with non-integer tag type",
|
cases.add("@Type for exhaustive enum with non-integer tag type",
|
||||||
\\const TypeInfo = @import("builtin").TypeInfo;
|
\\const TypeInfo = @import("builtin").TypeInfo;
|
||||||
\\const Tag = @Type(.{
|
\\const Tag = @Type(.{
|
||||||
|
|
|
||||||
7
test/stage1/behavior/bugs/1467.zig
Normal file
7
test/stage1/behavior/bugs/1467.zig
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
pub const E = enum(u32) { A, B, C };
|
||||||
|
pub const S = extern struct {
|
||||||
|
e: E,
|
||||||
|
};
|
||||||
|
test "bug 1467" {
|
||||||
|
const s: S = undefined;
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue