aboutsummaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2024-12-13test: Add armeb-linux-* to the module test matrix.Alex Rønne Petersen
2024-12-13test: Disable some vector behavior tests on armeb.Alex Rønne Petersen
https://github.com/ziglang/zig/issues/22060
2024-12-13Merge pull request #22035 from alexrp/unwind-fixesAlex Rønne Petersen
Better unwind table support + unwind protection in `_start()` and `clone()`
2024-12-11AstGen: fix analysis when encountering discard of error captureTechatrix
2024-12-11compiler: Improve the handling of unwind table levels.Alex Rønne Petersen
The goal here is to support both levels of unwind tables (sync and async) in zig cc and zig build. Previously, the LLVM backend always used async tables while zig cc was partially influenced by whatever was Clang's default.
2024-12-09Merge pull request #22157 from mlugg/astgen-error-lazyAndrew Kelley
compiler: allow semantic analysis of files with AstGen errors
2024-12-09Merge pull request #22164 from mlugg/astgen-ref-dedupAndrew Kelley
AstGen: correctly deduplicate `ref` of `param` and `alloc_inferred`
2024-12-08Sema: fix use of Zcu.LazySrcLoc in error messagewooster0
It currently prints as: :3:18: error: untagged union 'Zcu.LazySrcLoc{ .base_node_inst = InternPool.TrackedInst.Index(104), .offset = Zcu.LazySrcLoc.Offset{ .node_offset = Zcu.LazySrcLoc.Offset.TracedOffset{ .x = -2, .trace = (value tracing disabled) } } }' cannot be converted to integer
2024-12-08cbe: prevent tautological-compare warnings in generated codeJacob Young
2024-12-08AstGen: correctly deduplicate `ref` of `param` and `alloc_inferred`mlugg
Both of these instructions were previously under a special case in `rvalue` which resulted in every reference to such an instruction adding a new `ref` instruction. This had the effect that, for instance, `&a != &a` for parameters. Deduplicating these `ref` instructions was problematic for different reasons. For `alloc_inferred`, the problem was that it's not valid to `ref` the alloc until the allocation has been resolved (`resolve_inferred_alloc`), but `AstGen.appendBodyWithFixups` would place the `ref` directly after the `alloc_inferred`. This is solved by bringing `resolve_inferred_alloc` in line with `make_ptr_const` by having it *return* the final pointer, rather than modifying `sema.inst_map` of the original `alloc_inferred`. That way, the `ref` refers to the `resolve_inferred_alloc` instruction, so is placed immediately after it, avoiding this issue. For `param`, the problem is a bit trickier: `param` instructions live in a body which must contain only `param` instructions, then a `func{,_inferred,_fancy}`, then a `break_inline`. Moreover, `param` instructions may be referenced not only by the function body, but also by other parameters, the return type expression, etc. Each of these bodies requires separate `ref` instructions. This is solved by pulling entries out of `ref_table` after evaluating each component of the function declaration, and appending the refs later on when actually putting the bodies together. This gives way to another issue: if you write `fn f(x: T) @TypeOf(x.foo())`, then since `x.foo()` takes a reference to `x`, this `ref` instruction is now in a comptime context (outside of the `@TypeOf` ZIR body), so emits a compile error. This is solved by loosening the rules around `ref` instructions; because they are not side-effecting, it is okay to allow `ref` of runtime values at comptime, resulting in a runtime-known value in a comptime scope. We already apply this mechanism in some cases; for instance, it's why `runtime_array.len` works in a `comptime` context. In future, we will want to give similar treatment to many operations in Sema: in general, it's fine to apply runtime operations at comptime provided they don't have side effects! Resolves: #22140
2024-12-08std.zig.WindowsSdk: Support cross-arch SDK lookups.Alex Rønne Petersen
This makes e.g. cross-compiling for x86-windows-msvc on a x86_64-windows-msvc system work properly. Closes #11926.
2024-12-05compiler: allow files with AstGen errors to undergo semantic analysismlugg
This commit enhances AstGen to introduce a form of error resilience which allows valid ZIR to be emitted even when AstGen errors occur. When a non-fatal AstGen error (e.g. `appendErrorNode`) occurs, ZIR generation is not affected; the error is added to `astgen.errors` and ultimately to the errors stored in `extra`, but that doesn't stop us getting valid ZIR. Fatal AstGen errors (e.g. `failNode`) are a bit trickier. These errors return `error.AnalysisFail`, which is propagated up the stack. In theory, any parent expression can catch this error and handle it, continuing ZIR generation whilst throwing away whatever was lost. For now, we only do this in one place: when creating declarations. If a call to `fnDecl`, `comptimeDecl`, `globalVarDecl`, etc, returns `error.AnalysisFail`, the `declaration` instruction is still created, but its body simply contains the new `extended(astgen_error())` instruction, which instructs Sema to terminate semantic analysis with a transitive error. This means that a fatal AstGen error causes the innermost declaration containing the error to fail, but the rest of the file remains intact. If a source file contains parse errors, or an `error.AnalysisFail` happens when lowering the top-level struct (e.g. there is an error in one of its fields, or a name has multiple declarations), then lowering for the entire file fails. Alongside the existing `Zir.hasCompileErrors` query, this commit introduces `Zir.loweringFailed`, which returns `true` only in this case. The end result here is that files with AstGen failures will almost always still emit valid ZIR, and hence can undergo semantic analysis on the parts of the file which are (from AstGen's perspective) valid. This is a noteworthy improvement to UX, but the main motivation here is actually incremental compilation. Previously, AstGen failures caused lots of semantic analysis work to be thrown out, because all `AnalUnit`s in the file required re-analysis so as to trigger necessary transitive failures and remove stored compile errors which would no longer make sense (because a fresh compilation of this code would not emit those errors, as the units those errors applied to would fail sooner due to referencing a failed file). Now, this case only applies when a file has severe top-level errors, which is far less common than something like having an unused variable. Lastly, this commit changes a few errors in `AstGen` to become fatal when they were previously non-fatal and vice versa. If there is still a reasonable way to continue AstGen and lower to ZIR after an error, it is non-fatal; otherwise, it is fatal. For instance, `comptime const`, while redundant syntax, has a clear meaning we can lower; on the other hand, using an undeclared identifer has no sane lowering, so must trigger a fatal error.
2024-12-03std.Target: Remove Os.Tag.bridgeos.Alex Rønne Petersen
It doesn't appear that targeting bridgeOS is meaningfully supported by Apple. Even LLVM/Clang appear to have incomplete support for it, suggesting that Apple never bothered to upstream that support. So there's really no sense in us pretending to support this.
2024-12-01test: Add x86_64-linux-(gnux32,muslx32) to module tests.Alex Rønne Petersen
2024-11-29defaultPanic: @trap on 'other' targetPat Tullmann
The freestanding and other OS targets by default need to just @trap in the default Panic implementation. And `isValidMemory` won't work with freestanding or other targets. Update the unwind_freestanding.zig test case to also run on the 'other' OS target, too. This should keep the Zig's stacktrace generation from regressing on the standalone targets.
2024-11-29Merge pull request #22095 from alexrp/test-llvm-emitAndrew Kelley
Change `llvm_targets` tests to actually emit objects, and fix bugs found as a result
2024-11-29compiler: use `@Type` instead of `@TypeOf` to print enum literal typemlugg
2024-11-29Merge pull request #22099 from Rexicon226/fix-cat-mulAndrew Kelley
change `++` and `**` to not return mutable pointers
2024-11-28test: adjust behaviour test to new concat/mul semanticsDavid Rubin
2024-11-28test: Change llvm_targets to actually emit an object for each target.Alex Rønne Petersen
Without doing this, we don't actually test whether the data layout string we generate matches LLVM's. A number of targets had to be commented out due to this change: * Some are using a non-working experimental LLVM backend (arc, csky, ...). * Some don't have working LLD support (lanai, sparc, ...). * Some don't have working self-hosted linker support (nvptx). * Some are using ABIs that haven't been standardized (loongarch32). Finally, all non-x86 uefi targets are hopelessly broken and can't really be fixed until we change our emit logic to lower *-uefi-* verbatim rather than to *-windows-*. See: https://github.com/ziglang/zig/issues/21630
2024-11-28test: Remove aarch64(_be)-linux-gnuilp32 from llvm_targets.Alex Rønne Petersen
LLVM doesn't handle this target correctly (pointer size, etc).
2024-11-28test: Add m68k-linux-musl to llvm_targets.Alex Rønne Petersen
2024-11-28test: Add aarch64(_be)-linux-musl to llvm_targets.Alex Rønne Petersen
2024-11-28test: Remove aarch64-rtems-ilp32 from llvm_targets.Alex Rønne Petersen
LLVM can't represent this target at the moment.
2024-11-28test: Add *-windows-cygnus triples to llvm_targets.Alex Rønne Petersen
2024-11-28Merge pull request #22067 from alexrp/pie-testsAlex Rønne Petersen
Add PIC/PIE tests and fix some bugs + some improvements to the test harness
2024-11-24dwarf: fix stepping through an inline loop containing one statementJacob Young
Previously, stepping from the single statement within the loop would always exit the loop because all of the code unrolled from the loop is associated with the same line and treated by the debugger as one line.
2024-11-24test: Set emit_bin=false for some safety tests.Alex Rønne Petersen
This should hopefully be reverted soon with Andrew's work on the self-hosted wasm linker. error: thread 171731 panic: integer overflow /home/alexrp/Source/ziglang/zig/src/link/Wasm.zig:2392:32: 0x22b709e in setupMemory (zig) break :index sym.index - wasm.imported_globals_count; ^ /home/alexrp/Source/ziglang/zig/src/link/Wasm.zig:2678:25: 0x1ed1be6 in flushModule (zig) try wasm.setupMemory(); ^ /home/alexrp/Source/ziglang/zig/src/link/Wasm.zig:2619:28: 0x1c2e4d4 in flush (zig) return wasm.flushModule(arena, tid, prog_node); ^ /home/alexrp/Source/ziglang/zig/src/link.zig:874:77: 0x1a55ad7 in flush (zig) return @as(*tag.Type(), @fieldParentPtr("base", base)).flush(arena, tid, prog_node); ^ /home/alexrp/Source/ziglang/zig/src/Compilation.zig:2411:17: 0x1a553f9 in flush (zig) lf.flush(arena, tid, prog_node) catch |err| switch (err) { ^ /home/alexrp/Source/ziglang/zig/src/Compilation.zig:2371:22: 0x1a58d60 in update (zig) try flush(comp, arena, .{ ^ /home/alexrp/Source/ziglang/zig/src/main.zig:4114:32: 0x1ae392b in serve (zig) try comp.update(main_progress_node); ^ /home/alexrp/Source/ziglang/zig/src/main.zig:3555:22: 0x1b05322 in buildOutputType (zig) try serve( ^ /home/alexrp/Source/ziglang/zig/src/main.zig:265:31: 0x195faca in mainArgs (zig) return buildOutputType(gpa, arena, args, .{ .build = .Obj }); ^ /home/alexrp/Source/ziglang/zig/src/main.zig:200:20: 0x195c995 in main (zig) return mainArgs(gpa, arena, args); ^ /home/alexrp/Source/ziglang/zig/lib/std/start.zig:617:37: 0x195c49e in main (zig) const result = root.main() catch |err| { ^
2024-11-24test: Set emit_bin=false for spirv_mergable_pointers.zig.Alex Rønne Petersen
/home/alexrp/.cache/zig/b/18236e302af25e3fb99bc6a232ddc447/builtin.zig:6:5: error: TODO (SPIR-V): Implement unsigned composite int type of 64 bits pub const zig_backend = std.builtin.CompilerBackend.stage2_spirv64; ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2024-11-24test: Set emit_bin=false for all nvptx tests.Alex Rønne Petersen
error: thread 165232 panic: TODO: rewrite the NvPtx.flushModule function /home/alexrp/Source/ziglang/zig/src/link/NvPtx.zig:123:5: 0x1ed99ce in flushModule (zig) @panic("TODO: rewrite the NvPtx.flushModule function"); ^ /home/alexrp/Source/ziglang/zig/src/link/NvPtx.zig:110:28: 0x1c2e7e6 in flush (zig) return self.flushModule(arena, tid, prog_node); ^ /home/alexrp/Source/ziglang/zig/src/link.zig:874:77: 0x1a55bd3 in flush (zig) return @as(*tag.Type(), @fieldParentPtr("base", base)).flush(arena, tid, prog_node); ^ /home/alexrp/Source/ziglang/zig/src/Compilation.zig:2411:17: 0x1a553f9 in flush (zig) lf.flush(arena, tid, prog_node) catch |err| switch (err) { ^ /home/alexrp/Source/ziglang/zig/src/Compilation.zig:2348:22: 0x1a595ba in update (zig) try flush(comp, arena, .{ ^ /home/alexrp/Source/ziglang/zig/src/main.zig:4114:32: 0x1ae392b in serve (zig) try comp.update(main_progress_node); ^ /home/alexrp/Source/ziglang/zig/src/main.zig:3555:22: 0x1b05322 in buildOutputType (zig) try serve( ^ /home/alexrp/Source/ziglang/zig/src/main.zig:265:31: 0x195faca in mainArgs (zig) return buildOutputType(gpa, arena, args, .{ .build = .Obj }); ^ /home/alexrp/Source/ziglang/zig/src/main.zig:200:20: 0x195c995 in main (zig) return mainArgs(gpa, arena, args); ^ /home/alexrp/Source/ziglang/zig/lib/std/start.zig:617:37: 0x195c49e in main (zig) const result = root.main() catch |err| { ^
2024-11-24test: Allow tests to set emit_bin=false.Alex Rønne Petersen
2024-11-24test: Force compile test cases to be codegen'd if requested.Alex Rønne Petersen
2024-11-24test: Add test cases for PIC/PIE on various supported platforms.Alex Rønne Petersen
Closes #22052.
2024-11-24test: Allow setting PIC/PIE in test cases.Alex Rønne Petersen
2024-11-24test: Enable -Dtest-target-filter=... to work for test-debugger.Alex Rønne Petersen
2024-11-24test: Enable -Dtest-target-filter=... to work for test-cases and ↵Alex Rønne Petersen
test-translate-c.
2024-11-24test: Enable -Dtest-target-filter=... to work for test-c-abi.Alex Rønne Petersen
2024-11-24std.Target: Add Os.HurdVersionRange for Os.Tag.hurd.Alex Rønne Petersen
This is necessary since isGnuLibC() is true for hurd, so we need to be able to represent a glibc version for it. Also add an Os.TaggedVersionRange.gnuLibCVersion() convenience function.
2024-11-23lldb: implement tuple typesJacob Young
2024-11-23compiler: Disallow align(0) everywhere in the language.Alex Rønne Petersen
Thus leaving the design space for this alignment value open, e.g. for packing.
2024-11-20Fix peer type resolution with allowzero pointersxdBronch
2024-11-16Sema: fix peer resolution alignment between slice and empty structJacob Young
An empty struct that coerces to an empty array should not force `align(1)` on the resulting slice type.
2024-11-16link: fix failing incremental test casesJacob Young
2024-11-12AstGen: add missing `rvalue` call to `labeledBlockExpr`mlugg
...and fix a minor x86_64 backend bug exposed by this fix. Resolves: #21974
2024-11-11test: add new incremental casemlugg
This is similar to the old `llvm/shift_right_plus_left` case, which was disabled by 1b1c78c. The case is not enabled on the LLVM backend, since incremental compilation support for this backend is a work in progress and is tracked by #21165. It passes on the x86_64-linux target with the self-hosted backend. Resolves: #12288
2024-11-11test: remove old-style incremental cases, add a few new incremental casesmlugg
These cases have been disabled for a while, and we have transitioned to using a compact file format for incremental test cases. I was originally planning to port all of these cases, but the vast majority aren't testing anything interesting, so it wasn't worth the effort. I did look through each one; anything interesting being tested has been extracted into a new case in `test/incremental/`. Two of the new tests are currently failing with the self-hosted ELF linker, and thus are currently only enabled with the C backend. Resolves: #12844
2024-11-09Sema: fix wording in error messageWooster
It's an FQN, not an actual file name.
2024-11-05Revert "test: Add aarch64_be-linux-(none,gnu,musl) to module tests."Alex Rønne Petersen
This reverts commit 4049be90de6a557c1ab522363fddbb71d3ccdb18. See: https://github.com/ziglang/zig/issues/21911
2024-11-04test: Add aarch64_be-linux-(none,gnu,musl) to module tests.Alex Rønne Petersen
2024-11-04test: Disable 128-bit atomics behavior tests on aarch64_be.Alex Rønne Petersen
See: https://github.com/ziglang/zig/issues/21892