Commit Graph

5361 Commits

Author SHA1 Message Date
Jakub Konka
bb62d5105c
Merge pull request #14049 from ziglang/issue-14045
macho+zld: write code signature padding before committing load commands
2022-12-23 19:07:36 +01:00
Jakub Konka
2cb6db2219 link-tests: add macho strict validation test
Support more operators when running simple arithmetic tests, and
allow for int literals in the program spec.
2022-12-23 14:02:52 +01:00
Andrew Kelley
f211c1559a
Merge pull request #13960 from r00ster91/stage1cruft
Close more old stage1 issues
2022-12-22 16:36:55 -05:00
r00ster91
a429f72ae8 cases: more test coverage
Closes #11986
Closes #11850
Closes #12159
2022-12-21 23:34:29 +01:00
r00ster91
5ecc2b99af behavior: more test coverage
Closes #12450
Closes #13113
Closes #12051
Closes #12092
Closes #12119
Closes #12142
Closes #12450
Closes #13113
Closes #11995
Closes #12000
2022-12-21 23:34:22 +01:00
Jacob Young
a52dcdd3c5 CBE: fix bitwise not
Closes #13911
2022-12-21 03:04:59 -05:00
Veikka Tuominen
e1345fd0a0
Merge pull request #14004 from Vexu/packed-struct-vector
llvm: handle vectors in packed structs
2022-12-20 23:13:36 +02:00
Veikka Tuominen
9f23702c21 llvm: fix C ABI for <=256 bit vectors
Closes #13918
2022-12-20 18:34:33 +02:00
Veikka Tuominen
6da070c5ac Sema: fix crash with generic function with generic function parameter
Closes #12810
2022-12-20 17:32:04 +02:00
Andrew Kelley
0fb53bd245
Merge pull request #14000 from jacobly0/zero-bit-fields
codegen: fix taking the address of a field in a zero-bit struct
2022-12-19 15:47:31 -05:00
Veikka Tuominen
6511afcfe0 Sema: fix coercion from [:0]T to [*c]T 2022-12-19 20:45:53 +02:00
Veikka Tuominen
22d46e1d77 value: use int tag type when querying for tag value
Closes #13757
2022-12-19 15:08:49 +02:00
Jacob Young
0768115b01 behavior: disable failing test
Also add an assert to catch this issue earlier.  For future reference,
the decl without a type and value is the string literal "GET".
2022-12-19 05:59:45 -05:00
Veikka Tuominen
2926d95e6a llvm: handle vectors in packed structs
Closes #13201
2022-12-19 12:19:52 +02:00
Veikka Tuominen
0eddf0cbc0 Sema: fix condition for non-pointer noalias error
Closes #13987
2022-12-19 12:19:25 +02:00
Ryan Liptak
3db8cffa3b spawnWindows: Fix PATH searching when cwd is absolute
Fixes a regression caused by https://github.com/ziglang/zig/pull/13983

From the added comment:

We still search the path if the cwd is absolute because of the
"cwd set in ChildProcess is in effect when choosing the executable path
to match posix semantics" behavior--we don't want to skip searching
the PATH just because we were trying to set the cwd of the child process.
2022-12-19 04:12:46 -05:00
Jacob Young
0e3feebb04 codegen: fix taking the address of a zero-bit field in a zero-bit struct
Normally when we want a pointer to the end of a struct we just add 1 to
the struct pointer.  However, when it is a zero-bit struct, the pointer
type being used during lowering is often a dummy pointer type that
actually points to a non-zero-bit type, so we actually want to add 0
instead, since a zero-bit struct begins and ends at the same address.
2022-12-18 22:11:26 -05:00
Jacob Young
e96f65db77 llvm: fix lowering pointer to final zero-width field of a comptime value
* Handle a `null` return from `llvmFieldIndex`.
 * Add a behavior test to test this code path.
 * Reword this test name, which incorrectly described how pointers to
   zero-bit fields behave, and instead describe the actual test.
2022-12-18 22:11:26 -05:00
Andrew Kelley
6018a3ad39 add behavior test for empty error set inference
closes #1386
closes #7541
2022-12-18 18:37:12 -07:00
Andrew Kelley
09ee887e9f add behavior test for comptime pointer casting
closes #1150
closes #1292
closes #4093
2022-12-18 18:37:12 -07:00
Andrew Kelley
aca9c74e80
Merge pull request #13914 from Vexu/variadic
implement defining C variadic functions
2022-12-18 16:24:13 -05:00
Andrew Kelley
d93edadead
Merge pull request #13993 from squeek502/windows-childprocess-perf
`spawnWindows`: Improve worst-case performance considerably + tests
2022-12-18 16:22:19 -05:00
Andrew Kelley
6ed0910d6d Revert "llvm: fix lowering pointer to final zero-width field of a comptime value"
This reverts commit e0bc5f65b9.

Caused an assertion failure when running the behavior tests:

```
zig: llvm/lib/IR/Type.cpp:729: static llvm::PointerType* llvm::PointerType::get(llvm::Type*, unsigned int): Assertion `isValidElementType(EltTy) && "Invalid type for pointer element!"' failed.
Aborted (core dumped)
```
2022-12-18 13:51:15 -07:00
Veikka Tuominen
40ed6ae846
Merge pull request #13930 from r00ster91/renamings
std.builtin: renamings
2022-12-18 19:33:15 +02:00
shwqf
11a81e1b29 Call ensureResultUsed before comptime .call is evaluated.
Fixes #12580
2022-12-18 16:04:33 +02:00
r00ster91
ceff03f3e9 std.builtin: remove layout field from Type.Enum 2022-12-18 13:31:38 +01:00
Ryan Liptak
0cbc59f227 standalone tests: Add windows spawn test
Tests a decent amount of edge cases dealing with how PATH and PATHEXT searching is handled.
2022-12-18 03:55:28 -08:00
Jacob Young
e0bc5f65b9 llvm: fix lowering pointer to final zero-width field of a comptime value
* Handle a `null` return from `llvmFieldIndex`.
 * Add a behavior test to test this code path.
 * Reword this test name, which incorrectly described how pointers to
   zero-bit fields behave, and instead describe the actual test.
2022-12-18 02:17:11 -05:00
Veikka Tuominen
901c3e9636
Merge pull request #13552 from hryx/comparus-tautologicus
Sema: elide integer comparisons with guaranteed outcomes
2022-12-18 01:57:49 +02:00
r00ster91
aac2d6b56f std.builtin: rename Type.UnionField and Type.StructField's field_type to type 2022-12-17 14:11:33 +01:00
r00ster91
7350ea3e2d std.builtin: rename Type.Fn's args to params
This was a poor naming choice; these are parameters, not arguments.
Parameters specify what kind of arguments are expected, whereas the arguments are the actual values passed.
2022-12-17 14:11:33 +01:00
r00ster91
20d3fd901e std.builtin: rename Type.Fn.Param's arg_type to type
It's the type of a parameter, not an argument, but the prefix is redundant either way.
2022-12-17 14:11:33 +01:00
Veikka Tuominen
9bb1104e37 implement defining C variadic functions 2022-12-17 13:22:09 +02:00
Veikka Tuominen
728dd29f1a Type: fix incorrect usage of hasRuntimeBits
Closes #13962
2022-12-17 13:22:09 +02:00
Veikka Tuominen
58caed1c71 Sema: make is_non_{null,err} stricter about types
Closes #13023
2022-12-17 13:22:09 +02:00
Jakub Konka
270b6c4c2f
Merge pull request #13964 from ziglang/issue-11737
Misc MachO linker improvements and link-tests refactor
2022-12-17 10:26:56 +01:00
Jakub Konka
b20a610f03 link-tests: force cross-comp to exclude host differences 2022-12-17 00:53:47 +01:00
yujiri8
68d2f68ed8
zig fmt: fix extra whitespace with multiline strings
Fixes #13937
2022-12-17 00:24:58 +02:00
Jakub Konka
9ad24a4aee macho: add uuid link test 2022-12-16 18:31:48 +01:00
Evin Yulo
8c8f6bfa64 Add test for #13366
Closes #13366
2022-12-16 18:21:56 +02:00
Evin Yulo
b5d1df091b Add test for #12571
Closes #12571
2022-12-16 18:19:32 +02:00
Travis Staloch
1ebb761244 codegen - lower str_lit to vector 2022-12-16 06:08:10 -05:00
Veikka Tuominen
8a0a6b7387 port packed vector elem ptr logic from stage1
Closes #12812
Closes #13925
2022-12-15 21:06:35 -05:00
Stevie Hryciw
e57e835904 Sema: elide integer comparisons with guaranteed outcomes 2022-12-15 00:56:27 -08:00
Veikka Tuominen
bc97a5662d Sema: display cimport errors from clang 2022-12-14 14:08:22 +02:00
Veikka Tuominen
886fa455fa Sema: avoid analyzing functions which failed when inlining 2022-12-14 14:08:21 +02:00
Veikka Tuominen
e6588857df Sema: fix memory management of union enum tag int tag
This likely went unnoticed due to all power of two integer types being special cased.

Closes #13812
2022-12-14 14:08:21 +02:00
Veikka Tuominen
41913ddb1a remove no longer relevant stage1 compile errors 2022-12-14 14:08:21 +02:00
Veikka Tuominen
927d20b46b Sema: implement missing stage1 errors 2022-12-14 14:08:21 +02:00
Veikka Tuominen
423d7a74a4 move async compile errors into their own folder 2022-12-14 14:05:57 +02:00
Veikka Tuominen
327fb798c3 move stage2 compile errors out of special folder 2022-12-14 14:05:57 +02:00
IntegratedQuantum
0b4461d97b
Fix tautological big_int tests. 2022-12-14 00:29:25 +00:00
Andrew Kelley
6378644d4e
Merge pull request #13907 from Vexu/call-merge
Remove `stack` option from `@call`
2022-12-13 18:15:18 -05:00
Andrew Kelley
2e66b3be6e
Merge pull request #13910 from Luukdegram/wasm-simd 2022-12-13 14:11:22 -05:00
Meghan
3318611618 re-enable "signed zeros are represented properly" beahvior tests for f80 and c_longdouble 2022-12-13 13:33:16 +02:00
Veikka Tuominen
08b2d491bc update usages of @call 2022-12-13 13:14:20 +02:00
Luuk de Gram
37561a920b
wasm: enable passing vector tests 2022-12-12 17:42:09 +01:00
Coin
5e111098e5 Revert "compiler_c test: skip build modes on aarch64-windows"
This reverts commit c029a98f1c.
2022-12-12 04:58:10 +08:00
Coin
ed0ecd9bff Revert "mix_c_files: skip build modes on aarch64-windows due to bug"
This reverts commit cf543199ca.
2022-12-12 04:57:55 +08:00
IntegratedQuantum
15a6336bb4
Add a helpful note when using ** on number types. (#13871) 2022-12-11 14:41:42 -05:00
Andrew Kelley
74718a1183 disable failing CBE behavior tests failing on aarch64-windows
Also start to move redundant tests next to each other to make them
slightly more obvious that they need to be cleaned up.

See tracking issue #13876
2022-12-10 16:28:49 -07:00
Jakub Konka
c029a98f1c compiler_c test: skip build modes on aarch64-windows 2022-12-10 16:00:59 -07:00
Jakub Konka
cf543199ca mix_c_files: skip build modes on aarch64-windows due to bug 2022-12-10 16:00:59 -07:00
Andrew Kelley
cffbb32d31
Merge pull request #13872 from koachan/sparc64-codegen
stage2: sparc64: Some Air lowerings + skip unbuildable tests
2022-12-10 15:10:21 -05:00
Koakuma
f9e9ba784f stage2: sparc64: Skip unimplemented tests 2022-12-10 21:51:46 +07:00
Koakuma
fb9357f06c stage2: sparc64: Implement atomic ops 2022-12-10 21:11:14 +07:00
r00ster91
654e30069d behavior and cases: more test coverage for old issues
Closes #2622
Closes #2727
Closes #6047
Closes #6947
Closes #6656
2022-12-10 12:34:42 +01:00
r00ster91
bf863878ac behavior: add test coverage for slice and array-related issues
Closes #10684
Closes #6905
Closes #8646
2022-12-10 12:34:42 +01:00
r00ster91
7a8f7dcb8c behavior: add test coverage for corrupted slice in release
Closes #7325
2022-12-10 12:34:42 +01:00
r00ster91
01947bfe92 behavior: add test coverage for previous i128 regression on aarch64
Closes #8429
2022-12-10 12:34:42 +01:00
r00ster91
981cfd9c1c behavior and langref: reenable previously-regressed tests on aarch64 and powerpc64le
Closes #3282
2022-12-10 12:34:42 +01:00
r00ster91
3370d58956 aarch64: reenable tests that are no longer regressed
Closes #12013
Closes #10627
Closes #12027
2022-12-10 12:34:34 +01:00
r00ster91
75f8c04d6d behavior: add test coverage for slicing zero length array field of struct
Closes #11787
2022-12-10 12:33:17 +01:00
Veikka Tuominen
9d93b2ccf1 Eliminate BoundFn type from the language
Closes #9484
2022-12-09 20:37:18 -07:00
Veikka Tuominen
5831b68341 AstGen: add check for missing builtin argument
Closes #13817
2022-12-09 20:37:18 -07:00
Veikka Tuominen
ee9fc54cd0 TypedValue: fix handling of tuples represented as empty_struct_value 2022-12-08 22:21:49 +02:00
Veikka Tuominen
653c0bae0c remove stage1 specific compile error tests 2022-12-07 20:32:27 +02:00
Veikka Tuominen
dff32a2cd7 Sema: resolve lazy values in analyzeMinMax
Closes #13797
2022-12-07 14:48:24 +02:00
Andrew Kelley
1310ef7577 disable failing behavior tests with -ofmt=c -target x86_64-windows
and enable CI checks for the C backend on Windows.
2022-12-07 04:01:04 -05:00
Andrew Kelley
c8aba15c22 remove references to stage1 in behavior tests
Good riddance.
2022-12-06 19:06:48 -07:00
Andrew Kelley
b7b905d227 add behavior test for while(true) not needing else unreachable
closes #707
2022-12-06 17:57:27 -07:00
Andrew Kelley
57995c2100 translate-c: remove stage1 conditions from tests 2022-12-06 12:15:05 -07:00
Andrew Kelley
28514476ef remove -fstage1 option
After this commit, the self-hosted compiler does not offer the option to
use stage1 as a backend anymore.
2022-12-06 12:15:04 -07:00
Andrew Kelley
518392d6fe disable CBE behavior tests that are not passing in release modes 2022-12-04 15:57:40 -07:00
r00ster91
f094c4bce5 Sema: detect duplicate enum tag values 2022-12-04 14:12:24 +02:00
Jacob Young
e3b8658e65 cbe: add forward declarations for optionals and error unions
Arrays will have to wait for type rewrite.
2022-12-03 21:58:18 -05:00
Jacob Young
6d1292552e cbe: implement function alignment 2022-12-03 08:40:08 -05:00
Jacob Young
ec3116f573 cbe: fix zero-bit struct field pointer 2022-12-03 08:40:08 -05:00
Jacob Young
7fb6eb3d14 cbe: implement multiple exports of a symbols 2022-12-03 08:21:03 -05:00
Jacob Young
81c271cc62 cbe: don't emit extern decls that are already exported 2022-12-03 08:21:03 -05:00
Andrew Kelley
610d604f5b
Merge pull request #13748 from jacobly0/c-unaligned
cbe: use memcpy for underaligned loads and stores
2022-12-03 02:18:07 -05:00
Andrew Kelley
fdbb0fb7b9
Merge pull request #13744 from Vexu/stage2-fixes
Improve error messages, fix dependency loops
2022-12-03 00:42:11 -05:00
Jacob Young
e1216077f0 cbe: add support for constraint modifiers specified after a colon
This translates `%[name:mod]` to `%mod[name]` for C.
2022-12-02 22:21:24 -05:00
Jacob Young
fdedd62365 cbe: use memcpy for underaligned loads and stores 2022-12-02 22:21:24 -05:00
Andrew Kelley
29e8e67a7e CBE: use bool, true, false, instead of zig_ prefixes
In general the C backend should lower to human-maintainable C code
whenever possible. Directly using C types that one would use when
writing C code is one part of the strategy.

The concern with including stdint.h is C89 compatibility. Well, we can
just check the C std lib version before deciding to include that header.
2022-12-02 16:12:49 -07:00
Veikka Tuominen
b500e0eb17 Sema: add "parameter type declared here" note to type coercion 2022-12-03 00:48:04 +02:00
Veikka Tuominen
74285a4ed7 add test for error message improved by self-hosted
Closes #5099
2022-12-03 00:48:04 +02:00
Veikka Tuominen
f20e449fd6 Sema: improve error for mismatched type in implicit return
Closes #2653
2022-12-03 00:48:03 +02:00
Veikka Tuominen
e2509ddbe6 AstGen: add error for invalid string comparisons
These operations are allowed because the string literals are just
pointers but they produce unexpected results. These errors prevent
beginners from shooting themselves in the foot while still allowing
advanced users to circumvent them if they desire to do so.

Closes #8290
2022-12-03 00:09:23 +02:00
Veikka Tuominen
0e38cc16d5 Sema: fix comparisons between lazy and runtime values
Closes #12498
2022-12-03 00:09:23 +02:00
Veikka Tuominen
7f9e841f74 Sema: do not forcibly canonicalize unresolved pointer element type
Closes #13308
2022-12-03 00:09:23 +02:00
Veikka Tuominen
59dad43de2 Sema: add error for failed assumption about struct having runtime bits 2022-12-02 18:46:59 +02:00
Veikka Tuominen
86e6acb37b AstGen: improve error message for missing parameter name
Closes #13393
2022-12-02 15:39:40 +02:00
Andrew Kelley
665eba93c1 CBE: eliminate zig_void
C void is perfectly fine.
2022-12-02 00:46:27 -05:00
Andrew Kelley
4071b22454
Merge pull request #13715 from Vexu/cbe
cbe bug fixes and improvements
2022-12-01 17:38:11 -05:00
Veikka Tuominen
6ded2d2adb cbe: disable failing behavior test on aarch64 2022-12-01 12:18:10 +02:00
Veikka Tuominen
d0edaabf9d Value: fix elemValueAdvanced for optional payloads
Closes #13707
2022-12-01 11:49:06 +02:00
Andrew Kelley
a943422672
Merge pull request #13717 from GethDW/option-fix
std.build.Builder: fix for Allocator changes
2022-11-30 19:43:51 -05:00
Andrew Kelley
b1793c2b52 add test coverage for zig build CLI and options API 2022-11-30 13:22:43 -07:00
Luuk de Gram
090deae41d
wasm: enable behavior tests for packed structs 2022-11-30 21:01:09 +01:00
Veikka Tuominen
11ec7109c3 cbe: do not memcpy identical integer types when bitcasting 2022-11-30 17:11:06 +02:00
Veikka Tuominen
15cc83e27a cbe: reduce amount of temporary locals 2022-11-30 17:11:06 +02:00
Veikka Tuominen
f4afeb3ffd AstGen: fix incorrect handling of source cursor with shift builtins
Closes #13714
2022-11-30 17:11:06 +02:00
Veikka Tuominen
2dcac348e5 cbe: implement packed unions 2022-11-30 15:14:33 +02:00
Veikka Tuominen
1a1a5702ab cbe: correctly handle pointers to zero bit error union payloads 2022-11-30 15:14:33 +02:00
Veikka Tuominen
4def9c4a9b cbe: operand of address of operator must be an lvalue 2022-11-30 15:14:33 +02:00
Veikka Tuominen
6310186d52 cbe: cast pointer switch target to int 2022-11-30 15:14:33 +02:00
Veikka Tuominen
8af5648015 Sema: make inferred allocs always mutable
Const allocs don't make any sense, make_ptr_const handles making
the pointers not mutable.
2022-11-30 15:14:33 +02:00
Veikka Tuominen
63ae7899ae cbe: ensure test and tagName function names are unique 2022-11-30 15:14:33 +02:00
Andrew Kelley
ceb0a632cf std.mem.Allocator: allow shrink to fail
closes #13535
2022-11-29 23:30:38 -07:00
Andrew Kelley
deda6b5146 LLVM: fix canElideLoad behavior with loops
closes #13546
2022-11-30 00:20:49 -05:00
Veikka Tuominen
b2b1d421c3 Sema: add missing failWithBadMemberAccess to zirExport
The assumption that AstGen would error only holds when exporting
a identifier not a namespace member.
2022-11-29 21:44:08 +02:00
Veikka Tuominen
4b0ef6a409 Sema: make non-existent field error point to field name
Closes #13698
2022-11-29 21:44:08 +02:00
Veikka Tuominen
6f5a438946 AstGen: unstack block scope when creating opaque type
Closes #13697
2022-11-29 21:44:08 +02:00
Veikka Tuominen
ed73429926 Sema: explain why parameter must be declared comptime
Closes #13692
2022-11-29 21:44:08 +02:00
Veikka Tuominen
17ff002bc0 Sema: improve safety panic for access of inactive union field 2022-11-29 21:44:08 +02:00
Veikka Tuominen
6337c04244 Sema: improve panic for slice start index being greater than end index
Closes #13689
2022-11-29 15:47:02 +02:00
Veikka Tuominen
6f9c7e33b9 llvm: implement union_init for packed unions
Closes #13664
2022-11-29 15:47:02 +02:00
Jakub Konka
1829b6eab8
Merge pull request #13625 from kcbanner/windows_disable_symlink_tests
Skip linker tests requiring symlinks on Windows
2022-11-29 02:57:37 +01:00
Jakub Konka
033aa1d761 aarch64-windows: skip failing standalone tests 2022-11-28 19:45:53 -05:00
Jakub Konka
870872dd63 aarch64-windows: skip failing floatop behavior test 2022-11-28 18:10:51 -05:00
Jakub Konka
07bf4de6a9 aarch64-windows: skip failing align behavior test 2022-11-28 18:10:51 -05:00
kcbanner
ea84eda904 'fmt' 2022-11-26 17:16:56 -05:00
Veikka Tuominen
304e828088
Merge pull request #13637 from Vexu/stage2-fixes
Stage2 bug fixes
2022-11-26 22:03:49 +02:00
kcbanner
57bc61ab26 test-link: add -Denable-symlinks-windows to opt-in to using symlinks
Adds a way for standalone tests to declare they need symlinks, and these
tests won't be run on windows unless -Denable-symlinks-windows is set
2022-11-26 14:26:26 -05:00
Veikka Tuominen
71937f75d8 Sema: correctly detect union target in zirSwitchBlock
Closes #13655
2022-11-26 18:05:27 +02:00
Veikka Tuominen
fe38898246 Sema: pass c_import_buf to child block in more places
Closes  #13651
2022-11-26 18:05:27 +02:00
Veikka Tuominen
587ef60a28 Sema: resolve union fields before using getTagType
Closes #13649
2022-11-26 18:05:27 +02:00
Veikka Tuominen
bf62cb453b Sema: handle anytype parameter requiring comptime
Closes #13645
2022-11-26 18:05:27 +02:00
Veikka Tuominen
72fa8d4880 Sema: fix overflow arithmetic with runtime vectors
It should return a a vector of bools for compatibility with scalar
operands and stage1 until #10248 can be implemented.

Closes #13201
2022-11-26 18:05:27 +02:00
Andrew Kelley
30eb2a1753
Merge pull request #13627 from Vexu/tuple-decls
Implement tuple type declarations
2022-11-25 18:06:09 -05:00
Veikka Tuominen
9f055e2eb0 Sema: improve compile error for tuple coercion mismatch 2022-11-23 22:16:31 +02:00
Veikka Tuominen
8eea73fb92 add tests for tuple declarations 2022-11-23 22:16:31 +02:00
Andrew Kelley
4ec27a4e25 C backend: implement vector reduce and overflow intrinsics 2022-11-22 23:33:58 -07:00
Veikka Tuominen
fc5209c139 llvm: fix x86_64 sysV ABI of big vectors on avx512 enabled CPUs
Closes #13629
2022-11-23 00:05:07 +02:00
Andrew Kelley
5e42378227 disable failing C ABI test
see tracking issue #13629
2022-11-22 13:06:09 -07:00
Cody Tapscott
3fa226a80c AstGen: Pop error trace for continue
PR #12837 handled control flow for break and return, but I forgot
about `continue`. This is effectively another break, so we just
need another `.restore_err_ret_index` ZIR instruction.

Resolves #13618.
2022-11-22 14:00:41 +02:00
Andrew Kelley
7829c73ccf disable failing arm-linux non-llvm backend tests
See #13623
2022-11-21 22:56:05 -07:00
Veikka Tuominen
d968d9d103 llvm: add attributes to the arguments of function pointer calls
Closes #13605
2022-11-20 20:25:12 +02:00
Veikka Tuominen
9e276d32f3 Sema: fix memory management of missing field error
Closes #13590
2022-11-20 20:25:12 +02:00