Commit Graph

230 Commits (c2db077574be841da586fa62d67619c901dd535d)

Author SHA1 Message Date
Andrew Kelley b1775ca168
thread local storage working for linux x86_64 2019-02-06 13:48:04 -05:00
Matthew McAllister 8bedb10939 Fix runtime assignment to comptime aggregate field
This was causing a segfault
2019-02-01 17:14:12 -05:00
Andrew Kelley ae1ebe09b7
add compile errror for @bitCast when bit counts mismatch
fixes invalid LLVM IR from previous commit
2019-02-01 14:06:51 -05:00
Andrew Kelley 169a789b34
fix test after merging ad8381e0d2
this test slipped through due to branching
2019-01-30 16:12:30 -05:00
Matthew McAllister ad8381e0d2 Move tokenizer error location to offending char
Previously, it pointed to the start of the current token, but this made
it difficult to tell where the error occurred when it was, say, in the
middle of a string.
2019-01-30 14:02:01 -05:00
Andrew Kelley 581edd643f
backport copy elision changes
This commit contains everything from the copy-elision-2
branch that does not have to do with copy elision directly,
but is generally useful for master branch.

 * All const values know their parents, when applicable, not
   just structs and unions.
 * Null pointers in const values are represented explicitly,
   rather than as a HardCodedAddr value of 0.
 * Rename "maybe" to "optional" in various code locations.
 * Separate DeclVarSrc and DeclVarGen
 * Separate PtrCastSrc and PtrCastGen
 * Separate CmpxchgSrc and CmpxchgGen
 * Represent optional error set as an integer, using the 0 value.
   In a const value, it uses nullptr.
 * Introduce type_has_one_possible_value and use it where applicable.
 * Fix debug builds not setting memory to 0xaa when storing
   undefined.
 * Separate the type of a variable from the const value of a variable.
 * Use copy_const_val where appropriate.
 * Rearrange structs to pack data more efficiently.
 * Move test/cases/* to test/behavior/*
 * Use `std.debug.assertOrPanic` in behavior tests instead of
   `std.debug.assert`.
 * Fix outdated slice syntax in docs.
2019-01-29 22:30:30 -05:00
Andrew Kelley 9c328b4291
simpler implementation of `&&` and `||` hints
This accomplishes the same goal, but with less changes, so that
I can backport copy elision stuff easier.
2019-01-29 22:29:56 -05:00
kristopher tate 5bf9ffdc5b Hint at use of and/or when &&/|| is improperly used (#1886) 2019-01-25 21:10:40 +01:00
Andrew Kelley 1357bc7430
add test case for previous commit 2019-01-20 14:09:17 -05:00
alexander 64061cc1bf Test cases for compiler error and working behavior for switching on booleans 2018-12-27 13:46:32 -06:00
Andrew Kelley b883bc873d
breaking API changes to all readInt/writeInt functions & more
* add `@bswap` builtin function. See #767
 * comptime evaluation facilities are improved to be able to
   handle a `@ptrCast` with a backing array.
 * `@truncate` allows "truncating" a u0 value to any integer
   type, and the result is always comptime known to be `0`.
 * when specifying pointer alignment in a type expression,
   the alignment value of pointers which do not have addresses
   at runtime is ignored, and always has the default/ABI alignment
 * threw in a fix to freebsd/x86_64.zig to update syntax from
   language changes
 * some improvements are pending #863

closes #638
closes #1733

std lib API changes
 * io.InStream().readIntNe renamed to readIntNative
 * io.InStream().readIntLe renamed to readIntLittle
 * io.InStream().readIntBe renamed to readIntBig
 * introduced io.InStream().readIntForeign
 * io.InStream().readInt has parameter order changed
 * io.InStream().readVarInt has parameter order changed
 * io.InStream().writeIntNe renamed to writeIntNative
 * introduced io.InStream().writeIntForeign
 * io.InStream().writeIntLe renamed to writeIntLittle
 * io.InStream().writeIntBe renamed to writeIntBig
 * io.InStream().writeInt has parameter order changed
 * mem.readInt has different parameters and semantics
 * introduced mem.readIntNative
 * introduced mem.readIntForeign
 * mem.readIntBE renamed to mem.readIntBig and different API
 * mem.readIntLE renamed to mem.readIntLittle and different API
 * introduced mem.readIntSliceNative
 * introduced mem.readIntSliceForeign
 * introduced mem.readIntSliceLittle
 * introduced mem.readIntSliceBig
 * introduced mem.readIntSlice
 * mem.writeInt has different parameters and semantics
 * introduced mem.writeIntNative
 * introduced mem.writeIntForeign
 * mem.writeIntBE renamed to mem.readIntBig and different semantics
 * mem.writeIntLE renamed to mem.readIntLittle and different semantics
 * introduced mem.writeIntSliceForeign
 * introduced mem.writeIntSliceNative
 * introduced mem.writeIntSliceBig
 * introduced mem.writeIntSliceLittle
 * introduced mem.writeIntSlice
 * removed mem.endianSwapIfLe
 * removed mem.endianSwapIfBe
 * removed mem.endianSwapIf
 * added mem.littleToNative
 * added mem.bigToNative
 * added mem.toNative
 * added mem.nativeTo
 * added mem.nativeToLittle
 * added mem.nativeToBig
2018-12-12 20:35:04 -05:00
Andrew Kelley 1b0f4d5976
implement compile error note for function parameter type mismatch 2018-12-05 15:32:25 -05:00
Sahnvour 703c6684d1 Crash fixes and small improvements to inline asm. (#1756)
* codegen: LLVMConstInlineAsm is deprecated.

* codegen: replace commas in asm constraint strings by pipes as required by LLVM.

* ir: enforce usage of '=' constraint modifier for inline assembly outputs.

Others are not currently supported and this was just asserted alter in `ir_render_asm`.

* asm: forbid comptime_int/floats as inputs in favor of explicitely sized constants.

Fixes a crash due to comptime_int/floats having no type_ref.

* asm: handle inputs with integers of <8 or non power of 2 bitsize.

We widen them to the next highest power of two.
2018-11-19 16:22:21 -05:00
Andrew Kelley 2f5d1ec500
improve error message when wrong type returned
closes #1650
2018-11-19 11:22:57 -05:00
Andrew Kelley f8a782fb2e
all numbers with comptime known values implicitly cast
to all number types. If the value does not fit,
a compile error is emitted.

closes #422
closes #1712
2018-11-18 19:37:59 -05:00
Andrew Kelley 704374e512
rename `section` keyword to `linksection`
add zig fmt support for this syntax

closes #1152
2018-11-17 01:38:35 -05:00
Jimmi Holst Christensen 8139c5a516
New Zig formal grammar (#1685)
Reverted #1628 and changed the grammar+parser of the language to not allow certain expr where types are expected
2018-11-13 05:08:37 -08:00
Andrew Kelley 63f636e7b7
limit integer types to maximum bit width of 65535
closes #1541
2018-11-06 11:09:14 -05:00
Andrew Kelley 2b395d4ede
remove @minValue,@maxValue; add std.math.minInt,maxInt
closes #1466
closes #1476
2018-10-26 15:01:51 -04:00
Jimmi Holst Christensen 378d3e4403
Solve the return type ambiguity (#1628)
Changed container and initializer syntax
* <container> { ... } -> <container> . { ... }
* <exrp> { ... } -> <expr> . { ...}
2018-10-15 09:51:15 -04:00
Jimmi Holst Christensen bc3e99c5e5
Fixed StackTrace not being resolved when panic is invalid (#1615) 2018-10-01 20:30:34 +02: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 dcfd15a7f0
the last number in a packed ptr is host int bytes
See #1121
2018-09-26 14:54:52 -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
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 c84548e71d
fix @compileLog having unintended side effects
closes #1459
2018-09-22 10:46:22 -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 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 9c8dfadbb1
add compile error for casting const array to mutable slice
See #1565
2018-09-20 12:24:51 -04:00
Andrew Kelley c1af360532
add compile error for slice.*.len
closes #1372
2018-09-18 16:32:40 -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 3f776af3fa
fix alignment of structs
closes #1248
closes #1052
closes #1154
2018-09-14 19:08:59 -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 52f4e934a9
fix llvm assertion and missing compile error 2018-09-10 22:44:27 -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 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 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 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 b65cca37ce
add test coverage for invalid switch expression parameter
closes #604
2018-08-28 15:48:39 -04:00