Refactor corpus_files from .{ "name", @embedFile("path") } tuples to
just "path" strings. The @embedFile is now called inline in the test
loop. Port from zig1.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The RoundMode packed struct had Direction as enum(u4) occupying bits 3:0,
which pushed the precision exception suppress field to bit 4. Per Intel
SDM, the ROUNDSS/VROUNDSS/VCVTPS2PH immediate layout is:
bits 1:0 = rounding mode
bit 2 = rounding source (MXCSR.RC vs immediate)
bit 3 = precision exception suppress
bits 7:4 = reserved (must be 0)
The old encoding emitted e.g. vroundss $0x12 for ceil-suppress (bit 4
set, reserved), which CPUs silently ignore but valgrind 3.26.0 correctly
rejects with SIGILL. Fix by changing Direction to enum(u3) so precision
lands at bit 3, producing the correct $0x0a encoding.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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>
Replace GCC/glibc extensions (__float128, strtof128, __uint128_t) with
portable C11 code so astgen.c compiles with TCC and other C11 compilers.
The f64 vs f128 decision uses an exact algebraic round-trip test: a decimal
value m*10^e round-trips through f64 iff the odd part of m*5^e fits in 53
binary bits. This requires only integer arithmetic, no floating-point.
For f128 encoding, strtold parses the value at 80-bit extended precision,
then bit manipulation converts to IEEE 754 binary128 layout (both formats
share 15-bit exponent; bottom 49 of 112 fraction bits are zero-padded).
The big integer multiply-add path uses a portable mul64() helper instead
of __uint128_t.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix segfaults caused by reading AST OptionalIndex fields (none=UINT32_MAX)
without converting to the C convention (none=0):
- extractVarDecl: convert GlobalVarDecl extra_data OptionalIndex fields
(type_node, align_node, addrspace_node, section_node) from UINT32_MAX
to 0 when none. Also handle simple_var_decl's opt_node_and_opt_node.
- fnDecl: extract align_expr, addrspace_expr, section_expr from
FnProtoOne/FnProto extra_data with proper OptionalIndex conversion.
Also fix FN_PROTO_SIMPLE param check to use UINT32_MAX.
- fnDecl: add separate type_gz, align_gz, linksection_gz, addrspace_gz
sub-blocks matching upstream AstGen.zig:4149-4192, and pass their
bodies to setDeclaration. Update decl_id selection to account for
has_type_body and has_special_body.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Port multiple missing/incorrect code paths to match upstream AstGen.zig:
- Fix continue label matching for labeled loops
- Fix comptimeExpr labeled block optimization
- Fix numberLiteral big integer and octal/binary parsing
- Fix addNodeExtended/addExtendedPayload undefined small field
- Fix blockExprExpr force_comptime parameter
- Port various missing builtins and instruction handlers
- Add union_decl/opaque_decl to test hash skip mask
- Remove all debug fprintf statements
- Fix int base type for -Wsign-conversion
All 25 corpus test files now pass.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add AST_NODE_ANYFRAME_LITERAL and AST_NODE_ANYFRAME_TYPE handlers
in exprRl, matching upstream AstGen.zig:1008-1016.
- Fix error capture usage detection in switchExprErrUnion: replace
broken instruction-scanning heuristic with proper scope tracking
via is_used_or_discarded field on ScopeLocalVal. This fixes 42
missing dbg_var_val emissions in switch_on_captured_error.zig.
- Remove temporary debug output (fprintf, stdio.h).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>