Commit Graph

7471 Commits

Author SHA1 Message Date
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
David Rubin ca83f52fd9 ubsan: update wording 2025-02-25 11:22:33 -08:00
David Rubin 44d3b5a6e4 build: add comments explaining why we disable ubsan 2025-02-25 11:22:33 -08:00
David Rubin 35b9db3b15 correct some bugs 2025-02-25 11:22:33 -08:00
Ali Cheraghi aec0f9b3e7 test: skip failing tests with spirv-vulkan 2025-02-24 19:39:42 +01:00
Ali Cheraghi 181a89e728 build: add spirv to test matrix
Signed-off-by: Ali Cheraghi <alichraghi@proton.me>
2025-02-24 19:12:38 +01:00
mlugg 5e20e9b449 Sema: allow @ptrCast of slices changing the length
Also, refactor `Sema.ptrCastFull` to not be a horrifying hellscape.
2025-02-23 08:28:58 +00:00
Jacob Young 220f80e71d Dwarf: fix lowering of comptime-only optional pointer null values
Closes #22974
2025-02-22 22:47:32 -05:00
David Rubin 84aac8b6c7 Type: resolve union tag type before checking for runtime bits 2025-02-22 22:22:55 -05:00
Andrew Kelley eb3c7f5706 zig build fmt 2025-02-22 17:09:20 -08:00
mlugg b6a1fdd3fa tests: disable failing tests
These were previously incremental tests, so weren't running. They didn't
*need* to be incremental. They worked under the old runner because of
how it directly integrated with the compiler so tracked error messages
differently.
2025-02-23 00:52:50 +00:00
mlugg a3b3a33d7a cases: remove old incremental case system
We now run incremental tests with `tools/incr-check.zig` (with the
actual cases being in `test/incremental/`).
2025-02-23 00:52:50 +00:00
Pavel Verigo b25d93e7d9 stage2-wasm: implement switch_dispatch + handle > 32 bit integers in switches
Updated solution is future proof for arbitary size integer handling for both strategies .br_table lowering if switch case is dense, .br_if base jump table if values are too sparse.
2025-02-22 18:34:00 -05:00
Andrew Kelley 61b69a418d Merge pull request #22659 from ifreund/linker-script-fix
link: fix ambiguous names in linker scripts
2025-02-22 18:18:24 -05:00