Commit graph

144 commits

Author SHA1 Message Date
Robin Voetter
65157d30ab
spirv: ptr_elem_val
Implements the ptr_elem_val air tag. Implementation is unified
with ptr_elem_ptr.
2023-05-20 17:30:23 +02:00
Robin Voetter
37aa343079
spirv: more passing tests 2023-05-20 17:30:22 +02:00
Andrew Kelley
ad391ad399 Revert "Sema: handle recursive inferred errors better in analyzeIsNonErrComptimeOnly"
This reverts commit 5aa9628de3.

This is a breaking language change and I do not agree with it. Please go
through the proposal process on this one.
2023-05-18 16:24:07 -07:00
Ali Chraghi
9c550721e4 spirv: lower float_to_int and int_to_float 2023-05-15 03:04:17 +03:30
Veikka Tuominen
68bacad804
Merge pull request #15643 from Vexu/fixes
make `@call` compile errors match regular calls
2023-05-13 12:52:16 +03:00
Veikka Tuominen
5aa9628de3 Sema: handle recursive inferred errors better in analyzeIsNonErrComptimeOnly
Closes #15669
2023-05-12 14:59:26 +03:00
Ali Chraghi
ccc490ef68
setup spirv backend in behavior tests 2023-05-11 20:31:52 +02:00
Jacob Young
1c53f0a6b0 Dwarf: workaround crash 2023-05-08 07:36:20 -04:00
Jacob Young
5900dc0580 x86_64: fix typos 2023-04-03 18:02:55 +02:00
Jacob Young
83a208c355 x86_64: implement large cmp 2023-04-02 04:49:53 -04:00
Jacob Young
677427bc3a x86_64: implement error name 2023-04-02 04:49:53 -04:00
Jacob Young
3f4569bf18 codegen: fix backend breakage due to optional layout change 2023-03-21 08:49:54 +01:00
Jacob Young
f95faac5ae x86_64: (re)implement optional ops
Note that this commit also changes the layout of optional for all
other backends using `src/codegen.zig` without updating them!
2023-03-21 08:49:54 +01:00
Jacob Young
24f0900ecb x86_64: implement some error union ops 2023-03-21 08:49:54 +01:00
Jacob Young
c51930b060 behavior: enable passing behavior tests on stage2_x86_64 2023-03-15 01:04:21 -04:00
Ryan Liptak
9db084f43d Add test for optional error set return types
Closes #5820
2023-02-03 14:48:08 +02:00
joachimschmidt557
09122650ba stage2 AArch64: bump up alignment of stack items fitting in regs
This enables us to use more efficient loading and storing for these
small stack items
2023-01-03 19:56:09 +01:00
joachimschmidt557
1caf56c5fb stage2 AArch64: implement errUnion{Err,Payload} for registers 2022-12-29 11:12:08 +01:00
Andrew Kelley
f4b067743f add behavior test for optional error union return type
closes #1814
2022-12-27 13:46:57 -07:00
joachimschmidt557
d6e6162081
stage2 AArch64: unify callee-preserved regs on all targets
also enables many passing behavior tests
2022-12-27 21:17:52 +08:00
Andrew Kelley
6018a3ad39 add behavior test for empty error set inference
closes #1386
closes #7541
2022-12-18 18:37:12 -07:00
Koakuma
f9e9ba784f stage2: sparc64: Skip unimplemented tests 2022-12-10 21:51:46 +07:00
Andrew Kelley
c8aba15c22 remove references to stage1 in behavior tests
Good riddance.
2022-12-06 19:06:48 -07:00
Veikka Tuominen
5d28d171df Sema: adjust result type of anyerror field access
Closes #13448
2022-11-05 13:22:21 +02:00
Jacob Young
8b6a3ba74e cbe: fix typedef declaration order 2022-10-25 05:11:29 -04:00
Jacob Young
525dcaecba behavior: enable stage2_c tests that are currently passing
Also fix C warnings triggered by these tests.
2022-10-25 05:11:28 -04:00
Jacob Young
6f3654ad69 c: implement @errorName 2022-10-25 05:11:28 -04:00
Jacob Young
c8d0e71de6 c: fix mangling of error names
Closes #12751
2022-10-25 05:11:28 -04:00
Cody Tapscott
d060cbbec7 stage2: Keep error return traces alive when storing to const
This change extends the "lifetime" of the error return trace associated
with an error to continue throughout the block of a `const` variable
that it is assigned to.

This is necessary to support patterns like this one in test_runner.zig:
```zig
const result = foo();
if (result) |_| {
    // ... success logic
} else |err| {
    // `foo()` should be included in the error trace here
    return error.TestFailed;
}
```

To make this happen, the majority of the error return trace popping logic
needed to move into Sema, since `const x = foo();` cannot be examined
syntactically to determine whether it modifies the error return trace. We
also have to make sure not to delete pertinent block information before it
makes it to Sema, so that Sema can pop/restore around blocks correctly.

* Why do this only for `const` and not `var`? *

There is room to relax things for `var`, but only a little bit. We could
do the same thing we do for const and keep the error trace alive for the
remainder of the block where the *assignment* happens. Any wider scope
would violate the stack discipline for traces, so it's not viable.

In the end, I decided the most consistent behavior for the user is just
to kill all error return traces assigned to a mutable `var`.
2022-10-21 12:40:29 -07:00
Veikka Tuominen
b316c25cc6
Merge pull request #13075 from Vexu/stage2-fixes
Stage2 misc fixes
2022-10-10 23:27:17 +02:00
Veikka Tuominen
4a6cc1c602 Sema: allow equality comparisons between error unions and error sets
Closes #1302
2022-10-07 11:04:02 +03:00
Veikka Tuominen
0b1dd845d9 stage2: add error for non-void error union payload being ignored
See https://github.com/ziglang/zig/pull/6060#discussion_r471032912
2022-10-06 15:39:06 +03:00
Koakuma
2263bba6cd stage2: sparc64: Skip Sema-failing tests for now 2022-09-14 16:57:31 -07:00
joachimschmidt557
261fec8036
stage2 ARM: amend implementation of various AIR instructions
- unwrap_errunion_err for registers
- unwrap_errunion_payload for registers
- ptr_slice_len_ptr for all MCValues
- ptr_slice_ptr_ptr for all MCValues
2022-09-09 19:17:17 +02:00
Andrew Kelley
d2ad8afff4 LLVM: fix missing alignment on wrapping instructions
Previously, when lowering AIR instructions `wrap_errunion_payload`,
`wrap_errunion_err`, and `wrap_optional`, the LLVM backend would create
an alloca instruction to store the result, but did not set the alignment
on it. This caused UB which went undetected for a long time until we
started enabling the stack protector.

Closes #12594
Unblocks #12508
Inspires #12634

Tests passed locally:
 * test-behavior
 * test-cases
2022-08-25 16:15:48 -07:00
Veikka Tuominen
b55a5007fa Sema: fix parameter of type 'T' must be comptime error
Closes #12519
Closes #12505
2022-08-22 11:16:36 +03:00
Veikka Tuominen
b0a55e1b3b Sema: make noreturn error union behave correctly 2022-08-17 20:10:18 +03:00
Veikka Tuominen
03b1fbe50d stage2: fix airIsErr when is_ptr == true 2022-07-22 21:07:55 +03:00
Andrew Kelley
c3ae909e93 Revert "AstGen: preserve inferred ptr result loc for breaks"
This reverts commit 8bf3e1f8d0, which
introduced miscompilations for peer expressions any time they needed
coercions to runtime types.

I opened #11957 as a proposal to accomplish the goal of the reverted
commit.

Closes #11898
2022-06-28 18:38:25 -07:00
joachimschmidt557
960c142060 stage2 ARM: implement basic intCast and error union wrapping 2022-06-25 21:16:51 +02:00
Veikka Tuominen
0333ff4476 stage2: make error{} the same size as anyerror
Having `error{}` be a zero bit type causes issues when it interracts
with empty inferred error sets which are the same size as `anyerror`.
2022-06-11 23:49:33 +03:00
Veikka Tuominen
e4c0b848a4 Sema: allow simple else body even when all errors handled 2022-06-07 21:27:06 +03:00
Veikka Tuominen
d5e3d5d74c Sema: make analyzeIsNonErr even lazier for inferred error sets 2022-06-07 21:27:06 +03:00
joachimschmidt557
ddd5b57045 stage2 AArch64: complete genTypedValue 2022-05-27 16:43:11 -04:00
Andrew Kelley
1f16b07d6f stage2: treat error{}!void as a zero-bit type 2022-05-24 17:53:04 -07:00
Andrew Kelley
c711c788f0 stage2: fixes for error unions, optionals, errors
* `?E` where E is an error set with only one field now lowers the same
   as `bool`.
 * Fix implementation of errUnionErrOffset and errUnionPayloadOffset to
   properly compute the offset of each field. Also name them the same
   as the corresponding LLVM functions and have the same function
   signature, to avoid confusion. This fixes a bug where wasm was
   passing the error union type instead of the payload type.
 * Fix C backend handling of optionals with zero-bit payload types.
 * C backend: separate out airOptionalPayload and airOptionalPayloadPtr
   which reduces branching and cleans up control flow.
 * Make Type.isNoReturn return true for error sets with no fields.
 * Make `?error{}` have only one possible value (null).
2022-05-24 15:34:52 -07:00
joachimschmidt557
c847a462ae stage2 ARM: update to new union layout 2022-05-24 15:34:52 -07:00
Jakub Konka
8c49420928 aarch64: update for new error union layout 2022-05-24 15:34:52 -07:00
Jakub Konka
c043d57cab x64,arm,aarch64: omit unsupported tests for now 2022-05-24 15:34:52 -07:00
Andrew Kelley
02e9d9b43b stage2: make ?anyerror represented the same as anyerror
I was able to get the backend implementation working on LLVM and the C
backend, but I'm going to ask for some help on the other backends.
2022-05-24 15:34:52 -07:00