Commit Graph

4184 Commits

Author SHA1 Message Date
Andrew Kelley
ee5e196f88
add test for truncate on comptime integers
closes #703
2019-02-15 02:02:19 -05:00
Andrew Kelley
c58b802034
remove the "top of the comptime stack" compile error
It's still best practice to put `@setEvalBranchQuota` at the top of
the comptime stack, but as Jimmi notes in #1949, when a function
can be called at comptime and also can be the top of the comptime stack,
this compile error is fundamentally unsound.

So now it's gone.

closes #1949
2019-02-14 10:51:59 -05:00
Andrew Kelley
a4e32d9fb1
ci: freebsd: remove '.git' from URL as per upstream suggestion
https://todo.sr.ht/~sircmpwn/dispatch.sr.ht/24#comment-1465
2019-02-14 09:46:08 -05:00
Jimmi Holst Christensen
2911eb34de Added error for nesting vectors 2019-02-13 12:19:08 +01:00
Jimmi Holst Christensen
53297a1bd0 We already support vector bit operators, so let's test it 2019-02-13 11:40:32 +01:00
Jimmi Holst Christensen
c7b9ab985c Merge branch 'master' of github.com:ziglang/zig 2019-02-13 11:31:20 +01:00
Jimmi Holst Christensen
c221b29c9d We already support vector on floats, so let's test it 2019-02-13 11:31:13 +01:00
Matthew McAllister
0b3db784f1 Enable compileLog to display slices 2019-02-13 02:00:02 -05:00
Andrew Kelley
43df49cb35
README: move i386-macosx to Tier 4
See #1930
2019-02-11 12:59:33 -05:00
Andrew Kelley
8e68d43ad3
avoid needlessly creating global constants
This deletes some legacy cruft, and produces leaner object files.
Example:

```
var x: i32 = 1234;

export fn entry() i32 {
    return x;
}
```

This produces:

```
@x = internal unnamed_addr global i32 1234, align 4
@0 = internal unnamed_addr constant i32* @x, align 8
```

and @0 is never even used. After this commit, @0 is not produced.

This fixes a bug: Zig was creating invalid LLVM IR when one of these
globals that shouldn't exist takes the address of a thread local
variable. In LLVM 8.0.0rc2, it would produce a linker error. But
probably after my bug report is solved it will be caught by the IR
verifier.

https://bugs.llvm.org/show_bug.cgi?id=40652
2019-02-10 10:58:00 -05:00
Jimmi HC
2f9fedabf0 testing.expectEqual use expected type as the type of actual
This allows for impl casts
2019-02-10 12:43:49 +01: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
Sahnvour
6860db66fe Typo: use the joined path to try executables available from PATH. 2019-02-05 23:13:17 +01:00
Sahnvour
a9faace8b4 Notify failure to create a process when the executable is not found even in PATH. 2019-02-05 23:12:54 +01:00
Andrew Kelley
ac4e38226b
docs: clarify passing aggregate types as parameters 2019-02-05 10:28:56 -05:00
Jimmi Holst Christensen
4010f6a11d Added support for vector wrapping mult and sub
* I also merged the code that generates ir for add, sub, and mult
2019-02-05 09:57:11 -05:00
Andrew Kelley
06be65a602
fix vector debug info tripping LLVM assertion 2019-02-04 22:16:16 -05:00
Andrew Kelley
8c6fa982cd
SIMD: array to vector, vector to array, wrapping int add
also vectors and arrays now use the same ConstExprVal representation

See #903
2019-02-04 20:30:00 -05:00
Andrew Kelley
2828a9695f
Merge branch 'kristate-zig-backport-std.mem.separate' 2019-02-04 15:27:44 -05:00
Andrew Kelley
67bd45f0cf
adjustments to std.mem split / separate
* rename std.mem.split to std.mem.tokenize
 * add future deprecation notice to docs
 * (unrelated) add note to std.os.path.resolve docs
 * std.mem.separate - assert delimiter.len not zero
 * fix implementation of std.mem.separate to respect the delimiter
 * separate the two iterators to different structs
2019-02-04 15:24:06 -05:00
Andrew Kelley
f44ce7836a
Merge branch 'zig-backport-std.mem.separate' of https://github.com/kristate/zig into kristate-zig-backport-std.mem.separate 2019-02-04 13:29:17 -05:00
Andrew Kelley
dfbc063f79
std.mem.Allocator.create replaced with better API
`std.mem.Allocator.createOne` is renamed to `std.mem.Allocator.create`.

The problem with the previous API is that even after copy elision,
the initalization value passed as a parameter would always be a copy.
With the new API, once copy elision is done, initialization
functions can directly initialize allocated memory in place.

Related:
 * #1872
 * #1873
2019-02-03 16:13:28 -05:00
Matthew McAllister
c90c256868 Fix slice concatenation
This was causing an underflow error
2019-02-02 22:22:00 -05:00