Marc Tiehuis
98859c885e
std/fmt.zig: Pass full options struct to all internal functions
...
The fill specifier is now handled in some cases. The default fill of '0'
is now ' ' for integers and non-byte sequences.
2019-08-19 22:15:15 +12:00
Andrew Kelley
ea1734773b
add compile error for async frames depending on themselves
2019-08-17 19:47:49 -04:00
Andrew Kelley
57b90d2d98
allow implicit cast of fn to async fn
...
it forces the fn to be async. closes #3079
2019-08-17 17:22:20 -04:00
Andrew Kelley
66a490c27c
detect non-async function pointer of inferred async function
...
closes #3075
2019-08-17 16:49:23 -04:00
Vexu
0ff396c34f
add compile error for incorrect atomic ordering in fence #3082
2019-08-17 16:05:41 -04:00
Andrew Kelley
4d8a6f6fea
fix compiler not checking alignment of function frames
...
closes #3086
2019-08-17 13:04:50 -04:00
Andrew Kelley
bf7b6fbbdb
add missing compile error for fn call bad implicit cast
...
when the function's return type handle is a pointer but the result
location's result value type handle is not a pointer
closes #3055
2019-08-16 16:30:24 -04:00
Andrew Kelley
cbca6586e7
add test for struct parameter to async function being copied
...
closes #1155
2019-08-16 13:56:26 -04:00
Andrew Kelley
5a2cbe239f
fix and test case for returning from suspend block
...
See #3063
2019-08-16 13:07:07 -04:00
Andrew Kelley
13c584d325
add compile error for casting const frame to anyframe
...
See #3063
2019-08-16 11:38:41 -04:00
Andrew Kelley
7798054b58
add tests for bad implicit casting of anyframe types
...
See #3063
2019-08-16 11:00:21 -04:00
Andrew Kelley
4ea2331e3d
add test for async call of generic function
...
See #3063
2019-08-16 10:54:45 -04:00
Andrew Kelley
5df89dafef
add test for wrong frame type used for async call
...
See #3063
2019-08-16 10:49:00 -04:00
Andrew Kelley
1254a453b9
add compile error for @Frame() of generic function
...
See #3063
2019-08-16 10:44:51 -04:00
Andrew Kelley
49c88e23af
zig fmt
2019-08-16 10:13:40 -04:00
Andrew Kelley
ff7e826b82
fix crash with sometimes type not being resolved
2019-08-15 18:54:23 -04:00
Andrew Kelley
7e75e1075e
zig fmt
2019-08-15 18:19:04 -04:00
Andrew Kelley
55f5cee86b
fix error return traces for async calls of blocking functions
2019-08-15 15:06:05 -04:00
Andrew Kelley
13b5a4bf8c
remove cancel
2019-08-15 14:05:12 -04:00
Andrew Kelley
f3f838cc01
add compile error for await in exported function
2019-08-14 11:22:12 -04:00
Andrew Kelley
7799423f24
rename behavior test files
2019-08-14 00:38:27 -04:00
Andrew Kelley
5749dc49d8
respect local variable alignment in async functions
2019-08-14 00:35:51 -04:00
Andrew Kelley
12ff91c1c9
alignment of structs no longer depends on LLVM
...
fixes async function tests in optimized builds
2019-08-13 12:44:30 -04:00
Andrew Kelley
8a9289996a
Merge remote-tracking branch 'origin/master' into rewrite-coroutines
2019-08-13 11:39:32 -04:00
Andrew Kelley
4d8d513e16
all tests passing
2019-08-11 19:53:10 -04:00
Andrew Kelley
b87686dfa0
fix enum with one member and custom tag type
2019-08-11 13:43:44 -04:00
Andrew Kelley
1b83ee78a4
allow comptime_int to implicit cast to comptime_float
2019-08-11 12:01:02 -04:00
Andrew Kelley
3f5c6d7a89
add test case for typical async/await usage
2019-08-10 18:03:36 -04:00
Andrew Kelley
77d098e92d
fix returning a const error from async function
2019-08-10 17:23:45 -04:00
Andrew Kelley
22428a7546
fix try in an async function with error union and non-zero-bit payload
2019-08-10 15:20:08 -04:00
Andrew Kelley
b9d1d45dfd
fix combining try with errdefer cancel
2019-08-09 21:49:40 -04:00
Andrew Kelley
2e7f53f1f0
fix cancel inside an errdefer
2019-08-09 17:34:06 -04:00
Andrew Kelley
614cab5d68
fix passing string literals to async functions
2019-08-08 19:08:41 -04:00
Andrew Kelley
bfa1d12fba
better compile errors when frame depends on itself
2019-08-08 13:44:57 -04:00
Andrew Kelley
d813805f77
more debuggable safety for awaiting twice
2019-08-08 12:02:56 -04:00
Andrew Kelley
34bfdf193a
cancel, defer, errdefer all working as intended now
2019-08-08 11:37:49 -04:00
Andrew Kelley
e11cafbd4f
cancel works on non-pointers
2019-08-07 10:56:37 -04:00
Andrew Kelley
7e1fcb55b3
implement cancel
...
all behavior tests passing in this branch
2019-08-07 00:53:04 -04:00
Andrew Kelley
1afbb53661
fix awaiting when result type is a struct
2019-08-06 19:07:25 -04:00
Andrew Kelley
966c9ea63c
error return trace across suspend points
2019-08-06 18:47:09 -04:00
Andrew Kelley
17199b0879
passing the error return trace async function test
2019-08-06 18:29:56 -04:00
Andrew Kelley
20f63e588e
async functions have error return traces where appropriate
...
however the traces are not merged on `await` or async function calls
yet.
When an async function has an error set or error union as its return
type, it has a `StackTrace` before the args in the frame, so that it is
accessible from `anyframe->T` awaiters. However when it does not have an
errorable return type, but it does call or await an errorable, it has a
stack trace just before the locals. This way when doing an `@asyncCall`
on an async function pointer, it can populate the args (which are after
the `StackTrace`) because it knows the offset of the args based only on
the return type.
This sort of matches normal functions, where a stack trace pointer could
be supplied by a parameter, or it could be supplied by the stack of the
function, depending on whether the function itself is errorable.
2019-08-05 03:10:14 -04:00
Andrew Kelley
0d8c9fcb18
support async functions with inferred error sets
2019-08-05 00:41:49 -04:00
Andrew Kelley
fa30ebfbe5
suspension points inside branching control flow
2019-08-04 18:24:10 -04:00
Andrew Kelley
87710a1cc2
implement @asyncCall
which supports async function pointers
2019-08-03 16:17:42 -04:00
Andrew Kelley
c879209661
add compile error for calling async function pointer
2019-08-03 02:40:38 -04:00
Andrew Kelley
e444e737b7
add runtime safety for resuming an awaiting function
2019-08-03 02:11:52 -04:00
Andrew Kelley
24d78177ee
add compile error for async call of function pointer
2019-08-03 01:06:14 -04:00
Andrew Kelley
0920bb0872
implement async functions returning structs
2019-08-02 19:27:27 -04:00
Andrew Kelley
5bd330e76c
add heap allocated async function frame test
2019-08-02 16:32:24 -04:00
Andrew Kelley
b3b6a98451
Merge remote-tracking branch 'origin/master' into rewrite-coroutines
2019-08-02 16:31:43 -04:00
Andrew Kelley
f07f09a373
Merge branch 'master' into rewrite-coroutines
2019-08-02 16:13:36 -04:00
Andrew Kelley
d105769926
fix regressions regarding writing through const pointers
2019-08-02 16:09:40 -04:00
Andrew Kelley
9069ee957c
fix discarding function call results
2019-08-02 15:17:02 -04:00
Andrew Kelley
90e64bc620
fix cmpxchg with discarded result
2019-08-02 14:47:26 -04:00
Andrew Kelley
a5cb0f77d1
assignment participates in result location
...
fix one regression with optionals but there are more
2019-08-02 13:54:58 -04:00
Andrew Kelley
056c4e2c98
implement async await and return
2019-08-02 01:06:00 -04:00
Andrew Kelley
0f879d02a4
more passing coroutine tests
2019-08-01 19:14:48 -04:00
Andrew Kelley
1dd0c3d49f
fix calling an inferred async function
2019-08-01 16:41:30 -04:00
Andrew Kelley
e7ae4e4645
reimplement async with function splitting instead of switch
2019-08-01 16:08:52 -04:00
Andrew Kelley
6cb4cac5cd
disable behavior test for 128-bit cmpxchg
...
once #2883 is done this can be revisited
2019-08-01 03:36:03 -04:00
Andrew Kelley
38b5812c48
allow 128 bit cmpxchg on x86_64
2019-08-01 02:46:37 -04:00
Andrew Kelley
dbdc4d62d0
improve support for anyframe and anyframe->T
...
* add implicit cast from `*@Frame(func)` to `anyframe->T` or `anyframe`.
* add implicit cast from `anyframe->T` to `anyframe`.
* `resume` works on `anyframe->T` and `anyframe` types.
2019-07-29 19:32:49 -04:00
Andrew Kelley
ee64a22045
add the anyframe
and anyframe->T
types
2019-07-26 19:52:35 -04:00
Andrew Kelley
538c0cd225
implement @frameSize
2019-07-25 15:05:55 -04:00
Andrew Kelley
70bced5dcf
implement @frame
and @Frame
2019-07-25 01:47:56 -04:00
Andrew Kelley
ead2d32be8
calling an inferred async function
2019-07-25 00:03:06 -04:00
Andrew Kelley
9e11f67f0d
add test for previous commit
2019-07-24 15:05:39 -04:00
Andrew Kelley
e220812f2f
implement local variables in async functions
2019-07-24 02:59:51 -04:00
Andrew Kelley
19ee495750
add error for function with ccc indirectly calling async function
2019-07-23 19:35:41 -04:00
Vexu
57aa8997bd
fix escape sequence rendering
2019-07-23 14:49:19 -04:00
Andrew Kelley
317d1ecb2c
Merge remote-tracking branch 'origin/master' into rewrite-coroutines
2019-07-22 14:37:08 -04:00
Andrew Kelley
fcadeb50c0
fix multiple coroutines existing clobbering each other
2019-07-22 14:36:14 -04:00
Andrew Kelley
16be70cbbf
compiler-rt: add __muldi3
2019-07-22 12:49:26 -04:00
Andrew Kelley
59bf9ca58c
implement async function parameters
2019-07-21 23:27:47 -04:00
Andrew Kelley
11bd50f2b2
implement coroutine resume
2019-07-21 20:54:08 -04:00
Andrew Kelley
78e03c466c
simple async function passing test
2019-07-21 19:56:37 -04:00
Andrew Kelley
54e716afdc
remove coroutines implementation and promise type
2019-07-19 18:18:44 -04:00
Andrew Kelley
af8661405b
fix usingnamespace
...
It used to be that usingnamespace was only allowed at top level. This
made it OK to put the state inside the AST node data structure. However,
now usingnamespace can occur inside any aggregate data structure, and
therefore the state must be in the TopLevelDeclaration rather than in
the AST node.
There were two other problems with the usingnamespace implementation:
* It was passing the wrong destination ScopeDecl, so it could cause an
incorrect error such as "import of file outside package path".
* When doing `usingnamespace` on a file that already had
`pub usingnamespace` in it would "steal" the usingnamespace, causing
incorrect "use of undeclared identifier" errors in the target file.
closes #2632
closes #2580
2019-07-19 16:56:44 -04:00
Andrew Kelley
9dcddc2249
retire the example/ folder, rename test-build-examples to "standalone"
...
closes #2759
2019-07-16 12:15:46 -04:00
Andrew Kelley
741c74e427
cleanups
2019-07-16 11:50:00 -04:00
Andrew Kelley
45cc488cef
Merge branch 'main-return-!u8' of https://github.com/SamTebbs33/zig into SamTebbs33-main-return
2019-07-16 11:27:11 -04:00
Andrew Kelley
6fe3b20962
Merge branch 'translate-c-userland' of https://github.com/hryx/zig into hryx-translate-c-userland
2019-07-15 22:19:54 -04:00
Andrew Kelley
c0489abcdb
translate-c: fix incorrectly translated double function pointer
...
closes #2887
2019-07-13 12:38:10 -04:00
Andrew Kelley
4e58855a4a
translate-c: better detection of pointer to struct demoted to opaque
2019-07-12 12:11:26 -04:00
SamTebbs33
b118806c69
Add implicit cast for *[N]T to [*c]T
2019-07-06 17:02:17 -04:00
hryx
6bfa8546bb
Unicode escapes: stage1 tokenizer and behavior tests
2019-07-04 22:40:19 -07:00
SamTebbs33
f24b8f2a4a
Support returning !u8 from main
2019-07-04 14:26:05 +01:00
Andrew Kelley
96fd103073
improve the error message and test coverage
2019-07-04 00:35:28 -04:00
Andrew Kelley
bfe0bf695b
Merge branch 'impl-1107' of https://github.com/emekoi/zig into emekoi-impl-1107
2019-07-03 23:40:47 -04:00
emekoi
a1b952f4b0
added tests for #1107 and a note in the reference
2019-07-03 13:12:14 -05:00
Andrew Kelley
9da054095c
Merge branch 'comptime-union-init' of https://github.com/rbscott/zig into rbscott-comptime-union-init
2019-07-03 11:26:55 -04:00
Andrew Kelley
9daf0140e5
add missing compile error for comptime continue inside runtime catch
...
See #2604
2019-07-02 21:14:42 -04:00
Andrew Kelley
df11512f85
fixups
2019-07-02 16:52:55 -04:00
Andrew Kelley
140335b99f
Merge branch 'has-field' of https://github.com/shawnl/zig into shawnl-has-field
2019-07-02 16:21:40 -04:00
hryx
cc74bf5136
Translate IntegralCast; add stage2 test coverage
2019-06-27 23:12:33 -07:00
hryx
2060c7c39b
Merge branch 'master' into translate-c-userland
2019-06-27 22:12:34 -07:00
Andrew Kelley
0a0c11685f
fix for with null and T peer types and inferred result location type
...
See #2762
2019-06-27 17:22:35 -04:00
Andrew Kelley
1b23c46138
fix switch with null and T peer types and inferred result location type
...
closes #2762
2019-06-27 16:54:19 -04:00
Andrew Kelley
1ccf6a2c9e
compile error for using slice as array init expr type
...
when there are more than 0 elements.
closes #2764
2019-06-27 12:24:13 -04:00
Andrew Kelley
6c195ede54
add test case for defer modifying return value before returned
...
See #961
2019-06-26 23:25:53 -04:00
Andrew Kelley
3085d29af8
Merge remote-tracking branch 'origin/master' into copy-elision-3
2019-06-26 14:44:01 -04:00
Andrew Kelley
ff737cc648
fix peer type resolution: unreachable, error set, unreachable
2019-06-26 12:31:51 -04:00
Andrew Kelley
b4e40cb59a
fix peer type resolution with null
2019-06-26 00:36:24 -04:00
Andrew Kelley
fd4c5f54f0
all compile error tests passing
2019-06-25 19:03:56 -04:00
Andrew Kelley
0a77325916
fix several compile error test regressions
2019-06-25 18:06:03 -04:00
Andrew Kelley
cb55803a59
fix implicit cast vector to array
2019-06-25 13:57:45 -04:00
Andrew Kelley
c61e0a078c
fix union init with void payload
...
all std lib tests passing now
2019-06-25 11:31:38 -04:00
Marc Tiehuis
f5af349bd6
Merge pull request #2714 from ziglang/fmt-overhaul
...
Add positional, precision and width support to std.fmt
2019-06-25 20:15:33 +12:00
hryx
b2e06c3bf4
Observe translate mode in stage2
2019-06-23 14:32:45 -07:00
Andrew Kelley
b2cbc59e4c
Merge branch 'simd2' of https://github.com/shawnl/zig into shawnl-simd2
2019-06-23 17:10:33 -04:00
hryx
226a23d977
stage1: always render space after fn
like stage2
2019-06-23 12:46:17 -07:00
Andrew Kelley
020d5b529e
compile error tests only for debug mode
2019-06-23 02:06:57 -04:00
Andrew Kelley
036cc48a82
Merge remote-tracking branch 'origin/master' into copy-elision-3
2019-06-23 01:29:48 -04:00
Shawn Landden
71e014caec
stage1: add @sin @cos @exp @exp2 @ln @log2 @log10 @fabs @floor @ceil @trunc @round
...
and expand @sqrt
This revealed that the accuracy of ln is not as good as the current algorithm in
musl and glibc, and should be ported again.
v2: actually include tests
v3: fix reversal of in and out arguments on f128M_sqrt()
add test for @sqrt on comptime_float
do not include @nearbyInt() until it works on all targets.
2019-06-22 14:34:34 -05:00
Sahnvour
987c209b40
heap: make one global instance of DirectAllocator
...
it is now stateless, so the de/init are not necessary anymore
2019-06-22 14:10:53 -04:00
Andrew Kelley
3c4b255a3c
fix implicit cast fn call result to optional in field result
2019-06-22 13:37:13 -04:00
Andrew Kelley
727af307c6
fix return result loc and then switch with range...
...
...implicit casted to error union
2019-06-21 18:21:12 -04:00
Andrew Kelley
ff6d563b04
fix implicit cast to optional to error union to return result loc
2019-06-21 17:49:54 -04:00
Andrew Kelley
5441f77672
fix implicit cast bitcast result to error union by returning
2019-06-21 16:54:46 -04:00
Andrew Kelley
142e77abbb
fix extern functions returning byval structs
2019-06-21 14:44:49 -04:00
Andrew Kelley
48ccf427af
fix nested orelse and nested catch
2019-06-21 14:06:01 -04:00
Marc Tiehuis
11526b6e9d
breaking: Add positional, precision and width support to std.fmt
...
This removes the odd width and precision specifiers found and replacing
them with the more consistent api described in #1358 .
Take the following example:
{1:5.9}
This refers to the first argument (0-indexed) in the argument list. It
will be printed with a minimum width of 5 and will have a precision of 9
(if applicable).
Not all types correctly use these parameters just yet. There are still
some missing gaps to fill in. Fill characters and alignment have yet to
be implemented.
2019-06-21 20:11:15 +12:00
Andrew Kelley
4f21dc8a80
fix regression with zero sized array
...
thanks mikdusan!
2019-06-21 00:58:18 -04:00
Andrew Kelley
0498bd40d9
fix loops with multiple break statements
2019-06-20 22:38:40 -04:00
Andrew Kelley
237233b04b
fix coroutines
2019-06-20 18:27:04 -04:00
Andrew Kelley
057b105fad
one more test passing
2019-06-20 18:03:55 -04:00
Andrew Kelley
3c541d7be3
fix peer result loc fn call with comptime condition
2019-06-19 23:52:51 -04:00
Andrew Kelley
6217b401f9
fix labeled break inside comptime if inside runtime if
2019-06-19 23:39:49 -04:00
Andrew Kelley
78eeb6e9ae
fix double getelementptr of runtime global
2019-06-19 22:29:39 -04:00
Andrew Kelley
04c25efe11
Merge remote-tracking branch 'origin/master' into copy-elision-3
2019-06-19 19:01:28 -04:00
Andrew Kelley
4ffab5b85f
fix optional pointer to size zero struct
2019-06-19 18:47:02 -04:00
Andrew Kelley
c7dc03fcb1
fix try
not setting error code on result location
2019-06-19 17:07:05 -04:00
Andrew Kelley
96931228af
fix comptime test error for empty error set
2019-06-19 16:29:46 -04:00
Andrew Kelley
974db231a0
fix extraneous nested union field instruction
2019-06-19 16:16:47 -04:00
Andrew Kelley
e36680d3bd
fix detection of unable to evaluate constant expression
2019-06-19 15:18:51 -04:00
Andrew Kelley
b588a803bf
fix comptime modification of const struct field
2019-06-19 14:35:59 -04:00
Shawn Landden
39ad072a84
test: include muladd.zig in behavior tests
2019-06-19 12:07:02 -05:00
Shawn Landden
fce2d2d18b
stage1: add support for @mulAdd fused-multiply-add for floats and vectors of floats
...
Not all of the softfloat library is being built....
Vector support is very buggy at the moment, but should work when the bugs are fixed.
(as I had the same code working with another vector function, that hasn't been merged yet).
2019-06-19 12:07:02 -05:00
Andrew Kelley
79671efd3a
fix inline loop behavior with variable result loc
2019-06-18 17:43:05 -04:00
Andrew Kelley
e27da17ff2
back to many behavioral tests passing
2019-06-18 17:07:27 -04:00
Andrew Kelley
9050a07540
when resolving slice types, might need to...
...
...resolve alignment if custom alignment is provided
fixes #2689
2019-06-18 11:31:05 -04:00
Andrew Kelley
8ed88280a6
Revert "fixes resolving aligment of child type in slice"
...
This reverts commit aa60d2a688
.
The copyright ownership of this 10 line patch is under dispute.
See #2701 for details. So I'll revert it and then fix it myself without
looking at this patch.
2019-06-18 11:18:53 -04:00
Andrew Kelley
f4b8850002
fix type info crash on extern lib name
2019-06-16 14:14:57 -04:00
Jimmi HC
aa60d2a688
fixes resolving aligment of child type in slice
2019-06-16 00:03:43 -04:00
Andrew Kelley
9564c05cd5
better result location handling of inline loops
2019-06-15 19:19:13 -04:00
Andrew Kelley
6bf193af19
better result location semantics with optionals and return locations
...
somewhere along this branch, #1901 has been fixed.
2019-06-15 12:28:21 -04:00
Andrew Kelley
60025a3704
Merge remote-tracking branch 'origin/master' into copy-elision-3
2019-06-15 10:34:04 -04:00
Andrew Kelley
42ea2d0d1c
fix @export
for arrays and allow sections on extern variables
...
previously `@export` for an array would panic with a TODO message.
now it will do the export. However, it uses the variable's name
rather than the name passed to `@export`. Issue #2679 remains open
for that problem.
2019-06-14 15:28:52 -04:00
Andrew Kelley
acf16b5fb3
uncomment more passing tests
2019-06-14 13:32:04 -04:00
Andrew Kelley
7c074b8516
fix peer result locs with switch
2019-06-14 11:41:53 -04:00
Andrew Kelley
2ba29a1907
fix peer result location with error code and payload
2019-06-14 11:01:38 -04:00
Andrew Kelley
fdaca1b5f3
fix a couple more test regressions
2019-06-13 20:30:39 -04:00
Andrew Kelley
eaf74f4f96
fix bitcast packed struct to integer and back
2019-06-13 20:24:10 -04:00
Andrew Kelley
57347aacd7
fix atomic builtin functions
2019-06-13 20:01:25 -04:00
Andrew Kelley
24cfa3534f
allow comptime array literals casted to slices
2019-06-13 16:51:26 -04:00
Andrew Kelley
3cbe827464
fix behavior for nested array literals
...
new compile error for trying to cast runtime array literals to slices
2019-06-13 16:25:35 -04:00
Andrew Kelley
efb064449f
fix runtime initialize array elem and then implicit cast to slice
2019-06-13 13:31:15 -04:00
Andrew Kelley
ca0988e1d0
comment out the behavior tests that are failing
2019-06-12 22:19:56 -04:00
SamTebbs33
6c160b8856
Add check for null body in if, for and while
2019-06-10 00:41:33 -04:00
Andrew Kelley
b735764898
different array literal syntax when inferring the size
...
old syntax: []i32{1, 2, 3}
new syntax: [_]i32{1, 2, 3}
closes #1797
2019-06-09 19:26:32 -04:00
Andrew Kelley
78f32259da
default struct field initialization expressions
...
closes #485
2019-05-30 15:46:11 -04:00
Andrew Kelley
8ca294c430
update load dynamic library test for std lib changes
2019-05-30 00:04: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
NBonaparte
e716c9ba4b
build_examples: reenable load_dynamic_library
2019-05-29 19:48:36 -04:00
Andrew Kelley
bfc86776d5
run zig fmt to update use
to usingnamespace
2019-05-29 19:09:58 -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
9891c4f30d
Merge branch 'use-struct-pt2' of https://github.com/LemonBoy/zig into LemonBoy-use-struct-pt2
2019-05-29 15:48:49 -04:00
Andrew Kelley
b66438eb80
no "use of undeclared identifer" in dead comptime branches
2019-05-28 18:19:27 -04:00
LemonBoy
528c151a55
Reject undefined as type
...
Make analyze_type_expr behave like ir_resolve_type when the user tries
to use `undefined` as a type.
Closes #2436
2019-05-28 18:02:57 -04:00
Andrew Kelley
9d16839420
fix invalid LLVM IR generated for ?*void const casts
...
closes #2578
2019-05-28 16:11:36 -04:00
Andrew Kelley
f924fbddcf
Merge pull request #2552 from Sahnvour/issue-2543
...
gen-h: do not output visibility macros when the build is static
2019-05-27 21:51:34 -04:00
Shawn Landden
5a91dbc16c
allow const to be passed to @hasField()
...
Actually include the tests I wrote
2019-05-27 00:38:36 -05:00
Andrew Kelley
0c6ab61b22
tests passing on linux
2019-05-26 23:35:26 -04:00
Andrew Kelley
2b42e910bf
behavior tests passing on Linux
2019-05-26 19:56:37 -04:00
Andrew Kelley
44a049e01e
more cleanup. down to just the @hasDecl
builtin
2019-05-26 18:32:45 -04:00
Andrew Kelley
2f040a23c8
clean up references to os
2019-05-26 18:32:44 -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
Sahnvour
99ee0608f7
gen-h: do not output visibility macros when the build is static
2019-05-25 14:17:59 +02:00
Sahnvour
c89b522233
test: slightly better output for failure of tests based on text comparison
2019-05-25 13:43:52 +02:00
Robert Scott
9b7ad12481
Implement @unionInit
2019-05-24 01:48:45 -07:00
LemonBoy
f67ca20655
Make use work with arbitrary structs
2019-05-21 17:07:40 +02:00
LemonBoy
6672ee9eb3
Fix too eager comptime evaluation of error ptr
2019-05-19 15:53:32 -04:00
LemonBoy
b660134a18
Use the correct scope for use
...
use expressions outside the top-level scope now work as intended.
2019-05-19 00:32:49 -04:00
Andrew Kelley
860684cc2f
Merge pull request #2516 from LemonBoy/32bfix
...
More 32bit fixes for stdlib
2019-05-19 00:31:16 -04:00
LemonBoy
0a3aec020a
Fix load/store of non-integer fields in packed struct
2019-05-18 19:59:47 -04:00
LemonBoy
6957927194
Fix some test cases to run on 32bit systems
2019-05-18 10:59:56 +02: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
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
hryx
3a3a738478
Recursive rewrite of stage2 parser, part 3
2019-05-12 02:01:45 -07:00
LemonBoy
b05e8d46ec
Change the enum value allocation strategy
2019-05-11 21:29:53 +02:00
LemonBoy
c766f3f9ca
Support signed types as enum tags
2019-05-11 21:28:58 +02:00
Jimmi Holst Christensen
6cf7fb1177
fixes #2235
2019-05-11 20:51:59 +02:00
Jimmi Holst Christensen
fb3b943b07
added tests for global variable declaration syntax
2019-05-11 20:11:56 +02:00
Andrew Kelley
10e9d47b49
stage2 translate-c: implement functions with no prototype
...
stage1 translate-c actually has this wrong. When exporting a function,
it's ok to use empty parameters. But for prototypes, "no prototype"
means that it has to be emitted as a function that accepts anything,
e.g. extern fn foo(...) void;
See #1964
2019-05-11 12:09:11 -04:00
Andrew Kelley
5f4c3e6557
stage2 translate-c: simple function definitions
...
See #1964
2019-05-10 23:35:46 -04:00
Andrew Kelley
dbb5da14f4
stage2 translate-c: builtin types and pub
...
See #1964
2019-05-10 17:56:00 -04:00
Andrew Kelley
82219b1fd5
translate-c: better handling of restore points
2019-05-10 17:44:47 -04:00
Andrew Kelley
2933d6b848
add test case for previous commit
...
closes #2467
2019-05-10 16:57:37 -04:00
Andrew Kelley
a6f7a9ce2b
translate-c: we have our first test of self-hosted
...
See #1964
2019-05-10 16:03:54 -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
c459edac18
compile error for attempt to cast enum literal to error
...
closes #2203
2019-05-09 13:18:13 -04:00
Andrew Kelley
eb65410b62
translate-c: enough C tokenization/parsing to handle shifting in macros
...
See #2451
2019-05-09 12:48:38 -04:00
Andrew Kelley
62065a9aea
translate-c: handle int to ptr and ptr to int casting
...
See #2451
2019-05-09 12:17:23 -04:00
Andrew Kelley
e3542196c0
translate-c: NULL pointers translate to null
...
See #1967
2019-05-08 19:21:54 -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
Shawn Landden
c19bdc2d37
stage1: add @hasField() built-in
...
This was quite straight-forward
Closes : #1439
2019-05-06 11:52:47 -05:00
Andrew Kelley
9dfd24a334
add test case to cover solved bug
...
closes #2114
2019-04-30 14:17:16 -04:00
LemonBoy
77383f968d
translate-c: Emit @ptrCast + @alignPtr sequence
...
Avoid producing Zig code that doesn't compile due to mismatched
alignments between pointers.
Always emit a @alignOf instead of hardcoding the alignment value
returned by LLVM for portability sake of the generated code.
2019-04-29 21:30:19 -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
LemonBoy
9ec4ccc68f
Do not invoke UB in BigInt shr operations
...
Shifting a value of type T by an amount that's greater or equal to the
size of the type itself is UB.
Spotted by @tgschultz
2019-04-26 14:24:35 -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
ab424bbb35
translate-c: Add test for implicit casts
2019-04-22 22:23:41 +02:00
Michael Dusan
611d4bc6a1
stage1: const_values_equal support tagged union
2019-04-16 13:55:23 -04:00
LemonBoy
8f5753ba9f
Fix normalization of right-shifted BigInt at CT
...
The pointer value for the `digits` field was being treated as if it were
a limb.
Fixes #2225
2019-04-11 03:49:15 -04:00
Andrew Kelley
a4c7e4c4eb
__muloti4 does not need the ABI workaround on Windows
...
Fixes 128-bit integer multiplication on Windows.
closes #2250
2019-04-10 22:33:33 -04:00
Jimmi Holst Christensen
43e219b0d9
Merge branch 'master' of github.com:ziglang/zig
2019-04-08 05:30:32 +02:00
Jimmi Holst Christensen
f86ea797ba
Import 1607.zig to behavior.zig
2019-04-08 05:30:27 +02:00
Andrew Kelley
6715c54cc6
Merge pull request #2205 from kristate/zig-backport-issue532
...
stage1: create ir.cpp specific `analyze_type_expr`
2019-04-07 15:32:02 -04:00
kristopher tate
fae0c35195
test/compile_errors.zig: add regression test for ziglang/zig#532 ;
2019-04-07 10:37:43 +09:00
Jimmi Holst Christensen
7c38651a65
Merge branch 'master' of github.com:ziglang/zig
2019-04-07 03:19:08 +02:00
Jimmi Holst Christensen
6960cd156a
Added regression test for #1607 . fixes #1607
2019-04-07 03:18:51 +02:00
Jimmi Holst Christensen
65cf5a8e44
removed todo comment and added test
2019-04-06 11:04:55 +02:00
Andrew Kelley
846f72b57c
zig build: support single-threaded builds
...
and fix the zig test suite not setting the --single-threaded flag
2019-04-05 14:54:37 -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
be0f656c21
fix @divFloor
returning incorrect value and add __modti3
...
Closes #2152
See #1290
2019-04-04 15:45:37 -04:00
Andrew Kelley
c195d645e4
add regression test for #1025
...
closes #1025
2019-04-04 01:45:18 -04:00
Andrew Kelley
e4d595a8ba
fix thread local variables for non- position independent code
...
This fixes comes thanks to Rich Felker from the musl libc project,
who gave me this crucial information:
"to satisfy the abi, your init code has to write the same value
to that memory location as the value passed to the [arch_prctl]
syscall"
This commit also changes the rules for when to build statically
by default. When building objects and static libraries, position
independent code is disabled if no libraries will be dynamically
linked and the target does not require position independent code.
closes #2063
2019-04-04 01:08:26 -04:00
Andrew Kelley
5aee17e888
regression fixes and fix packed struct abi size
2019-04-02 18:31:19 -04:00
emekoi
b7aa289ae4
fixed broken casts in std
2019-03-31 16:47:34 -05: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
Andrew Kelley
3306e43984
add compile error test for invalid enum literal implicit cast
...
See #683
2019-03-24 18:51:24 -04:00
Andrew Kelley
da9d8a6ecf
implement peer type resolution for enum literals
...
See #683
2019-03-24 18:47:36 -04:00
Andrew Kelley
aff7b38838
make switch expressions allow enum literal types
...
See #683
2019-03-24 01:15:21 -04:00
Andrew Kelley
a736dfe6a1
implement implicit cast from enum literal to enum
...
See #683
2019-03-24 00:55:55 -04:00
Andrew Kelley
d0551db5cd
introduce the enum literal type
...
see #683
2019-03-24 00:44:18 -04:00
Andrew Kelley
64dddd7afe
add compile error for ignoring error
...
closes #772
2019-03-23 19:33:00 -04:00
Andrew Kelley
6a9c32f759
add regression tests for a bug fixed by an older commit
...
closes #1914
2019-03-23 19:01:51 -04:00
Andrew Kelley
4d50bc3f8d
add peer type resolution for *const T
and ?*T
...
closes #1298
2019-03-23 18:48:12 -04:00
Andrew Kelley
89953ec83d
character literals: allow unicode escapes
...
also make the documentation for character literals more clear.
closes #2089
see #2097
2019-03-23 17:35:21 -04:00
Andrew Kelley
3e9697bb35
remove octal and hex floats from the language
...
closes #2093
This is technically a breaking change but I would be
surprised if anyone was actually using this feature.
2019-03-23 14:04:52 -04:00
Andrew Kelley
4615ed5ea0
float literals now parse using musl's 128 bit float code
...
fixes float literals not having 128 bit precision
2019-03-22 14:56:03 -04:00
Andrew Kelley
127bb124a0
Merge pull request #2091 from ziglang/bigint-print-fix
...
Fix bigint_append_buf
2019-03-22 10:23:18 -04:00
Marc Tiehuis
a3f42a5fe1
Fix compile-error test case for large integer type
2019-03-23 00:20:03 +13:00
Marc Tiehuis
e3b70fe4ba
Simplify hex-float parsing code
2019-03-22 17:11:57 +13:00
Andrew Kelley
d04a1456df
hex float parsing: solve another case
...
this works now: 0x1.edcb34a235253948765432134674fp-1
2019-03-21 16:35:18 -04:00
Andrew Kelley
af509c68b0
fix parsing of large hex float literals
...
closes #2083
2019-03-21 16:17:29 -04:00
Andrew Kelley
15c316b0d8
add docs for assembly and fix global assembly parsing
...
Previously, global assembly was parsed expecting it to have
the template syntax. However global assembly has no inputs,
outputs, or clobbers, and thus does not have template syntax.
This is now fixed.
This commit also adds a compile error for using volatile
on global assembly, since it is meaningless.
closes #1515
2019-03-20 19:00:23 -04:00
Andrew Kelley
3c7555cb67
Merge remote-tracking branch 'origin/llvm8'
2019-03-20 13:34:07 -04:00
Andrew Kelley
2fdf69bc40
Merge pull request #2079 from Sahnvour/issue-2050
...
Fixes c_ABI tests on windows
2019-03-20 00:11:11 -04:00
Sahnvour
d669db7673
c_abi: activate tests on windows
2019-03-19 22:41:27 +01:00
Sahnvour
27d5e1f36c
c_abi: add some tests for int and float parameter passing potentially using both registers and stack
2019-03-19 22:09:12 +01:00
Andrew Kelley
85256521ba
fix translate-c regression
2019-03-18 20:09:27 -04:00
Andrew Kelley
a581f4f0e2
Merge remote-tracking branch 'origin/master' into llvm8
2019-03-18 20:03:23 -04:00
Andrew Kelley
a17bf219c6
Merge pull request #2069 from ziglang/glibc-assert-translation
...
Implemented enough of translate-c to translate assert
2019-03-18 14:43:17 -04:00
Jimmi Holst Christensen
9171e7a7c1
More work on ignoring values correctly
2019-03-18 14:55:57 +01:00
Andrew Kelley
6abe6dbfe4
enable issue_339 test on macos
...
closes #1126
2019-03-16 01:18:46 -04:00
Andrew Kelley
6d6195424d
add regression test for invalid multiple dereferences
...
closes #1042
2019-03-16 00:23:18 -04:00
Andrew Kelley
c40448eb9a
add compile error for wrong type with use
...
closes #1557
2019-03-16 00:18:10 -04:00
Andrew Kelley
4a5cd0b895
fix while continue block not checking for ignored expression
...
closes #957
2019-03-15 23:52:11 -04:00
Andrew Kelley
9c13e9b7ed
breaking changes to std.mem.Allocator interface API
...
Before, allocator implementations had to provide `allocFn`,
`reallocFn`, and `freeFn`.
Now, they must provide only `reallocFn` and `shrinkFn`.
Reallocating from a zero length slice is allocation, and
shrinking to a zero length slice is freeing.
When the new memory size is less than or equal to the
previous allocation size, `reallocFn` now has the option
to return `error.OutOfMemory` to indicate that the allocator
would not be able to take advantage of the new size.
For more details see #1306 . This commit closes #1306 .
This commit paves the way to solving #2009 .
This commit also introduces a memory leak to all coroutines.
There is an issue where a coroutine calls the function and it
frees its own stack frame, but then the return value of `shrinkFn`
is a slice, which is implemented as an sret struct. Writing to
the return pointer causes invalid memory write. We could work
around it by having a global helper function which has a void
return type and calling that instead. But instead this hack will
suffice until I rework coroutines to be non-allocating. Basically
coroutines are not supported right now until they are reworked as
in #1194 .
2019-03-15 17:57:21 -04:00
Jimmi HC
5ae400fb39
fixed void cast and added the last tests
2019-03-15 19:11:46 +01:00
Andrew Kelley
4090fe81f6
Merge pull request #2068 from ziglang/workaround-for-2043
...
workaround for #2043
2019-03-15 11:19:21 -04:00
Jimmi Holst Christensen
a77b2a0810
Implemented enough of translate-c to translate assert
...
This required the following
* __extention__
* ({})
* Fixing if (0) ; else ;
2019-03-15 16:12:41 +01:00
Jimmi Holst Christensen
3ef9b899e4
workaround for #2043
2019-03-15 11:17:21 +01:00
Andrew Kelley
080dd27157
breaking: fix @typeInfo handling of global error set type
...
`builtin.TypeInfo.ErrorSet` is now `?[]Error`
instead of `struct{errors:[]Error}`.
closes #1936
2019-03-14 11:57:56 -04:00
Andrew Kelley
20c36949e1
fix target_requires_pic and reloc_mode
...
disable failing thread local variable test.
see #2063
2019-03-13 23:15:34 -04:00
Andrew Kelley
54edbc6815
Merge remote-tracking branch 'origin/master' into llvm8
2019-03-13 12:56:58 -04:00
LemonBoy
49838a9f3e
Fix generation of comptime slices
...
By erasing the global_refs field we'd trip any codepath using
const_values_equal_ptr to figure if two slices were different.
2019-03-13 11:35:05 -04:00
Andrew Kelley
761356209b
add test cases to cover switching on u0 values
...
closes #1563
2019-03-11 19:42:07 -04:00
Sahnvour
9b99356551
translate-c: additional test case for integer suffixes on 0
2019-03-11 16:36:27 -04:00
Andrew Kelley
f2ca2ace09
zig build: do a better job of detecting system paths
...
See #2041
2019-03-11 15:22:05 -04:00
Andrew Kelley
80e5af2be2
Merge pull request #2049 from ziglang/problematic-mtime-detection
...
stage1 caching system: detect problematic mtimes
2019-03-11 12:47:55 -04:00
Andrew Kelley
9efa18f687
enable C ABI tests on macOS
2019-03-11 12:21:30 -04:00
Andrew Kelley
e1fbb24d64
add test for spawning child process with empty environment
...
thanks to BenoitJGirard for pointing out the child process
implementation needs 3 extra null bytes in #2031
2019-03-11 11:56:08 -04:00
Jimmi Holst Christensen
357813b193
added tests
2019-03-11 10:55:43 -04:00
Andrew Kelley
6a5c2b249d
Revert "use unique test source names for test-gen-h"
...
This reverts commit 264b03d570
.
This workaround is no longer necessary.
2019-03-11 10:35:39 -04:00
Andrew Kelley
4cb55d3af6
Merge remote-tracking branch 'origin/master' into llvm8
2019-03-10 18:07:28 -04:00
Sahnvour
fa9fcab620
translate-c: add support for integer suffixes on 0 (zero) litteral inside macro definitions
2019-03-10 14:56:35 -04:00
Andrew Kelley
3cdd2c0bdd
Merge remote-tracking branch 'origin/master' into llvm8
2019-03-10 13:48:06 -04:00
Andrew Kelley
264b03d570
use unique test source names for test-gen-h
2019-03-09 09:52:33 -05:00
Andrew Kelley
91955dee58
breaking changes to zig build API and improved caching
...
* in Zig build scripts, getOutputPath() is no longer a valid function
to call, unless setOutputDir() was used, or within a custom make()
function. Instead there is more convenient API to use which takes
advantage of the caching system. Search this commit diff for
`exe.run()` for an example.
* Zig build by default enables caching. All build artifacts will go
into zig-cache. If you want to access build artifacts in a convenient
location, it is recommended to add an `install` step. Otherwise
you can use the `run()` API mentioned above to execute programs
directly from their location in the cache. Closes #330 .
`addSystemCommand` is available for programs not built with Zig
build.
* Please note that Zig does no cache evicting yet. You may have to
manually delete zig-cache directories periodically to keep disk
usage down. It's planned for this to be a simple Least Recently
Used eviction system eventually.
* `--output`, `--output-lib`, and `--output-h` are removed. Instead,
use `--output-dir` which defaults to the current working directory.
Or take advantage of `--cache on`, which will print the main output
path to stdout, and the other artifacts will be in the same directory
with predictable file names. `--disable-gen-h` is available when
one wants to prevent .h file generation.
* `@cImport` is always independently cached now. Closes #2015 .
It always writes the generated Zig code to disk which makes debug
info and compile errors better. No more "TODO: remember C source
location to display here"
* Fix .d file parsing. (Fixes the MacOS CI failure)
* Zig no longer creates "temporary files" other than inside a
zig-cache directory.
This breaks the CLI API that Godbolt uses. The suggested new invocation
can be found in this commit diff, in the changes to `test/cli.zig`.
2019-03-08 23:23:11 -05:00
Sahnvour
5469e3e3c1
missed change when switching TypeInfo to use comptime_int
...
fixes #2030
2019-03-06 15:27:56 -05:00
Andrew Kelley
0714e19598
Merge remote-tracking branch 'origin/master' into llvm8
2019-03-04 08:24:56 -05:00
Andrew Kelley
9c5852aa86
fix slice of C pointer
...
closes #2002
2019-03-03 13:04:04 -05:00
Andrew Kelley
e3b275fa47
fix build.zig not respecting --static
...
closes #2027
2019-03-03 12:35:09 -05:00
Andrew Kelley
d0d615d819
fix const initialization of optional C pointer to null
2019-03-03 10:47:06 -05:00
Andrew Kelley
e402455704
rename std lib files to new convention
2019-03-02 16:46:04 -05:00
Andrew Kelley
ea5cedced1
fix @typeName on slices
...
closes #2026
2019-03-02 14:31:27 -05:00
Andrew Kelley
67b4de33d2
compile error for import outside package path
...
closes #2024
there's a new cli option `--main-pkg-path` which you can use to choose
a different root package directory besides the one inferred from the
root source file
and a corresponding build.zig API:
foo.setMainPkgPath(path)
2019-03-02 10:38:27 -05:00
Andrew Kelley
5f7d9c5845
@typeInfo for structs and opaque types is the bare name
2019-03-01 17:15:58 -05:00
Andrew Kelley
582fdc2869
fix dependency loops, pub, tests, use decls, root source
...
* fix dependency loop detection
- closes #679
- closes #1500
* fix `pub`
* fix tests
* fix use decls
* main package file gets a special "" namespace path
2019-03-01 15:35:29 -05:00
Andrew Kelley
02f3a834b0
struct types get fully qualified names
...
and function symbol names become fully qualified
2019-02-28 15:40:57 -05:00
Andrew Kelley
5424b4320d
remove namespace type; files are empty structs
...
closes #1047
2019-02-28 10:11:32 -05:00
Andrew Kelley
2dcf1a2392
Merge remote-tracking branch 'origin/master' into llvm8
2019-02-28 09:19:18 -05:00
Andrew Kelley
557983e502
fix handling when there are multiple externs and
...
an export in the same object
closes #529
2019-02-26 19:43:12 -05:00
Andrew Kelley
763357c9c3
add test coverage for type used as switch case
...
closes #996
2019-02-26 19:41:36 -05:00
Andrew Kelley
d5fc826437
add test coverage for binary OR on error sets
...
closes #1074
2019-02-26 19:34:22 -05:00
Andrew Kelley
ade10387a5
breaking changes to the way targets work in zig
...
* CLI: `-target [name]` instead of `--target-*` args.
This matches clang's API.
* `builtin.Environ` renamed to `builtin.Abi`
- likewise `builtin.environ` renamed to `builtin.abi`
* stop hiding the concept of sub-arch. closes #1526
* `zig targets` only shows available targets. closes #438
* include all targets in readme, even those that don't
print with `zig targets` but note they are Tier 4
* refactor target.cpp and make the naming conventions
more consistent
* introduce the concept of a "default C ABI" for a given
OS/Arch combo. As a rule of thumb, if the system compiler
is clang or gcc then the default C ABI is the gnu ABI.
2019-02-26 15:58:10 -05:00
Andrew Kelley
82fafca375
fix the libc compile error tests to only run on linux
2019-02-25 21:46:32 -05:00
Andrew Kelley
7571db05de
fix incorrectly trying to memset at comptime
...
closes #718
2019-02-25 20:33:40 -05:00
Andrew Kelley
4b7e285b76
add a regression test for #704
...
closes #704
2019-02-25 20:18:35 -05:00
Andrew Kelley
152db27146
better error message when forgetting to link against libc
...
closes #1698
2019-02-25 20:09:18 -05:00
Andrew Kelley
3ca861c7dd
add a compile error note when C import fails and not linking libc
...
closes #558
2019-02-25 19:31:30 -05:00
Andrew Kelley
7b8c5578c6
fix infinite recursion in type_has_one_possible_value
...
closes #2006
2019-02-25 16:28:23 -05:00
Andrew Kelley
525c2eaf5d
building DLLs on Windows works better
2019-02-25 13:34:25 -05:00
Andrew Kelley
e76ce2c1d0
first class support for compiling C code
...
New CLI parameter: --c-source [options] [file]
It even works with `--cache on` when there are transitive dependencies.
Instead of `builder.addCExecutable`, use `builder.addExecutable` and pass
`null` for the root source file. Then use `builder.addCSourceFile`,
which takes the path to the C code, and a list of C compiler args.
Be sure to linkSystemLibrary("c") if you want libc headers to be
available.
Merge TestStep into LibExeObjStep. That was long overdue.
2019-02-25 11:45:00 -05:00
Andrew Kelley
52bb71867d
implement vector negation
...
also fix vector behavior tests, they weren't actually testing
runtime vectors, but now they are.
See #903
2019-02-22 13:28:57 -05:00
Andrew Kelley
2fe8a0831f
add regression test for bitcast to array
...
closes #421
2019-02-22 11:09:17 -05:00
Andrew Kelley
0c5f897904
fix @bitCast
when src/dest types have mismatched handle_is_ptr
...
* separate BitCast and BitCastGen instructions
* closes #991
* closes #1934
* unrelated: fix typo in docs (thanks gamester for pointing it out)
2019-02-22 08:49:27 -05:00
Andrew Kelley
cbce61a209
better field access of types which have one possible value
...
* When you do field access of a type which only has one possible
value, the result is comptime-known.
* StorePtr instructions which operate on pointers to types which
only have one possible value, the result is a comptime no-op.
closes #1554
2019-02-21 16:09:14 -05:00
Andrew Kelley
1066004b79
better handling of arrays in packed structs
...
* Separate LoadPtr IR instructions into pass1 and pass2 variants.
* Define `type_size_bits` for extern structs to be the same as
their `@sizeOf(T) * 8` and allow them in packed structs.
* More helpful error messages when trying to use types in
packed structs that are not allowed.
* Support arrays in packed structs even when they are not
byte-aligned.
* Add compile error for using arrays in packed structs when the
padding bits would be problematic. This is necessary since
we do not have packed arrays.
closes #677
2019-02-21 14:44:14 -05:00
Andrew Kelley
2bb795dc45
@sliceToBytes
works at comptime
...
closes #262
2019-02-21 10:07:11 -05:00
Andrew Kelley
db31c2524d
extern structs support comptime bitcasting
2019-02-21 08:46:43 -05:00
Andrew Kelley
3ee9d06cbd
packed structs support comptime bitcasting
...
* `type_size_store` is no longer a thing. loading and storing a pointer
to a value may dereference up to `@sizeOf(T)` bytes, even for
integers such as `u24`.
* fix `types_have_same_zig_comptime_repr` to not think that the
same `ZigTypeId` means the `ConstExprValue` neccesarily has the
same representation.
* implement `buf_write_value_bytes` and `buf_read_value_bytes` for
`ContainerLayoutPacked`
closes #1120
2019-02-20 22:40:41 -05:00
Andrew Kelley
079728752e
deduplicate compile errors for undeclared identifiers
...
closes #111
2019-02-20 08:04:46 -05:00
Andrew Kelley
1034af40f9
Merge branch 'slice-deref-failure' of https://github.com/matthew-mcallister/zig into matthew-mcallister-slice-deref-failure
2019-02-19 15:27:10 -05:00
LemonBoy
400006bbe7
Prevent crash in tagged enums rendering ( #1986 )
...
* Prevent crash in tagged enums rendering
* Add a test case
2019-02-19 15:18:57 -05:00
Andrew Kelley
ea3d9d5c53
add test for 74bdc1d1f8
2019-02-18 18:11:30 -05:00
Andrew Kelley
28bf768883
export _mh_execute_header with weak linkage
...
* also fix extern variables with initialiaztion values to generate runtime code
* remove the workaround in example/shared_library/mathtest.zig
* introduce the ability for global variables to have Weak and LinkOnce
linkage
* fix `@export` to work for non-functions. this code needs to be
audited though.
* fix comptime ptrcast not keeping bigger alignment
* fix linker warnings when targeting darwin
closes #1903
2019-02-18 16:47:30 -05:00
Andrew Kelley
7a84fe79b9
pull request fixups
2019-02-18 13:05:26 -05:00
emekoi
9b3013d2f6
make @enumToInt work on union(enum)
...
closes #1711
2019-02-18 11:43:45 -05:00
LemonBoy
e280dce30f
Translate parameterless C functions ( #1978 )
...
Both FunctionNoProto and FunctionProto are subclasses of FunctionType,
the only difference is that the former is parameterless.
2019-02-18 10:26:45 -05:00
Matthew McAllister
c70ee9177e
Check for duped error messages in compile tests
2019-02-17 15:33:28 -08:00
Matthew McAllister
51783510b9
Deduplicate compile log statement warnings
2019-02-17 14:02:37 -08:00
Matthew McAllister
91989e70ba
Fix lvalue dereference type checking
...
Previously, if a dereference instruction was an lvalue, it would fail to
typecheck that the value being dereferenced was indeed a pointer.
Although a little clunky, this change obviates the need for redundant
type checks scattered about the analysis.
2019-02-16 17:37:47 -08:00
Andrew Kelley
f57182456d
Merge pull request #1898 from Sahnvour/translate-c-arrays
...
Translate c arrays
2019-02-16 14:07:41 -05:00
Andrew Kelley
a05e224150
typecheck the panic function
...
this adds the prototype of panic to @import("builtin")
and then uses it to do an implicit cast of the panic
function to this prototype, rather than redoing all the
implicit cast logic.
closes #1894
closes #1895
2019-02-15 19:19:28 -05:00
Andrew Kelley
7293e012d7
breaking: fix @sizeOf to be alloc size rather than store size
...
* Fixes breaches of the guarantee that `@sizeOf(T) >= @alignOf(T)`
* Fixes std.mem.secureZero for integers where this guarantee previously
was breached
* Fixes std.mem.Allocator for integers where this guarantee previously
was breached
Closes #1851
Closes #1864
2019-02-15 18:05:50 -05:00
Andrew Kelley
567c9b688e
Merge pull request #1965 from ziglang/c-pointer-type
...
implement C pointers
2019-02-15 02:20:42 -05:00
Andrew Kelley
ee5e196f88
add test for truncate on comptime integers
...
closes #703
2019-02-15 02:02:19 -05:00
Andrew Kelley
d6e0d82c32
translate-c: back to *c_void for opaque types
...
See #1059
2019-02-14 23:09:31 -05:00
Andrew Kelley
d5bbd74871
allow C pointers to have alignment
...
clang/gcc support pointer alignment attribute:
https://clang.llvm.org/docs/AttributeReference.html#align-value
2019-02-14 20:04:13 -05:00
Andrew Kelley
cc7060d0d9
compile error for C pointer with align attribute
...
See #1059
2019-02-14 20:02:29 -05:00
Andrew Kelley
6769183a9d
fix implicit cast error unions with non-optional to optional pointer
...
and update self hosted compiler for C pointers
See #1059
2019-02-14 15:48:28 -05:00
Andrew Kelley
52c03de5c2
add missing compile error for OpaqueType inside structs/unions
...
closes #1862
2019-02-14 13:07:51 -05:00
Andrew Kelley
e03c770145
compile error tests for implicit C pointer casting
...
See #1059
2019-02-14 12:28:50 -05:00