mirror of
https://github.com/ziglang/zig.git
synced 2025-12-26 16:13:07 +00:00
Adds 2 new AIR instructions: * dbg_var_ptr * dbg_var_val Sema no longer emits dbg_stmt AIR instructions when strip=true. LLVM backend: fixed lowerPtrToVoid when calling ptrAlignment on the element type is problematic. LLVM backend: fixed alloca instructions improperly getting debug location annotated, causing chaotic debug info behavior. zig_llvm.cpp: fixed incorrect bindings for a function that should use unsigned integers for line and column. A bunch of C test cases regressed because the new dbg_var AIR instructions caused their operands to be alive, exposing latent bugs. Mostly it's just a problem that the C backend lowers mutable and const slices to the same C type, so we need to represent that in the C backend instead of printing two duplicate typedefs.
39 lines
1.2 KiB
Zig
39 lines
1.2 KiB
Zig
const std = @import("std");
|
|
const testing = std.testing;
|
|
const builtin = @import("builtin");
|
|
|
|
pub const Mesh = struct {
|
|
id: u32,
|
|
};
|
|
pub const Material = struct {
|
|
transparent: bool = true,
|
|
emits_shadows: bool = true,
|
|
render_color: bool = true,
|
|
};
|
|
pub const Renderable = struct {
|
|
material: Material,
|
|
// The compiler inserts some padding here to ensure Mesh is correctly aligned.
|
|
mesh: Mesh,
|
|
};
|
|
|
|
var renderable: Renderable = undefined;
|
|
|
|
test "assignment of field with padding" {
|
|
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
|
|
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
|
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
|
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
|
|
|
renderable = Renderable{
|
|
.mesh = Mesh{ .id = 0 },
|
|
.material = Material{
|
|
.transparent = false,
|
|
.emits_shadows = false,
|
|
},
|
|
};
|
|
try testing.expect(false == renderable.material.transparent);
|
|
try testing.expect(false == renderable.material.emits_shadows);
|
|
try testing.expect(true == renderable.material.render_color);
|
|
}
|