aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/struct.zig
AgeCommit message (Collapse)Author
2022-02-28x64: pass more behavior testsJakub Konka
2022-02-27stage2 ARM: enable more behavior testsjoachimschmidt557
2022-02-26stage2: actually coerce in coerce_result_ptr at comptimeVeikka Tuominen
2022-02-25x64+aarch64: check for pointer to zero-bit type when lowering declJakub Konka
Unless the pointer is a pointer to a function, if the pointee type has zero-bits, we need to return `MCValue.none` as the `Decl` has not been lowered to memory, and therefore, any GOT reference will be wrong.
2022-02-23stage2: integer-backed packed structsAndrew Kelley
This implements #10113 for the self-hosted compiler only. It removes the ability to override alignment of packed struct fields, and removes the ability to put pointers and arrays inside packed structs. After this commit, nearly all the behavior tests pass for the stage2 llvm backend that involve packed structs. I didn't implement the compile errors or compile error tests yet. I'm waiting until we have stage2 building itself and then I want to rework the compile error test harness with inspiration from Vexu's arocc test harness. At that point it should be a much nicer dev experience to work on compile errors.
2022-02-23stage2 AArch64: more support for MCValue.got_load and direct_loadjoachimschmidt557
2022-02-22Port more behavior testsJakub Konka
2022-02-22Merge pull request #10959 from joachimschmidt557/stage2-aarch64Andrew Kelley
stage2 AArch64: misc improvements
2022-02-21stage2 AArch64: pass a few more behavior testsjoachimschmidt557
2022-02-20stage2: make field/array base ptr work at comptimeVeikka Tuominen
2022-02-20stage2: support anon init through error unions and optionals at runtimeVeikka Tuominen
2022-02-19stage2: support anon init through error unions and optionalsVeikka Tuominen
2022-02-15stage2: disable failing aarch64-macos behavior testsJakub Konka
2022-02-14stage2 AArch64: Enable behavior testingjoachimschmidt557
2022-02-12organize behavior testsAndrew Kelley
moving towards disabling failing tests on an individual basis
2022-02-08stage2 ARM: airStructFieldVal for more MCValuesjoachimschmidt557
2022-02-08stage2 ARM: support all integer types in genTypedValuejoachimschmidt557
2022-02-07stage2: pass more struct testsJakub Konka
2022-02-07stage2,arm: add lowering of unnamed constsJakub Konka
* implement `struct_field_ptr` when `MCValue == .stack_argument_offset` * enable simple `struct` test for ARM
2022-02-07stage2: lower unnamed constants in Elf and MachOJakub Konka
* link: add a virtual function `lowerUnnamedConsts`, similar to `updateFunc` or `updateDecl` which needs to be implemented by the linker backend in order to be used with the `CodeGen` code * elf: implement `lowerUnnamedConsts` specialization where we lower unnamed constants to `.rodata` section. We keep track of the atoms encompassing the lowered unnamed consts in a global table indexed by parent `Decl`. When the `Decl` is updated or destroyed, we clear the unnamed consts referenced within the `Decl`. * macho: implement `lowerUnnamedConsts` specialization where we lower unnamed constants to `__TEXT,__const` section. We keep track of the atoms encompassing the lowered unnamed consts in a global table indexed by parent `Decl`. When the `Decl` is updated or destroyed, we clear the unnamed consts referenced within the `Decl`. * x64: change `MCValue.linker_sym_index` into two `MCValue`s: `.got_load` and `.direct_load`. The former signifies to the emitter that it should emit a GOT load relocation, while the latter that it should emit a direct load (`SIGNED`) relocation. * x64: lower `struct` instantiations
2022-02-02stage2: pad out (non-packed) struct fields when lowering to bytesJakub Konka
* pad out (non-packed) struct fields when lowering to bytes to be saved in the binary - prior to this change, fields would be saved at non-aligned addresses leading to wrong accesses * add a matching test case to `behavior/struct.zig` tests * fix offset to field calculation in `struct_field_ptr` on `x86_64`
2022-02-02x86_64: pass more behaviour testsJakub Konka
2022-01-23c backend: Implement aligning fields and local/global variablesJimmi Holst Christensen
There are some restrictions here. - We either need C11 or a compiler that supports the aligned attribute - We cannot provide align less than the type's natural C alignment.
2022-01-17remove `zig_is_stage2` from `@import("builtin")`Andrew Kelley
Instead use the standarized option for communicating the zig compiler backend at comptime, which is `zig_backend`. This was introduced in commit 1c24ef0d0b09a12a1fe98056f2fc04de78a82df3.
2021-12-29compiler_rt: move more functions to the stage2 sectionAndrew Kelley
also move more already-passing behavior tests to the passing section.
2021-11-30put the passing stage2 behavior tests backAndrew Kelley
This mostly reverts commit 692c254336da71cbe21aaf9fbc21240fd1269b95. The test "for loop over pointers to struct, getting field from struct pointer" is still failing on the CI so that one is not moved over.
2021-11-30Revert "I found some more passing behavior tests"Andrew Kelley
This reverts commit 0a9b4d092f58595888f9e4be8ef683b2ed8a0da1. Hm, these are all passing for me locally. I'll have to do some troubleshooting to figure out which one(s) are failing on the CI.
2021-11-29I found some more passing behavior testsAndrew Kelley
2021-11-08C backend: while, struct tests, better undefined global handlingEmily Bellows
1. Function signatures that return a no member struct return void 2. Undefined var decls don't get a value generated for them 3. Don't generate bitcast code if the result isn't used, since bitcast is a pure function. Right now struct handling code generates some weird unused bitcast AIR, and this optimization side steps that issue.
2021-10-11stage2: support nested structs and arrays and sretAndrew Kelley
* Add AIR instructions: ret_ptr, ret_load - This allows Sema to be blissfully unaware of the backend's decision to implement by-val/by-ref semantics for struct/union/array types. Backends can lower these simply as alloc, load, ret instructions, or they can take advantage of them to use a result pointer. * Add AIR instruction: array_elem_val - Allows for better codegen for `Sema.elemVal`. * Implement calculation of ABI alignment and ABI size for unions. * Before appending the following AIR instructions to a block, resolveTypeLayout is called on the type: - call - return type - ret - return type - store_ptr - elem type * Sema: fix memory leak in `zirArrayInit` and other cleanups to this function. * x86_64: implement the full x86_64 C ABI according to the spec * Type: implement `intInfo` for error sets. * Type: implement `intTagType` for tagged unions. The Zig type tag `Fn` is now used exclusively for function bodies. Function pointers are modeled as `*const T` where `T` is a `Fn` type. * The `call` AIR instruction now allows a function pointer operand as well as a function operand. * Sema now has a coercion from function body to function pointer. * Function type syntax, e.g. `fn()void`, now returns zig tag type of Pointer with child Fn, rather than Fn directly. - I think this should probably be reverted. Will discuss the lang specs before doing this. Idea being that function pointers would need to be specified as `*const fn()void` rather than `fn() void`. LLVM backend: * Enable calling the panic handler (previously this just emitted `@breakpoint()` since the backend could not handle the panic function). * Implement sret * Introduce `isByRef` and implement it for structs and arrays. Types that are `isByRef` are now passed as pointers to functions, and e.g. `elem_val` will return a pointer instead of doing a load. * Move the function type creating code from `resolveLlvmFunction` to `llvmType` where it belongs; now there is only 1 instance of this logic instead of two. * Add the `nonnull` attribute to non-optional pointer parameters. * Fix `resolveGlobalDecl` not using fully-qualified names and not using the `decl_map`. * Implement `genTypedValue` for pointer-like optionals. * Fix memory leak when lowering `block` instruction and OOM occurs. * Implement volatile checks where relevant.
2021-10-07stage2: fix returning structs byval from functionsAndrew Kelley
2021-09-29stage2: LLVM backend: implement struct type fwd declsAndrew Kelley
Makes struct types able to refer to themselves.
2021-09-25stage2: implement zirCoerceResultPtrAndrew Kelley
and remove Module.simplePtrType and Module.ptrType in favor of `Type.ptr`.
2021-09-25stage2: implement `@sizeOf` for non-packed structsAndrew Kelley
2021-09-22stage2: fix AstGen for some struct syntaxesAndrew Kelley
* AstGen: fix not emitting `struct_init_empty` when an explicit type is present in struct initialization syntax. * AstGen: these two syntaxes now lower to identical ZIR: - `var a = A{ .b = c };` - `var a = @as(A, .{ .b = c });` * Zir: clarify `auto_enum_tag` in the doc comments. * LLVM Backend: fix lowering of function return types when the type has 0 bits.
2021-08-24stage1: remove incorrect compile error for var redeclarationAndrew Kelley
Locals are not allowed to shadow declarations, but declarations are allowed to shadow each other, as long as there are no ambiguous references. closes #678
2021-06-21fix code broken from previous commitJacob G-W
2021-06-21std, src, doc, test: remove unused variablesJacob G-W
2021-06-12Renamed @byteOffsetOf to @offsetOfExonorid
2021-05-08Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
Conflicts: * doc/langref.html.in * lib/std/enums.zig * lib/std/fmt.zig * lib/std/hash/auto_hash.zig * lib/std/math.zig * lib/std/mem.zig * lib/std/meta.zig * test/behavior/alignof.zig * test/behavior/bitcast.zig * test/behavior/bugs/1421.zig * test/behavior/cast.zig * test/behavior/ptrcast.zig * test/behavior/type_info.zig * test/behavior/vector.zig Master branch added `try` to a bunch of testing function calls, and some lines also had changed how to refer to the native architecture and other `@import("builtin")` stuff.
2021-04-29move behavior tests from test/stage1/ to test/Andrew Kelley
And fix test cases to make them pass. This is in preparation for starting to pass behavior tests with self-hosted.