Commit Graph

3673 Commits

Author SHA1 Message Date
LemonBoy
a090a5e3bc ir: Don't crash when converting undefined ptrs 2020-02-13 16:18:24 -05:00
LemonBoy
c5260f7f86 ir: Allow implicit conversion between vector types
Only valid when the number of elements match and the types are
compatible.

Fixes #4334
2020-02-13 12:13:56 +01:00
LemonBoy
55304128c0 Fix rendering of empty arrays 2020-02-12 23:10:53 +01:00
LemonBoy
327d40e7a3 Fix a UAF when verbose-llvm-ir is specified
The g->module is long gone when codegen_link is called.
2020-02-12 23:10:08 +01:00
LemonBoy
6c05f0949a ir: Fix erroneous error message for ptr casts
Don't blindly throw an error if two integer types are checked for
compatibility.

Bug reported in #4430
2020-02-11 17:03:11 +01:00
Michael Dusan
e624c86289 Merge pull request #4389 from mikdusan/stage1-mem
stage1: memory/report overhaul
2020-02-10 23:08:33 -05:00
Michael Dusan
edb210905d stage1: memory/report overhaul
- split util_base.hpp from util.hpp
- new namespaces: `mem` and `heap`
- new `mem::Allocator` interface
- new `heap::CAllocator` impl with global `heap::c_allocator`
- new `heap::ArenaAllocator` impl
- new `mem::TypeInfo` extracts names without RTTI
- name extraction is enabled w/ ZIG_ENABLE_MEM_PROFILE=1
- new `mem::List` takes explicit `Allocator&` parameter
- new `mem::HashMap` takes explicit `Allocator&` parameter
- add Codegen.pass1_arena and use for all `ZigValue` allocs
- deinit Codegen.pass1_arena early in `zig_llvm_emit_output()`
2020-02-10 21:08:08 -05:00
Timon Kruiper
2618366055 Add cast between [*c]T and ?[*:0]T on fn parameter
Fixes #4176
2020-02-10 19:43:58 -05:00
Andrew Kelley
3170ead9eb compile error instead of abort for unimplemented @typeInfo
of `@Frame(func)`. Closes #3995
2020-02-10 19:14:54 -05:00
Andrew Kelley
70a4794c57 fix compiler assertion when duplicating fields...
...in nested anonymous struct literals

closes #4391
2020-02-10 10:57:40 -05:00
Andrew Kelley
014f66e6de Merge pull request #4404 from ziglang/async-std
a big step towards std lib integration with async I/O
2020-02-10 00:22:59 -05:00
Andrew Kelley
5ea79bfc4a fix not checking type of return pointer
Thanks to Vexu for the test cases.

Closes #3422
Closes #3646
Closes #3224
Closes #3327
Closes #3269
2020-02-09 22:34:34 -05:00
Andrew Kelley
04ee3b01a1 fix defer interfering with return value spill 2020-02-09 17:19:28 -05:00
Andrew Kelley
24d197b037 solve previous commit a better way 2020-02-08 15:28:12 -05:00
Andrew Kelley
d80db3546c Revert "properly spill optional payload capture value"
This reverts commit 80ba21b83c.
2020-02-08 15:07:12 -05:00
Andrew Kelley
80ba21b83c properly spill optional payload capture value 2020-02-08 14:59:33 -05:00
Andrew Kelley
884804dbc3 fix async runtime function call resolves target fn frame 2020-02-08 13:45:31 -05:00
Jared Miller
b55bc5eb26 Add wWinMain and wWinMainCRTStartup to fix #4376 2020-02-07 22:52:40 -05:00
Andrew Kelley
877f39d227 fix async function call resolves target fn frame 2020-02-07 22:48:31 -05:00
Andrew Kelley
39ee1f4b97 fix invalid behavior tests from prev commit
and fix "no-op casts" from incorrectly spilling
2020-02-07 16:31:52 -05:00
Andrew Kelley
4a60689309 more carefully calculate llvm field indexes
more correctly solves #4403
2020-02-07 14:54:58 -05:00
Andrew Kelley
0b5bcd2f56 more std lib async I/O integration
* `zig test` gainst `--test-evented-io` parameter and gains the ability
   to seamlessly run async tests.
 * `std.ChildProcess` opens its child process pipe with O_NONBLOCK when
   using evented I/O
 * `std.io.getStdErr()` gives a File that is blocking even in evented
   I/O mode.
 * Delete `std.event.fs`. The functionality is now merged into `std.fs`
   and async file system access (using a dedicated thread) is
   automatically handled.
 * `std.fs.File` can be configured to specify whether its handle is
   expected to block, and whether that is OK to block even when in
   async I/O mode. This makes async I/O work correctly for e.g. the
   file system as well as network.
 * `std.fs.File` has some deprecated functions removed.
 * Missing readv,writev,pread,pwrite,preadv,pwritev functions are added
   to `std.os` and `std.fs.File`. They are all integrated with async
   I/O.
 * `std.fs.Watch` is still bit rotted and needs to be audited in light
   of the new async/await syntax.
 * `std.io.OutStream` integrates with async I/O
 * linked list nodes in the std lib have default `null` values for
   `prev` and `next`.
 * Windows async I/O integration is enabled for reading/writing file
   handles.
 * Added `std.os.mode_t`. Integer sizes need to be audited.
 * Fixed #4403 which was causing compiler to crash.

This is working towards:

./zig test ../test/stage1/behavior.zig --test-evented-io

Which does not successfully build yet. I'd like to enable behavioral
tests and std lib tests with --test-evented-io in the test matrix in the
future, to prevent regressions.
2020-02-06 18:05:50 -05:00
Andrew Kelley
704cd977bd ability to run tests in evented I/O mode
This adds `--test-evented-io` as a CLI parameter.

see #3117
2020-02-05 16:53:29 -05:00
LemonBoy
21932a0ef2 Fix edge case in cast between fn with varargs
* Prevent the next_param_index to become greater than the param_count
  one as it's expected by every other function.
* Fix a typo in a error message.

Closes #4381
2020-02-05 20:31:18 +01:00
LemonBoy
958f00f1c7 Don't generate any type info for void return types
Closely matches what the LLVM debug emitter expects, the generated DWARF
infos are now standard-compliant.
2020-02-02 15:30:12 -05:00
Andrew Kelley
58c97b3561 fix llvm assertion with debug info for vectors 2020-01-30 15:30:38 -05:00
Andrew Kelley
f97b398b65 simplify int/float comparison 2020-01-29 17:20:41 -05:00
LemonBoy
fe4ef7b461 Fix comptime float-int comparisons
Closes #4259
2020-01-29 16:37:55 -05:00
Valentin Anger
d448c3d38a Add support for code model selection 2020-01-29 16:09:07 -05:00
LemonBoy
59bc1d2721 Fix edge case in switch with single else
ir_gen_switch_expr doesn't set the switch_br field at all if there are
zero cases, detect this situation and handle it gracefully.

Closes #4322
2020-01-29 16:05:14 -05:00
Andrew Kelley
4fad16284e Merge pull request #4320 from fengb/while-spills
Add async spills to while captured variables
2020-01-29 13:37:58 -05:00
Benjamin Feng
a4ac7980b4 Add a spill to while error union 2020-01-29 10:01:51 -06:00
Benjamin Feng
2f239e3dbd Add a spill to while optional 2020-01-28 23:36:43 -06:00
LemonBoy
3ec37c979e Build compiler_rt/c with optimizations if possible 2020-01-28 19:28:39 -05:00
Andrew Kelley
504ce86ac9 fix more compile error test regressions 2020-01-28 14:17:25 -05:00
Andrew Kelley
793d81c4e8 fix result locations not handling undefined correctly 2020-01-28 13:33:51 -05:00
Andrew Kelley
86da9346e4 fix error message column/line number regressions 2020-01-28 13:25:49 -05:00
Andrew Kelley
e0000c47bd fix regression of storing optional with 0-bit payload 2020-01-28 12:32:39 -05:00
Andrew Kelley
5c55a9b4e8 fix compile error regression with struct containing itself 2020-01-28 11:52:48 -05:00
Andrew Kelley
287d3c37e1 fix 0-bit child type coerced to optional return ptr result location
by un-special-casing 0 bit types in result locations
2020-01-28 11:39:36 -05:00
Andrew Kelley
8710fdbf39 fix line, column numbers of compile errors 2020-01-27 22:05:27 -05:00
Andrew Kelley
ae20574d5e add missing spill for for loops with pointer elems 2020-01-27 21:30:11 -05:00
Andrew Kelley
c58633ef17 fix assertion with var debug loc not initialized 2020-01-27 20:56:24 -05:00
Andrew Kelley
9d59cdb8c1 fix auto created variables not having correct alignment 2020-01-27 19:42:32 -05:00
Andrew Kelley
37ab960492 fix not handling undefined u0 correctly 2020-01-27 18:59:46 -05:00
Andrew Kelley
b38b967844 fix triple level result location with bitcast sandwich
...passed as tuple element
2020-01-27 18:26:39 -05:00
Andrew Kelley
b96872ef2f @bitCast result location: fix passing invalid alignment
when the value has 0 bits
2020-01-27 17:45:29 -05:00
Andrew Kelley
c0fee9dfc7 fix nested bitcast passed as tuple element 2020-01-27 17:30:39 -05:00
Andrew Kelley
e2778c03e0 Merge branch 'master' into ir-clean-up-vars 2020-01-27 13:32:39 -05:00
Andrew Kelley
f41e50dc08 Merge branch 'fx-4274' of https://github.com/LemonBoy/zig into LemonBoy-fix-4274 2020-01-27 09:52:31 -05:00