7807 Commits

Author SHA1 Message Date
Alex Rønne Petersen
6317417fe1
test: enable tsan test for x86_64-netbsd 2025-08-14 08:25:50 +02:00
Matthew Lugg
b87b958687
Merge pull request #24816 from mlugg/small-fixes
two small fixes
2025-08-13 23:55:21 +01:00
Matthew Lugg
a495628862
Merge pull request #24674 from Justus2308/undef-shift-bitwise
Sema: Improve comptime arithmetic undef handling
2025-08-13 14:04:59 +01:00
David Rubin
8e02f9f70d sema: strip @splat operand result type before checking it 2025-08-13 13:55:57 +01:00
Matthew Lugg
6e90ce2536
Merge pull request #24381 from Justus2308/switch-better-underscore
Enhance switch on non-exhaustive enums
2025-08-13 13:54:15 +01:00
mlugg
ba6abd71c2
llvm: unions which are equivalent to enums are not by-ref
The LLVM backend lowers unions where all fields are zero-bit as
equivalent to their backing enum, and expects them to have the same
by-ref-ness in at least one place in the backend, probably more.

Resolves: #23577
2025-08-13 11:36:16 +01:00
Alex Rønne Petersen
662303d7e7
Merge pull request #24734 from Rexicon226/tsan-fix 2025-08-13 08:57:52 +02:00
Justus Klausecker
4ec421372f add remaining undef value tests ; fix @truncate undef retval type 2025-08-12 16:33:58 +02:00
Justus Klausecker
f0ffe30f2f add undef shift tests ; mirror zirShl logic for @shlWithOverflow 2025-08-12 16:33:58 +02:00
Justus Klausecker
79756e681d remove redundant test cases 2025-08-12 16:33:58 +02:00
Justus Klausecker
05762ca02f address most comments 2025-08-12 16:33:57 +02:00
Justus Klausecker
0ef26d113a make >> a compile error with any undef arg ; add a bunch of test cases 2025-08-12 16:33:57 +02:00
Justus Klausecker
d0586da18e Sema: Improve comptime arithmetic undef handling
This commit expands on the foundations laid by https://github.com/ziglang/zig/pull/23177
and moves even more `Sema`-only functionality from `Value`
to `Sema.arith`. Specifically all shift and bitwise operations,
`@truncate`, `@bitReverse` and `@byteSwap` have been moved and
adapted to the new rules around `undefined`.

Especially the comptime shift operations have been basically
rewritten, fixing many open issues in the process.

New rules applied to operators:
* `<<`, `@shlExact`, `@shlWithOverflow`, `>>`, `@shrExact`: compile error if any operand is undef
* `<<|`, `~`, `^`, `@truncate`, `@bitReverse`, `@byteSwap`: return undef if any operand is undef
* `&`, `|`: Return undef if both operands are undef, turn undef into actual `0xAA` bytes otherwise

Additionally this commit canonicalizes the representation of
aggregates with all-undefined members in the `InternPool` by
disallowing them and enforcing the usage of a single typed
`undef` value instead. This reduces the amount of edge cases
and fixes a bunch of bugs related to partially undefined vecs.

List of operations directly affected by this patch:
* `<<`, `<<|`, `@shlExact`, `@shlWithOverflow`
* `>>`, `@shrExact`
* `&`, `|`, `~`, `^` and their atomic rmw + reduce pendants
* `@truncate`, `@bitReverse`, `@byteSwap`
2025-08-12 16:33:57 +02:00
Andrew Kelley
749f10af49 std.ArrayList: make unmanaged the default 2025-08-11 15:52:49 -07:00
Jacob Young
38dfa6537e cbe: emit nonstring attribute
Closes #24545
2025-08-11 11:30:51 -07:00
David Rubin
826b33863f test: add a standalone test for compiling tsan 2025-08-11 03:02:54 +02:00
Ali Cheraghi
64563e2fff
test: skip tests that were not meant to pass for spirv 2025-08-09 13:27:45 +03:30
Andrew Kelley
3fb86841cc
Merge pull request #24661 from alichraghi/spv4
spirv: refactor and remove deduplication ISel
2025-08-07 20:55:50 -07:00
Justus Klausecker
0ecbd5a0e1 address comments 2025-08-07 13:58:49 +02:00
Justus Klausecker
ba549a7d67 Add support for both '_' and 'else' prongs at the same time in switch statements
If both are used, 'else' handles named members and '_' handles
unnamed members. In this case the 'else' prong will be unrolled
to an explicit case containing all remaining named values.
2025-08-07 13:58:47 +02:00
Justus Klausecker
1d9b1c0212 Permit explicit tags with '_' switch prong
Mainly affects ZIR representation of switch_block[_ref]
and special prong (detection) logic for switch.
Adds a new SpecialProng tag 'absorbing_under' that allows
specifying additional explicit tags in a '_' prong which
are respected when checking that every value is handled
during semantic analysis but are not transformed into AIR
and instead 'absorbed' by the '_' branch.
2025-08-07 13:57:57 +02:00
Matthew Lugg
fd9cfc39f5
Merge pull request #24199 from Justus2308/24106-fmt-casts
zig fmt: canonicalize nested cast builtin order
2025-08-07 10:55:03 +01:00
mlugg
3de8bbd3d4 Sema: fix initializing comptime-known constant with OPV union field
Resolves: #24716
2025-08-06 20:47:03 +01:00
Alex Rønne Petersen
7ee6dab39f Revert "Sema: Stop adding Windows implib link inputs for extern "..." syntax."
This reverts commit b461d07a5464aec86c533434dab0b58edfffb331.

After some discussion in the team, we've decided that this is too disruptive,
especially because the linker errors are less than helpful. That's a fixable
problem, so we might reconsider this in the future, but revert it for now.
2025-08-06 06:15:13 +02:00
Justus Klausecker
7c35070b90 zig fmt: apply new cast builtin order 2025-08-03 14:59:56 +02:00
Alex Rønne Petersen
a5f891d0b3
Merge pull request #24562 from h57624paen/fix-win-spawn-double-normalize
std.process.Child: fix double path normalization in spawnWindows
2025-08-03 11:19:10 +02:00
Matthew Lugg
c80aa9f719
Merge pull request #22997 from Rexicon226/align-0-reify
sema: compile error on reifying align(0) fields and pointers
2025-08-03 09:58:23 +01:00
David Rubin
e82d67233b
disallow alignment on packed union fields 2025-08-02 09:51:26 -07:00
Alex Rønne Petersen
239efa7e67
Merge branch 'riscv-ci' 2025-08-02 09:41:04 +02:00
Alex Rønne Petersen
bcaae562d6
build: add -Dskip-compile-errors option
Skips tests in test/cases/compile_errors.
2025-08-02 09:34:55 +02:00
Ali Cheraghi
31de2c873f
spirv: refactor 2025-08-02 04:16:01 +03:30
David Rubin
d6c74a95fd
remove usages of .alignment = 0 2025-08-01 14:57:16 -07:00
David Rubin
17330867eb
Sema: compile error on reifying align(0) struct fields 2025-08-01 14:57:16 -07:00
Andrew Kelley
ae67c26cab disable failing incremental test cases due to dwarf linker logic
tracked by #24634
2025-07-31 22:10:11 -07:00
Jackson Wambolt
264bd7053e Sema: remove incorrect requireRuntimeBlock calls
Part of #22353

Resolves: #24273
Co-Authored-By: Matthew Lugg <mlugg@mlugg.co.uk>
2025-07-31 22:28:46 +01:00
Matthew Lugg
04d7b491b4
Merge pull request #24632 from mlugg/lossy-int-to-float-coercion
Sema: compile error on lossy int to float coercion
2025-07-31 21:49:37 +01:00
mikastiv
1a15fbe960 Sema: add note suggesting dropping try on non error-unions 2025-07-31 16:55:17 +01:00
dweiller
19fc5f4fb2 Sema: disallow slicing many-item pointer with different sentinel
This change prevents adding or changing the sentinel in the type of a
many-item pointer via the slicing syntax `ptr[a.. :S]`.
2025-07-31 12:02:19 +01:00
mlugg
e664bf4d81
Sema: compile error on lossy int to float coercion
Resolves: #21586
2025-07-31 10:57:04 +01:00
Matthew Lugg
032bbd68a7
Merge pull request #24537 from IOKG04/some-documentation-updates-0
some small langref changes
2025-07-31 02:32:32 +01:00
Jackson Wambolt
eb1a4970da
Sema: check min/max operand types 2025-07-30 20:48:38 +00:00
Matthew Lugg
389ccf692a
Merge pull request #24278 from gooncreeper/atomic-fixes
atomic fixes and clarification
2025-07-30 21:30:29 +01:00
Krzysztof Wolicki
3d639481d9
Sema: disallow tags on non-auto unions when reifying (#23488) 2025-07-30 18:18:49 +00:00
Justus Klausecker
6ec275ebd8 Sema: remove incorrect safety check for saturating left shift 2025-07-30 10:15:48 +01:00
Kendall Condon
b0d6c227d3 Sema: catch error sets in atomic operations
also fix the struct test
2025-07-30 09:56:38 +01:00
Kendall Condon
f7dc9b50ab llvm: fix atomic widening of packed structs
Additionally, disable failing big-endian atomic test

also improve test paramaters to catch this when condition is removed

also some other cleanups
2025-07-30 09:56:38 +01:00
mlugg
08f1d63be1
disable more failing tests
Wow, *lots* of backends were reliant on Sema doing the heavy lifting for
them. CBE, Wasm, and SPIR-V have all regressed in places now that they
actually need to, like, initialize unions and such.
2025-07-29 22:44:01 +01:00
mlugg
a8888afcc0
Sema: remove redundant comptime-known initializer tracking
This logic predates certain Sema enhancements whose behavior it
essentially tries to emulate in one specific case in a problematic way.
In particular, this logic handled initializing comptime-known `const`s
through RLS, which was reworked a few years back in 644041b to not rely
on this logic, and catching runtime fields in comptime-only
initializers, which has since been *correctly* fixed with better checks
in `Sema.storePtr2`. That made the highly complex logic in
`validateStructInit`, `validateUnionInit`, and `zirValidatePtrArrayInit`
entirely redundant. Worse, it was also causing some tracked bugs, as
well as a bug which I have identified and fixed in this PR (a
corresponding behavior test is added).

This commit simplifies union initialization by bringing the runtime
logic more in line with the comptime logic: the tag is now always
populated by `Sema.unionFieldPtr` based on `initializing`, where this
previously happened only in the comptime case (with `validateUnionInit`
instead handling it in the runtime case). Notably, this means that
backends are now able to consider getting a pointer to an inactive union
field as Illegal Behavior, because the `set_union_tag` instruction now
appears *before* the `struct_field_ptr` instruction as you would
probably expect it to.

Resolves: #24520
Resolves: #24595
2025-07-29 15:52:19 +01:00
Jacob Young
3fbdd58a87 aarch64: implement scalar @mod 2025-07-28 22:23:19 -07:00
Jacob Young
c334956a54 aarch64: workaround some optional/union issues 2025-07-28 09:03:17 -07:00