3820 Commits

Author SHA1 Message Date
Andrew Kelley
2164b511cc
partial revert of an improvement this branch made
because it uncovered a result location bug, and I need to get this
branch merged before going into a result location rabbit hole.

also fix the result type of slicing when the indexes are runtime known
and the result should be sentinel terminated.
2020-03-19 09:53:55 -04:00
Andrew Kelley
8688c43745
when result loc is a slice, avoid evaluating lazy start..end
This prevents lazy values from being unnecessarily evaluated.
2020-03-19 09:53:55 -04:00
Andrew Kelley
e947f0c740
0-bit array type does not resolve child type 2020-03-19 09:53:55 -04:00
Andrew Kelley
72a261b4d3
fix runtime slice of pointer not setting length 2020-03-19 09:53:55 -04:00
Andrew Kelley
4435b05b6b
fix regression when slicing 0-bit pointers 2020-03-19 09:53:55 -04:00
Andrew Kelley
2b4134459d
fix alignment when slicing with comptime start and end index 2020-03-19 09:53:54 -04:00
Andrew Kelley
8d0ac6dc4d
@ptrCast supports casting a slice to pointer 2020-03-19 09:53:54 -04:00
Andrew Kelley
c896c5001f
fix slice of string literal having the wrong type 2020-03-19 09:53:54 -04:00
Andrew Kelley
0707be8de8
fixes in semantic analysis needed to support this feature 2020-03-19 09:53:54 -04:00
Andrew Kelley
2182d28cb0
slicing with comptime start and end results in array
implements #863
2020-03-19 09:53:51 -04:00
LemonBoy
e3c92d0532 ir: More changes to sentinel-terminated const arrays
* Don't add an extra slot for the sentinel. Most of the code keeps using
  the constant value from the type descriptor, let's harmonize all the
  code dealing with sentinels.

* Properly write out sentinel values when reinterpreting pointers at
  comptime.

* Allow the reading of the 0th element in a `[0:S]T` type.
2020-03-19 09:53:30 -04:00
Andrew Kelley
63a4dbc30d
array sentinel does not count towards type_has_one_possible_value 2020-03-18 11:11:41 -04:00
LemonBoy
1479c28b49
ir: Correct ABI size calculation for arrays
Zero-length array with a sentinel may not have zero size.

Closes #4749
2020-03-18 11:10:45 -04:00
Andrew Kelley
a77386eb98
for build-obj with only 1 C file, name .o file after root_out_name 2020-03-14 17:11:51 -04:00
Andrew Kelley
4a8e766ef5
fix mismatch between expected and actual output name 2020-03-14 01:26:49 -04:00
Andrew Kelley
66d7370fac
special case when doing build-obj with just one source file
When building an object file from only one source file, instead of
having a two-stage cache system, we special case it and use the cache
directory that the .o file is output to as the final cache directory for
all the build artifacts.

When there are more than 1 source file, the linker has to merge objects
into one, and so the two stage approach makes sens. But in the case of
only one source file, this prevents needlessly copying the object file.

This commit fixes an issue with the previous one, where zig with cache
enabled would print a directory that actually did not have any build
artifacts in it.
2020-03-13 23:59:36 -04:00
Andrew Kelley
66e76a0209
zig build system: correctly handle multiple output artifacts
Previously the zig build system incorrectly assumed that the only build
artifact was a binary. Now, when you enable the cache, only the output
dir is printed to stdout, and the zig build system iterates over the
files in that directory, copying them to the output directory.

To support this change:

 * Add `std.os.renameat`, `std.os.renameatZ`, and `std.os.renameatW`.
 * Fix `std.os.linux.renameat` not compiling due to typos.
 * Deprecate `std.fs.updateFile` and `std.fs.updateFileMode`.
 * Add `std.fs.Dir.updateFile`, which supports using open directory
   handles for both the source and destination paths, as well as an
   options parameter which allows overriding the mode.
 * Update `std.fs.AtomicFile` to support operating based on an open
   directory handle. Instead of `std.fs.AtomicFile.init`, use
   `std.fs.Dir.atomicFile`.
 * `std.fs.AtomicFile` deinit() better handles the situation when the
    rename fails but the temporary file still exists, by still
    attempting to remove the temporary file.
 * `std.fs.Dir.openFileWindows` is moved to `std.os.windows.OpenFileW`.
 * `std.os.RenameError` gains the error codes `NoDevice`,
   `SharingViolation`, and `PipeBusy` which have been observed from
   Windows.

Closes #4733
2020-03-13 21:22:08 -04:00
Noam Preil
eb4d313dbc Fix compilation with --no-emit-bin 2020-03-13 15:40:29 -04:00
Andrew Kelley
2f06971a7e
Merge pull request #4725 from ziglang/update-musl
Upgrade musl libc to 1.2.0
2020-03-12 19:56:38 -04:00
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
Andrew Kelley
6e25ac2a2b
stage1: update musl libc building code for v1.2.0 2020-03-12 17:45:55 -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
daurnimator
8a22c50c08 Remove unused static_crt_dir field from libc config 2020-03-12 12:27:45 -04:00
Vexu
710b05b153
support @atomicRmw at comptime 2020-03-12 16:46:16 +02:00
Andrew Kelley
f58705b4a6
fix zig targets not reporting native info 2020-03-12 00:33:06 -04:00
Michael Dusan
bfebc11d06
fix zig-cache to treat cpu-features as raw-bytes
- add Stage2Target.cache_hash_len
- add cache_mem(ch, ptr, len)
- update call sites to use { ptr, len }
2020-03-11 19:33:12 -04:00
Vexu
9262f065f5
Move abi size checking to codegen 2020-03-11 16:48:18 +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
Vexu
21809c3300
support non power of two integers in atomic ops 2020-03-11 09:24:53 +02:00
LemonBoy
4ab13a359d ir: Fix shift code for u0 operands 2020-03-10 23:04:49 +01:00
Vexu
ee5b00a8b9
use atomic bools in std lib 2020-03-10 22:54:47 +02:00
Vexu
8dc188ebe0
support atomic operations with bools 2020-03-10 22:33:32 +02:00
LemonBoy
300fceac6e ir: Implement more safety checks for shl/shr
The checks are now valid on types whose size is not a power of two.

Closes #2096
2020-03-10 20:54:05 +01:00
Vexu
cb4c488cbd
translate-c support struct field alignment 2020-03-10 15:57:57 +02:00
Andrew Kelley
675f01f176
Merge pull request #4590 from xackus/fix-4587
fix failed assert on generic fn opaque return type
2020-03-09 22:10:57 -04: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
xackus
e7cc456421 better error messages and more tests 2020-03-09 22:33:18 +01:00
Andrew Kelley
7db6da7cb8
lazy_cmp_zero only resolves type is zero bits for alignof 2020-03-09 14:24:04 -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
Vexu
03c1431f9c
disallow resume and suspend in noasync scopes 2020-03-09 15:51:51 +02:00
Vexu
3618256c97
implement noasync scopes 2020-03-09 12:33:24 +02:00
Vexu
6f8d732599
update parsers to new noasync syntax 2020-03-09 12:23:30 +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
LemonBoy
06d0dac0fb ir: Prevent crash in compiler error
Anonymous containers have no struct_field->type AstNode set, let's
always use the field node itself to make the error messages consistent.

Closes #4691
2020-03-08 18:12:50 -04:00
xackus
7782c76bee fix failed assert on generic fn opaque return type 2020-03-08 18:05:45 +01:00