Commit Graph

1936 Commits

Author SHA1 Message Date
LemonBoy
4ebcf64864 Initial support for mipsel architecture¬ 2019-09-26 09:31:55 +02:00
Andrew Kelley
dc7016344e
remove --override-std-dir. fix issues caused by moving std lib 2019-09-25 23:59:07 -04:00
Andrew Kelley
d1705baa74
enable test coverage for armv8-linux-musleabihf
* fix libc prototypes of offsets to have correct integer sizes and
   signedness. This gets all behavior tests to pass for
   armv8-linux-musleabihf
 * fix linux mmap syscall to have correct integer size and signedness
   for offset
 * disable failing armv8-linux-musleabihf std lib tests. See 3289. I
   suspect compiler-rt issue. Note these tests fail with this target
   triple regardless of whether musl is actually linked (-lc).
2019-09-25 16:21:04 -04:00
Michael Dusan
9983501ff2 add VarDecl support for struct-method call syntax
implements #3306
2019-09-24 19:24:48 -04:00
LemonBoy
5fb7af26ab
Fix result loc unwrapping with optional in error union
Fixes #2899
2019-09-24 01:09:26 -04:00
LemonBoy
93367adaa7
Fix assignment to optional payload
Closes #3081
2019-09-24 00:31:35 -04:00
Jay Weisskopf
0bdc85181c Create user-specified output-dir
Fixes #2637
2019-09-24 00:20:29 -04:00
LemonBoy
663e665843
Prevent crash with invalid extern type
Fixes #3240
2019-09-23 17:30:28 -04:00
LemonBoy
db988f42a7 Fix computation of switch coverage
Closes #3258
2019-09-23 16:13:28 -04:00
Andrew Kelley
96affd683a
enable test coverage for cross compiling windows mingw-w64
closes #3285
2019-09-22 19:11:41 -04:00
Andrew Kelley
cf4cc9b148
do the release tests last because they take longer 2019-09-22 14:41:47 -04:00
Andrew Kelley
786052c7d3 disable running cross compiled macos tests
due to #3295
2019-09-22 14:40:54 -04:00
Andrew Kelley
ffef5d26b6
significantly increase test coverage
* add zig build option `-Dskip-libc` to skip tests that build libc
   (e.g. if you don't want to wait for musl to build)
 * add `-Denable-wine` option which uses wine to run cross compiled
   windows tests on non-windows hosts
 * add `-Denable-qemu` option which uses qemu to run cross compiled
   foreign architecture tests
 * add `-Denable-foreign-glibc=path` option which combined with
   `-Denable-qemu` enables running cross compiled tests that link
   against glibc. See
   https://github.com/ziglang/zig/wiki/Updating-libc#glibc for how to
   produce this directory.
 * the test matrix is done manually. release test builds are only
   enabled by default for the native target. this should save us some CI
   time, while still providing decent coverage of release builds.
   - add test coverage for `x86_64-linux-musl -lc` (building musl libc)
   - add test coverage for `x86_64-linux-gnu -lc` (building glibc)
   - add test coverage for `aarch64v8_5a-linux-none`
   - add test coverage for `aarch64v8_5a-linux-musl -lc` (building musl libc)
   - add test coverage for `aarch64v8_5a-linux-gnu -lc` (building glibc)
   - add test coverage for `arm-linux-none`
   - test coverage for `arm-linux-musleabihf -lc` (building musl libc) is
     disabled due to #3286
   - test coverage for `arm-linux-gnueabihf -lc` (building glibc) is disabled
     due to #3287
   - test coverage for `x86_64-windows-gnu -lc` (building mingw-w64) is
     disabled due to #3285
 * enable qemu testing on the Linux CI job. There's not really a good
   reason to enable wine, since we have a Windows CI job as well.
 * remove the no longer needed `--build-file ../build.zig` from CI
   scripts
 * fix bug in glibc compilation where it wasn't properly reading the abi
   list txt files, resulting in "key not found" error.
 * std.build.Target gains:
   - isNetBSD
   - isLinux
   - osRequiresLibC
   - getArchPtrBitWidth
   - getExternalExecutor
 * zig build system gains support for enabling wine and enabling qemu.
   `artifact.enable_wine = true;`, `artifact.enable_qemu = true;`. This
   communicates that the system has these tools installed and the build
   system will use them to run tests.
 * zig build system gains support for overriding the dynamic linker of
   an executable artifact.
 * fix std.c.lseek prototype. makes behavior tests for
   arm-linux-musleabihf pass.
 * disable std lib tests that are failing on ARM. See #3288, #3289
 * provide `std.os.off_t`.
 * disable some of the compiler_rt symbols for arm 32 bit. Fixes
   compiler_rt tests for arm 32 bit
 * add __stack_chk_guard when linking against glibc. Fixes std lib tests
   for aarch64-linux-gnu
 * workaround for "unable to inline function" using `@inlineCall`. Fixes
   compiler_rt tests for arm 32 bit.
2019-09-22 11:22:17 -04:00
Andrew Kelley
2c681d7ba1
add behavior test for float widening f16 to f128
it's disabled on aarch64, see #3282
2019-09-21 14:22:23 -04:00
LemonBoy
34d02f249b Fix a test on ARM due to the use of undefined ptr 2019-09-21 11:39:50 +02:00
LemonBoy
57f751a864 Adjust tests for AArch64 2019-09-21 11:39:50 +02:00
LemonBoy
75ec7e4e00 Fix generation of tail fields for packed struct 2019-09-21 11:39:43 +02:00
Sahnvour
74d0b5bf7c reject types of automatic container layout in packed unions 2019-09-20 13:25:32 -04:00
Andrew Kelley
c9a5a6b83a
add test case for already fixed bug
closes #3046
2019-09-20 13:19:29 -04:00
Timon Kruiper
3b4a6679a6 Fix comptime bitcast inside an expression 2019-09-20 13:13:26 -04:00
Andrew Kelley
005a54a853
fixups for @splat
* Fix codegen for splat - instead of giving vectors of length N
   to shufflevector for both of the operands, it gives vectors of length
   1. The mask vector is the only one that needs N elements.
 * Separate Splat into SplatSrc and SplatGen; the `len` is not needed
   once it gets to codegen since it is redundant with the result type.
 * Refactor compile error for wrong vector element type so that the
   compile error message is not duplicated in zig source code
 * Improve implementation to correctly handle comptime values such as
   undefined and lazy values.
 * Improve compile error for bad vector element type to point to the
   correct place.
 * Delete dead code.
 * Modify behavior test to use an array cast instead of vector element
   indexing since I'm merging this splat commit out-of-order from
   Shawn's patch set.
2019-09-19 10:58:12 -04:00
Shawn Landden
01577a3af4
@splat 2019-09-19 10:11:06 -04:00
Andrew Kelley
380c8ec2c9
implement runtime @byteSwap and other fixups
* update docs for `@byteSwap`.
 * fix hash & eql functions for ZigLLVMFnIdBswap not updated to
   include vector len. this was causing incorrect bswap function
   being called in unrelated code
 * fix `@byteSwap` behavior tests only testing comptime and not
   runtime operations
 * implement runtime `@byteSwap`
 * fix incorrect logic in ir_render_vector_to_array and
   ir_render_array_to_vector with regards to whether or not to bitcast
 * `@byteSwap` accepts an array operand which it will cast to vector
 * simplify `@byteSwap` semantic analysis code and various fixes
2019-09-19 00:59:04 -04:00
Shawn Landden
76f5396077
@byteSwap on vectors 2019-09-18 16:49:14 -04:00
Andrew Kelley
2038f4d45a
rework the implementation
* update documentation
   - move `@shuffle` to be sorted alphabetically
   - remove mention of LLVM
   - minor clarifications & rewording
 * introduce ir_resolve_vector_elem_type to avoid duplicate compile
   error message and duplicate vector element checking logic
 * rework ir_analyze_shuffle_vector to solve various issues
 * improve `@shuffle` to allow implicit cast of arrays
 * the shuffle tests weren't being run
2019-09-18 16:15:19 -04:00
Shawn Landden
193604c837
stage1: add @shuffle() shufflevector support
I change the semantics of the mask operand, to make it a little more
flexible. There is no real danger in this because it is a compile-error
if you do it the LLVM way (and there is an appropiate error to tell you
this).

v2: avoid problems with double-free
2019-09-18 11:26:45 -04:00
Shawn Landden
74ce5e9e13
stage1: proper return type on vector comparisons 2019-09-18 10:36:10 -04:00
Shawn Landden
0e3ca4c63e
Fix array->vector and vector->array for many types. Allow vector of bool.
Vectors do not have the same packing as arrays, and just bitcasting
is not the correct way to convert them.
2019-09-18 09:52:58 -04:00
Andrew Kelley
914ad1ec2e
fix peer result location with typed parent, ...
...runtime condition, comptime prongs.

closes #3244
2019-09-17 22:30:49 -04:00
Andrew Kelley
c6e77f248d
fix tripping llvm assert
```
Assertion `!isa<DIType>(Scope) && "shouldn't
make a namespace scope for a type"
```

We've had this problem and solved it before; see #579.
2019-09-16 14:31:41 -04:00
LemonBoy
eb7d36ae0d Make single-element enum default to u0
* Allow comptime_int as explicit enum tag type

Closes #2997
2019-09-13 15:13:10 -04:00
Andrew Kelley
0eddee449d
add behavior test for @enumToInt(enum(u1){x}.x)
closes #2737
2019-09-11 15:05:00 -04:00
stratact
a165cc0535 Get more of the tests passing for FreeBSD (#3197)
* Add missing <stdint.h> include for uint8_t type declaration

* Add needed FreeBSD check to link to libpthread

* Apply patch to enable more tests in the FreeBSD CI
2019-09-10 14:50:54 -04:00
LemonBoy
8fbae77770
Force LLVM to generate byte-aligned packed unions
Sometimes the frontend and LLVM would disagree on the ABI alignment of a
packed union. Solve the problem by telling LLVM we're gonna manage the
struct layout by ourselves.

Closes #3184
2019-09-10 10:07:32 -04:00
Sahnvour
a06f84fcc6 forbid opaque types in function return types 2019-09-10 10:11:49 -04:00
Michael Dusan
8bd5681651 fix tests.addPkgTests to always run native target
- include native-target when native-target ∉ cross_targets

old behavior:

- do nothing when `-Dskip-non-native`
- never execute pkg tests for non-members of cross_targets
2019-09-10 10:10:14 -04:00
Andrew Kelley
852679c369
fix a var decl in scope preventing for loop spills 2019-09-09 16:44:23 -04:00
Andrew Kelley
a3993465fe
Merge pull request #3200 from LemonBoy/eq-tagged-union
Allow comparison between union tag and enum literal
2019-09-09 16:17:45 -04:00
Andrew Kelley
f50bfb94b5
fix bad LLVM IR when for target expr needs to be spilled
Also reduce the size of ZigVar in memory by making the name
a `const char *` rather than a `Buf`.
2019-09-09 15:59:16 -04:00
LemonBoy
4b1cd45472 Comptime folding of enum/union comparisons 2019-09-09 19:09:56 +02:00
LemonBoy
cc63760587 Allow comparison between union tag and enum literal
Closes #2810
2019-09-09 18:51:13 +02:00
Andrew Kelley
f7721ac37c
implement spilling when returning error union async function call
closes #3190
2019-09-09 12:15:39 -04:00
Michael Dusan
0d9a78a852 test-stack-traces: add FreeBSD 2019-09-09 00:25:21 -04:00
Andrew Kelley
229323e13a
fix suspensions inside for loops generating invalid LLVM IR
closes #3076
2019-09-07 17:37:17 -04:00
Andrew Kelley
9a18db8a80
properly spill expressions with async function calls 2019-09-07 00:27:45 -04:00
Andrew Kelley
d1a98ccff4
implement spills when expressions used across suspend points
closes #3077
2019-09-07 00:13:12 -04:00
Andrew Kelley
9ca8d9e21a
fix await used in an expression generating bad LLVM 2019-09-07 00:13:12 -04:00
Andrew Kelley
7d303ae861
runtime safety for noasync function calls
See #3157
2019-09-06 13:08:44 -04:00
Andrew Kelley
0a3c6dbda9
implement noasync function calls
See #3157
2019-09-05 21:55:32 -04:00
Timon Kruiper
ca70ca7e26 Add compiler error when negating invalid type 2019-09-05 15:27:50 -04:00
Andrew Kelley
2045b4d932
prefer result type casting to peer type resolution
See #2749
2019-09-05 14:56:52 -04:00
Timon Kruiper
866c253e0e
Add compile error when shifting amount is not an int type 2019-09-05 13:10:39 -04:00
LemonBoy
8e3c56b912
Always resolve the struct field types
Packed structs used to skip the zero-sized types and trip some
assertions that expected the type reference not to be null.

Fixes #3143
2019-09-05 13:07:04 -04:00
LemonBoy
0107b19124 Resolve lazy values when checking for definedness
Fixes #3154
2019-09-05 13:09:43 -04:00
Jonathan Marler
9a358d2d33 Add Array support to @Type 2019-09-05 13:08:45 -04:00
Timon Kruiper
e540e5b8ec
Implicit cast from enum literal to optional enum and implicit cast to payload of error union 2019-09-04 12:30:23 -04:00
Andrew Kelley
ac7703f65f
fixups and add documentation for @Type 2019-09-04 11:12:14 -04:00
Jonathan Marler
b728cb6d4e Add @Type builtin 2019-09-03 22:50:29 -06:00
Sahnvour
ce14c543d1 error message and test for alignment of variables of zero-bit types 2019-09-03 21:14:40 -04:00
Andrew Kelley
a81e4351a2
Merge branch 'fixSegfault' of https://github.com/marler8997/zig into marler8997-fixSegfault 2019-09-03 18:15:01 -04:00
Andrew Kelley
be17a4b6c1
fix compiler crash in struct field pointers
when the llvm type has not been fully analyzed. This is a regression
from lazy values.
2019-09-03 14:51:34 -04:00
Andrew Kelley
aba67ecf44
rename test-compare-panic to test-stack-traces 2019-09-03 10:08:39 -04:00
Andrew Kelley
1fd24791a7
rename compare-panic to compare-stack-traces 2019-09-03 10:05:19 -04:00
Michael Dusan
a19e73d8ae
test: add compare-panic
`zig build test-compare-panic`

Create basic tests to compare panic output. The address field
is replaced by a symbolic constant and each expected output is
specific to os. Tests will only run for explicitly defined
platforms.

see also #2485
2019-09-03 09:59:43 -04:00
Andrew Kelley
4a5b0cde13
fix const result loc, runtime if cond, else unreachable
Closes #2791. See that issue for more details; I documented the
debugging process quite thoroughly on this one.
2019-09-02 20:28:25 -04:00
Andrew Kelley
ab4cba14c8
fix recursive call of await @asyncCall with struct return type 2019-09-02 14:35:41 -04:00
Andrew Kelley
d291d3c8c0
fix using @typeOf on a generic function call 2019-09-02 13:07:44 -04:00
Andrew Kelley
0c4d47c6d5
add regression test for already fixed bug
closes #2692
2019-09-01 23:35:58 -04:00
Andrew Kelley
ec6f15b0f5
fix @typeOf an async function call of generic fn with error union type 2019-09-01 00:27:22 -04:00
Andrew Kelley
5c3a9a1a3e
improvements to @asyncCall
* `await @asyncCall` generates better code. See #3065
 * `@asyncCall` works with a real `@Frame(func)` in addition to
   a byte slice. Closes #3072
 * `@asyncCall` allows passing `{}` (a void value) as the result
   pointer, which uses the result location inside the frame.
   Closes #3068
 * support `await @asyncCall` on a non-async function. This is in
   preparation for safe recursion (#1006).
2019-08-31 18:50:16 -04:00
Andrew Kelley
a223063923
@typeOf now guarantees no runtime side effects
related: #1627
2019-08-31 11:00:31 -04:00
Andrew Kelley
6ab8b2aab4
support recursive async and non-async functions
which heap allocate their own frames

related: #1006
2019-08-30 20:06:02 -04:00
Andrew Kelley
d9fed5cdfd
align(@alignOf(T)) T does not force resolution of T 2019-08-30 14:53:44 -04:00
Andrew Kelley
e9a4bcbcc6
fix regressions 2019-08-29 22:44:07 -04:00
Andrew Kelley
03910925f0
await does not force async if callee is blocking
closes #3067
2019-08-29 21:51:37 -04:00
Andrew Kelley
0512beca9d
comparing against zero participates in lazy values 2019-08-29 14:46:22 -04:00
Andrew Kelley
af90da1531
fix implicit cast from zero sized array ptr to slice
closes #1850
2019-08-28 12:16:52 -04:00
Andrew Kelley
7139eef4cf
implement lazy values for error union types
closes #3129
2019-08-28 11:17:20 -04:00
Andrew Kelley
47fcbfdc51
add regression test for already fixed bug
closes #3112
2019-08-27 17:39:06 -04:00
Andrew Kelley
f4519c520a
support self-referential struct through a slice of optional
by making optionals even more lazy

closes #1805
2019-08-27 16:55:58 -04:00
Andrew Kelley
c1fd7ed6e2
add regression test for struct with optional list of self
closes #1735
2019-08-27 14:06:17 -04:00
Andrew Kelley
428a2fdedd
better handle struct depends on itself via optional field
closes #1995
2019-08-27 13:59:18 -04:00
Andrew Kelley
e1b258f39f
add regression test for bug fixed by lazy values
closes #624
2019-08-27 13:44:04 -04:00
Andrew Kelley
8fef23a525
add regression test for bug fixed by lazy values
closes #1310
2019-08-27 13:36:42 -04:00
Andrew Kelley
d9ed55f017
fix not properly casting align values
and add check for alignment specified on enum fields
2019-08-27 12:54:50 -04:00
Andrew Kelley
ffac0b02e7
implement and test struct field explicit alignment 2019-08-27 10:14:11 -04:00
Andrew Kelley
db50cf7049
fix more compile error regressions 2019-08-26 22:38:45 -04:00
Andrew Kelley
bad4b040cc
miscellaneous fixes regarding compile errors 2019-08-26 18:35:36 -04:00
Andrew Kelley
ae65c236c5
fix regression with global variable assignment...
...with optional unwrapping with var initialized to undefined
2019-08-26 15:24:24 -04:00
Andrew Kelley
d316f70450
fix regression on struct field with undefined type 2019-08-26 14:01:59 -04:00
Andrew Kelley
73a7747a9c
fix some compile error regressions 2019-08-26 12:43:36 -04:00
Jonathan Marler
1b19c28c79 Fix issue 3058: zig build segfault 2019-08-24 10:47:27 -06:00
Andrew Kelley
276eb4402b
specify the target for the newest test case 2019-08-20 14:40:57 -04:00
Timon Kruiper
2addec8ea1
compiler error when variable in asm template cannot be found 2019-08-20 14:11:03 -04:00
Marc Tiehuis
2aa18b9097
Merge pull request #3090 from ziglang/fmt-internal
fmt changes
2019-08-19 19:48:05 -10:00
Andrew Kelley
3dbed54294
fix @bitCast of packed struct literal
closes #3042
2019-08-19 17:50:37 -04:00
Andrew Kelley
6bc520ab95
solve it a slightly different way
the error handling of result locations is a bit awkward but it should
basically be the same everywhere
2019-08-19 17:35:19 -04:00
Michael Dusan
24deb1a7fe
fix @bitCast segfault with literal array param
closes #3010
2019-08-19 17:24:14 -04:00
Andrew Kelley
d067a037cc
fix void array as a local variable initializer
Related: #1767
2019-08-19 15:58:31 -04:00
Andrew Kelley
44fb5275c1
fix array multiplication not setting parent value info
closes #3095
2019-08-19 14:46:12 -04:00
Marc Tiehuis
98859c885e std/fmt.zig: Pass full options struct to all internal functions
The fill specifier is now handled in some cases. The default fill of '0'
is now ' ' for integers and non-byte sequences.
2019-08-19 22:15:15 +12:00
Andrew Kelley
ea1734773b
add compile error for async frames depending on themselves 2019-08-17 19:47:49 -04:00
Andrew Kelley
57b90d2d98
allow implicit cast of fn to async fn
it forces the fn to be async. closes #3079
2019-08-17 17:22:20 -04:00
Andrew Kelley
66a490c27c
detect non-async function pointer of inferred async function
closes #3075
2019-08-17 16:49:23 -04:00
Vexu
0ff396c34f add compile error for incorrect atomic ordering in fence #3082 2019-08-17 16:05:41 -04:00
Andrew Kelley
4d8a6f6fea
fix compiler not checking alignment of function frames
closes #3086
2019-08-17 13:04:50 -04:00
Andrew Kelley
bf7b6fbbdb
add missing compile error for fn call bad implicit cast
when the function's return type handle is a pointer but the result
location's result value type handle is not a pointer

closes #3055
2019-08-16 16:30:24 -04:00
Andrew Kelley
cbca6586e7
add test for struct parameter to async function being copied
closes #1155
2019-08-16 13:56:26 -04:00
Andrew Kelley
5a2cbe239f
fix and test case for returning from suspend block
See #3063
2019-08-16 13:07:07 -04:00
Andrew Kelley
13c584d325
add compile error for casting const frame to anyframe
See #3063
2019-08-16 11:38:41 -04:00
Andrew Kelley
7798054b58
add tests for bad implicit casting of anyframe types
See #3063
2019-08-16 11:00:21 -04:00
Andrew Kelley
4ea2331e3d
add test for async call of generic function
See #3063
2019-08-16 10:54:45 -04:00
Andrew Kelley
5df89dafef
add test for wrong frame type used for async call
See #3063
2019-08-16 10:49:00 -04:00
Andrew Kelley
1254a453b9
add compile error for @Frame() of generic function
See #3063
2019-08-16 10:44:51 -04:00
Andrew Kelley
49c88e23af
zig fmt 2019-08-16 10:13:40 -04:00
Andrew Kelley
ff7e826b82
fix crash with sometimes type not being resolved 2019-08-15 18:54:23 -04:00
Andrew Kelley
7e75e1075e
zig fmt 2019-08-15 18:19:04 -04:00
Andrew Kelley
55f5cee86b
fix error return traces for async calls of blocking functions 2019-08-15 15:06:05 -04:00
Andrew Kelley
13b5a4bf8c
remove cancel 2019-08-15 14:05:12 -04:00
Andrew Kelley
f3f838cc01
add compile error for await in exported function 2019-08-14 11:22:12 -04:00
Andrew Kelley
7799423f24
rename behavior test files 2019-08-14 00:38:27 -04:00
Andrew Kelley
5749dc49d8
respect local variable alignment in async functions 2019-08-14 00:35:51 -04:00
Andrew Kelley
12ff91c1c9
alignment of structs no longer depends on LLVM
fixes async function tests in optimized builds
2019-08-13 12:44:30 -04:00
Andrew Kelley
8a9289996a
Merge remote-tracking branch 'origin/master' into rewrite-coroutines 2019-08-13 11:39:32 -04:00
Andrew Kelley
4d8d513e16
all tests passing 2019-08-11 19:53:10 -04:00
Andrew Kelley
b87686dfa0
fix enum with one member and custom tag type 2019-08-11 13:43:44 -04:00
Andrew Kelley
1b83ee78a4
allow comptime_int to implicit cast to comptime_float 2019-08-11 12:01:02 -04:00
Andrew Kelley
3f5c6d7a89
add test case for typical async/await usage 2019-08-10 18:03:36 -04:00
Andrew Kelley
77d098e92d
fix returning a const error from async function 2019-08-10 17:23:45 -04:00
Andrew Kelley
22428a7546
fix try in an async function with error union and non-zero-bit payload 2019-08-10 15:20:08 -04:00
Andrew Kelley
b9d1d45dfd
fix combining try with errdefer cancel 2019-08-09 21:49:40 -04:00
Andrew Kelley
2e7f53f1f0
fix cancel inside an errdefer 2019-08-09 17:34:06 -04:00
Andrew Kelley
614cab5d68
fix passing string literals to async functions 2019-08-08 19:08:41 -04:00
Andrew Kelley
bfa1d12fba
better compile errors when frame depends on itself 2019-08-08 13:44:57 -04:00
Andrew Kelley
d813805f77
more debuggable safety for awaiting twice 2019-08-08 12:02:56 -04:00
Andrew Kelley
34bfdf193a
cancel, defer, errdefer all working as intended now 2019-08-08 11:37:49 -04:00
Andrew Kelley
e11cafbd4f
cancel works on non-pointers 2019-08-07 10:56:37 -04:00
Andrew Kelley
7e1fcb55b3
implement cancel
all behavior tests passing in this branch
2019-08-07 00:53:04 -04:00
Andrew Kelley
1afbb53661
fix awaiting when result type is a struct 2019-08-06 19:07:25 -04:00
Andrew Kelley
966c9ea63c
error return trace across suspend points 2019-08-06 18:47:09 -04:00
Andrew Kelley
17199b0879
passing the error return trace async function test 2019-08-06 18:29:56 -04:00
Andrew Kelley
20f63e588e
async functions have error return traces where appropriate
however the traces are not merged on `await` or async function calls
yet.

When an async function has an error set or error union as its return
type, it has a `StackTrace` before the args in the frame, so that it is
accessible from `anyframe->T` awaiters. However when it does not have an
errorable return type, but it does call or await an errorable, it has a
stack trace just before the locals. This way when doing an `@asyncCall`
on an async function pointer, it can populate the args (which are after
the `StackTrace`) because it knows the offset of the args based only on
the return type.

This sort of matches normal functions, where a stack trace pointer could
be supplied by a parameter, or it could be supplied by the stack of the
function, depending on whether the function itself is errorable.
2019-08-05 03:10:14 -04:00
Andrew Kelley
0d8c9fcb18
support async functions with inferred error sets 2019-08-05 00:41:49 -04:00
Andrew Kelley
fa30ebfbe5
suspension points inside branching control flow 2019-08-04 18:24:10 -04:00
Andrew Kelley
87710a1cc2
implement @asyncCall which supports async function pointers 2019-08-03 16:17:42 -04:00
Andrew Kelley
c879209661
add compile error for calling async function pointer 2019-08-03 02:40:38 -04:00
Andrew Kelley
e444e737b7
add runtime safety for resuming an awaiting function 2019-08-03 02:11:52 -04:00
Andrew Kelley
24d78177ee
add compile error for async call of function pointer 2019-08-03 01:06:14 -04:00
Andrew Kelley
0920bb0872
implement async functions returning structs 2019-08-02 19:27:27 -04:00
Andrew Kelley
5bd330e76c
add heap allocated async function frame test 2019-08-02 16:32:24 -04:00
Andrew Kelley
b3b6a98451
Merge remote-tracking branch 'origin/master' into rewrite-coroutines 2019-08-02 16:31:43 -04:00
Andrew Kelley
f07f09a373
Merge branch 'master' into rewrite-coroutines 2019-08-02 16:13:36 -04:00
Andrew Kelley
d105769926
fix regressions regarding writing through const pointers 2019-08-02 16:09:40 -04:00
Andrew Kelley
9069ee957c
fix discarding function call results 2019-08-02 15:17:02 -04:00
Andrew Kelley
90e64bc620
fix cmpxchg with discarded result 2019-08-02 14:47:26 -04:00
Andrew Kelley
a5cb0f77d1
assignment participates in result location
fix one regression with optionals but there are more
2019-08-02 13:54:58 -04:00
Andrew Kelley
056c4e2c98
implement async await and return 2019-08-02 01:06:00 -04:00
Andrew Kelley
0f879d02a4
more passing coroutine tests 2019-08-01 19:14:48 -04:00
Andrew Kelley
1dd0c3d49f
fix calling an inferred async function 2019-08-01 16:41:30 -04:00
Andrew Kelley
e7ae4e4645
reimplement async with function splitting instead of switch 2019-08-01 16:08:52 -04:00
Andrew Kelley
6cb4cac5cd
disable behavior test for 128-bit cmpxchg
once #2883 is done this can be revisited
2019-08-01 03:36:03 -04:00
Andrew Kelley
38b5812c48
allow 128 bit cmpxchg on x86_64 2019-08-01 02:46:37 -04:00
Andrew Kelley
dbdc4d62d0
improve support for anyframe and anyframe->T
* add implicit cast from `*@Frame(func)` to `anyframe->T` or `anyframe`.
 * add implicit cast from `anyframe->T` to `anyframe`.
 * `resume` works on `anyframe->T` and `anyframe` types.
2019-07-29 19:32:49 -04:00
Andrew Kelley
ee64a22045
add the anyframe and anyframe->T types 2019-07-26 19:52:35 -04:00
Andrew Kelley
538c0cd225
implement @frameSize 2019-07-25 15:05:55 -04:00
Andrew Kelley
70bced5dcf
implement @frame and @Frame 2019-07-25 01:47:56 -04:00
Andrew Kelley
ead2d32be8
calling an inferred async function 2019-07-25 00:03:06 -04:00
Andrew Kelley
9e11f67f0d
add test for previous commit 2019-07-24 15:05:39 -04:00
Andrew Kelley
e220812f2f
implement local variables in async functions 2019-07-24 02:59:51 -04:00
Andrew Kelley
19ee495750
add error for function with ccc indirectly calling async function 2019-07-23 19:35:41 -04:00
Vexu
57aa8997bd fix escape sequence rendering 2019-07-23 14:49:19 -04:00
Andrew Kelley
317d1ecb2c
Merge remote-tracking branch 'origin/master' into rewrite-coroutines 2019-07-22 14:37:08 -04:00
Andrew Kelley
fcadeb50c0
fix multiple coroutines existing clobbering each other 2019-07-22 14:36:14 -04:00
Andrew Kelley
16be70cbbf
compiler-rt: add __muldi3 2019-07-22 12:49:26 -04:00
Andrew Kelley
59bf9ca58c
implement async function parameters 2019-07-21 23:27:47 -04:00
Andrew Kelley
11bd50f2b2
implement coroutine resume 2019-07-21 20:54:08 -04:00
Andrew Kelley
78e03c466c
simple async function passing test 2019-07-21 19:56:37 -04:00
Andrew Kelley
54e716afdc
remove coroutines implementation and promise type 2019-07-19 18:18:44 -04:00
Andrew Kelley
af8661405b
fix usingnamespace
It used to be that usingnamespace was only allowed at top level. This
made it OK to put the state inside the AST node data structure. However,
now usingnamespace can occur inside any aggregate data structure, and
therefore the state must be in the TopLevelDeclaration rather than in
the AST node.

There were two other problems with the usingnamespace implementation:

 * It was passing the wrong destination ScopeDecl, so it could cause an
   incorrect error such as "import of file outside package path".
 * When doing `usingnamespace` on a file that already had
   `pub usingnamespace` in it would "steal" the usingnamespace, causing
   incorrect "use of undeclared identifier" errors in the target file.

closes #2632
closes #2580
2019-07-19 16:56:44 -04:00
Andrew Kelley
9dcddc2249
retire the example/ folder, rename test-build-examples to "standalone"
closes #2759
2019-07-16 12:15:46 -04:00
Andrew Kelley
741c74e427
cleanups 2019-07-16 11:50:00 -04:00
Andrew Kelley
45cc488cef
Merge branch 'main-return-!u8' of https://github.com/SamTebbs33/zig into SamTebbs33-main-return 2019-07-16 11:27:11 -04:00
Andrew Kelley
6fe3b20962
Merge branch 'translate-c-userland' of https://github.com/hryx/zig into hryx-translate-c-userland 2019-07-15 22:19:54 -04:00
Andrew Kelley
c0489abcdb
translate-c: fix incorrectly translated double function pointer
closes #2887
2019-07-13 12:38:10 -04:00
Andrew Kelley
4e58855a4a
translate-c: better detection of pointer to struct demoted to opaque 2019-07-12 12:11:26 -04:00
SamTebbs33
b118806c69 Add implicit cast for *[N]T to [*c]T 2019-07-06 17:02:17 -04:00
hryx
6bfa8546bb
Unicode escapes: stage1 tokenizer and behavior tests 2019-07-04 22:40:19 -07:00
SamTebbs33
f24b8f2a4a Support returning !u8 from main 2019-07-04 14:26:05 +01:00
Andrew Kelley
96fd103073
improve the error message and test coverage 2019-07-04 00:35:28 -04:00
Andrew Kelley
bfe0bf695b
Merge branch 'impl-1107' of https://github.com/emekoi/zig into emekoi-impl-1107 2019-07-03 23:40:47 -04:00
emekoi
a1b952f4b0 added tests for #1107 and a note in the reference 2019-07-03 13:12:14 -05:00
Andrew Kelley
9da054095c
Merge branch 'comptime-union-init' of https://github.com/rbscott/zig into rbscott-comptime-union-init 2019-07-03 11:26:55 -04:00
Andrew Kelley
9daf0140e5
add missing compile error for comptime continue inside runtime catch
See #2604
2019-07-02 21:14:42 -04:00
Andrew Kelley
df11512f85
fixups 2019-07-02 16:52:55 -04:00
Andrew Kelley
140335b99f
Merge branch 'has-field' of https://github.com/shawnl/zig into shawnl-has-field 2019-07-02 16:21:40 -04:00
hryx
cc74bf5136
Translate IntegralCast; add stage2 test coverage 2019-06-27 23:12:33 -07:00
hryx
2060c7c39b
Merge branch 'master' into translate-c-userland 2019-06-27 22:12:34 -07:00
Andrew Kelley
0a0c11685f
fix for with null and T peer types and inferred result location type
See #2762
2019-06-27 17:22:35 -04:00
Andrew Kelley
1b23c46138
fix switch with null and T peer types and inferred result location type
closes #2762
2019-06-27 16:54:19 -04:00
Andrew Kelley
1ccf6a2c9e
compile error for using slice as array init expr type
when there are more than 0 elements.

closes #2764
2019-06-27 12:24:13 -04:00
Andrew Kelley
6c195ede54
add test case for defer modifying return value before returned
See #961
2019-06-26 23:25:53 -04:00
Andrew Kelley
3085d29af8
Merge remote-tracking branch 'origin/master' into copy-elision-3 2019-06-26 14:44:01 -04:00
Andrew Kelley
ff737cc648
fix peer type resolution: unreachable, error set, unreachable 2019-06-26 12:31:51 -04:00
Andrew Kelley
b4e40cb59a
fix peer type resolution with null 2019-06-26 00:36:24 -04:00
Andrew Kelley
fd4c5f54f0
all compile error tests passing 2019-06-25 19:03:56 -04:00
Andrew Kelley
0a77325916
fix several compile error test regressions 2019-06-25 18:06:03 -04:00
Andrew Kelley
cb55803a59
fix implicit cast vector to array 2019-06-25 13:57:45 -04:00
Andrew Kelley
c61e0a078c
fix union init with void payload
all std lib tests passing now
2019-06-25 11:31:38 -04:00
Marc Tiehuis
f5af349bd6
Merge pull request #2714 from ziglang/fmt-overhaul
Add positional, precision and width support to std.fmt
2019-06-25 20:15:33 +12:00
hryx
b2e06c3bf4
Observe translate mode in stage2 2019-06-23 14:32:45 -07:00
Andrew Kelley
b2cbc59e4c
Merge branch 'simd2' of https://github.com/shawnl/zig into shawnl-simd2 2019-06-23 17:10:33 -04:00
hryx
226a23d977
stage1: always render space after fn like stage2 2019-06-23 12:46:17 -07:00
Andrew Kelley
020d5b529e
compile error tests only for debug mode 2019-06-23 02:06:57 -04:00
Andrew Kelley
036cc48a82
Merge remote-tracking branch 'origin/master' into copy-elision-3 2019-06-23 01:29:48 -04:00
Shawn Landden
71e014caec stage1: add @sin @cos @exp @exp2 @ln @log2 @log10 @fabs @floor @ceil @trunc @round
and expand @sqrt

This revealed that the accuracy of ln is not as good as the current algorithm in
musl and glibc, and should be ported again.

v2: actually include tests
v3: fix reversal of in and out arguments on f128M_sqrt()
    add test for @sqrt on comptime_float
    do not include @nearbyInt() until it works on all targets.
2019-06-22 14:34:34 -05:00
Sahnvour
987c209b40 heap: make one global instance of DirectAllocator
it is now stateless, so the de/init are not necessary anymore
2019-06-22 14:10:53 -04:00
Andrew Kelley
3c4b255a3c
fix implicit cast fn call result to optional in field result 2019-06-22 13:37:13 -04:00
Andrew Kelley
727af307c6
fix return result loc and then switch with range...
...implicit casted to error union
2019-06-21 18:21:12 -04:00
Andrew Kelley
ff6d563b04
fix implicit cast to optional to error union to return result loc 2019-06-21 17:49:54 -04:00
Andrew Kelley
5441f77672
fix implicit cast bitcast result to error union by returning 2019-06-21 16:54:46 -04:00
Andrew Kelley
142e77abbb
fix extern functions returning byval structs 2019-06-21 14:44:49 -04:00
Andrew Kelley
48ccf427af
fix nested orelse and nested catch 2019-06-21 14:06:01 -04:00
Marc Tiehuis
11526b6e9d breaking: Add positional, precision and width support to std.fmt
This removes the odd width and precision specifiers found and replacing
them with the more consistent api described in #1358.

Take the following example:

    {1:5.9}

This refers to the first argument (0-indexed) in the argument list. It
will be printed with a minimum width of 5 and will have a precision of 9
(if applicable).

Not all types correctly use these parameters just yet. There are still
some missing gaps to fill in. Fill characters and alignment have yet to
be implemented.
2019-06-21 20:11:15 +12:00
Andrew Kelley
4f21dc8a80
fix regression with zero sized array
thanks mikdusan!
2019-06-21 00:58:18 -04:00
Andrew Kelley
0498bd40d9
fix loops with multiple break statements 2019-06-20 22:38:40 -04:00
Andrew Kelley
237233b04b
fix coroutines 2019-06-20 18:27:04 -04:00
Andrew Kelley
057b105fad
one more test passing 2019-06-20 18:03:55 -04:00
Andrew Kelley
3c541d7be3
fix peer result loc fn call with comptime condition 2019-06-19 23:52:51 -04:00
Andrew Kelley
6217b401f9
fix labeled break inside comptime if inside runtime if 2019-06-19 23:39:49 -04:00
Andrew Kelley
78eeb6e9ae
fix double getelementptr of runtime global 2019-06-19 22:29:39 -04:00
Andrew Kelley
04c25efe11
Merge remote-tracking branch 'origin/master' into copy-elision-3 2019-06-19 19:01:28 -04:00
Andrew Kelley
4ffab5b85f
fix optional pointer to size zero struct 2019-06-19 18:47:02 -04:00
Andrew Kelley
c7dc03fcb1
fix try not setting error code on result location 2019-06-19 17:07:05 -04:00
Andrew Kelley
96931228af
fix comptime test error for empty error set 2019-06-19 16:29:46 -04:00
Andrew Kelley
974db231a0
fix extraneous nested union field instruction 2019-06-19 16:16:47 -04:00
Andrew Kelley
e36680d3bd
fix detection of unable to evaluate constant expression 2019-06-19 15:18:51 -04:00
Andrew Kelley
b588a803bf
fix comptime modification of const struct field 2019-06-19 14:35:59 -04:00
Shawn Landden
39ad072a84 test: include muladd.zig in behavior tests 2019-06-19 12:07:02 -05:00
Shawn Landden
fce2d2d18b stage1: add support for @mulAdd fused-multiply-add for floats and vectors of floats
Not all of the softfloat library is being built....

Vector support is very buggy at the moment, but should work when the bugs are fixed.
(as I had the same code working with another vector function, that hasn't been merged yet).
2019-06-19 12:07:02 -05:00
Andrew Kelley
79671efd3a
fix inline loop behavior with variable result loc 2019-06-18 17:43:05 -04:00
Andrew Kelley
e27da17ff2
back to many behavioral tests passing 2019-06-18 17:07:27 -04:00
Andrew Kelley
9050a07540
when resolving slice types, might need to...
...resolve alignment if custom alignment is provided

fixes #2689
2019-06-18 11:31:05 -04:00
Andrew Kelley
8ed88280a6
Revert "fixes resolving aligment of child type in slice"
This reverts commit aa60d2a688.

The copyright ownership of this 10 line patch is under dispute.
See #2701 for details. So I'll revert it and then fix it myself without
looking at this patch.
2019-06-18 11:18:53 -04:00
Andrew Kelley
f4b8850002
fix type info crash on extern lib name 2019-06-16 14:14:57 -04:00
Jimmi HC
aa60d2a688 fixes resolving aligment of child type in slice 2019-06-16 00:03:43 -04:00
Andrew Kelley
9564c05cd5
better result location handling of inline loops 2019-06-15 19:19:13 -04:00
Andrew Kelley
6bf193af19
better result location semantics with optionals and return locations
somewhere along this branch, #1901 has been fixed.
2019-06-15 12:28:21 -04:00
Andrew Kelley
60025a3704
Merge remote-tracking branch 'origin/master' into copy-elision-3 2019-06-15 10:34:04 -04:00
Andrew Kelley
42ea2d0d1c
fix @export for arrays and allow sections on extern variables
previously `@export` for an array would panic with a TODO message.
now it will do the export. However, it uses the variable's name
rather than the name passed to `@export`. Issue #2679 remains open
for that problem.
2019-06-14 15:28:52 -04:00
Andrew Kelley
acf16b5fb3
uncomment more passing tests 2019-06-14 13:32:04 -04:00