4360 Commits

Author SHA1 Message Date
Veikka Tuominen
ee651c3cd3 Revert "reserve correct space for bitfields"
This reverts commit 22cb6938891c73d64b749a2516c8eaf79aa25b03.
2022-05-29 12:04:50 +03:00
TwoClocks
22cb693889 reserve correct space for bitfields 2022-05-28 17:31:26 +03:00
joachimschmidt557
ddd5b57045 stage2 AArch64: complete genTypedValue 2022-05-27 16:43:11 -04:00
Andrew Kelley
4994ac18e4
Merge pull request #11733 from Vexu/stage2
more misc stage2 fixes
2022-05-27 16:20:49 -04:00
Veikka Tuominen
989c0f55e8 stage2: add test for fixed issue 2022-05-27 10:29:24 +03:00
Veikka Tuominen
8bf3e1f8d0 AstGen: preserve inferred ptr result loc for breaks 2022-05-27 10:29:24 +03:00
Veikka Tuominen
e08cdad53b Sema: add error for runtime indexing comptime array 2022-05-27 10:29:15 +03:00
Andrew Kelley
83a2c41cd5 fix alignment behavior test case
As demonstrated by this new test case, stage1's functionality is
incorrect since it does not handle slicing from len..len correctly.

stage2 already has the correct behavior here.
2022-05-26 21:58:19 -07:00
Andrew Kelley
4751356d7f clean up some behavior tests
* improve names
 * properly categorize a couple of bug cases
 * mark one as already passing
2022-05-26 21:58:19 -07:00
Jakub Konka
5ce9c878cf apply Vexu's suggestion to use failing_allocator for now 2022-05-26 16:55:31 +02:00
Jakub Konka
d1e4600675 test: correctly track identical error msgs in handled errors list
Prior to this change, for an example compiler error test case with
multiple identical errors messages such as

```
:1:2: error: foo
:1:2: error: foo
```

the test harness would never increment the error index thus only
marking the very first error message as handled yielding a false
positive.

Additionally, while here, regress `dereference_anyopaque` test case
as not passing on `wasm32-wasi` target.
2022-05-26 16:23:56 +02:00
Veikka Tuominen
92c4e4f2c2 Sema: zirArrayType does need source location 2022-05-26 13:26:55 +03:00
Andrew Kelley
83f69af971 stage2: implement runtime array multiplication
Additionally:

 * Sema: fix array cat/mul not setting the sentinel value
   - This required an LLVM backend enhancement to the handling of the
     AIR instruction aggregate_init that likely needs to be
     propagated to the other backends.
 * Sema: report integer overflow of array concatenation in a proper
   compile error instead of crashing.
 * Sema: fix not using proper pointer address space for array cat/mul
2022-05-25 22:33:48 -07:00
Andrew Kelley
b82081e709 Sema: implement array concatenation with runtime operands 2022-05-25 22:33:48 -07:00
Andrew Kelley
ab88165326 Sema: generic function instantiations inherit branch quota 2022-05-25 23:32:52 -04:00
Veikka Tuominen
f409d925ad Sema: check for generic poison in resolveInst 2022-05-25 23:11:13 +03:00
Veikka Tuominen
eba66f4a58 Sema: handle block.is_typeof in more places 2022-05-25 19:57:44 +03:00
Veikka Tuominen
d214b6bdf0 stage2: packed struct fields do not have a byte offset 2022-05-25 19:57:38 +03:00
Veikka Tuominen
b0e8bf15f5 Sema: add error for dereferencing comptime value at runtime 2022-05-25 17:39:55 +03:00
Andrew Kelley
71e2a56e3e mark some more behavior tests as passing 2022-05-25 00:12:56 -07:00
Andrew Kelley
60af42705d mark two behavior tests as passing 2022-05-24 18:21:34 -07: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
7db39384f7 move bound function behavior test to compile error test 2022-05-24 15:34:52 -07:00
Andrew Kelley
1bf7a6dff5 enable passing behavior test
This was disabled for macOS but I just tested it on my M1 and it works
fine.
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
Luuk de Gram
3a059ebe4c wasm: Fixes for error union semantics 2022-05-24 15:34:52 -07:00
Andrew Kelley
3264abe3d8 stage2: fixes for error union semantics
* Sema: avoid unnecessary safety checks when an error set is empty.
 * Sema: make zirErrorToInt handle comptime errors that are represented
   as integers.
 * Sema: make empty error sets properly integrate with
   typeHasOnePossibleValue.
 * Type: correct the ABI alignment and size of error unions which have
   both zero-bit error set and zero-bit payload. The previous code did
   not account for the fact that we still need to store a bit for
   whether there is an error.
 * LLVM: lower error unions possibly with the payload first or with the
   error code first, depending on alignment. Previously it always put
   the error code first and used a padding array.
 * LLVM: lower functions which have an empty error set as the return
   type the same as anyerror, so that they can be used where
   fn()anyerror function pointers are expected. In such functions, Zig
   will lower ret to returning zero instead of void.

As a result, one more behavior test is passing.
2022-05-24 15:34:52 -07: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
Andrew Kelley
818fbd9c56 stage2: string literal interning
This is a temporary addition to stage2 in order to match stage1 behavior,
however the end-game once the lang spec is settled will be to use a global
InternPool for comptime memoized objects, making this behavior consistent
across all types, not only string literals. Or, we might decide to not
guarantee string literals to have equal comptime pointers, in which case
this commit can be reverted.
2022-05-24 01:01:24 -07:00
Andrew Kelley
b64a1d5abb
Merge pull request #11684 from ziglang/fix-10318
Set macOS/iPhoneOS/tvOS/watchOS ABI to none (unspecified) by default
2022-05-22 19:29:42 -04:00
joachimschmidt557
b56b4428a3 stage2 ARM: fix recursive fibonacci
Some handling of register_c_flag/register_v_flag was incorrect.
2022-05-22 21:02:32 +02:00
Jakub Konka
f8a1a2c4a1 stage2: append min version to target triple when lowering to LLVM 2022-05-22 17:45:07 +02:00
Andrew Kelley
1a92264b3d
Merge pull request #11671 from ziglang/stage2-behavior
stage2 bug fixes aimed towards more behavior tests passing
2022-05-20 18:35:19 -04:00
Andrew Kelley
fcd4efd8ec Sema: introduce laziness to @sizeOf
Motivation: the behavior test that is now passing.

The main change in this commit is introducing `Type.abiSizeAdvanced`,
`Value.Tag.lazy_size`, and adjusting `Sema.zirSizeOf` to take advantage
of these.

However, the bulk of lines changed in this commit ended up being moving
logic from value.zig and type.zig into Sema.zig. This logic had no
business being in Type/Value as it was only called from a Sema context,
and we need access to the Sema context for error reporting when a lazy
Value is resolved.

Also worth mentioning is that I bumped up the comptime `@floatToInt`
implementation from using f64 to f128.
2022-05-20 02:47:20 -07:00
Andrew Kelley
cd04b49041 stage2: fix @call when used in a comptime or nosuspend block
`@call` allows specifying the modifier explicitly, however it can still
appear in a context that overrides the modifier. This commit adds flags
to the BuiltinCall ZIR encoding. Since we have unused bits I also threw
in the ensure_result_used mechanism.

I also deleted a behavior test that was checking for bound function
behavior where I think stage2 behavior is correct and stage1 behavior
is incorrect.
2022-05-20 02:47:20 -07:00
Andrew Kelley
5626bb45d2 Sema: fix comptime @floatCast downcast 2022-05-20 02:47:20 -07:00
Jakub Konka
6d32498c55 x64: re-enable behavior tests 2022-05-19 19:39:34 +02:00
Jakub Konka
36b939e8db x64: handle basic f32 using AVX registers 2022-05-19 19:39:34 +02:00
Andrew Kelley
50a5ddecc5
Merge pull request #11635 from wsengir/stage2-errsetcast-safety
stage2: `@errSetCast` safety
2022-05-18 16:35:37 -04:00
Andrew Kelley
9031cc54f2 Sema: implement @intCast for vectors 2022-05-17 23:50:38 -07:00
Andrew Kelley
691fba38d8 enable passing behavior test 2022-05-17 23:50:38 -07:00
Andrew Kelley
b6798c26ef stage2: fix pointer arithmetic result type
This makes it so the result of doing pointer arithmetic creates a new
pointer type that has adjusted alignment.
2022-05-17 23:50:38 -07:00
Andrew Kelley
95f5e17e49 behavior tests: correction of C pointer test
This test was also covering this behavior:

```zig
test "equality of pointers to comptime const" {
    const a: i32 = undefined;
    comptime assert(&a == &a);
}
```

This check belongs in its own behavior test which isolates this
behavior; not bundled along with a C pointer test.
2022-05-17 23:50:38 -07:00
Andrew Kelley
00f3d84f38 LLVM: support mixing extern and export with the same symbol name 2022-05-17 23:50:38 -07:00
Luuk de Gram
e252f92b99 wasm: enable 128bit integer behavior tests 2022-05-18 07:43:33 +02:00
Jakub Konka
a0de0adb8e arm: disable recursive fibonacci 2022-05-16 13:55:26 -07:00