Commit Graph

3782 Commits (fe524a1fa565004c3c0c3faecbe14f2331feefab)

Author SHA1 Message Date
Andrew Kelley fe524a1fa5 build: add support for ZIG_STATIC on MacOS 2018-09-27 15:09:14 -04:00
Andrew Kelley cc490f0026
update @typeInfo docs 2018-09-27 12:34:41 -04:00
Andrew Kelley af3263d7a8 add dll export storage class where appropriate
closes #1443
2018-09-27 10:22:16 -04:00
Josh Wolfe e7d9d00ac8 overhaul api for getting random integers (#1578)
* rand api overhaul
* no retry limits. instead documented a recommendation
  to call int(T) % len directly.
2018-09-27 00:35:38 -04:00
Andrew Kelley 1c26c2f4d5
fix crash when compile error evaluating return...
...type of inferred error set. closes #1591
2018-09-26 16:59:08 -04:00
Andrew Kelley 589201b104
fix variables which are pointers to packed struct fields
closes #1121
2018-09-26 14:54:53 -04:00
Andrew Kelley dcfd15a7f0
the last number in a packed ptr is host int bytes
See #1121
2018-09-26 14:54:52 -04:00
Wink Saville 631851f8b5 Tweak SYMBOL_CHAR define in tokenizer.cpp
Make it a little clearer what a SYMBOL_CHAR is, use ALPHA instead of
ALPHA_EXCEPT_C and case 'c', which is ALPHA's definition.
2018-09-26 11:29:01 -04:00
Andrew Kelley 9485043b3c
fix implicit casting to *c_void
closes #1588

also some small std lib changes regarding posix sockets
and one doc typo fix
2018-09-26 11:06:09 -04:00
Jay Weisskopf 7b204649e3 stage1: Added `zig help` to show usage on stdout
This will make it easier to do things like `zig help | grep something`.

Invalid arguments will now display a short notice for `zig help`
instead of showing the full usage information. This will make it easier
to see the actual error.
2018-09-25 22:05:44 -04:00
Andrew Kelley 2e562a5f36
fix crash on runtime index into slice of comptime type
closes #1435
2018-09-25 12:03:39 -04:00
Andrew Kelley 839492d0e8
fix not syntax highlighting builtin module 2018-09-25 12:03:09 -04:00
Andrew Kelley eafb8e8572
fix self reference through fn ptr field crash
closes #1208
2018-09-25 10:45:11 -04:00
Wink Saville 0e6c18c820 Remove StrLitKind enum
I was looking at the tokenizer specifically fn testTokenize and the
this statement looked odd:

  if (@TagType(Token.Id)(token.id) != @TagType(Token.Id)(expected_token_id)) {

I then saw the TODO and thought I'd remove StrLitKind figuring that
would make testTokenize simpler. It did so I thought I'd prepare this PR.

The tests are still working and stage2 zig seems to work, it compiles and
I was able to use the fmt command.
2018-09-24 19:28:46 -04:00
Andrew Kelley 4241cd666d
fix more bigint code paths and add tests 2018-09-24 16:31:22 -04:00
Andrew Kelley 877036e7ef fix translate-c test expecting incorrect C ABI on windows 2018-09-24 15:14:20 -04:00
Andrew Kelley 32c91ad892
fix comptime bitwise operations with negative values
closes #1387
closes #1529
2018-09-24 14:38:51 -04:00
Andrew Kelley 422269ea6e
minor langref improvements 2018-09-24 14:38:51 -04:00
Wink Saville c5509a07ca Ignore class-memaccess error for gcc 8 and above
On Arch Linux the current default compiler is gcc 8.2.1 and this change
is needed to ignore the following errors:

  In file included from /home/wink/local/include/llvm/ADT/STLExtras.h:21,
                   from /home/wink/local/include/llvm/ADT/StringRef.h:13,
                   from /home/wink/local/include/llvm/ADT/StringMap.h:17,
                   from /home/wink/local/include/llvm/Support/Host.h:17,
                   from /home/wink/local/include/llvm/ADT/Hashing.h:49,
                   from /home/wink/local/include/llvm/ADT/ArrayRef.h:13,
                   from /home/wink/local/include/llvm/ADT/APFloat.h:21,
                   from /home/wink/local/include/clang/AST/APValue.h:18,
                   from /home/wink/local/include/clang/AST/Decl.h:17,
                   from /home/wink/local/include/clang/AST/ASTTypeTraits.h:20,
                   from /home/wink/local/include/clang/AST/ASTContext.h:18,
                   from /home/wink/local/include/clang/Frontend/ASTUnit.h:18,
                   from /home/wink/prgs/ziglang/zig/src/translate_c.cpp:18:
  /home/wink/local/include/llvm/ADT/SmallVector.h: In instantiation of ‘void llvm::SmallVectorTemplateBase<T, true>::push_back(const T&) [with T = std::pair<void*, long unsigned int>]’:
  /home/wink/local/include/llvm/Support/Allocator.h:249:33:   required from ‘void* llvm::BumpPtrAllocatorImpl<AllocatorT, SlabSize, SizeThreshold>::Allocate(size_t, size_t) [with AllocatorT = llvm::MallocAllocator; long unsigned int SlabSize = 4096; long unsigned int SizeThreshold = 4096; size_t = long unsigned int]’
  /home/wink/local/include/clang/AST/ASTContext.h:659:42:   required from here
  /home/wink/local/include/llvm/ADT/SmallVector.h:313:11: error: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘struct std::pair<void*, long unsigned int>’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Werror=class-memaccess]
       memcpy(this->end(), &Elt, sizeof(T));
       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from /usr/include/c++/8.2.1/utility:70,
                   from /home/wink/local/include/llvm/Support/type_traits.h:19,
                   from /home/wink/local/include/llvm/Support/Casting.h:19,
                   from /home/wink/local/include/clang/Basic/LLVM.h:22,
                   from /home/wink/local/include/clang/AST/APValue.h:17,
                   from /home/wink/local/include/clang/AST/Decl.h:17,
                   from /home/wink/local/include/clang/AST/ASTTypeTraits.h:20,
                   from /home/wink/local/include/clang/AST/ASTContext.h:18,
                   from /home/wink/local/include/clang/Frontend/ASTUnit.h:18,
                   from /home/wink/prgs/ziglang/zig/src/translate_c.cpp:18:
  /usr/include/c++/8.2.1/bits/stl_pair.h:198:12: note: ‘struct std::pair<void*, long unsigned int>’ declared here
       struct pair
              ^~~~
2018-09-24 14:01:59 -04:00
Andrew Kelley 004c383292
fix translate-c incorrectly translating negative enum init values
closes #1360
2018-09-24 12:19:16 -04:00
Andrew Kelley 8a7737eef4
fix godbolt cli test on non-linux-x86_64 hosts 2018-09-24 12:01:51 -04:00
Andrew Kelley 6d048aa3bf
add panic function to godbolt CLI API test 2018-09-24 11:14:39 -04:00
Andrew Kelley a155f2973b
add test to cover the CLI API that godbolt is using
closes #1399
2018-09-24 11:12:21 -04:00
Wink Saville a170a64776 Fix typo in argsAlloc comment
Changed freeArgs to argsFree.
2018-09-23 13:12:57 -04:00
Andrew Kelley af01c6e2bf
include LICENSE in windows static builds 2018-09-23 12:29:38 -04:00
Jeff Fowler f955844435 rm extraneous macro 2018-09-22 10:50:35 -04:00
Andrew Kelley c84548e71d
fix @compileLog having unintended side effects
closes #1459
2018-09-22 10:46:22 -04:00
Andrew Kelley 3c1f9baff1
doc: add note about reproducible builds 2018-09-22 10:22:01 -04:00
Andrew Kelley 5c15c5fc48
add compile error for slice of undefined slice
closes #1293
2018-09-22 10:04:47 -04:00
Andrew Kelley 2e27407161
stage1: unify 2 implementations of pointer deref
I found out there were accidentally two code paths
in zig ir for pointer dereference. So this should
fix a few bugs.

closes #1486
2018-09-21 18:47:12 -04:00
Andrew Kelley 9e5cd43e6d
fix comptime string concatenation ignoring slice bounds
closes #1362
2018-09-21 15:45:13 -04:00
Andrew Kelley 0ca12ded2f
Merge branch 'raulgrell-BitByteOffsetOfs' 2018-09-21 14:16:14 -04:00
Andrew Kelley 7c5e3e1f8e
fixups 2018-09-21 14:15:58 -04:00
Andrew Kelley 5a21d3dce0
Merge branch 'BitByteOffsetOfs' of https://github.com/raulgrell/zig into raulgrell-BitByteOffsetOfs 2018-09-21 13:10:21 -04:00
Andrew Kelley 44f2ee101f
fix comptime slice of pointer to array
closes #1565
2018-09-21 10:31:11 -04:00
Andrew Kelley 073f7ebb0e
fix formatInt to handle upcasting to base int size 2018-09-20 13:46:20 -04:00
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 492821781d
add workaround for `llvm-config --system-libs`
not handling static libs correctly
2018-09-19 18:28:50 -04:00
Andrew Kelley f9bf04c38b
travis: build zig with gcc to match what llvm was built with
from #llvm IRC:

<andrewrk> does llvm 7 as a .so have some kind of new initialization
requirement? I'm getting a segfault in llvm::DIBuilder::createFile
(with valid non-null parameters), when linking my frontend against
llvm-7.so but not when linking against llvm .a libraries

<d0k> we have an ABI bug in LLVM 7 when the .so is built with gcc
but your program is build with clang. I'm sorry for that.
2018-09-19 17:15:33 -04:00
Andrew Kelley 287f5cce50
build: fix finding llvm and clang 7 2018-09-19 15:38:36 -04:00
Andrew Kelley e3d8cae35a
travis: fix llvm apt package names 2018-09-19 14:54:32 -04:00
Andrew Kelley 6d23619cce
fix typo from previous commit 2018-09-19 13:53:47 -04:00
Andrew Kelley f418a943cc
travis: fix package names 2018-09-19 13:46:20 -04:00
Andrew Kelley d4cb373024
travis: update apt repo url 2018-09-19 13:25:11 -04:00
Andrew Kelley 69c876cc87
appveyor: remove old cache file 2018-09-19 12:58:58 -04:00
Andrew Kelley 15301504e2
Merge remote-tracking branch 'origin/llvm7' 2018-09-19 12:57:58 -04:00
Christian Wesselhoeft 5eeef1f5ed std/index.zig: Fix import
BufferOutStream is defined in io.zig
2018-09-18 19:01:35 -04:00
Andrew Kelley 6dd93ee5d9
fix regression from previous commit 2018-09-18 18:56:29 -04:00
Andrew Kelley 21328e0036
zig fmt: handle shebang lines
closes #1546
2018-09-18 18:36:39 -04:00