Commit Graph

35006 Commits

Author SHA1 Message Date
aca2cd4f34 improve zig3 2026-02-17 22:10:58 +02:00
9d438d5674 cppcheck: remove all suppressions, fix all warnings
Split cppcheck into per-file checks (warning,style,performance,portability)
and a combined unusedFunction check across all C files. Remove dead code
(addExtraU32, rvalueDiscard, wipMembersNextDecl, wipMembersBodiesAppend,
findNextContainerMember, NodeContainerField). Wire up zig0Run to actually
call astParse/astGen and print stats, eliminating unusedFunction warnings
for the public API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:13:52 +00:00
0ac1c87225 unify error handling: SET_ERROR(ctx, msg) for both parser and astgen
Replace parser's fail() and astgen's flag-only SET_ERROR(ag) with a
single SET_ERROR(ctx, msg) macro in common.h that stores the error
message in ctx->err_buf and sets ctx->has_compile_errors.  Both Parser
and AstGenCtx now carry the same err_buf[ERR_BUF_SIZE] field.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 17:02:00 +00:00
762e02283f fix syntax errors with -O3 2026-02-17 14:55:22 +00:00
556c1010bb stages_test: use C-based parser. 2026-02-17 14:26:29 +00:00
759bdcde24 parser: add warn, assign destructure, fix statement bodies; enable CodeGen.zig
- Add warn() for non-fatal parse errors (like Zig's Parse.warn)
- Implement finishAssignDestructureExpr for destructuring assignments
- Use parseBlockExpr instead of parseBlock in for/while statement bodies
- Use parseSingleAssignExpr in switch prongs
- Enable x86_64/CodeGen.zig corpus entry

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 12:17:18 +00:00
0e057167c2 Merge branch 'zig1' into zig0-0.15.2 2026-02-17 10:58:14 +00:00
b2b9428f85 use C parser in AstGen 2026-02-17 10:56:11 +00:00
426a106538 stages_test: enable main.zig, git.zig
Both were blocked by the container_field extra_data bug fixed in 164b4ad7.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:27:57 +00:00
a78bbaaa49 astgen: fix @unionInit context propagation, enable Assemble.zig
The @unionInit handler in builtinCallMultiArg was propagating the parent's
result info context (e.g. RI_CTX_RETURN) to the init value expression.
Upstream Zig creates a fresh ResultInfo with .ctx = .none. This caused
call flags mismatch (pop_error_return_trace) in return expressions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:22:54 +00:00
bd709678f6 astgen: handle @frameAddress in rlBuiltinCall, enable debug.zig
rlBuiltinCall was always returning false (not consuming result location).
The Zig reference marks @frameAddress as consuming the RL (workaround for
llvm/llvm-project#68409), which affects declaration codegen path (pointer
vs value based). Match the upstream behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 07:13:25 +00:00
164b4ad79c astgen: fix container_field extra_data guard, enable aes_ocb, SmpAllocator, Mir
The AST_NODE_CONTAINER_FIELD case in structDeclInner had an incorrect guard
`if (nd.rhs != 0)` before reading align/value from extra_data. Since rhs is
an extra_data index (not a node), 0 is a valid index. Removing the guard
fixes 3-5 missing instructions in files where the first extra_data entry
happens to be a container_field's align+value.

Also fix clang-format: addBuiltinValue arg wrapping, for-loop semicolons.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 06:56:06 +00:00
93b97c3858 stages_test: enable exp, atan, expm1, gamma, log1p, zon/parse
All float-tag mismatches resolved by the 128-bit decimal_float_fits_f64.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 06:27:13 +00:00
5300af68b4 stages_test: enable 22 more corpus files; upgrade decimal_float_fits_f64 to 128-bit
Upgrade decimal_float_fits_f64() to use 128-bit integer arithmetic for the
algebraic round-trip test, handling mantissas up to ~38 significant digits.
This fixes float128-vs-float tag mismatches for values that fit in 128-bit
mantissa but overflow 64-bit.

Newly enabled: gpu, memmove, mulf3, udivmodei4, udivmod, scalar, ff,
p256_64, p256_scalar_64, p384_64, p384_scalar_64, secp256k1_64,
secp256k1_scalar_64, sha2, sha3, Decompress, testing, log10, log2, log,
rem_pio2f, rem_pio2_large, rem_pio2.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 06:15:26 +00:00
4577974e1f astgen: fix decimal_float_fits_f64 for non-zero underflow, enable divtf3_test, divxf3_test
decimal_float_fits_f64() incorrectly returned true when a non-zero mantissa
(that had overflowed uint64_t) was converted to 0.0 by strtod. These values
do not fit in f64 and need f128 representation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 05:50:38 +00:00
d3d76d59a6 astgen: fix ptrTypeExpr addrspace, do_err_trace check, switchExpr capture, blockExprStmts heap alloc
- ptrTypeExpr: use addBuiltinValue + RL_COERCED_TY for addrspace (matching
  AstGen.zig:3880-3881) instead of RL_NONE_VAL
- do_err_trace: check ag->fn_block != NULL instead of ag->fn_ret_ty != 0 in
  ifExpr, orelseCatchExpr, switchExprErrUnion (matching Zig semantics)
- switchExpr: don't reset capture for underscore discards (AstGen.zig:7870)
- nodeIsTriviallyZero: handle prefixed zero forms (0b0, 0o0, 0x0, with
  underscores)
- blockExprStmts: heap-allocate scope arrays sized to stmt_count instead of
  fixed 128, fixing compile errors on large blocks (e.g. scalar.zig)
- build.zig: increase default test timeout from 10s to 300s
- Remove debug fprintf counters

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 05:30:35 +00:00
3829a7f5af astgen: fix decimal_float_fits_f64 underflow and enable 700+ corpus files
Fix strtod underflow/overflow edge cases in decimal_float_fits_f64.
Enables 707 files across lib/std/, lib/compiler_rt/, src/, and more.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 04:47:13 +00:00
a80960d00a astgen: fix fnProtoExprInner lparen computation for named fn protos
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 03:23:19 +00:00
fa3232cc1d astgen: use plain expr instead of comptimeExpr for @setRuntimeSafety operand
Enables 326 files from compiler/, compiler_rt/, and more.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 23:39:04 +00:00
eba04d91cc astgen.c: fix forExpr to use nodeIsTriviallyZero for range start check
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 22:47:52 +00:00
7d52ad5e97 parser: fix extra_data write ordering in parseSwitchProng for multi-item switch cases
Enables 39 files from compiler/aro/.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 22:36:07 +00:00
945caa475c stages_test: enable time_report.zig, common.zig, inttypes.zig, and 6 files from compiler/aro/
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 22:11:17 +00:00
d509c0a8c6 astgen.c: port @trap builtin handler from upstream AstGen.zig
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 22:01:36 +00:00
363f54df64 astgen: port lib_name handling for extern fn declarations from upstream Zig
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 21:52:29 +00:00
67774255ed add skill 2026-02-16 21:28:50 +00:00
be6348de8f stages_test.zig 2026-02-16 21:25:28 +00:00
9d35ef90f7 astgen.c: replace UINT32_MAX sentinels with NULL_TOKEN/NULL_NODE/NULL_INST
Define named constants for the three categories of optional sentinel
values, matching their Zig counterparts (?TokenIndex null,
?Node.Index null, Zir.Inst.OptionalIndex .none). This makes intent
explicit and prevents sentinel/zero confusion bugs like the one
fixed in 921a7021.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 20:32:51 +00:00
921a70210e fix break label check in rlExpr: use UINT32_MAX sentinel instead of 0 for optional token
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 16:37:50 +00:00
1377fae4cd astgen: fix InternPool.zig — parser fallthrough for struct/enum/union, add @compileLog, fix @"..." escape scanning
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 16:18:20 +00:00
58702f9648 astgen_test: enable Compilation.zig corpus test (already passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 15:27:32 +00:00
5857ea2f6a astgen.c: port @errorReturnTrace, nosuspend expr, and remaining zero-arg builtins
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 15:24:25 +00:00
539e5244b6 Fix identAsString for @"..." identifiers with escape sequences
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 15:05:35 +00:00
07d8045a3f astgen.c: port @wasmMemorySize and @wasmMemoryGrow builtins
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 14:54:02 +00:00
53f4ef2f98 astgen_test: enable print_value, target, link, Air, print_zir, Value, Type, translate_c corpus tests (already passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 14:44:44 +00:00
91d81ad688 astgen_test: enable while.zig corpus test (already passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 14:41:28 +00:00
a86bec7160 astgen.c: port @cVaArg, @cVaCopy, @cVaEnd, @cVaStart builtins from AstGen.zig
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 14:37:43 +00:00
665b89d4f2 astgen.c: call identAsString before underscore check in whileExpr to match upstream string table ordering
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 14:29:14 +00:00
ec1e056e34 astgen_test: enable type_info.zig corpus test (already passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 14:14:05 +00:00
381ae80d73 astgen.c: add rvalue call to callExpr, matching upstream AstGen.zig:10169
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 14:11:42 +00:00
010a7109ca fix labeled switch: parser passes is_labeled flag, init GenZir continue_block/label_token to UINT32_MAX
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 14:01:25 +00:00
7d92160d73 astgen.c: port @src builtin (ZIR_EXT_BUILTIN_SRC), enable src.zig and string_literals.zig
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:38:11 +00:00
907812056e astgen_test: enable sizeof_and_typeof.zig corpus test (already passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:29:52 +00:00
66940c2911 astgen.c: port @select builtin (ZIR_EXT_SELECT)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:27:58 +00:00
b2cdf27048 astgen.c: port @returnAddress builtin (ZIR_EXT_RET_ADDR)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:14:55 +00:00
7ea605e63d astgen_test: enable prefetch.zig corpus test (already passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:08:55 +00:00
fde6c03d2a astgen_test: enable multiple_externs_with_conflicting_types.zig corpus test (already passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:07:03 +00:00
ee19503d4d astgen.c: implement @mulAdd builtin handler
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:05:14 +00:00
2707757d9c astgen.c: port multi-arg @min/@max builtins (minMax, AstGen.zig:9149-9189)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 12:55:41 +00:00
b27bbd3a38 astgen_test: enable import_c_keywords.zig corpus test (already passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 12:45:04 +00:00
d67fdf168c astgen_test: enable generics.zig corpus test (already passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 12:43:15 +00:00