Commit Graph

4539 Commits

Author SHA1 Message Date
Veikka Tuominen
b2486fbc5e
Merge pull request #12121 from Vexu/span
Stage2 point to error location using spans
2022-07-16 12:22:53 +03:00
Veikka Tuominen
1463144fc8 Compilation: point caret in error message at the main token 2022-07-15 15:11:43 +03:00
Andrew Kelley
04572f6e34 Sema: fix coerceResultPtr
It did not handle properly when the dummy operand was a comptime_int; it
was crashing in coerce because comptime_int is supposed to be
comptime-known. So when calling coerceResultPtr, we pass the actual
operand, not a dummy operand, which means it will have the proper
comptime value when necessary.
2022-07-14 18:11:46 -07:00
Andrew Kelley
667ad9250f Sema: fix coerce_result_ptr in case of inferred result type
Previously, the logic for analyzing coerce_result_ptr would generate
invalid bitcast instructions which did not include coercion logic, such
as optional wrapping, resulting in miscompilations.

Now, the logic of resolve_inferred_alloc goes back over all the
placeholders inserted by coerce_result_ptr, and replaces them with logic
doing the proper coercions.

Closes #12045
2022-07-14 16:48:44 -07:00
Andrew Kelley
1653a9b259
Merge pull request #12098 from ziglang/llvm-riscv64
LLVM: implement signext/zeroext attributes
2022-07-13 19:15:19 -04:00
Andrew Kelley
fad95741db AstGen: fix loop control flow applying to wrong loop
In the case of 'continue' or 'break' inside the 'else' block of a
'while' or 'for' loop.

Closes #12109
2022-07-13 16:10:41 -07:00
Andrew Kelley
35e7011124 LLVM: implement signext/zeroext attributes
For calling convention ABI purposes, integer attributes and return
values need to have an LLVM attribute signext or zeroext added
sometimes. This commit implements that logic.

It also implements a proof-of-concept of moving the F16T type from
being a compiler_rt hack to being how the compiler lowers f16 in
functions that need to match certain calling conventions.

Closes #12054
2022-07-13 11:14:46 -07:00
Andrew Kelley
4a28c1d5c3 stage2: lower each struct field type, align, init separately
Previously, struct types, alignment values, and initialization
expressions were all lowered into the same ZIR body, which caused false
positive "depends on itself" errors when the initialization expression
depended on the size of the struct.

This also uses ResultLoc.coerced_ty for struct field alignment and
initialization values. The resulting ZIR encoding ends up being roughly
the same, neither smaller nor larger than previously.

Closes #12029
2022-07-13 02:38:13 -04:00
Luuk de Gram
8033767082
wasm-linker: Implement linker tests (#12006)
* test/link: initial wasm support

This adds basic parsing and dumping of wasm section so they
can be tested using the new linker-test infrastructure.

* test/link: all wasm sections parsing and dumping

We now parse and dump all sections for the wasm binary format.
Currently, this only dumps the name of a custom section.
Later this should also dump symbol table, name, linking metadata and relocations.
All of those live within the custom sections.

* Add wasm linker test

This also fixes a parser mistake in reading the flags.

* test/link: implement linker tests wasm & fixes

Adds several test cases to test the wasm self-hosted linker.
This also introduces fixes that were caught during the implementation
of those tests.

* test-runner: obey omit_stage2 for standalone

When a standalone test requires stage2, but stage2 is omit
from the compiler, such test case will not be included as part
of the test suite that is being ran. This is to support CI's
where we omit stage2 to lower the memory usage.
2022-07-12 14:36:33 +02:00
Andrew Kelley
7d2e142679
Merge pull request #12044 from Vexu/stage2-compile-errors
Sema: add detailed error notes to `coerceInMemoryAllowed`
2022-07-11 20:45:27 -04:00
Andrew Kelley
dc815e5e8f
Merge pull request #12075 from Vexu/stage2-validate-extern
Stage2 validate extern types
2022-07-11 20:25:35 -04:00
r00ster91
da75eb0d79
Compilation: indent multiline error messages properly
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-07-12 00:10:39 +03:00
Veikka Tuominen
122c76a167 Sema: allow void as an extern union field & fix invalid extern unions 2022-07-11 20:30:16 +03:00
Veikka Tuominen
d00da05ecb Sema: validate extern types 2022-07-11 18:47:29 +03:00
Veikka Tuominen
3ceb27c840 Sema: better explanation why opaque types require comptime 2022-07-11 18:47:29 +03:00
Veikka Tuominen
20d4f7213d Sema: add notes about function return type 2022-07-11 17:55:19 +03:00
Veikka Tuominen
c9e1360cdb Sema: add "cannot convert to payload type" error notes 2022-07-11 14:17:22 +03:00
Veikka Tuominen
0370006c1f Sema: only add note about int mismatch if not coercible
`unsigned 64-bit int cannot represent all possible unsigned 63-bit values`
is nonsensical.
2022-07-11 11:59:26 +03:00
Cody Tapscott
d182e2ebda stage1: Lower libcalls on Windows x86-64 correctly
This change is the Zig counterpart to https://reviews.llvm.org/D110413

Since we lower some libcalls directly (just like clang does), we need to
make sure that the ABI we call with matches the ABI of the compiler-rt
we are providing (and also the ABI expected by LLVM).

While I was at it, I noticed some flawed vector handling in the binary
soft float ops in stage 1, so I shored up the logic a bit and expanded
an existing test to cover the missing functionality.
2022-07-10 20:52:28 -07:00
Veikka Tuominen
34fe2b4f4b Sema: prefer original error message in coerce 2022-07-10 23:47:56 +03:00
Veikka Tuominen
b9f01bc394 Sema: add detailed error notes to coerceInMemoryAllowed 2022-07-10 23:15:17 +03:00
Andrew Kelley
b88151e0e1
Merge pull request #12001 from ziglang/llvm14
Upgrade to LLVM 14
2022-07-10 03:06:05 -04:00
Andrew Kelley
e0d5ae75af these riscv64 behavior tests work for stage1 but not stage2 2022-07-09 12:48:59 -07:00
Andrew Kelley
a1c56ffd5a disable regressed translate-c test case on freebsd
see #12055
2022-07-08 23:17:41 -07:00
Andrew Kelley
f976758855 disable failing riscv64 tests from LLVM 14 upgrade
See #12054
2022-07-08 23:11:03 -07:00
Cody Tapscott
c830606bbe stage2: Support @fieldParentPtr for tuples and anon structs 2022-07-08 19:52:23 -07:00
Cody Tapscott
51a8f52e6c stage2: Support @offsetOf for tuples and anon structs 2022-07-08 19:51:35 -07:00
Cody Tapscott
2fff25fd22 stage2: Support initializing anonymous struct type
This commit adds support for initializing `.anon_struct` types. There
is also some follow-up work to do for both tuples and structs regarding
comptime fields, so this also adds some tests to keep track of that
work.
2022-07-08 19:50:28 -07:00
Andrew Kelley
6a3a0fe7ae Merge remote-tracking branch 'origin/master' into llvm14 2022-07-07 18:25:01 -07:00
Cody Tapscott
cbc85f4516 stage1: Fix seg-fault when slicing string literal with sentinel 2022-07-08 02:14:38 +03:00
VÖRÖSKŐI András
75c33ba85e Sema: add a note about @setEvalBranchQuota() when branch quota is exceeded
closes #11996
2022-07-08 02:13:33 +03:00
Andrew Kelley
8e07b0c4b9 Merge remote-tracking branch 'origin/master' into llvm14 2022-07-07 14:01:54 -07:00
Andrew Kelley
0c78ece1c9
Merge pull request #12016 from Vexu/stage2-compile-errors
Stage2 compile error improvements
2022-07-07 14:52:28 -04:00
r00ster91
6f17be063d
std.log: give friendly error to freestanding users 2022-07-07 21:40:31 +03:00
emma
81bbefe9b8
AstGen: fix catch payoad not checking for shadowing 2022-07-07 21:38:32 +03:00
Veikka Tuominen
b5ac2b4330 Sema: improve array source location 2022-07-07 10:50:06 +03:00
Veikka Tuominen
27ee414159 Sema: improve slice source locations 2022-07-07 10:50:06 +03:00
Veikka Tuominen
89cef9f5f7 stage2: make line field of @src runtime known 2022-07-07 10:50:06 +03:00
Veikka Tuominen
226994cd7e Sema: misc error message fixes 2022-07-07 10:50:06 +03:00
Veikka Tuominen
c07c2d68c7 Sema: more runtime indexing comptime value checks 2022-07-07 10:50:06 +03:00
Veikka Tuominen
1569b9c165 Sema: validate pointer types 2022-07-07 10:50:05 +03:00
Veikka Tuominen
299836dbd9 Sema: panic at comptime + misc error message improvements 2022-07-07 10:50:05 +03:00
Andrew Kelley
1b610d7853 Merge remote-tracking branch 'origin/master' into llvm14 2022-07-06 17:55:05 -07:00
Andrew Kelley
c061b3a572 disable more standalone tests
these are tripping LLVM 13 assertions.

See #12015
See #12022
2022-07-06 15:10:41 -07:00
Andrew Kelley
6164801efb update install_raw_hex test case
LLVM 14 optimizes differently, so it's reasonable to have there be a
binary difference here.
2022-07-06 11:52:21 -07:00
Andrew Kelley
fa40bddf27 Merge remote-tracking branch 'origin/master' into llvm14 2022-07-06 02:40:05 -07:00
Andrew Kelley
aab1284e10 disable failing standalone test - tools/gen_spirv_spec.zig
Because it is tripping an LLVM 13 assertion.

See #12015
2022-07-06 02:39:28 -07:00
Andrew Kelley
d8fc8d0118 compiler_rt: work around LLVM optimizing __muloti4 to call itself
This is a workaround for
https://github.com/llvm/llvm-project/issues/56403
2022-07-05 21:28:39 -07:00
Andrew Kelley
558ad19095 disable regressed behavior tests from llvm 14
See #12012
See #12013
2022-07-05 18:50:03 -07:00
Andrew Kelley
9a5c7b4b4d Merge remote-tracking branch 'origin/master' into llvm14 2022-07-05 16:24:18 -07:00