Commit Graph

553 Commits

Author SHA1 Message Date
Andrew Kelley
f51bec321b
Merge pull request #4707 from Vexu/small-atomics
Support atomic operations with bools and non power of two integers
2020-03-12 18:55:16 -04:00
Vexu
71d776c3be
add note to disabled tests, improve comptime cmpxchg 2020-03-12 22:42:01 +02:00
Vexu
6dde769279
Simplify stores, use sext for signed ints 2020-03-12 22:02:58 +02:00
Vexu
ce19638cd4
disable test on mipsel 2020-03-12 17:31:10 +02:00
Vexu
710b05b153
support @atomicRmw at comptime 2020-03-12 16:46:16 +02:00
Vexu
ec906a9771
fix codegen, update docs 2020-03-11 13:55:52 +02:00
Vexu
1f66435a6b
support cmpxchg at comptime 2020-03-11 12:02:05 +02:00
Vexu
64e60d8ae2
special case atomic operations on zero bit types 2020-03-11 10:29:15 +02:00
LemonBoy
4ab13a359d ir: Fix shift code for u0 operands 2020-03-10 23:04:49 +01:00
Vexu
8dc188ebe0
support atomic operations with bools 2020-03-10 22:33:32 +02:00
LemonBoy
1f44b29724 ir: Fix codegen of ?*T types where T is zero-sized
* Fix codegen for optional types that decay to a pointer, the type
  behaves as a boolean
* Fix comptime evaluation of zero-sized arrays, always initialize the
  internal array elements

Closes #4673
2020-03-09 22:08:56 -04:00
Andrew Kelley
638d5c3aca
Merge pull request #4700 from Vexu/noasync
Implement new noasync syntax
2020-03-09 18:36:01 -04:00
LemonBoy
14bbb82832
ir: Fix lazy comparison between @alignOf and zero
Closes #4527
2020-03-09 14:05:38 -04:00
Vexu
3fd2cd4367
add LemonBoy's test 2020-03-09 18:43:09 +02:00
LemonBoy
e2fd289a33 ir: Create usize result_loc for array subscript expr
Allow the subscript expression to infer the resulting type.

Closes #4169
2020-03-08 18:52:44 -04:00
Andrew Kelley
fa46bcb368
stage1: make get_optional_type more robust
Now it will emit a compile error rather than crashing when the child
type has not been resolved properly.

Introduces `get_optional_type2` which should be used generally inside
ir.cpp.

Fix some std lib compile errors noticed by the provided test case.

Thanks @LemonBoy for the test case. Closes #4377.

Fixes #4374.
2020-03-06 18:30:30 -05:00
Andrew Kelley
01c722c21c
Revert "Allow constant struct val to reallocate its fields when resolving an inferred struct field with a comptime value."
This reverts commit debcc79d56.

This caused a regression when building self-hosted
2020-03-05 17:19:01 -05:00
Alexandros Naskos
debcc79d56 Allow constant struct val to reallocate its fields when resolving an inferred struct field with a comptime value. 2020-03-05 15:48:03 -05:00
LemonBoy
0c310f0fbf
ir: Implement @TypeOf with multiple arguments
Closes #439
2020-03-04 17:21:10 -05:00
Andrew Kelley
24fc69acad
Merge pull request #4573 from alexnask/tuple_concat
Allow concatenation of tuples that contain a mix of runtime and comptime values
2020-03-04 17:09:43 -05:00
Andrew Kelley
f247a90541
get_codegen_ptr_type returns possible error
And fix most of the fallout. This also makes optional pointers not
require resolving zero bits, because the comptime value struct layout no
longer depends on whether the type has zero bits.

Thanks to @LemonBoy for the behavior test case

Closes #4357
Closes #4359
2020-03-04 17:04:59 -05:00
Alexandros Naskos
b838122cc0 Merge branch 'master' of https://github.com/ziglang/zig into tuple_concat 2020-03-02 00:55:19 +02:00
Andrew Kelley
ef3d761da5
breaking: std.mem.len no longer takes a type argument
also update fmt code to use std.mem.span.
2020-03-01 13:21:39 -05:00
Andrew Kelley
4505857e30
revert changes outside std.fmt 2020-03-01 13:07:31 -05:00
daurnimator
0b0de22fd1
std: format contents of sentinel terminated many pointers
std: add std.meta.Sentinel to get sentinel of a type
2020-03-01 13:04:29 -05:00
Andrew Kelley
7617610400
Merge pull request #4550 from ziglang/os-version-ranges
introduce operating system version ranges as part of the target; self-host native dynamic linker detection and native glibc version detection
2020-02-29 01:57:06 -05:00
Alexandros Naskos
1b41f2d77e
C pointer slices are no longer allowzero (#4462)
* Slices from C pointers are no longer allowzero but instead insert a runtime assertion.

* Added a test, fixed code for cases with non-allowzero C pointers

* Create new type when flipping allow_zero, sometimes we get a cached value back from adjust_ptr_len.

* Added comments, changed panic message

* Added runtime safety test.
2020-02-29 01:36:42 -05:00
Andrew Kelley
bee4007ec9
fix crash with multiple comptime fn calls and...
...default initialized array to undefined

closes #4578
2020-02-28 15:49:19 -05:00
Andrew Kelley
87b9e744dd
update std lib to new Target API 2020-02-28 14:51:54 -05:00
Andrew Kelley
4616af0ca4
introduce operating system version ranges as part of the target
* re-introduce `std.build.Target` which is distinct from `std.Target`.
   `std.build.Target` wraps `std.Target` so that it can be annotated as
   "the native target" or an explicitly specified target.
 * `std.Target.Os` is moved to `std.Target.Os.Tag`. The former is now a
   struct which has the tag as well as version range information.
 * `std.elf` gains some more ELF header constants.
 * `std.Target.parse` gains the ability to parse operating system
   version ranges as well as glibc version.
 * Added `std.Target.isGnuLibC()`.
 * self-hosted dynamic linker detection and glibc version detection.
   This also adds the improved logic using `/usr/bin/env` rather than
   invoking the system C compiler to find the dynamic linker when zig
   is statically linked. Related: #2084
   Note: this `/usr/bin/env` code is work-in-progress.
 * `-target-glibc` CLI option is removed in favor of the new `-target`
   syntax. Example: `-target x86_64-linux-gnu.2.27`

closes #1907
2020-02-28 14:51:53 -05:00
Alexandros Naskos
261c94629e Added test 2020-02-28 02:52:09 +02:00
LemonBoy
fd1eade4ca ir: Allow empty inferred error sets
Closes #4564
2020-02-26 21:02:22 -05:00
Vexu
22432b15e3
add test for @intToEnum 2020-02-26 11:19:40 -05:00
Vexu
d505ea6caf
fix @tagName on extern and non-exhaustive enums 2020-02-26 11:19:39 -05:00
Andrew Kelley
c4a2734aa0
Merge pull request #4561 from LemonBoy/fix-4536-1
Resend of #4552
2020-02-26 11:11:28 -05:00
LemonBoy
d2535c003c ir: Fix regression with self-referencing containers 2020-02-26 10:05:04 +01:00
Andrew Kelley
a55e536391
fix typo in previous commit
oops, forgot to actually run the test
2020-02-25 21:32:03 -05:00
Andrew Kelley
e75598af3d
add test case to catch regression from previous commit
Once this test case is passing, previous commit can be re-added.

Closes #4560
2020-02-25 21:24:27 -05:00
Andrew Kelley
dad62a7e27
Revert "ir: Fix sizeOf comparison with ptr to zst"
This reverts commit 89812217b4.

This caused #4560
2020-02-25 21:23:35 -05:00
LemonBoy
e9bac8be6b ir: Fix array to slice conversion for zero-sized arrays
Closes #3848
2020-02-25 17:40:01 -05:00
LemonBoy
55ea855e2c ir: Various fixes for comptime ptr handling
* Correctly fold ptrToInt on optional types
* Generate null as ConstPtrSpecialNull in intToPtr
* Correctly stop ptrToInt on ?*T where T is zero-sized

Closes #4535
2020-02-25 17:38:56 -05:00
LemonBoy
89812217b4 ir: Fix sizeOf comparison with ptr to zst
Closes #4536
2020-02-25 17:36:54 -05:00
LemonBoy
b46efcde82 ir: Fix sizeOf comparison with ptr to zst
Closes #4536
2020-02-25 12:48:08 +01:00
Vexu
538d9a5dd8
remove uses of @ArgType and @IntType 2020-02-24 23:39:03 +02:00
Vexu
45da72c5b6
remove usages of @typeId, @memberCount, @memberName and @memberType 2020-02-24 23:09:01 +02:00
Andrew Kelley
1d06c82c3b
Merge pull request #4516 from xackus/remove-bytes-to-slice
remove @bytesToSlice, @sliceToBytes from the language
2020-02-24 13:51:47 -05:00
xackus
7664c3bc11 remove @bytesToSlice, @sliceToBytes from tests, docs 2020-02-23 18:03:50 +01:00
Andrew Kelley
570973761a
add regression test for already fixed bug
closes #3586
2020-02-21 15:31:00 -05:00
Andrew Kelley
dd58278dbe
add behavior test for previous commit 2020-02-18 15:28:14 -05:00
Andrew Kelley
7f7d1fbe5a
Implement noasync awaits
Note that there is not yet runtime safety for this.

See #3157
2020-02-16 01:44:52 -05:00