Commit Graph

2582 Commits

Author SHA1 Message Date
Andrew Kelley
9c8dfadbb1 add compile error for casting const array to mutable slice
See #1565
2018-09-20 12:24:51 -04:00
Andrew Kelley
f8fe517d12 better string literal caching implementation
We were caching the ConstExprValue of string literals,
which works if you can never modify ConstExprValues.
This premise is broken with `comptime var ...`.

So I implemented an optimization in ConstExprValue
arrays, where it stores a `Buf *` directly rather
than an array of ConstExprValues for the elements,
and then similar to array of undefined, it is
expanded into the canonical form when necessary.
However many operations can happen directly on the
`Buf *`, which is faster.

Furthermore, before a ConstExprValue array is expanded
into canonical form, it removes itself from the string
literal cache. This fixes the issue, because before an
array element is modified it would have to be expanded.

closes #1076
2018-09-20 11:04:31 -04:00
Andrew Kelley
345f8db1c4 fix optional pointer to empty struct incorrectly being non-null
closes #1178
2018-09-18 17:51:50 -04:00
Andrew Kelley
c1af360532 add compile error for slice.*.len
closes #1372
2018-09-18 16:32:40 -04:00
Andrew Kelley
8c77c5705f implementation for bitcasting extern enum type to c_int
closes #1036
2018-09-18 15:00:14 -04:00
Andrew Kelley
5fd3af9dc6 fix implicit cast of packed struct field to const ptr
closes #966
2018-09-18 14:34:30 -04:00
Andrew Kelley
d353d5aef8 fix @bytesToSlice on a packed struct
closes #1551
2018-09-18 09:49:57 -04:00
Josh Wolfe
13645585fe link to #1544 2018-09-17 21:25:37 -04:00
Josh Wolfe
d7492b2c22 somewhat realistic usecase test for shifting strange integer sizes 2018-09-17 20:49:23 -04:00
Andrew Kelley
bfcfaaf5bd fix codegen for @intCast to u0 2018-09-17 20:33:42 -04:00
Andrew Kelley
b16229da1d add compile error for @ptrCast 0 bit type to non-0 bit type 2018-09-17 19:41:11 -04:00
Andrew Kelley
78a9a465a3 add compile error for non-optional types compared against null
closes #1539
2018-09-17 18:58:50 -04:00
Andrew Kelley
6c71e9a54d fix crash when bit shifting a u1 2018-09-17 18:44:45 -04:00
Andrew Kelley
cf9200b815 dereferencing a *u0 is comptime-known to be 0 2018-09-17 18:13:38 -04:00
Andrew Kelley
4c6f1e614a remove zig build --init. add zig init-lib and zig init-exe
init-lib creates a working static library with tests, and
init-exe creates a working hello world with a `run` target.

both now have test coverage with the new "cli tests" file.

closes #1035
2018-09-17 17:11:18 -04:00
Andrew Kelley
9c9eefc841 allow extern structs to have stdcallcc function pointers
closes #1536
2018-09-17 11:22:30 -04:00
Andrew Kelley
dd5b2d1b04 fix crash when pointer casting a runtime extern function 2018-09-16 11:23:38 -04:00
Andrew Kelley
3f776af3fa fix alignment of structs
closes #1248
closes #1052
closes #1154
2018-09-14 19:08:59 -04:00
Wink Saville
82af31ce36 Fix additional regressions calling FileOutStream/FileInStream init()
This is caused by change 686663239a and not
fixed in 832caefc2a.
2018-09-14 12:07:21 -04:00
Andrew Kelley
3d38feded9 fix tagged union with all void payloads but meaningful tag
closes #1322
2018-09-14 00:38:22 -04:00
Andrew Kelley
1e03cf1739 fix assertion failure on compile-time @intToPtr of function 2018-09-13 19:12:25 -04:00
Andrew Kelley
c06a61e9bf remove this. add @This().
closes #1283
2018-09-13 16:34:33 -04:00
Andrew Kelley
7c3636aaa3 remove the scope parameter of setFloatMode
also document that scopes inherit this value. See #367
See #1283
2018-09-13 15:46:34 -04:00
Andrew Kelley
ac0cda8df8 add compile error for merging non- error sets
closes #1509
2018-09-13 13:48:41 -04:00
Andrew Kelley
22e39e1e5a fix tagged union with only 1 field tripping assertion
closes #1495

now the tag type of an enum with only 1 item is comptime_int.
2018-09-13 13:33:11 -04:00
Andrew Kelley
7dd3c3814d fix incorrect error union const value generation
closes #1442

zig needed to insert explicit padding into this structure before
it got bitcasted.
2018-09-11 15:16:50 -04:00
Andrew Kelley
dd1338b0e6 fix incorrect union const value generation
closes #1381

The union was generated as a 3 byte struct when it needed to be
4 bytes so that the packed struct bitcast could work correctly.

Now it recognizes this situation and adds padding bytes to become
the correct size so that it can fit into an array.
2018-09-11 12:59:39 -04:00
Andrew Kelley
52f4e934a9 fix llvm assertion and missing compile error 2018-09-10 22:44:27 -04:00
Andrew Kelley
9c169f3cf7 C ABI: support returning large structs on x86_64
also panic instead of emitting bad code for returning small structs

See #1481
2018-09-07 20:09:33 -04:00
Andrew Kelley
9017efee22 C ABI: support medium size structs & unions for x86_64 params
See #1481
2018-09-07 18:51:34 -04:00
raulgrell
09a1162af5 builtin functions: @byteOffsetOf and @bitOffsetOf 2018-09-07 22:49:19 +01:00
Andrew Kelley
b18af37c57 fix crash when var init has compile error
and then the var is referenced

closes #1483
2018-09-07 15:17:24 -04:00
Andrew Kelley
743b2e4afc add C ABI test for big unions 2018-09-07 13:51:11 -04:00
Andrew Kelley
be6cccb3a5 stage1: c abi for big struct works 2018-09-07 11:52:57 -04:00
Andrew Kelley
a9a925e500 add C ABI tests 2018-09-06 16:29:35 -04:00
Andrew Kelley
6632d85e5f stage1: improve handling of generic fn proto type expr
closes #902
2018-09-05 21:21:59 -04:00
Andrew Kelley
1d8b8ad687 add compile error for using outer scoped runtime variables
from a fn defined inside it. closes #876
2018-09-05 20:32:06 -04:00
Andrew Kelley
a3d384e593 add test case for #726 2018-09-05 18:20:04 -04:00
Andrew Kelley
b517bea734 allow comptime_int to @floatToInt 2018-09-05 18:01:48 -04:00
hfcc
768d1fc539 Added compilation error when a non-float is given to @floatToInt() 2018-09-05 23:31:25 +02:00
Andrew Kelley
ffb3b1576b stage1: fix tagged union with no payloads
closes #1478
2018-09-05 16:19:58 -04:00
Andrew Kelley
c87a576cb5 stage1 compile error instead of crashing for unsupported comptime ptr cast
See #955
2018-09-05 15:53:36 -04:00
Andrew Kelley
a76a72469b stage1: fix crash when invalid type used in array type
closes #1186
2018-09-05 10:43:35 -04:00
Andrew Kelley
869167fc6d compile error for @noInlineCall on an inline fn
closes #1133
2018-09-04 17:38:48 -04:00
Andrew Kelley
68db9d5074 add compile error for comptime control flow inside runtime block
closes #834
2018-09-04 15:28:35 -04:00
Andrew Kelley
e82cd53df4 fix incorrect value for inline loop
09cc1dc660 failed to handle mem_slot_index correctly

closes #1436
2018-09-03 21:24:20 -04:00
Andrew Kelley
95636c7e5f ability to @ptrCast to *void
fixes #960
2018-09-03 00:04:12 -04:00
Andrew Kelley
832caefc2a fix regressions 2018-09-02 18:35:32 -04:00
Andrew Kelley
b65cca37ce add test coverage for invalid switch expression parameter
closes #604
2018-08-28 15:48:39 -04:00
Andrew Kelley
901b5c1566 add compile error for function prototype with no body
closes #1231
2018-08-28 15:39:32 -04:00