aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/struct.zig
AgeCommit message (Collapse)Author
2024-05-11riscv: add stage2_riscv to test matrix and bypass failing testsDavid Rubin
2024-03-30Update uses of `@fieldParentPtr` to use RLSJacob Young
2024-03-30Sema: rework `@fieldParentPtr` to accept a pointer typeJacob Young
There is no way to know the expected parent pointer attributes (most notably alignment) from the type of the field pointer, so provide them in the first argument.
2024-03-06behavior: add tests for #18816mlugg
2024-02-15test: skip new failing tests for spirvAli Chraghi
2024-02-15llvm: fix lowering of recursive debug infoJacob Young
This change allows recursing over types that are currently being resolved fully with a second pass of forward resolution. Closes #16414
2024-02-04spirv: update testsRobin Voetter
2024-01-15test/behavior: replace all 'comptime expect' with 'comptime assert'dweiller
2024-01-06categorize `behavior/bugs/<issueno>.zig` testsVeikka Tuominen
2023-11-25Sema: ensure tuple fields is resolved and fix internal out-of-bounds accessBogdan Romanyuk
2023-11-24spirv: disable failing testsRobin Voetter
2023-11-19test: update behavior to silence 'var is never mutated' errorsmlugg
2023-11-08Sema: do not force resolution of struct field inits when calling function ↵mlugg
pointer field b3462b7 caused a regression in a third-party project, since it forced resolution of field initializers for any field call 'foo.bar()', despite this only being necessary when 'bar' is a comptime field. See https://github.com/ziglang/zig/pull/17692#issuecomment-1802096734.
2023-11-07sema: analyze field init bodies in a second passkcbanner
This change allows struct field inits to use layout information of their own struct without causing a circular dependency. `semaStructFields` caches the ranges of the init bodies in the `StructType` trailing data. The init bodies are then resolved by `resolveStructFieldInits`, which is called before the inits are actually required. Within the init bodies, the struct decl's instruction is repurposed to refer to the field type itself. This is to allow us to easily rebuild the inst_map mapping required for the init body instructions to refer to the field type. Thanks to @mlugg for the guidance on this one!
2023-11-01wasm: re-enable regressed testsLuuk de Gram
2023-10-31mem: fix ub in writeIntJacob Young
Use inline to vastly simplify the exposed API. This allows a comptime-known endian parameter to be propogated, making extra functions for a specific endianness completely unnecessary.
2023-10-29Fix hasRuntimeBitsAdvanced lazy case for pointers and optionals DilithiumNitrate
As suggested by mlugg, always returns `error.NeedLazy`. If this has a performance impact, it could be replaced by adding lazy handling to `comptimeOnlyAdvanced`.
2023-10-23Revert "Revert "Merge pull request #17657 from Snektron/spirv-recursive-ptrs""Robin Voetter
This reverts commit 9f0359d78f9facc38418e32b0e8c1bf6f99f0d26 in an attempt to make the tests pass again. The CI failure from that merge should be unrelated to this commit.
2023-10-22Revert "Merge pull request #17657 from Snektron/spirv-recursive-ptrs"Andrew Kelley
This reverts commit b822e841cda0adabe3fec260ff51c18508f7ee32, reversing changes made to 0c99ba1eab63865592bb084feb271cd4e4b0357e. This caused a CI failure when it landed in master branch.
2023-10-21spirv: self-referential pointers via new fwd_ptr_typeRobin Voetter
Its a little ugly but it works.
2023-10-21spirv: improve union operationsRobin Voetter
This removes the strategy where union with different active fields would be generated, and instead simply pointer casts the active field type where required. This also allows removing spv.ptrType and using self.ptrType instead, and allows caching all union types (because there is only the canonical one).
2023-10-15spirv: update failing / passing testsRobin Voetter
Some tests are now failing due to debug info changes, some tests now pass due to improved compiler functionality.
2023-10-15std.testing: disable expectEqualSlices printing for spirvRobin Voetter
2023-10-15spirv: properly skip comptime function parametersRobin Voetter
2023-10-15spirv: aggregate_init for structsRobin Voetter
2023-10-14tests: enable already passing behaviour tests for self-hosted wasmXavier Bouchoux
1611 passed; 262 skipped; 0 failed. (was: 1543 passed; 330 skipped; 0 failed.)
2023-10-01x86_64: implement float compare and cast builtinsJacob Young
2023-09-25type: handle the 0-length array case in abiSizeAdvancedkcbanner
This fixes a panic in `unionAbiSize` when a 0-length array of a union is used as a struct field. Because `resolveTypeLayout` does not resolve the `elem_ty` if `arrayLenIncludingSentinel` returns 0 for the array, the child union type is not guaranteed to have a resolved layout at this point. Fixed this case by just returning 0 here.
2023-09-23compiler: preserve result type information through address-of operatormlugg
This commit introduces the new `ref_coerced_ty` result type into AstGen. This represents a expression which we want to treat as an lvalue, and the pointer will be coerced to a given type. This change gives known result types to many expressions, in particular struct and array initializations. This allows certain casts to work which previously required explicitly specifying types via `@as`. It also eliminates our dependence on anonymous struct types for expressions of the form `&.{ ... }` - this paves the way for #16865, and also results in less Sema magic happening for such initializations, also leading to potentially better runtime code. As part of these changes, this commit also implements #17194 by disallowing RLS on explicitly-typed struct and array initializations. Apologies for linking these changes - it seemed rather pointless to try and separate them, since they both make big changes to struct and array initializations in AstGen. The rationale for this change can be found in the proposal - in essence, performing RLS whilst maintaining the semantics of the intermediary type is a very difficult problem to solve. This allowed the problematic `coerce_result_ptr` ZIR instruction to be completely eliminated, which in turn also simplified the logic for inferred allocations in Sema - thanks to this, we almost break even on line count! In doing this, the ZIR instructions surrounding these initializations have been restructured - some have been added and removed, and others renamed for clarity (and their semantics changed slightly). In order to optimize ZIR tag count, the `struct_init_anon_ref` and `array_init_anon_ref` instructions have been removed in favour of using `ref` on a standard anonymous value initialization, since these instructions are now virtually never used. Lastly, it's worth noting that this commit introduces a slightly strange source of generic poison types: in the expression `@as(*anyopaque, &x)`, the sub-expression `x` has a generic poison result type, despite no generic code being involved. This turns out to be a logical choice, because we don't know the result type for `x`, and the generic poison type represents precisely this case, providing the semantics we need. Resolves: #16512 Resolves: #17194
2023-09-23spirv: enable passing testsRobin Voetter
2023-09-23spirv: disable failing testsRobin Voetter
2023-08-11Sema: avoid deleting runtime side-effects in comptime initializersJacob Young
Closes #16744
2023-08-09AstGen: handle `ty` result location for struct and array init correctlymlugg
Well, this was a journey! The original issue I was trying to fix is covered by the new behavior test in array.zig: in essence, `ty` and `coerced_ty` result locations were not correctly propagated. While fixing this, I noticed a similar bug in struct inits: the type was propagated to *fields* fine, but the actual struct init was unnecessarily anonymous, which could lead to unnecessary copies. Note that the behavior test added in struct.zig was already passing - the bug here didn't change any easy-to-test behavior - but I figured I'd add it anyway. This is a little harder than it seems, because the result type may not itself be an array/struct type: it could be an optional / error union wrapper. A new ZIR instruction is introduced to unwrap these. This is also made a little tricky by the fact that it's possible for result types to be unknown at the time of semantic analysis (due to `anytype` parameters), leading to generic poison. In these cases, we must essentially downgrade to an anonymous initialization. Fixing these issues exposed *another* bug, related to type resolution in Sema. That issue is now tracked by #16603. As a temporary workaround for this bug, a few result locations for builtin function operands have been disabled in AstGen. This is technically a breaking change, but it's very minor: I doubt it'll cause any breakage in the wild.
2023-07-31std: finish cleanup up asmJacob Young
This also required implementing the necessary syntax in the x86_64 backend.
2023-07-31cbe: get behavior tests running on armJacob Young
Specifically without linking libc.
2023-07-10Sema: resolve field type layout for anon struct type infoIan Johnson
Closes #16148
2023-06-30Unrevert "Sema: preserve extern struct field alignment"Jacob Young
This unreverts commit 1a2468abfcd8b539193d943c1eefb71319cc7b88.
2023-06-30Remerge pull request #15995 from mlugg/fix/union-field-ptr-alignJacob Young
Sema: copy pointer alignment to union field pointers This is an unrevert of 43c98dc11567eeb38be041c7dad179c53156f3df.
2023-06-30Sema: copy pointer alignment to struct field pointersmlugg
2023-06-29Revert "Merge pull request #15995 from mlugg/fix/union-field-ptr-align"Jacob Young
This reverts commit 40cf3f7ae5fbfb84b7af6b27e6296ee858b209ef, reversing changes made to d98147414d084bc41b00ba9c0be8c7b82ad4e76c.
2023-06-29Revert "Sema: preserve extern struct field alignment"Jacob Young
This reverts commit 4620972d086ebb3b7686a79914876488c6dfd171.
2023-06-28Sema: preserve extern struct field alignmentAlex Kladov
In extern struct { x: u32, y: u16 } we actually know that y's alignment is `@alignOf(u32)`, and not just `@alignOf(u16)`. closes: #16134
2023-06-26Merge pull request #15771 from jacobly0/x86_64-behaviorjacobly0
x86_64: behavior
2023-06-25x86_64: truncate packed field valueJacob Young
2023-06-25x86_64: fix global pointers to packed struct fieldsJacob Young
2023-06-25x86_64: fix packed store crashJacob Young
2023-06-25Sema: copy pointer alignment to struct field pointersmlugg
2023-06-24all: migrate code to new cast builtin syntaxmlugg
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-19all: zig fmt and rename "@XToY" to "@YFromX"Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13all: replace `comptime try` with `try comptime`Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>