Commit Graph

2481 Commits (129a4fb251f8eab22eacf219fbf81006baec3251)

Author SHA1 Message Date
Alexandros Naskos 129a4fb251 Copy union const values correctly 2020-06-24 15:21:58 -04:00
antlilja 0de35af98b Add duplicate checking for switch on types
* Add compile error tests
2020-06-23 15:17:04 -04:00
Andrew Kelley 44bd0a2670
Merge pull request #5662 from shtanton/meta-cast
Adds std.meta.cast and uses it to simplify translate-c
2020-06-22 19:54:30 -04:00
xackus d907f574e0 stage1: fix concat of sliced str literals 2020-06-21 14:57:12 -04:00
Robin Voetter 8696e52a3d
Make unary minus for unsigned types a compile error (#5654)
* Make unary minus for unsigned types a compile error

* Add unreachable when generating unsigned negate
2020-06-21 14:55:44 -04:00
Charlie Stanton 6f47513009 Adds std.meta.cast and uses it to simplify translate-c 2020-06-21 18:24:59 +01:00
Ryan Liptak 399f6b77c4 Add 'no changes' test to zig fmt cli test 2020-06-20 22:21:23 -07:00
Ryan Liptak b216d8de88 Simplify unformatted code in zig fmt cli test 2020-06-20 22:20:23 -07:00
Ryan Liptak ca9d8a1337 Add zig fmt test to cli tests for both files and directories
Should catch basic `zig fmt` regressions that were previously going uncaught and breaking things
2020-06-20 22:02:55 -07:00
Andrew Kelley c70633eacd
Merge pull request #5203 from tadeokondrak/@type-for-even-more-types
implement @typeInfo for Frame and implement @Type for Frame, EnumLiteral, and ErrorSet
2020-06-18 21:25:03 -04:00
Andrew Kelley 5ea0f589c9
Merge pull request #5625 from antlilja/master
Improve support for f128 and comptime_float operations
2020-06-18 20:32:43 -04:00
Andrew Kelley 4a38799631 make file and fn_name fields of SourceLocation also null-terminated
One of the main motivating use cases for this language feature is
tracing/profiling tools, which expect null-terminated strings for these
values. Since the data is statically allocated, making them
additionally null-terminated comes at no cost.

This prevents the requirement of compile-time code to convert to
null-termination, which could increase the compilation time of
code with tracing enabled.

See #2029
2020-06-18 17:09:10 -04:00
Vexu 14acc65675
add tests for `@src` 2020-06-18 21:11:34 +03:00
antlilja 1157ee1307 Improve builtin op support for f128/comptime_float
* Add support for fabs, floor, ceil, trunc and round
* Add behavior tests
2020-06-17 17:35:45 +02:00
Andrew Kelley f595545c10
Merge pull request #5422 from pixelherodev/error_tests
[Stage2/Testing] ZIR tests for expected errors
2020-06-16 03:50:56 -04:00
Noam Preil a99e61ebaa
Stage2/Testing: Code cleanup 2020-06-15 21:47:42 -04:00
Noam Preil afec3e72f4
Stage2/Testing: Enable another test 2020-06-15 20:42:22 -04:00
Noam Preil 7d1c9a69cc
Stage2/Testing: Remove dead code 2020-06-15 20:33:43 -04:00
Noam Preil 7ee0462f5f
Stage2/Testing: Fix transformation tests 2020-06-15 20:33:39 -04:00
Noam Preil b6bd51ed69
Stage2/Testing: Move Transformation case to ZIRCase 2020-06-15 20:33:25 -04:00
Noam Preil e77fc7fe7e
Stage2/Testing: Fix error specification 2020-06-15 20:33:17 -04:00
Noam Preil 6dce317fe3
Stage2/Testing: Fix error tests 2020-06-15 20:33:07 -04:00
Noam Preil 2ed07a36f8
[Stage2/Testing] Attempt to call nakedcc function 2020-06-15 17:52:21 -04:00
Noam Preil 68cc068a3a
[Stage2/Testing] Make API more friendly 2020-06-15 17:51:43 -04:00
Noam Preil bebc1f49cf
[Stage2/Testing] Add (failing) test 2020-06-15 17:51:43 -04:00
Noam Preil 2d1d012f11
[Stage2/Testing] Reduce test 2020-06-15 17:51:43 -04:00
Noam Preil c92816fbef
[Stage2/Testing] ZIR tests for expected errors 2020-06-15 17:51:29 -04:00
Andrew Kelley 2bb3e1aff4 stage1: implement type coercion of anon struct literal to struct
closes #3672
2020-06-15 16:52:18 -04:00
Jakub Konka 057d97c093 Return should be i32 due to error signaling in memory.grow
Also, fix tests.
2020-06-09 00:22:34 -04:00
Jakub Konka 8ffa8ed9a8 Expose full llvm intrinsic 2020-06-09 00:22:34 -04:00
Jakub Konka 73a3bfd1dd Add basic tests for the new builtins 2020-06-09 00:22:34 -04:00
Jonathan Marler 12051b02f1 fix memory errors 2020-06-09 00:17:22 -04:00
Andrew Kelley 9ee98f103b
Merge pull request #5539 from mikdusan/issue5474
stage1: fix constness in some corner cases
2020-06-09 00:12:57 -04:00
Andrew Kelley d2278f2156
Merge pull request #5566 from ziglang/stage2-garbage-collect-decls
Stage2 garbage collect decls
2020-06-08 18:29:12 -04:00
xackus 0d40cb6255 stage1: fix crash on slice byte reinterpretation 2020-06-08 17:19:06 -04:00
Andrew Kelley 47090d234e stage2: add passing test for compile error in unreferenced cycle 2020-06-08 15:16:40 -04:00
Andrew Kelley cf654b52d6 stage2: -femit-zir respects decl names and supports cycles 2020-06-08 15:16:40 -04:00
Michael Dusan c0c9d11d8c
stage1: fix constness in some corner cases
- for one-possible-value types, ir_analyze_struct_field_ptr()
  no longer hardcodes const/volatile

- when slicing arrays, ir_analyze_instruction_slice()
  no longer consults ConstValSpecialStatic

closes #5474
2020-06-05 00:49:57 -04:00
Vexu c27a8bd6be
translate-c: don't crash on complex switches 2020-06-04 14:22:27 +03:00
Andrew Kelley 6524a64bda stage2: fix referencing decls which appear later in the file 2020-06-02 17:43:51 -04:00
xackus 250dd9ac21 stage1: fix unresolved inferred error sets 2020-05-31 15:04:34 +02:00
foobles 51682717d7 Support equality comparison for optional to non-optional (?T ==/!= T)
extracted function ir_try_evaluate_bin_op_const
extracted type_is_self_comparable function
renamed ir_try_evaluate_bin_op_const to ir_try_evaluate_bin_op_cmp_const
implemented analysis of ?T == T
added ir_set_cursor_at_end_and_append_basic_block_gen
use build_br_gen and ir_set_cursor_at_end_and_append_block_gen
added ir_append_basic_block_gen
removed include of all_types in ir.cpp
extracted compile-time and runtime evaluation of cmp_optional_non_optional to separate functions

closes #5390
closes #1332
2020-05-29 18:46:09 -04:00
Veikka Tuominen 4c8b937fb0
Merge pull request #5184 from alexnask/typeof_extern_call
Extern functions are now evaluated to undefined values at comptime in TypeOf calls.
2020-05-30 01:11:22 +03:00
Timon Kruiper 6e89692d81 C ABI: Add C support for passing structs of floats to an extern function
Currently this does not handle returning these structs yet.

Related: #1481
2020-05-28 22:56:33 -04:00
Andrew Kelley 3eed7a4dea stage2: first pass at recursive dependency resolution 2020-05-28 12:19:00 -04:00
Andrew Kelley c7ca1fe6f7 self-hosted: introduce a virtual address allocation scheme
The binary file abstraction changed its struct named "Decl" to
"TextBlock" and it now represents an allocated slice of memory in
the .text section. It has two new fields: prev and next, making it
a linked list node. This allows a TextBlock to find its neighbors.

The ElfFile struct now has free_list and last_text_block fields.
Doc comments for free_list are reproduced here:

A list of text blocks that have surplus capacity. This list can have false
positives, as functions grow and shrink over time, only sometimes being added
or removed from the freelist.

A text block has surplus capacity when its overcapacity value is greater than
minimum_text_block_size * alloc_num / alloc_den. That is, when it has so
much extra capacity, that we could fit a small new symbol in it, itself with
ideal_capacity or more.

Ideal capacity is defined by size * alloc_num / alloc_den.

Overcapacity is measured by actual_capacity - ideal_capacity. Note that
overcapacity can be negative. A simple way to have negative overcapacity is to
allocate a fresh text block, which will have ideal capacity, and then grow it
by 1 byte. It will then have -1 overcapacity.

The last_text_block keeps track of the end of the .text section.

Allocation, freeing, and resizing decls are all now more sophisticated,
and participate in the virtual address allocation scheme. There is no
longer the possibility for virtual address collisions.
2020-05-27 15:23:27 -04:00
Vexu cd5b7b9e1d
translate-c: use correct scope in for loop condition 2020-05-27 14:14:17 +03:00
Jakub Konka 08b0cae777 Add matching compile error test 2020-05-26 18:00:08 +02:00
Jakub Konka 015c899297 Make align expr on fns a compile error in Wasm
In Wasm, specifying alignment of function pointers makes little sense
since function pointers are in fact indices to a Wasm table, therefore
any alignment check on those is invalid. This can cause unexpected
behaviour when checking expected alignment with `@ptrToInt(fn_ptr)`
or similar. This commit proposes to make `align` expressions a
compile error when compiled to Wasm architecture.

Some references:
[1] [Mozilla: WebAssembly Tables](https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format#WebAssembly_tables)
[2] [Sunfishcode's Wasm Ref Manual](https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#indirect-call)
2020-05-26 17:17:32 +02:00
Alexandros Naskos d88db4d34b Changed test name to reflect it only fixes #4328 2020-05-26 12:36:02 +03:00