8318 Commits

Author SHA1 Message Date
Alex Rønne Petersen 6bdb45beaf test: don't run test-zigc on targets that don't support libzigc 2026-03-26 08:48:38 +01:00
Alex Rønne Petersen a216c74131 test: partial revert of ac793232ee
This is just obviously wrong?! I'm fairly certain I didn't intend to push that
commit in that state.
2026-03-26 05:50:51 +01:00
Alex Rønne Petersen cef16b5130 std.Target: don't claim that OpenBSD requires libc
https://codeberg.org/ziglang/zig/issues/30982
2026-03-26 05:50:51 +01:00
kcbanner 571b151423 - Skip "floating point VaList args" on failing platforms 2026-03-26 00:33:15 -04:00
kcbanner ca99896d73 - x86_64: Copy arguments into the shadow store when generating a variadic function on Win64
- x86_64: Implement @cVaStart for Win64
- x86_64: Implement @cVaArg for Win64
- x86_64: Duplicate floating point register args equivalent integer registers when calling variadic functions on Win64
- tests: Enable var_args tests for the self-hosted backend on windows
- tests: Add var_args test for floating point arguments
2026-03-25 20:05:51 -04:00
Kendall Condon ebca8c2dbb x86_64: fix runtime array concat with comptime slice 2026-03-25 17:27:18 -04:00
squidy239 4c3877069d remove various workarounds for issues that are now fixed (#31567)
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31567
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: squidy239 <sachabarsayuracko@gmail.com>
Co-committed-by: squidy239 <sachabarsayuracko@gmail.com>
2026-03-20 19:58:33 +01:00
Adrià Arrufat c10cb44701 Zir: unify float rounding instructions into round_op 2026-03-20 21:27:38 +09:00
Jacob Young 3c8b96df6d windows: use enums for boolean types 2026-03-20 02:25:16 +01:00
Matthew Lugg 10d523f068 Air.Legalize: fix typo in bitcast legalization
A typo meant that the legalization of vector `@bitCast` was literally
just not considering the operand. Oops!

We had a behavior test which should have caught this, but it wasn't
really testing the right thing, so failed to do so. I've updated it to
test what it's supposed to test, so it fails before this patch and
passes after this patch.

Resolves: https://github.com/ziglang/zig/issues/26008
2026-03-19 15:41:22 +00:00
Jacob Young 9ac1386c10 std.Io.Threaded: windows networking without ws2_32 2026-03-18 20:13:59 -04:00
Justus Klausecker c10089d060 test: enable 'switch arbitrary int size' behavior test for cbe
was disabled in b25d93e7d9
2026-03-18 16:57:40 +01:00
Justus Klausecker 0b857eebeb test: disable 'switch on large types' behavior tests for wasm backend
The self-hosted wasm backend doesn't properly support very large integers yet.
2026-03-18 15:49:14 +01:00
Justus Klausecker dbe787a984 Revert "test: disable switch behavior test switching on type >64bits for cbe"
This reverts commit e91654b1e7.
2026-03-18 15:49:14 +01:00
Justus Klausecker 047df44d71 cbe: fix switch statements on large types
`switch` statements on types >128bits are now lowered to conditionals.
This is necessary because Zig lowers integers with more than 128 bits to
bigints, which are not 'native' integers and thus cannot be used as case
values.
128-bit integers get special treatment because Zig will emit actual 128bit
ints if they are supported by the target. They still *may* be lowered to
bigints though, e.g. for 32-bit targets or MSVC. To solve this, this commit
adds a bunch of switch macros to `zig.h` which will either resolve to an
actual `switch` statement or to conditionals. The `if` statements this
approach can generate are not as optimal as they could be but I think this
is a good trade-off since the generated `switch` statements are still the
same as the ones generated for smaller integers. Also the macros result
in pretty readable code.
2026-03-18 15:47:18 +01:00
Techatrix 097ca369d5 detect when switch on error shadows it's own switch case capture 2026-03-17 02:05:31 +01:00
Justus Klausecker 524345b635 Sema: handle containers as inline assembly output types correctly
Inline assembly now rejects output types that don't have a well-defined
in-memory layout and correctly resolves the layout of the ones that do.
2026-03-17 01:51:55 +01:00
mlugg abd099e97f Merge pull request 'compiler: fix missing "local variable is never mutated" error' (#31534) from variable-not-mutated into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31534
2026-03-16 00:05:30 +01:00
pentuppup 2383709431 coerce assembly clobbers in sema 2026-03-15 22:37:38 +01:00
Jan200101 43d5bea7af test: use expectEqualStrings to check cmakedefine behavior
this has the added benefit of outputting the difference making it
easier to figure out why the test is flakey.

https://codeberg.org/ziglang/zig/issues/31368
2026-03-15 21:41:37 +01:00
Matthew Lugg 827a96b1ef compiler: fix missing "local variable is never mutated" error
This regressed back in https://github.com/ziglang/zig/pull/25154. I
didn't get around to fixing it until now, so a few instances of the
warning snuck into the repo over the past few months, which were fixed
in the previous commit. The regression has not appeared in a tagged
release though, so this is not a breaking change in 0.16.0.

Resolves: https://codeberg.org/ziglang/zig/issues/31049
2026-03-15 18:24:32 +00:00
David Rubin 50cc3b91a5 Sema: coerce tail call result to immediate function 2026-03-14 05:23:13 -07:00
Matthew Lugg 0978566db8 incremental: handle loss of main struct instruction
My changes to how incremental compilation handles container types mean
that, at least for now, it is possible for the ZIR `.main_struct_inst`
of a source file to be lost (this happens if the number of top-level
fields in a file changes for instance). I missed a few things which
needed changing to account for this, which could lead to crashes with
certain (trivial) changes---oops!

Adds two new incremental test cases. They are currently disabled for
wasm32-wasi-selfhosted because they both trigger a crash in the WASM
backend.
2026-03-12 21:27:16 +01:00
Justus Klausecker 499aba9ca6 Sema: require else prong for comptime_int
This fixes a bug introduced a couple of commits ago.
2026-03-12 21:03:16 +01:00
Andrew Kelley d5bfa657c4 Merge pull request 'fix several fuzzing bugs' (#31470) from gooncreeper/zig:fuzzing-fixes into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31470
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-03-12 20:25:02 +01:00
Kendall Condon c3e6ff7206 libfuzzer: use error.SkipZigTest 2026-03-11 21:14:46 -04:00
Andrew Kelley 58890066d9 Merge pull request 'Sema: Support peer type resolution for floats and small integers' (#30921) from jayschwa/zig:ptr-small-int-and-floats into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30921
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-03-12 00:41:05 +01:00
Andrew Kelley 109d01371e Merge pull request 'Sema: implement switch for packed structs/unions' (#31464) from justusk/zig:packed-switch into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31464
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-03-12 00:39:19 +01:00
Pavel Verigo 2802276091 stage2-wasm: address TODO in instruction selection code
This PR started as addressing the long-standing TODO above `buildOpcode`:

    /// TODO: deprecated, should be split up per tag.

The code around this area was written a long time ago and has effectively
become a legacy approach. When I started doing semi-occasional work for
bringing >128-bit integer operations to the wasm backend, which is
the last big missing piece of this backend, this design became annoying.

While thinking about how to support that work, and also how vector unrolling
should be handled (in cases where we do not rely purely on the legalize pass),
I decided to do some architectural changes were needed.

The first step is removing helpers like `intBinOp`, `floatBinOp`, `UnOp`, etc.
They do not really capture all operations and resulted in a lot of small
pieces of code trying to artificially unify different ops.

Instead, the direction taken here is similar to `Sema/arith.zig`,  introduce
backend-oriented helpers such as `int*Op*Scalar` and `float*Op*` that operate
purely in backend structures without referencing AIR at all.

Additionally, the idea of introducing dedicated `IntType` and `FloatType`
types was chosen. Using `Type` from Sema inside the backend is awkward,
especially when strange or temporary types are needed. Creating them through
`PerThread` is also undesirable since the backend strives to not modify
`InternPool`. This goal is not fully achieved yet, some parts still require
changes, and `InternPool` type formatting still requires `pt` for error
reporting.

This PR also enables legalize passes for some packed operations. The previous
code in this area was buggy, and given the current state of the backend,
relying on legalization is simpler.

Finally, this PR disables one behavior test: `atomicrmw` with floats. The test
seems to only run the non-concurrency path, because it would crash otherwise,
and since we do not currently run behavior tests for the self-hosted backend
with concurrency or atomics enabled, it does not provide meaningful coverage yet.

In summary, this refactor reworks instruction selection in the wasm backend
to simplify the code and make future work, especially adding big integer
support.
2026-03-11 22:46:58 +01:00
Justus Klausecker e91654b1e7 test: disable switch behavior test switching on type >64bits for cbe
workaround for #31467
2026-03-11 21:14:43 +01:00
Justus Klausecker 28886ca9ec Sema: implement switch for packed structs/unions
Since packed containers are now represented by `bitpack` and can't include
pointers anymore this has become a very easy change to make. This commit
largely just reuses the logic already in place for integers.

Also fixes a small bug where captures-by-ref of errors wouldn't cause a
compile error for regular switch statements. There was already an astgen
error in place for error handling switch statements (`switch_block_err_union`)
capturing their error by reference.
2026-03-11 21:04:04 +01:00
Jay Petacat fcf64761d0 Sema: Support peer type resolution for floats and small integers
This builds on the changes in PR #30053 / commit 484cc15366.

Previously, peer type resolution would always result in a conflict for
fixed-width integer and float types. Now that small integer types can
coerce to floats, peer type resolution can take that into account. This
primarily benefits arithmetic with mixed float and integer operands. If
the integer operand can coerce to the float operand's type, it will do
so without requiring an explicit cast. If the integer type can't coerce,
there will be a compiler error; no float widening will occur. Explicit
casting will still be required to make it work.
2026-03-11 11:31:58 -06:00
Jay Petacat 89c98e2001 Sema: fix integer coercion to c_longdouble
This is a follow-up to PR #30053 / commit 484cc15366.

The code previously did not handle `c_longdouble`, whose size depends on
the target. A `floatSignificandBits` helper function and a smoke test
were added.

Also added the missing max int value to the exhaustive `f16` test cases.
2026-03-11 10:24:42 -06:00
Justus Klausecker be9b42d707 compiler: allow equality comparisons for packed unions
This was already possible in practice by just wrapping a packed union into
a packed struct. Now it's also possible without doing that.
2026-03-11 16:44:08 +01:00
Adrià Arrufat a25f94ddb2 Sema: handle generic poison in rounding builtins 2026-03-11 22:17:26 +09:00
Andrew Kelley a388b88ed4 Merge pull request 'std.heap.ArenaAllocator: add fuzz test + some optimizations' (#31407) from justusk/zig:fuzz-arena into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31407
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-03-11 03:00:07 +01:00
Adrià Arrufat 9d0b89aaea Merge branch 'master' into sema-rounding-casts 2026-03-11 02:57:17 +01:00
Meghan Denny bd5dc75068 std: remove GeneralPurposeAllocator alias 2026-03-11 01:55:49 +01:00
Alex Rønne Petersen 6015192fb6 test-libc: disable pthread_cond_wait-cancel_ignored.c
It's flaky under heavy load: https://codeberg.org/ziglang/zig/actions/runs/2208/jobs/20/attempt/1
2026-03-10 23:36:22 +01:00
Matthew Lugg a3d2f2999f tests: add new tests
Some for bugs which have been fixed, some for language changes.
2026-03-10 11:28:36 +00:00
Matthew Lugg f92b998f9f behavior: disable some tests under the C backend targeting MSVC
The bugs here actually exist on master branch too, but they are being
caught by the new static assertions which check type size and alignment.
It turns out that MSVC's struct/union "pack" pragma and its "align"
declspec interact in undocumented ways which are extremely problematic
for generated code. Solving this will require changing how the C backend
lowers various types; the disabled tests are all tagged unions, but
there are also issues with structs with underaligned fields which the
behavior tests just happen to not currently be triggering.
2026-03-10 10:38:51 +00:00
Matthew Lugg ce1f28a749 behavior: update for std.builtin.Type changes 2026-03-10 10:38:50 +00:00
Matthew Lugg 6d997ebe47 tests: get cases passing (and a few other bits) 2026-03-10 10:26:14 +00:00
Matthew Lugg bb78871aa4 behavior: re-introduce some previously-removed tests
Now that struct default value resolution is separate from struct layout
resolution, a handful of old behavior tests are now once again valid.

This partially reverts the commit titled "behavior: update for changes
to struct field default value resolution".
2026-03-10 10:26:13 +00:00
Matthew Lugg 774911b4ce behavior: small tweaks for new semantics 2026-03-10 10:26:11 +00:00
Matthew Lugg 09d0b1f87a behavior: misc fixes
They compile now! They don't *pass*, but they *compile*!
2026-03-10 10:26:11 +00:00
Matthew Lugg 12ddd5a698 behavior: update for changes to struct field default value resolution
This is separate from the previous commit so that these changes can be
easily reverted in the event that we decide to allow more granularity in
default value resolution in exchange for increased language complexity.
2026-03-10 10:26:11 +00:00
Matthew Lugg 1364cba90d behavior: update for type resolution changes 2026-03-10 10:26:11 +00:00
Matthew Lugg e2669689c4 behavior: auto structs with zero fields are not extern types 2026-03-10 10:26:10 +00:00
Matthew Lugg c9fc921abd tests: update for accepted language change
Pointers to comptime-only types (e.g. `*type`) are no longer themselves
comptime-only types. This means explicit `comptime` annotations are
required in a few more places. However, it also introduces the ability
to access pointers to (including slices of) comptime-only types at
runtime, provided only runtime fields are being accessed.
2026-03-10 10:26:10 +00:00