astgen: fix cppcheck warnings for err_scope_used and param_insts

Use memset initialization to satisfy cppcheck's data flow analysis:
- err_scope_used: cppcheck can't track writes through is_used_or_discarded pointer
- param_insts: cppcheck warns about potentially uninitialized array elements

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-15 19:49:54 +00:00
parent 500bc6a791
commit d2c301cc95
4 changed files with 16 additions and 10 deletions

View File

@@ -669,13 +669,13 @@ pub fn build(b: *std.Build) !void {
// Subtract all AVX-512 features so the zig CC won't emit them.
const F = std.Target.x86.Feature;
const avx512_features = [_]F{
.avx512f, .avx512bw,
.avx512cd, .avx512dq,
.avx512vl, .avx512bf16,
.avx512bitalg, .avx512er,
.avx512fp16, .avx512ifma,
.avx512pf, .avx512vbmi,
.avx512vbmi2, .avx512vnni,
.avx512f, .avx512bw,
.avx512cd, .avx512dq,
.avx512vl, .avx512bf16,
.avx512bitalg, .avx512er,
.avx512fp16, .avx512ifma,
.avx512pf, .avx512vbmi,
.avx512vbmi2, .avx512vnni,
.avx512vp2intersect, .avx512vpopcntdq,
.evex512,
};

View File

@@ -7,7 +7,9 @@ const maxInt = std.math.maxInt;
const zig0 = if (@hasDecl(@import("root"), "zig0"))
@import("root").zig0
else
struct { pub const enabled = false; };
struct {
pub const enabled = false;
};
test "zig fmt: remove extra whitespace at start and end of file with comment between" {
try testTransform(

View File

@@ -3,7 +3,9 @@ const std = @import("std");
const zig0 = if (@hasDecl(@import("root"), "zig0"))
@import("root").zig0
else
struct { pub const enabled = false; };
struct {
pub const enabled = false;
};
pub const Token = struct {
tag: Tag,

View File

@@ -10286,7 +10286,8 @@ static uint32_t switchExprErrUnion(GenZir* parent_gz, Scope* scope,
memset(&err_scope, 0, sizeof(err_scope));
memset(&capture_scope_val, 0, sizeof(capture_scope_val));
bool err_scope_used = false;
bool err_scope_used;
memset(&err_scope_used, 0, sizeof(err_scope_used));
err_scope = (ScopeLocalVal) {
.base = { .tag = SCOPE_LOCAL_VAL },
.parent = &case_scope.base,
@@ -14174,6 +14175,7 @@ static void fnDecl(AstGenCtx* ag, GenZir* gz, Scope* scope,
uint32_t param_scope_count = 0;
// Collect param instruction indices (AstGen.zig:4254, 4360).
uint32_t param_insts[256];
memset(param_insts, 0, sizeof(param_insts));
uint32_t param_insts_len = 0;
// noalias_bits tracking (AstGen.zig:4259).
uint32_t noalias_bits = 0;