6078 Commits

Author SHA1 Message Date
Andrew Kelley
a51ff3a903 AstGen: remove unused scope parameter from rvalue 2021-06-21 17:03:03 -07:00
Andrew Kelley
b9b0e53197 AstGen: remove unused parameter 2021-06-21 17:03:03 -07:00
Andrew Kelley
7a595f2e6c remove unused parameters 2021-06-21 17:03:03 -07:00
Andrew Kelley
a04a98ff3e AstGen: while loop continue expr captures in scope
Before this, the continue expression of a while loop did not have the
capture variable in it, making it incorrectly emit a compile error for
not using the capture, even if it was referenced.
2021-06-21 17:03:03 -07:00
Andrew Kelley
4f900e68d3 AstGen: fix crash in debug printing ZIR field types
The printing code did not properly set the parent Decl node field, so
the source location calculations were wrong.

closes #8825
2021-06-21 17:03:03 -07:00
Andrew Kelley
f4a9e0530a AstGen: convert a TODO comment to an issue
See #363
2021-06-21 17:03:03 -07:00
Jacob G-W
9fffffb07b fix code broken from previous commit 2021-06-21 17:03:03 -07:00
Jacob G-W
b83b3883ba stage2 AstGen: fix lots of bugs and catch more errors
Gotta catch 'em all!

also simplify identifier( logic
2021-06-21 17:03:03 -07:00
Jacob G-W
641ecc260f std, src, doc, test: remove unused variables 2021-06-21 17:03:03 -07:00
Jacob G-W
d34a1ccb0e stage2: fix TODO in @export to look for runtime-vars
Also rename LocalPtr.is_comptime to LocalPtr.maybe_comptime as
it is a better name, as it could be runtime, but is not
always runtime.
2021-06-21 17:03:03 -07:00
Jacob G-W
f8b8f50b63 stage2 astgen: make asm outputs count as referencing vars
This is temporary and putting this as a seperate commit
so that it can easily be reverted as andrewrk suggested.
2021-06-21 17:03:03 -07:00
Jacob G-W
7d4c8d7054 stage2: make loop vars be comptime if they are inline
thanks @Vexu
2021-06-21 17:03:02 -07:00
Jacob G-W
2092481265 stage2 astgen: fix bug in struct init where type not refed 2021-06-21 17:03:02 -07:00
Jacob G-W
75f7a8913e stage2 astgen: find unused vars 2021-06-21 17:03:02 -07:00
g-w1
e13a182990
stage2 Sema: implement @intToPtr (#9144)
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2021-06-21 18:47:34 +03:00
Jacob G-W
a95fdb0635 stage2: simplify codegen for errorToInt and intToError
We can just use bitcast instead of error_to_int, int_to_error since
errorToInt and intToError do not actually do anything, just change types.
This allows us to remove 2 air ops that were the exact same as bitcast
2021-06-21 18:45:28 +03:00
Dmitry Matveyev
00982f75e9
stage2: Remove special double ampersand parsing case (#9114)
* Remove parser error on double ampersand

* Add failing test for double ampersand case

* Add error when encountering double ampersand in AstGen

"Bit and" operator should not make sense when one of its operands
is an address.

* Check that 2 ampersands are adjacent to each other in source string

* Remove cases of unused variables in tests
2021-06-20 21:04:14 +03:00
Veikka Tuominen
6de45c826c
Merge pull request #8636 from jmc-88/issue-3779
Change builtins to return a string literal
2021-06-20 20:27:34 +03:00
Jacob G-W
1071ca6129 fmt: make --ast-check work with --stdin 2021-06-20 19:56:14 +03:00
pithlessly
8a7730672f stage2 sema: change impl of @setCold to use zirSetCold (typo?) 2021-06-20 19:50:06 +03:00
Michael Dusan
e006281d79 macho: LC_RPATH: reserve byte for null-terminator 2021-06-18 15:22:10 +02:00
Andrew Kelley
6ce8440987 AstGen: properly generate errdefer expressions when returning
`return` statements use a new function `nodeMayEvalToError` which does
some basic checks on the AST node to return never, always, or maybe.

Depending on this result, AstGen skips the errdefers, always includes
the errdefers, or emits a conditional branch to check whether the return
value is an error that Sema will have to evaluate.

Closes #8821
Unblocks #9047
2021-06-17 22:44:17 -07:00
LemonBoy
ccb6e1627e stage1: Store the specified code model in the LLVM module
This is needed for LTO builds to pick up the correct module.

Closes #9132
2021-06-18 08:29:23 +03:00
Andrew Kelley
b9e78593bb
Merge pull request #9117 from greenfork/unify-compiler-error-printing
stage2: Unify compiler error printing
2021-06-17 23:25:05 -04:00
Michael Dusan
9ff15e24f8 fix oob during riscv64 feature processing 2021-06-17 23:15:47 -04:00
Vincent Rischmann
6f0cfdb820 zig cc: improve linker args parsing
Handle linker args joined with a = like -Wl,-rpath=foo

Update existing args --major-os-version, --minor-os-version,
--major-subsystem-version and --minor-subsytem-version to work with the
new parsing.

Also handle -Wl,--script in addition to -Wl,-T
2021-06-17 17:32:17 -04:00
Andrew Kelley
e18ef71d98 stage1: fix zig0 help message
closes #9140
2021-06-17 13:39:30 -07:00
Daniele Cocca
171102ea7c errorName: return a null-terminated slice 2021-06-16 22:02:52 +01:00
Daniele Cocca
00e1c0082c tagName: return a null-terminated slice 2021-06-16 22:02:42 +01:00
Daniele Cocca
1184b1d560 Add create_sentineled_str_lit 2021-06-16 21:56:39 +01:00
Daniele Cocca
2242d3c3aa {create,init}_const_slice: accept custom sentinel 2021-06-16 21:56:39 +01:00
Michael Dusan
79a4da14ad netbsd: add args to limit number of PT_LOAD segs
NetBSD expects 2 PT_LOAD segments in a shared object, otherwise
ld.elf_so fails to load, emitting a general "not found" error.

Workaround issue by adding args `--no-rosegment` and `-znorelro`.

see #9109
2021-06-16 14:46:25 -04:00
joachimschmidt557
76584ad0c6 stage2 Sema: add type resolving from comptime_float to float 2021-06-15 17:14:09 -04:00
Andrew Kelley
90c73d8768 fix RISC-V assembly CPU features
Previously, Zig did not properly communicate the target CPU features for
RISC-V to clang assembler, because Clang has a different way to pass CPU
features for C code and for assembly code. This commit makes Zig pass a
RISC-V -march flag in order to communicate CPU features to Clang when
compiling assembly files.
2021-06-15 17:12:22 -04:00
Andrew Kelley
515d6430c0 AstGen: support @export with field access
The Zig language specification will support identifiers and field access
in order to refer to which declaration to export with `@export`.

This commit implements the change in AstGen and updates the language
reference.
2021-06-15 14:08:57 -07:00
Jakub Konka
0f4173c5d8
Merge pull request #9122 from ziglang/zld-proxies
zld: clean up stubs resolution, error messages and use ld64 defaults for system libs resolution
2021-06-15 14:55:12 +02:00
Veikka Tuominen
c54af9774d translate-c: move utility functions to a separate namespace 2021-06-15 12:14:04 +02:00
Jakub Konka
6362b82497 zld: map coalesced sections and handle undefines 2021-06-15 12:14:04 +02:00
Jakub Konka
cf26f8c19b zld: handle __eh_frame section 2021-06-15 12:14:04 +02:00
Jakub Konka
15ff0db794 zld: handle __gcc_except_tab section 2021-06-15 12:14:03 +02:00
Jakub Konka
96d3c4f54f zld: clean up parsing section by type and attrs 2021-06-15 12:14:03 +02:00
Andrew Kelley
c434a9a573 CLI: rename --override-lib-dir to --zig-lib-dir
This breaking change disambiguates between overriding the lib dir when
performing an installation with the Zig Build System, and overriding the
lib dir that the Zig installation itself uses.
2021-06-15 12:14:03 +02:00
xackus
e3fa18242b translate-c: remove old code i forgot in last pr 2021-06-15 12:14:03 +02:00
Jakub Konka
8204763328 zld: use ld64 defaults for searching system libs
By default, `ld64` uses `-search_paths_first` which firstly tries
to find a dylib, followed by an archive in each directory.
2021-06-15 11:52:03 +02:00
Jakub Konka
2034ca82b4 zld: stubs can also be part of unsigned relocs 2021-06-15 11:51:59 +02:00
Veikka Tuominen
97946e2a41
Merge pull request #9091 from Vexu/translate-c
Translate-c: move utility functions to a separate namespace
2021-06-15 07:59:46 +03:00
Takeshi Yoneda
0063f642d1 fix comments.
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2021-06-15 11:50:13 +09:00
Takeshi Yoneda
dc7d354ee4 Add a missing comment.
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2021-06-15 09:32:48 +09:00
Takeshi Yoneda
1795472eb7 cleanup, and disable threading completely.
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2021-06-15 09:28:19 +09:00
Jakub Konka
d2427e6490
Merge pull request #9118 from ziglang/zld-eh-frame
zld: handle __gcc_except_tab and __eh_frame, and streamline section mapping
2021-06-15 00:15:18 +02:00