18 Commits

Author SHA1 Message Date
Andrew Kelley
76d04c1662 zig fmt 2025-07-16 10:27:39 -07:00
Jacob Young
8159ff8b81 x86_64: implement error set and enum safety
This is all of the expected 0.14.0 progress on #21530, which can now be
postponed once this commit is merged.

This required rewriting the (un)wrap operations since the original
implementations were extremely buggy.

Also adds an easy way to retrigger Sema OPV bugs so that I don't have to
keep updating #22419 all the time.
2025-02-15 03:45:21 -05:00
Andrew Kelley
f303c3943f Revert "Merge pull request #20380 from tau-dev/master"
This reverts commit 397be0c9cc8156d38d1487a4c80210007033cbd0, reversing
changes made to 18d412ab2fb7bda92f7bfbdf732849bbcd066c33.

Caused test failures in master branch.
2024-07-21 02:44:58 -07:00
Tau
9c2d597e69 llvm: Fix debug gen for 0-bit types
Add a regression test for that, since these weirdly never occur in any
of the other tests on x86-64-linux.
2024-07-19 17:51:38 +02:00
mlugg
21fa187abc
test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
Veikka Tuominen
e765495b11 tests: translate-c and run-translated-c to the test harness 2023-10-17 11:55:17 +03:00
mlugg
f26dda2117 all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There
were a few exceptions which I had to manually fix:

* `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten
* `@truncate`'s fixup is incorrect for vectors
* Test cases are not formatted, and their error locations change
2023-06-24 16:56:39 -07:00
kcbanner
9d66481e3d llvm: fixup elem_count argument of ZigLLVMCreateDebugArrayType to be i64
The signature is `getOrCreateSubrange(int64_t  Lo, int64_t  Count)`, so this updates the bindings to match.

This fixes a crash in `lowerDebugTypeImpl` when analyzing slices that have a length of 2^32 or
larger (up to `2^64 >> 3`, which still crashes, because above that the array size in bits overflows u64).
2023-06-23 14:53:17 -07:00
Eric Joldasov
50339f595a all: zig fmt and rename "@XToY" to "@YFromX"
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-19 12:34:42 -07:00
mlugg
4976b58ab1
Prevent analysis of functions only referenced at comptime
The idea here is that there are two ways we can reference a function at runtime:

* Through a direct call, i.e. where the function is comptime-known
* Through a function pointer

This means we can easily perform a form of rudimentary escape analysis
on functions. If we ever see a `decl_ref` or `ref` of a function, we
have a function pointer, which could "leak" into runtime code, so we
emit the function; but for a plain `decl_val`, there's no need to.

This change means that `comptime { _ = f; }` no longer forces a function
to be emitted, which was used for some things (mainly tests). These use
sites have been replaced with `_ = &f;`, which still triggers analysis
of the function body, since you're taking a pointer to the function.

Resolves: #6256
Resolves: #15353
2023-05-29 23:06:08 +01:00
Andrew Kelley
171977dc1c test-cases: fix incorrectly linking libc when backend is llvm
Now link_libc=1 must be used to link with libc, instead of the test
harness assuming that using the llvm backend means additionally linking
with libc.
2023-03-15 10:48:15 -07:00
Andrew Kelley
29cfd47d65 re-enable test-cases and get them all passing
Instead of using `zig test` to build a special version of the compiler
that runs all the test-cases, the zig build system is now used as much
as possible - all with the basic steps found in the standard library.

For incremental compilation tests (the ones that look like foo.0.zig,
foo.1.zig, foo.2.zig, etc.), a special version of the compiler is
compiled into a utility executable called "check-case" which checks
exactly one sequence of incremental updates in an independent
subprocess. Previously, all incremental and non-incremental test cases
were done in the same test runner process.

The compile error checking code is now simpler, but also a bit
rudimentary, and so it additionally makes sure that the actual compile
errors do not include *extra* messages, and it makes sure that the
actual compile errors output in the same order as expected. It is also
based on the "ends-with" property of each line rather than the previous
logic, which frankly I didn't want to touch with a ten-meter pole. The
compile error test cases have been updated to pass in light of these
differences.

Previously, 'error' mode with 0 compile errors was used to shoehorn in a
different kind of test-case - one that only checks if a piece of code
compiles without errors. Now there is a 'compile' mode of test-cases,
and 'error' must be only used when there are greater than 0 errors.

link test cases are updated to omit the target object format argument
when calling checkObject since that is no longer needed.

The test/stage2 directory is removed; the 2 files within are moved to be
directly in the test/ directory.
2023-03-15 10:48:14 -07:00
Andrew Kelley
b13745ac03 disable failing x86_64 backend tests 2023-02-18 19:17:21 -07:00
Andrew Kelley
1b1c70ce38 disable failing incremental compilation test case
see #12288

now `zig build test-cases -Denable-llvm` passes locally for me.
2022-07-29 02:35:06 -07:00
Veikka Tuominen
3204d00a5e move passing stage1 compile error tests to stage2 2022-06-30 09:57:38 +02:00
Jakub Konka
914e2d4c99 test: fix spurious whitespace in nested_blocks test 2022-06-28 13:28:09 +02:00
Andrew Kelley
953e2778d4 clean up a compile error test case
These should be build-obj, not build-exe, where possible.
2022-05-24 01:20:18 -07:00
Jakub Konka
3624e1ef48 test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00