Commit Graph

801 Commits

Author SHA1 Message Date
Andrew Kelley 3d2752cc36 refactor type_requires_comptime to have possible error
fixes a compiler crash when building
https://github.com/AndreaOrru/zen
2018-11-24 16:15:58 -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 3829e200ec fix assertion failure related to @intToEnum 2018-11-18 20:04:16 -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
Jimmi Holst Christensen be9bb0a857 Fixed #1663 and removed IrInstructionArrayLen 2018-11-16 10:15:13 -05:00
Andrew Kelley 3666fbd9f9 ** and ++ operators force comptime on operands
closes #1707
2018-11-14 12:23:40 -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 67fbb0434f ir: remove redundant casting code 2018-11-11 12:48:55 -05:00
Andrew Kelley ef5d7ce463 array type syntax implies comptime 2018-11-09 19:26:54 -05: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 4e12f909df simplify logic of pass1 ir for while on error unions 2018-10-31 10:00:51 -04:00
Andrew Kelley 7405bc7618 remove implicit cast from number literal to enum
I missed this code when removing explicit cast syntax.
2018-10-30 17:28:03 -04:00
Andrew Kelley ca71373da1 remove another implicit cast to const pointer
* remove implicit cast from *T to ?*const T
 * remove implicit cast from T to ?*const T when T is a struct/union
2018-10-29 16:41:30 -04:00
Andrew Kelley 2b395d4ede remove @minValue,@maxValue; add std.math.minInt,maxInt
closes #1466
closes #1476
2018-10-26 15:01:51 -04:00
Andrew Kelley eb0b1d38ff remove 3 more implicit casts to const pointers
see #1465
2018-10-25 12:52:12 -04:00
Andrew Kelley d5648d2640 remove implicit cast from T to *const T
closes #1465
2018-10-15 18:23:47 -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
Andrew Kelley d07413f9b7 fix missing .h files
closes #1634
2018-10-04 18:14:57 -04:00
Andrew Kelley 23b07ad8d2 refactor ir.cpp
Analysis functions no longer return `ZigType *`. Instead they
return `IrInstruction *`.
2018-10-04 14:33:52 -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 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 9e5cd43e6d fix comptime string concatenation ignoring slice bounds
closes #1362
2018-09-21 15:45:13 -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 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 1fc2019031 fix @embedFile reading garbage memory
closes #1547
2018-09-18 10:25:57 -04:00
Andrew Kelley d353d5aef8 fix @bytesToSlice on a packed struct
closes #1551
2018-09-18 09:49:57 -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 3f776af3fa fix alignment of structs
closes #1248
closes #1052
closes #1154
2018-09-14 19:08:59 -04:00
Andrew Kelley 639c381128 fix coroutine alignment
zig returned the wrong alignment for coroutine promises
in some cases
2018-09-14 13:55:45 -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 ff0b7fe29a error messages for attempted cache when zig cannot perfectly do it 2018-09-11 22:59:40 -04:00