Andrew Kelley
4fc6f631e0
Merge pull request #8126 from xackus/translate_c_int_literal_promotion
...
translate-c: promote int literals to bigger types
2021-03-11 14:32:37 -05:00
joachimschmidt557
bdb917006c
stage2 tzir: Add wrapping integer arithmetic instructions
2021-03-11 14:31:21 -05:00
Andrew Kelley
b1a22fdbab
Merge pull request #8193 from kivikakk/elf-expose-em
...
elf: expose machine field in ELF header
2021-03-11 14:30:06 -05:00
Asherah Connor
24e5959840
elf: make EM non-exhaustive
2021-03-11 10:09:51 +11:00
Asherah Connor
c5eb15526d
expose machine field in ELF header
2021-03-10 16:26:41 +11:00
LemonBoy
f2b96782ec
stage2: Fix glibc lookup path for MIPS crt files
...
Add some more rules to let the compiler find the correct startup files
for the selected target and ABI.
2021-03-09 18:20:34 -05:00
LemonBoy
1a5d0cea15
stage2: Use correct ELF emulation for mips64
...
The n32 ABI requires a different emulation string than n64.
2021-03-09 18:20:34 -05:00
Loris Cro
a033735c8d
update to latest fetch-them-macos-headers
2021-03-09 22:43:16 +01:00
Loris Cro
767eb2d469
update to latest fetch-them-macos-headers
2021-03-09 22:15:01 +01:00
Evan Haas
c760532be0
translate-c: Add compound literal support
2021-03-08 10:09:12 +02:00
Isaac Freund
b988815bf0
parser: fix parsing/rendering of a[b.. :c] slicing
...
The modification to the grammar in the comment is in line with the
grammar in the zig-spec repo.
Note: checking if the previous token is a colon is insufficent to tell
if a block has a label, the identifier must be checked for as well. This
can be seen in sentinel terminated slicing: `foo[0..1:{}]`
2021-03-08 01:37:28 +01:00
Evan Haas
d01bb21173
translate-c: Explicitly cast decayed array to pointer with @ptrCast
...
This enables translation of code that uses pointer arithmetic with arrays
2021-03-08 00:35:17 +02:00
jacob gw
5d215cc76b
stage2 Elf linker: fill in bswapAllFields
...
I moved it to std.elf since it could be used there and added test
2021-03-07 23:18:26 +02:00
Jonathan Knezek
0447a2c041
Implement fmtDuration using Formatter ( #8137 )
...
* Implement fmtDuration using Formatter
Deprecate Duration, duration
* fmtDuration: Fixed ns remainder
* fmtDuration: Fixed visibility; removed [Dd]uration
2021-03-07 15:00:15 +02:00
LemonBoy
72664df491
std: Deprecate the B and Bi format specifiers
...
Following #8007 and #8137 let's get rid of the last weird format.
2021-03-07 14:58:45 +02:00
LemonBoy
e47b754b28
std: Prevent null pointer deref in mem.len{,Z}
...
Closes #8140
2021-03-07 14:58:45 +02:00
Evan Haas
6d69a29d75
translate-c: Support compound assignment of pointer and signed int
...
This handles `ptr += idx` and `ptr -= idx` when `idx` is a
signed integer expression.
2021-03-07 14:54:04 +02:00
Evan Haas
874c63f89c
translate-c: translate align attribute for block scoped variables
2021-03-07 14:53:33 +02:00
Josh Wolfe
a7c0234eee
docgen --skip-code-tests
2021-03-07 14:52:52 +02:00
Vincent Rischmann
272ae0ca0d
fix parsing of assignment with 'inline for' and 'inline while'
2021-03-06 17:39:54 -08:00
Andrew Kelley
34cb5934dd
Merge pull request #7910 from Vexu/stage2-async
...
Stage2: astgen async stuff, implement var args functions
2021-03-06 13:35:48 -08:00
Veikka Tuominen
8c6e7fb2c7
stage2: implement var args
2021-03-06 15:55:29 +02:00
Veikka Tuominen
17e6e09285
stage2: astgen async
2021-03-06 15:01:25 +02:00
Meghan
9f722f43ac
std/special: init-exe,lib make import(std) its own decl ( #8160 )
...
std/special: init-exe,lib make import(std) its own decl
2021-03-05 19:13:05 -08:00
Isaac Freund
ef3adbdb36
zig fmt: fix lastToken() for container_decl_arg
2021-03-05 21:33:27 +01:00
xackus
eda1b53723
strip the leading zero from octal literals
2021-03-05 21:21:23 +01:00
xackus
eee43a65ae
add tests
2021-03-05 21:21:23 +01:00
xackus
b4ef6fa09d
fix test-translate-c
2021-03-05 21:04:27 +01:00
Maciej Walczak
5f53b77c2b
remove redundant cast
...
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2021-03-05 21:04:27 +01:00
xackus
679910ecec
translate-c: promote int literals to bigger types
2021-03-05 21:04:27 +01:00
Veikka Tuominen
9cd038d73a
std: fix memory leak in MultiArrayList
2021-03-05 10:52:40 -08:00
Evan Haas
291edafa1b
translate-c: enable pointer arithmetic with signed integer operand
...
Given a pointer operand `ptr` and a signed integer operand `idx`
`ptr + idx` and `idx + ptr` -> ptr + @bitCast(usize, @intCast(isize, idx))
`ptr - idx` -> ptr - @bitCast(usize, @intCast(isize, idx))
Thanks @LemonBoy for pointing out that we can take advantage of wraparound
to dramatically simplify the code.
2021-03-05 14:16:40 +02:00
cryptocode
02737d535a
Reject bare +/- input when parsing floats
2021-03-05 13:11:20 +01:00
Andrew Kelley
434fce2146
zig fmt: recovery: missing while rbrace
...
Previously, this test case resulted in zig fmt entering an endless loop.
2021-03-04 20:54:09 -07:00
Andrew Kelley
041212a41c
zig cc: fix handling of -MM flag
...
Clang docs say:
> Like -MMD, but also implies -E and writes to stdout by default.
Previously, Zig handled this option by forwarding it directly to Clang,
and disabling depfiles. However this did not adhere to Clang's documented
behavior of these flags.
Now, in addition to being forwarded directly to Clang, `-MM` also
sets c_out_mode = .preprocessor, just like `-E`.
Another issue I noticed is that Zig did not recognize the aliases for
-MG, -MM, or -MMD. The aliases are now recognized.
2021-03-04 18:14:00 -07:00
Andrew Kelley
98b24aa47f
stage2: support environment variables for verbose options
...
The presence of ZIG_VERBOSE_LINK now enables --verbose-link.
The presence of ZIG_VERBOSE_CC now enables --verbose-cc.
These are useful when debugging usage of `zig cc` which does not have
CLI flags for these options, since they are not valid C compiler flags.
2021-03-04 17:37:53 -07:00
Andrew Kelley
ffb2568a9f
Merge pull request #7763 from kivikakk/zig-elf-parse
...
std.elf: expose parsing decoupled from std.fs.File
2021-03-04 11:56:31 -08:00
daurnimator
34ca6b7b44
std: add io.Writer.writeStruct
...
We have readStruct, add writeStruct for symmetry
2021-03-03 22:45:45 +01:00
Andrew Kelley
fcd25065ef
stage2: fix merge conflict with previous commit
...
The compiler failed to build from source; this fixes it.
2021-03-03 13:18:13 -07:00
jacob gw
2ebeb0dbf3
stage2: remove error number from error set map
...
This saves memory since it is already stored in module
as well as allowing for better threading.
Part 2 of what is outlined in #8079 .
2021-03-03 11:49:54 -08:00
Veikka Tuominen
904f774563
translate-c: fix c tokenizer giving invalid tokens
2021-03-03 11:33:14 -08:00
Josh Wolfe
7fbe9e7d60
update docs and grammar to allow CRLF line endings ( #8063 )
2021-03-03 14:30:46 -05:00
Andrew Kelley
5bd9a64516
Merge pull request #7778 from g-w1/stage2-merge-errors
...
stage2: error set merging with tests
2021-03-02 23:19:22 -08:00
Andrew Kelley
3995783207
astgen: fix crash looking for wrong token in error sets
...
Fixes a regression from #7920 .
2021-03-03 00:17:36 -07:00
Veikka Tuominen
ad3f7e0cf0
fix small inconsistency
2021-03-02 23:53:10 -07:00
g-w1
8b100792eb
stage2: error set merging with tests
...
I had to come up with creative tests because we don't have error set type equality yet.
2021-03-02 23:53:05 -07:00
Andrew Kelley
4b57fb5f23
Merge pull request #7741 from FireFox317/optionals-llvm
...
stage2: add support for optionals in the LLVM backend
2021-03-02 21:03:50 -08:00
Andrew Kelley
713f113822
stage2: improve orelse implementation
...
* Now it supports being an lvalue (see additional lines in the test
case).
* Properly handles a pointer result location (see additional lines in
the test case that assign the result of the orelse to a variable
rather than a const).
* Properly sets the result location type when possible, so that type
inference of an `orelse` operand expression knows its result type.
2021-03-02 21:59:23 -07:00
Timon Kruiper
6aa1ea9c59
stage2: fixup some formatting errors ({x} -> {s})
...
These were missed in cd7c870bd81391dd97c5c75eb3910382ba7280a1
2021-03-02 19:02:55 -07:00
Timon Kruiper
ed6757ece6
stage2: add a test for for loops in LLVM backend
2021-03-02 19:02:55 -07:00