Commit Graph

957 Commits

Author SHA1 Message Date
Andrew Kelley 78f32259da default struct field initialization expressions
closes #485
2019-05-30 15:46:11 -04:00
tgschultz f9e7bd2682 std.meta/trait: def/definition => decl/declaration
TypeInfo: defs/Definition => decls/Declarations
2019-05-29 20:43:07 -04:00
Shawn Landden 4188faeac5 stage1: AstNodes cannot be casted, but are rather accessed via a union.
Unlike IrInstruction[Foo]s, which all start with:
    IrInstruction base;
AstNodes do not work like this, and instead use a pointer to their
specializations. The code assumed otherwise.
2019-05-29 20:21:07 -04:00
Andrew Kelley 1ccbd1fb67 use works on unions and enums in addition to structs 2019-05-29 16:31:49 -04:00
Andrew Kelley b66438eb80 no "use of undeclared identifer" in dead comptime branches 2019-05-28 18:19:27 -04:00
Andrew Kelley df7aa9a4f0 allow implicit optional pointer to optional c_void pointer 2019-05-26 17:55:20 -04:00
Andrew Kelley 269a53b6af introduce @hasDecl builtin function
closes #1439
2019-05-26 16:21:03 -04:00
Andrew Kelley 21ed939117 support enum literals implicit casting to tagged unions 2019-05-26 12:59:30 -04:00
LemonBoy 6672ee9eb3 Fix too eager comptime evaluation of error ptr 2019-05-19 15:53:32 -04:00
Andrew Kelley 80983ca1ca fixups to the previous commit 2019-05-16 16:37:58 -04:00
Shawn Landden 1fdb24827f breaking changes to all bit manipulation intrinsics
* `@clz`, `@ctz`, `@popCount`, `@bswap`, `@bitreverse` now
   have a type parameter
 * rename @bitreverse to @bitReverse
 * rename @bswap to @byteSwap

Closes #2119
Closes #2120
2019-05-16 16:37:58 -04:00
Andrew Kelley 057a5d4898 slice types no longer have field access
* fix crash when doing field access of slice types. closes #2486
 * remove the deprecated Child property from slice types
 * add -Dskip-non-native build option to build script
2019-05-14 21:21:59 -04:00
Andrew Kelley e93a05b6e4 switching on error sets makes new error set for capture values
closes #769
2019-05-14 19:11:37 -04:00
Andrew Kelley c08c222d5e fix regression on switch capture value for multiple cases 2019-05-14 18:25:14 -04:00
Andrew Kelley df4f77024e else value when switching on error set has
optional capture value which is subset.

see #769
2019-05-14 18:06:57 -04:00
Andrew Kelley fee0e6c8b9 fix hang for some compile errors
see #2467
2019-05-10 16:39:50 -04:00
Michael Dusan d065f297ab stage1: compile error for loop expr val ignored
closes #2460
2019-05-10 10:05:40 -04:00
Jimmi HC 6b10f03b4a Fixes and simplifications for stage 1 parser 2019-05-10 16:09:58 +02:00
Andrew Kelley 010963ce43 stage1: make some asserts print source location 2019-05-09 14:52:06 -04:00
Andrew Kelley c459edac18 compile error for attempt to cast enum literal to error
closes #2203
2019-05-09 13:18:13 -04:00
Andrew Kelley a4aee8b24d C pointers support if and orelse
See #1967
2019-05-08 18:47:14 -04:00
Andrew Kelley 0099583bd3 C pointers support .? operator
see #1967
2019-05-08 17:39:00 -04:00
Andrew Kelley 50bbb34594 C pointers support null
See #1967
2019-05-08 16:06:34 -04:00
LemonBoy 9902b604cb Fix generation of container initializers
The code creates temporary ConstExprValue with global_refs set to
nullptr and that's carried over to the final value. Doing so prevents
the deduplication mechanism to work correctly, causing all sorts of
runtime crashes.

Fixes #1636
Fixes #1608 (Even though it was already fixed by #1991)
2019-04-28 13:13:42 -04:00
Andrew Kelley e1bf74fca3 translate-c: put -x c back in there, it's necessary 2019-04-25 00:06:58 -04:00
Andrew Kelley 712274997e translate-c: unify API for self-hosted and C++ translate-c
See #1964
2019-04-25 00:06:57 -04:00
Andrew Kelley 976080462c translate-c: a little closer to self-hosted implementation 2019-04-25 00:06:54 -04:00
Andrew Kelley fb2acaff06 @sizeOf returns 0 for comptime types
This defines `@sizeOf` to be the runtime size of a type, which means
that it is zero for types such as comptime_int, type, and (enum
literal).

See #2209
2019-04-24 22:31:53 -04:00
Andrew Kelley ad994c9642 Merge pull request #2296 from LemonBoy/translate-c-stuff
Handle implicit casts in translate-c
2019-04-24 14:43:46 -04:00
Jimmi HC 1a2e02e267 fixed #2356
const_ptr_pointee_unchecked did not take into account that if the
pointer is zero sized, then const_val->data.x_ptr.special would be
ConstPtrSpecialInvalid. This commit fixes this by also checking
that the child type of the pointer only have one possible value
and just returns that value.
2019-04-24 15:04:58 +02:00
LemonBoy a44ad08954 Add some zig_panic for 80-bit float codepaths 2019-04-22 22:23:41 +02:00
Shritesh Bhattarai 9465c6d538 link: exemption for wasm instead of wasi 2019-04-15 16:59:34 -05:00
Andrew Kelley 63a970a548 Merge pull request #2268 from shritesh/wasi
wasm: preliminary WASI OS support
2019-04-14 10:45:30 -04:00
Shritesh Bhattarai ecd0f89254 wasi: better extern wasi logic 2019-04-13 23:49:02 -05:00
Shritesh Bhattarai a2d8f03092 support extern "wasi" functions 2019-04-13 22:28:58 -05:00
Andrew Kelley 68d7e4a1b6 better handle quota of setEvalBranchQuota
Now that c58b802034 has removed
the "top of the comptime stack" requirement, the branch quota
can be modified somewhere other than the top of the comptime stack.

This means that the quota of a parent IrExecutable has to be
modifiable by an instruction in the child.

Closes #2261
2019-04-13 16:55:59 -04:00
kristopher tate 627b52fe65 src/ir.cpp: don't call-out to analyze_type_expr;
replaces `analyze_type_expr` with `ir_analyze_type_expr`
2019-04-07 10:37:43 +09:00
Jimmi Holst Christensen 65cf5a8e44 removed todo comment and added test 2019-04-06 11:04:55 +02:00
Jimmi Holst Christensen 3109c89850 fixed 1726 2019-04-06 10:56:07 +02:00
Andrew Kelley f00adb47f5 ir: avoid dependency on isnan
there's a simple way to check for nan that does not need this header.
hryx on IRC reported that Linux Mint based on ubuntu 16.04, kernel
4.15.0, x86_64 did not have the isnan function.
2019-04-06 01:03:30 -04:00
Andrew Kelley 83390bdfdd fix dereferencing a zero bit type
Before only u0 was special cased in handling a dereference;
now all zero bit types are handled the same way. Dereferencing
a pointer to a zero bit type always gives a comptime-known
result.

This previously had been failing on master branch but went unnoticed
because until 846f72b57c the CI server was mistakenly not actually
running the single-threaded tests with --single-threaded.

This fixes the standard library tests with --single-threaded
--release-fast.
2019-04-05 20:18:26 -04:00
Andrew Kelley 1dc6751721 fix NaN comparing equal to itself
This was broken both in comptime code and in runtime code.

closes #1174
2019-04-04 22:07:15 -04:00
Andrew Kelley ddb8aa73f5 more regression fixes 2019-04-02 18:31:18 -04:00
Andrew Kelley d3f2fe2cef remove the lazy value stuff
let's try to keep this branch to solving one problem at a time
2019-04-02 18:31:18 -04:00
Andrew Kelley 3dc8448680 introduce lazy values
but I think it's a bad idea, so I'm going to back out the change
2019-04-02 18:31:18 -04:00
Andrew Kelley ee5064c053 decouple llvm types from zig types
Not tested yet, but it builds.

This closes #761, and lays the groundwork for fixing the remaining
false positive "foo depends on itself" bugs, such as #624.

It also lays the groundwork for implementing ability to specify
alignment of fields (#1512).
2019-04-02 18:31:17 -04:00
emekoi 4a64f26627 added error for implicit cast from *const T to *[1]T. credit: @kristate 2019-03-31 16:47:34 -05:00
Andrew Kelley 25ac2fe8cd fix anon enum literal used with switch on union(enum)
closes #2141
closes #2142
2019-03-31 12:43:21 -04:00
Shawn Landden 66f13ba807 stage1: better error message when comparing against null
Closes: #2104
2019-03-28 15:54:44 -04:00
Andrew Kelley 5eaead6a56 implement allowzero pointer attribute
closes #1953

only needed for freestanding targets.

also adds safety for `@intToPtr` when the address is zero.
2019-03-25 12:55:45 -04:00