27037 Commits

Author SHA1 Message Date
expikr
27353bb936
langref: emphasize the use of dereferencing string literals 2023-11-21 13:54:13 +02:00
Ryan Liptak
15a6b27957 std.unicode: Disable utf8 -> utf16 ASCII fast path on mips
Fixes a compile error when the target is mips, since std.simd.interlace does not work correctly on mips and raises a compile error if it is used.
2023-11-21 13:51:03 +02:00
Bogdan Romanyuk
583afd6f0c
value: update isDeclRef for anonymous declarations 2023-11-21 13:21:32 +02:00
Maciej 'vesim' Kuliński
f64f3423e4 std.tar: trim also spaces from the beginning of file size 2023-11-21 00:55:22 -05:00
Tw
8ca4a5240e linux/bpf: update helper definitions
Signed-off-by: Tw <tw19881113@gmail.com>
2023-11-19 19:01:18 +02:00
Matthew Lugg
6b1a823b2b
Merge pull request #18017 from mlugg/var-never-mutated
compiler: add error for unnecessary use of 'var'
2023-11-19 16:19:06 +00:00
mlugg
9cf6c1ad11
behavior: work around LLVM bug
See #18034
2023-11-19 11:11:50 +00:00
mlugg
766306793a
std: correct faulty test 2023-11-19 11:11:50 +00:00
mlugg
ff838d8631
translate-c: work around unnecessary uses of 'var' 2023-11-19 11:11:50 +00:00
mlugg
3c585730f2
AstGen: preserve result type in comptime block 2023-11-19 11:11:50 +00:00
mlugg
38b373bf0b
cases: add compile error test for never-mutated local variable 2023-11-19 11:11:50 +00:00
mlugg
b355893438
compiler: correct unnecessary uses of 'var' 2023-11-19 11:11:49 +00:00
mlugg
172c2797bd
link: fix MachO boundary symbol resolution 2023-11-19 11:11:49 +00:00
mlugg
ed4bab66d8
langref: correct unnecessary uses of 'var' 2023-11-19 11:11:49 +00:00
mlugg
026a8278f8
tools: correct unnecessary uses of 'var' 2023-11-19 09:57:04 +00:00
mlugg
d82d327de2
test: update remaining code to fix 'var is never mutated' errors 2023-11-19 09:57:04 +00:00
mlugg
9c16b2370d
test: update behavior to silence 'var is never mutated' errors 2023-11-19 09:57:03 +00:00
mlugg
21fa187abc
test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
mlugg
2c1acb6180
test: update translate-c tests to match new discard format 2023-11-19 09:55:07 +00:00
mlugg
51595d6b75
lib: correct unnecessary uses of 'var' 2023-11-19 09:55:07 +00:00
mlugg
baabc6013e
compiler: add error for unnecessary use of 'var'
When a local variable is never used as an lvalue, we can determine that
`const` would be sufficient for this variable, so emit an error in this
case. More sophisticated checking is unfortunately not possible with
Zig's current analysis model, since whether an lvalue is actually
mutated depends on semantic analysis, in which some code paths may not
be analyzed, so attempting to determine this would result in false
positive compile errors.

It's worth noting that an unfortunate consequence of this is that any
field call `a.b()` will allow `a` to be `var`, even if `b` does not take
a pointer as its first parameter - this is again a necessary compromise
because the parameter type is not known until semantic analysis.

Also update `translate-c` to not trigger these errors. This is done by
replacing the `_ = @TypeOf(x)` emitted with `_ = &x` - the reference
there means that the local is permitted to be `var`. A similar strategy
will be used to prevent compile errors in the behavior tests, where we
sometimes want to force a value to be runtime-known.

Resolves: #224
2023-11-19 09:55:07 +00:00
dweiller
325e0f5f0e test: check compile errors when compilation has no errors 2023-11-19 00:12:43 +02:00
Eric Joldasov
4e212f1650 std.enums: allow non-exhaustive enums in EnumIndexer and make count comptime_int instead of usize
Seems like this restriction was actual when Ziglang had extern enums,
but now it's not neccessary and can be lifted. It was present since
original PR which introduced std.enums, https://www.github.com/ziglang/zig/pull/8171.
See also: https://ziggit.dev/t/catching-invalid-enum-value-errors/2206/11

* Make `count` comptime_int instead of usize

With previous type, creating EnumIndexer for enum(usize) and enum(isize)
would cause compile error since `count` could not store maxInt(usize) + 1.
Now it can store it and reflects len field from std.builtin.Type.Array
(most common use case of count field inside std.enums functions is creating arrays).

Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-11-18 16:25:55 +02:00
Curtis Tate Wilkinson
7b99189f19
Add struct declaration location to empty root struct field member error 2023-11-18 12:03:10 +00:00
Lucas Santos
d44f822821 Faster implementation of intToEnum. 2023-11-18 11:24:13 +02:00
Jakub Konka
91329ce944 std.macho: fix LoadCommandIterator to work with underaligned data 2023-11-17 20:49:32 +01:00
Veikka Tuominen
5f86414019
Merge pull request #18006 from Vexu/aro-translate-c
Sync Aro dependency & translate-c progress
2023-11-17 09:02:11 +02:00
Veikka Tuominen
acebf05be9 aro-translate-c: update to upstream changes 2023-11-17 09:01:25 +02:00
David
673a1efa22
Sema: include sentinel in type of pointer-to-array ptr field
Resolves: #18007
2023-11-16 16:08:30 +00:00
Jakub Konka
b173088089
Merge pull request #18015 from ziglang/elf-tests
More ELF tests
2023-11-16 16:11:24 +01:00
David
941090d94f
Move duplicate field detection for struct init expressions into AstGen
Partially addresses #17916.
2023-11-16 14:38:16 +00:00
Jakub Konka
85c0485fd9 elf: test -r mode does not create unneeded .eh_frame section 2023-11-16 10:54:39 +01:00
Jakub Konka
f6bf3353b1 elf: test -r mode with archive on the linker line 2023-11-16 10:51:21 +01:00
Krzysztof Wolicki
acf9de376d
Sema: Add error for non-power of 2 field alignment when reifying Unions, Structs, Pointers 2023-11-16 10:19:54 +02:00
Jakub Konka
359842f8d5
Merge pull request #18010 from ziglang/elf-symtab-fixes
elf: actually write synthetic globals to output symtab and other misc fixes
2023-11-16 01:18:22 +01:00
Jakub Konka
6e4d7362ce elf: fix emitting start/stop synthetic symbols 2023-11-15 19:20:03 +01:00
Jakub Konka
d771c0a7a1 elf: create .got.plt unconditionally 2023-11-15 19:07:09 +01:00
Jakub Konka
6f3bbd5eaa elf: we were writing too many symbols in the symtab 2023-11-15 19:00:13 +01:00
Jakub Konka
760ce69734 elf: actually write synthetic globals to output symtab 2023-11-15 15:07:09 +01:00
Veikka Tuominen
145ddb8104 sync Aro dependency
ref: 0c8c251e336148413ceca7b345c0b6f7255b009b
2023-11-15 11:26:49 +02:00
Veikka Tuominen
c327489d21 aro-translate-c: start work on translating statements 2023-11-15 10:51:26 +02:00
Veikka Tuominen
a15feeb694 aro-translate-c: translate function types 2023-11-15 10:50:45 +02:00
Jacob Young
0c6cb8d8c8 x86_64: actually track state during @divFloor of i128
Closes #17998
2023-11-14 22:50:05 -05:00
Jakub Konka
6fd1c64f23
Merge pull request #17978 from ziglang/elf-x86-tls
x86_64+elf: TLS support
2023-11-14 22:09:15 +01:00
Jakub Konka
ea3f1d27e0 std: disable failing test 2023-11-14 16:51:38 +01:00
Jakub Konka
4adb8f786f elf: do not pointlessly store zerofill data for TLVs 2023-11-14 16:51:25 +01:00
Andrew Kelley
f8b38a174f adjust building from source without LLVM process
The idea here is that the zig2 executable is perhaps the more useful
deliverable until we implement our own optimization passes. This will
allow system packages to provide Zig, and use it to compile Zig
projects, all without LLVM!
2023-11-14 02:17:51 -05:00
Jakub Konka
e883907431 coff: revert .rdata to be read-only again 2023-11-13 23:23:06 +01:00
Jakub Konka
028bfdbca3 coff: mark dirty any reloc target at [addr,..) inclusive 2023-11-13 23:07:21 +01:00
Michael Dusan
569182dbb2 compilation: forbid PIE for dynamic libraries
but allow for { .exe, .o, .a }.

closes #17928
2023-11-13 20:30:57 +01:00