zig/test/cases/error_in_nested_declaration.zig
mlugg f26dda2117 all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There
were a few exceptions which I had to manually fix:

* `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten
* `@truncate`'s fixup is incorrect for vectors
* Test cases are not formatted, and their error locations change
2023-06-24 16:56:39 -07:00

32 lines
569 B
Zig

const S = struct {
b: u32,
c: i32,
a: struct {
pub fn str(_: @This(), extra: []u32) []i32 {
return @bitCast(extra);
}
},
};
pub export fn entry() void {
var s: S = undefined;
_ = s.a.str(undefined);
}
const S2 = struct {
a: [*c]anyopaque,
};
pub export fn entry2() void {
var s: S2 = undefined;
_ = s;
}
// error
// backend=llvm
// target=native
//
// :17:12: error: C pointers cannot point to opaque types
// :6:20: error: cannot @bitCast to '[]i32'
// :6:20: note: use @ptrCast to cast from '[]u32'