Commit Graph

4195 Commits

Author SHA1 Message Date
Andrew Kelley
cc7060d0d9
compile error for C pointer with align attribute
See #1059
2019-02-14 20:02:29 -05:00
Andrew Kelley
973a93d43b
add docs for C pointers 2019-02-14 19:03:04 -05:00
Andrew Kelley
df87044fd6
omit nonnull attribute for C pointers
See #1059
2019-02-14 16:10:12 -05:00
Andrew Kelley
6769183a9d
fix implicit cast error unions with non-optional to optional pointer
and update self hosted compiler for C pointers

See #1059
2019-02-14 15:48:28 -05:00
Andrew Kelley
52c03de5c2
add missing compile error for OpaqueType inside structs/unions
closes #1862
2019-02-14 13:07:51 -05:00
Andrew Kelley
e03c770145
compile error tests for implicit C pointer casting
See #1059
2019-02-14 12:28:50 -05:00
Andrew Kelley
59de24817e
runtime safety check for casting null to pointer
see #1059
2019-02-14 01:09:33 -05:00
Andrew Kelley
d4d2718bca
comptime detection of casting null to pointer
See #1059
2019-02-14 00:40:39 -05:00
Andrew Kelley
5699ab5e77
C pointers: errors for nested pointer casting regarding null
See #1059
2019-02-12 18:20:00 -05:00
Andrew Kelley
270933b1e9
compile error test for casting integer to c pointer
when the int has more bits than pointers

See #1059
2019-02-12 10:25:21 -05:00
Andrew Kelley
6f05e8d1be
implicit casting between C pointer and optional non-C pointer
See #1059
2019-02-12 01:38:11 -05:00
Andrew Kelley
285e2f62ba
disallow C pointers to non-C-ABI-compatible element types
See #1059
2019-02-12 00:51:06 -05:00
Andrew Kelley
0abe6d668e
C pointers: delete dead code in ir_num_lit_fits_in_other_type 2019-02-12 00:39:08 -05:00
Andrew Kelley
069fc1a269
peer type resolution with C pointers
See #1059
2019-02-11 19:21:59 -05:00
Andrew Kelley
57a7ab0d33
comptime support for pointer arithmetic with hard coded addresses 2019-02-11 19:12:01 -05:00
Andrew Kelley
90b8cd4a45
add C pointer type to @typeInfo
See #1059
2019-02-11 16:07:40 -05:00
Andrew Kelley
342bca7f46
C pointer comparison and arithmetic
See #1059
2019-02-11 15:31:09 -05:00
Andrew Kelley
d9e01be973
translate-c: use C pointer type everywhere
See #1059
2019-02-11 14:56:59 -05:00
Andrew Kelley
4a1b910e03
zig fmt: support C pointers
See #1059
2019-02-11 14:07:19 -05:00
Andrew Kelley
661fc79fba
langref: update grammar with c pointers
See #1059
2019-02-10 12:02:56 -05:00
Andrew Kelley
73e8e46257
casting between C pointers and normal pointers
See #1059
2019-02-10 01:11:40 -05:00
Andrew Kelley
b8cbe3872e
added C pointer type and implicit int-to-ptr for this type
See #1059
2019-02-10 00:14:30 -05:00
Andrew Kelley
caf672c495
@truncate: comptime 0 when target type is 0 bits
also if the dest type is a comptime_int, then treat it
as an implicit cast.

also compile error for attempting to truncate undefined

closes #1568
2019-02-09 21:38:34 -05:00
Andrew Kelley
31be1ddf09
docs: add threadlocal keyword to grammar 2019-02-09 20:57:45 -05:00
Andrew Kelley
34eb9f18ac
fix not updating debug info type of optional error sets
There's an unfortunate footgun in the current design of error sets.
The debug info type for every error set is the same as the debug info
type of the global error set, which is essentially an enum forward
declaration. The problem is that when we "replace" the forward
declaration with the final value, once we know all the possible errors,
we have to update the pointers of every error set.

So the footgun is that if you ever copy the debug info type of the
global error set, you have to add the address of the pointer to a list
of pointers that need to be updated once we "replace" the forward
declaration. I activated the footgun when I introduced the optimization
that `?anyerror` types are the same size as `anyerror` types (using 0 as
the null value), because I introduced a pointer copy of the global error
set debug info type, but forgot to add it to the list.

I'm sure that there is a better way to code this, which does not have
the footgun, but this commit contains only a fix, not a reworking of the
logic.

closes #1937
2019-02-09 20:41:26 -05:00
Andrew Kelley
ca8580ece1
Merge branch 'vector-int-add-safety' 2019-02-09 16:24:41 -05:00
Andrew Kelley
373e21bb56
implement vector math safety with ext and trunc 2019-02-09 16:24:29 -05:00
Andrew Kelley
0a7bdc0077
implement vector addition with safety checking
this would work if @llvm.sadd.with.overflow supported
vectors, which it does in trunk. but it does not support
them in llvm 7 or even in llvm 8 release branch.

so the next commit after this will have to do a different
strategy, but when llvm 9 comes out it may be worth coming
back to this one.
2019-02-09 14:44:33 -05:00
Andrew Kelley
a8a63feba7
docgen: update for threadlocal keyword 2019-02-09 00:28:12 -05:00
Andrew Kelley
052800e952
zig fmt: support threadlocal 2019-02-09 00:19:24 -05:00
Andrew Kelley
d6f2af378a
fix docs
broken by c2db077574
2019-02-08 19:38:16 -05:00
Andrew Kelley
46ddd5f5f4
fix compiler assertion failure when returning value from test
closes #1935
2019-02-08 19:23:46 -05:00
Andrew Kelley
c2db077574
std.debug.assert: remove special case for test builds
Previously, std.debug.assert would `@panic` in test builds,
if the assertion failed. Now, it's always `unreachable`.

This makes release mode test builds more accurately test
the actual code that will be run.

However this requires tests to call `std.testing.expect`
rather than `std.debug.assert` to make sure output is correct.

Here is the explanation of when to use either one, copied from
the assert doc comments:

Inside a test block, it is best to use the `std.testing` module
rather than assert, because assert may not detect a test failure
in ReleaseFast and ReleaseSafe mode. Outside of a test block, assert
is the correct function to use.

closes #1304
2019-02-08 18:23:38 -05:00
John Schmidt
be6d022257 Make ThreadSafeFixedBufferAllocator alias FixedBufferAllocator when --single-threaded
Fixes #1910
2019-02-07 23:21:37 -05:00
Andrew Kelley
f330eebe4b fix using the result of @intCast to u0
closes #1817
2019-02-07 16:02:45 -05:00
Andrew Kelley
7843c96df8
build: make sure LLVM is exactly correct
* check the version to be the correct major version
 * ensure that it has all the default targets enabled
2019-02-07 12:18:01 -05:00
Andrew Kelley
2b2bf53a49
better error message when LLVM does not understand a triple 2019-02-07 11:40:56 -05:00
Andrew Kelley
a0590bda29
Merge branch 'kristate-zig-backport-std.mem.join' 2019-02-07 10:56:30 -05:00
Andrew Kelley
38a7716194
fixups 2019-02-07 10:55:23 -05:00
Andrew Kelley
130f422742
Merge branch 'zig-backport-std.mem.join' of https://github.com/kristate/zig into kristate-zig-backport-std.mem.join 2019-02-07 10:43:14 -05:00
Andrew Kelley
7fc99c33bd
Merge branch 'kristate-zig-backport-std.os.path' 2019-02-07 00:49:06 -05:00
Andrew Kelley
36bade5c56
fixups, and modify std.mem.join and std.os.path.resolve API
* zig fmt
 * std.mem.join takes a slice of slices instead of var args
 * std.mem.join takes a separator slice rather than byte,
   and always inserts it. Previously it would not insert the separator
   if there already was one, violating the documented behavior.
 * std.mem.join calculates exactly the correct amount to allocate
   and has no call to allocator.shrink()
 * bring back joinWindows and joinPosix and the corresponding tests.
   it is intended to be able to call these functions from any OS.
 * rename std.os.path.resolveSlice to resolve (now resolve takes
   a slice of slices instead of var args)
2019-02-07 00:42:41 -05:00
Andrew Kelley
c804ae2d6b
Merge branch 'zig-backport-std.os.path' of https://github.com/kristate/zig into kristate-zig-backport-std.os.path 2019-02-06 22:53:34 -05:00
Andrew Kelley
8a5d3e2eaf
Merge pull request #1924 from ziglang/tls
Implement Thread Local Variables
2019-02-06 20:21:13 -05:00
Andrew Kelley
89ffb58197 implement Thread Local Storage on Windows 2019-02-06 18:32:41 -05:00
Andrew Kelley
d2602b442e
require running std lib tests coherently
this should actually improve CI times a bit too

See the description at the top of std/os/startup.zig (deleted in this
commit) for a more detailed understanding of what this commit does.
2019-02-06 14:32:20 -05:00
Andrew Kelley
b1775ca168
thread local storage working for linux x86_64 2019-02-06 13:48:04 -05:00
Andrew Kelley
3abf293a84
doc/targets.md has moved to the github wiki
https://github.com/ziglang/zig/wiki/How-to-Add-Support-For-More-Targets
2019-02-06 11:53:09 -05:00
tgschultz
20e2d8da61 Fixed Serializer and BitOutStream when used with streams that have empty error sets. 2019-02-06 00:06:27 -05:00
Andrew Kelley
fd28b9d501
Merge pull request #1919 from Sahnvour/windows-childprocess
Better behaviour of ChildProcess under windows.
2019-02-05 21:03:33 -05:00