Commit graph

7484 commits

Author SHA1 Message Date
Alex Rønne Petersen
90e8af98eb
test: Fix incorrect interpretation of -Dtest-filter=... for test-debugger. 2025-05-14 05:44:32 +02:00
xdBronch
55acb29d68
translate-c: fix callconv attribute in macro 2025-05-09 16:43:35 +02:00
Matthew Lugg
e07d8fccd1
Merge pull request #23263 from mlugg/comptime-field-ptr
Sema: fix pointers to comptime fields of comptime-known aggregate pointers
2025-05-04 02:51:47 +02:00
mlugg
db936b9094
compiler: fix comptime memory store bugs
* When storing a zero-bit type, we should short-circuit almost
  immediately. Zero-bit stores do not need to do any work.
* The bit size computation for arrays is incorrect; the `abiSize` will
  already be appropriately aligned, but the logic to do so here
  incorrectly assumes that zero-bit types have an alignment of 0. They
  don't; their alignment is 1.

Resolves: #21202
Resolves: #21508
Resolves: #23307
2025-05-04 02:51:42 +02:00
Pavel Verigo
331bd83f11
wasm-c-abi: llvm fix struct handling + reorganize
I changed to `wasm/abi.zig`, this design is certainly better than the previous one. Still there is some conflict of interest between llvm and self-hosted backend, better design will appear when abi tests will be tested with self-hosted.

Resolves: #23304
Resolves: #23305
2025-05-02 18:30:32 +02:00
Alex Rønne Petersen
aea1272a3f
test: Disable vector reduce operation for sparc.
https://github.com/ziglang/zig/issues/23719
2025-05-01 21:34:57 +02:00
Alex Rønne Petersen
a09c1d91ed
test: Disable some varargs behavior tests on sparc.
https://github.com/ziglang/zig/issues/23718
2025-05-01 21:34:53 +02:00
Ali Cheraghi
200fb1e92e
test: skip "struct fields get automatically reordered" for spirv64 backend 2025-05-01 21:34:34 +02:00
mlugg
bee19572c8
Sema: fix a few indexing bugs
* Indexing zero-bit types should not produce AIR indexing instructions
* Getting a runtime-known element pointer from a many-pointer should
  check that the many-pointer is not comptime-only

Resolves: #23405
2025-04-28 20:48:24 +02:00
dweiller
b5c22777f8
sema: do checked cast when resolving aggregate size 2025-04-28 20:48:19 +02:00
xdBronch
7e68999f79
Sema: fix memcpy with C pointers 2025-04-28 12:10:04 +02:00
Alex Rønne Petersen
e6a71e9e7a
Sema: Fix some ptr alignment checks to handle a potential ISA tag bit.
Closes #23570.
2025-04-28 00:58:53 +02:00
phatchman
4b47e978e3
Return FileNotFound when CreateProcessW is called with a missing path (#23567) 2025-04-16 04:25:02 +02:00
kcbanner
527df938e1
Value: ensure that extern structs have their layout resolved in ptrField 2025-04-11 21:35:42 +02:00
Matthew Roush
fbb297fd2a
Make translate-c more robust in handling macro functions.
Translate-c didn't properly account for C macro functions having parameter names that are C keywords. So something like `#define FOO(float) ((float) + 10)` would've been interpreted as casting `+10` to a `float` type, instead of adding `10` to the parameter `float`.

An example of a real-world macro function like this is SDL3's `SDL_DEFINE_AUDIO_FORMAT` from `SDL_audio.h`, which uses `signed` as a parameter.
2025-04-08 12:11:30 +02:00
Jacob Young
cf6c8eacfe Dwarf: handle undefined type values
Closes #23461
2025-04-06 00:56:57 -04:00
Jacob Young
cac0f56c03 x86_64: fix incorrect handling of unreusable operands
Closes #23448
2025-04-06 00:56:44 -04:00
Parker Liu
06fc600aec
translate-c: fix function prototype decalared inside a function
* If a function prototype is declarated inside a function, do not
  translate it to a top-level extern function declaration. Similar to
  extern local variable, just wrapped it into a block-local struct.

* Add a new extern_local_fn tag of aro_translate_c node for present
  extern local function declaration.

* When a function body has a C function prototype declaration, it adds
  an extern local function declaration. Subsequent function references
  will look for this function declaration.
2025-04-02 23:56:07 +02:00
David Rubin
f2c838d2cf
Sema: increment extra index even if return type is generic 2025-04-02 08:43:28 +02:00
mlugg
f5e7850686
Sema: allow @ptrCast slice of zero-bit type to slice of non-zero-bit type
This is actually completely well-defined. The resulting slice always has
0 elements. The only disallowed case is casting *to* a slice of a
zero-bit type, because in that case, you cna't figure out how many
destination elements to use (and there's *no* valid destination length
if the source slice corresponds to more than 0 bits).
2025-04-02 08:43:13 +02:00
Parker Liu
6ecd143212
translate-c: fix referencing extern locals from nested blocks 2025-04-02 08:43:13 +02:00
Jacob Young
373ae980c0 Elf: fix incrementally reallocating the last atom in a section 2025-03-31 23:18:38 -04:00
David Rubin
aca8ed9dec
Sema: convert slice sentinel to single pointer correctly 2025-03-31 17:36:45 +02:00
mlugg
6ac462b088
Zcu: resolve layout of analyzed declaration type
Resolves: #19888
2025-03-31 17:36:44 +02:00
Alex Rønne Petersen
38ececf0a7
Merge pull request #23310 from Rexicon226/fix-23309
big.int: return normalized results from `{add,sub}Carry`
2025-03-25 18:44:58 +01:00
David Rubin
598413357d
Sema: use unwrapped generic owner in getFuncInstanceIes 2025-03-25 15:24:41 +01:00
mlugg
eedfce92b0
Sema: fix in-memory coercion of functions introducing new generic parameters
While it is not allowed for a function coercion to change whether a
function is generic, it *is* okay to make existing concrete parameters
of a generic function also generic, or vice versa. Either of these cases
implies that the result is a generic function, so comptime type checks
will happen when the function is ultimately called.

Resolves: #21099
2025-03-24 07:02:05 +01:00
Jacob Young
7199a86b97 Merge pull request #23256 from xtexx/fix-gh-20113
x86_64: fix packedStore miscomp by spilling EFLAGS
2025-03-23 21:53:16 -04:00
Jacob Young
fe8bdf6f04 codegen: fix packed byte-aligned relocations
Closes #23131
2025-03-23 21:40:03 -04:00
mlugg
6c690a966a
Sema: correctly handle empty by-ref initializers
Resolves: #23210
2025-03-18 04:57:57 +01:00
Andrew Kelley
22b7d02282 Merge pull request #23188 from jacobly0/fix-23143
x86_64: fix crashes with symbols
2025-03-12 12:25:05 -07:00
mlugg
623d5cc7f6 Sema: fix handling of @This() on opaques
Resolves: #22869
2025-03-11 11:21:03 -07:00
Andrew Kelley
372d56371f Merge pull request #21933 from kcbanner/comptime_nan_comparison
Fix float vector comparisons with signed zero and NaN, add test coverage
2025-03-09 12:07:47 -07:00
Ian Johnson
2ef72f84ca Sema: handle generated tag enums in union field order check
Fixes #23059

The "note: enum field here" now references the field in the base union type rather than crashing.
2025-03-08 11:29:56 -08:00
Alex Rønne Petersen
c9c58ebbe3
test: Disable test-elf-ld-script-path-error for now.
https://github.com/ziglang/zig/issues/23125
2025-03-08 07:07:49 +01:00
Matthew Lugg
c76f451abc
Merge pull request #22979 from mlugg/remove-legacy-coercions
Sema: remove legacy coercion
2025-03-03 22:18:28 +00:00
mlugg
501e84a96a incremental: invalidate namespace dependencies when a name changes visibility
We could have more fine-grained dependencies here, but I think this is
fine for now.
2025-03-03 22:18:02 +00:00
Jacob Young
a6525c1762
Merge pull request #22529 from xtexx/x86-64/shl-sat-int
x86_64: Implement integer saturating left shifting codegen
2025-03-02 02:51:36 -05:00
Bingwu Zhang
1da909a1e2
x86_64: add behavior tests for saturating shift left
Co-authored-by: Jacob Young <jacobly0@users.noreply.github.com>
Signed-off-by: Bingwu Zhang <xtex@aosc.io>
2025-03-02 10:30:43 +08:00
xtex
4e32193de3
x86_64: implement integer saturating left shifting codegen
Simliarly to shl_with_overflow, we first SHL/SAL the integer, then
SHR/SAR it back to compare if overflow happens.
If overflow happened, set result to the upper limit to make it saturating.

Bug: #17645
Co-authored-by: Jacob Young <jacobly0@users.noreply.github.com>
Signed-off-by: Bingwu Zhang <xtex@aosc.io>
2025-03-02 10:30:32 +08:00
Jacob Young
50b40c9621 x86_64: rewrite wrapping add/sub 2025-03-01 16:29:22 -05:00
Andrew Kelley
6b6c1b1b0e Revert "Merge pull request #22898 from kristoff-it/deprecated-proposal"
This reverts commit dea72d15da, reversing
changes made to ab381933c8.

The changeset does not work as advertised and does not have sufficient
test coverage.

Reopens #22822
2025-02-28 01:37:10 -08:00
Andrew Kelley
f74a856d84 reword deprecated error slightly
"found" -> "reached" to match "reached unreachable code"
2025-02-26 14:41:33 -05:00
Andrew Kelley
7c2649f89d langref: fix whitespace 2025-02-26 14:41:33 -05:00
Loris Cro
25790e95f1 @deprecated: remove per-module flag in Build
This implementation looks at the builder of each
module in the build graph instead of storing a
boolean for each module.
2025-02-26 14:41:33 -05:00
Loris Cro
c75fdd96d2 @deprecated: add tests 2025-02-26 14:41:33 -05:00
Andrew Kelley
c45dcd013b
Merge pull request #22488 from Rexicon226/ubsan-rt
implement a ubsan runtime for better error messages
2025-02-26 03:08:36 -05:00
mlugg
3aaf394249
test: remove dependencies on legacy coercion 2025-02-26 00:17:09 +00:00
mlugg
84da520c44
Sema: remove legacy coercion
This was meant to be removed in #21817, but was somehow missed.
2025-02-26 00:17:09 +00:00
mlugg
3fcb4408a5 AstGen: improve 'file cannot be a tuple' source location
Instead of just reporting this on token 0, report it on the first
tuple-like field.
2025-02-25 22:28:47 +00:00