4776 Commits

Author SHA1 Message Date
Veikka Tuominen
f281f3d10e Sema: improve behavior of comptime_int backed enums 2022-09-02 17:57:11 +03:00
Veikka Tuominen
a9cdacff95 Sema: add error for enum tag value overflow
Closes #12291
2022-09-02 17:57:11 +03:00
Veikka Tuominen
7a51e0befe Sema: fix noalias coercion error message
Closes #11769
2022-09-02 17:57:11 +03:00
Veikka Tuominen
1c4c68e6ba AstGen: use reachableExpr for try operand
Closes #12248
2022-09-02 17:57:10 +03:00
Veikka Tuominen
db54cd247d Sema: do not emit dbg_inline_end after NoReturn
Closes #12698
2022-09-02 17:57:10 +03:00
Veikka Tuominen
8b58dab78b Sema: resolve lazy value before intToFloat
Closes #12698
2022-09-02 17:57:10 +03:00
Veikka Tuominen
7a8d9af4a9 stage2 llvm: correct handling of zero-bit types in unionFieldPtr
Pointers to zero-bit types are not zero-bit types so the function should
return something.
Closes #12716
2022-09-02 17:57:10 +03:00
Veikka Tuominen
4462d08224 stage2 llvm: fix passing packed structs to callconv(.C) functions
Closes #12704
2022-09-02 17:57:10 +03:00
Veikka Tuominen
2cd3989cb3 Sema: add more validation to coerceVarArgParam
Closes #12706
2022-09-01 13:16:33 +03:00
Veikka Tuominen
26e9839132 disable test for non-llvm backends
Follow up to fdb88708527742e450e4c566024d9d50ce61dd8d
2022-08-31 16:46:51 +03:00
Evan Haas
fdb8870852 translate-c: promote large integer macros to unsigned long long if necessary
Closes #10793

Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-08-31 15:52:53 +03:00
Luuk de Gram
4ba0ad295f
Merge pull request #12687 from Luukdegram/wasm-extern-globals
wasm-linker: implement non-function extern variables
2022-08-31 13:44:06 +02:00
Andrew Kelley
7377dce368 avoid exposing supportsTailCall in the standard library
This is problematic because in practice it depends on whether the
compiler backend supports it too, as evidenced by the TODO comment about
LLVM not supporting some architectures that in fact do support tail
calls.

Instead this logic is organized strategically in src/target.zig, part of
the internal compiler source code, and the behavior tests in question
duplicate some logic for deciding whether to proceed with the test.

The proper place to expose this flag is in `@import("builtin")` - the
generated source file - so that third party compilers can advertise
whether they support tail calls.
2022-08-30 12:50:15 -07:00
Veikka Tuominen
65d3723968 Sema: check that target supports tail calls 2022-08-30 12:22:07 -07:00
Veikka Tuominen
c558de6655 stage2 llvm: use tag value instead of field index in airUnionInit
Closes #12656
2022-08-30 12:22:07 -07:00
Veikka Tuominen
d3b4b2edf1 Sema: shift of comptime int with runtime value
Closes #12290
2022-08-30 12:22:07 -07:00
Veikka Tuominen
01d19a8d3c Sema: do not emit generic poison for non generic parameters
Closes #12679
2022-08-30 12:22:07 -07:00
Veikka Tuominen
67a44211f7 Sema: improve handling of always_tail call modifier
Closes #4301
Closes #5692
Closes #6281
Closes #10786
Closes #11149
Closes #11776
2022-08-30 12:22:07 -07:00
Luuk de Gram
8627858bbc
test/link: add test for extern resolution
Adds a linker tests to verify extern/undefined symbols
representing non-functions are being resolved correctly.
2022-08-30 18:32:08 +02:00
Jakub Konka
e57fbe8069 test-cases: fix compiler error locations for hello world with updates 2022-08-30 11:01:08 +02:00
Andrew Kelley
d2d42cf7ba
Merge pull request #12641 from Luukdegram/wasm-c-types
stage2: fix size of c_longdouble for Wasm target
2022-08-29 18:21:38 -04:00
Veikka Tuominen
a4b52ccd9f Sema: fix access of inactive union field when enum and union fields are in different order
Closes #12667
2022-08-29 13:45:37 -07:00
Luuk de Gram
1eb22e7ad6
wasm: skip unimplemented behavior test
Since now the size of a c_longdouble is correctly 16 bytes,
the test is no longer passing. It was previously accidentally passing
due to incorrect sizing and it not being larger than the size
of a f64.

disable long_double test for windows
2022-08-28 17:50:07 +02:00
Veikka Tuominen
15cc4514e0 Sema: add missing calls to resolveStructLayout
Closes #12645
2022-08-28 15:41:21 +03:00
Veikka Tuominen
e2dc77ab62 Sema: correct one possible value for tuples
Closes #12376
2022-08-28 15:41:21 +03:00
Veikka Tuominen
776caaf999 Sema: fix handling of non-standard int types in empty non-exhaustive enums
Closes #12649
2022-08-28 15:41:21 +03:00
Veikka Tuominen
6aead18ab3 add error tests for now correctly behaving cases
Closes #6377
2022-08-28 15:41:21 +03:00
Veikka Tuominen
1401890ed5 Sema: add error for switch on slice
Closes #12651
2022-08-28 15:41:21 +03:00
Veikka Tuominen
fc213e2d61 AstGen: add error for named function type
Closes #12660
2022-08-28 15:41:21 +03:00
antlilja
ae8d26a6a0 Sema: add error for non-comptime param in comptime func
Adds error for taking a non comptime parameter in a function returning a
comptime-only type but not when that type is dependent on a parameter.

Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-08-27 11:17:48 +03:00
David Gonzalez Martin
da95da438e Add behavior test coverage for nested packed struct field access
Closes #3091
2022-08-26 21:43:38 -04:00
Luuk de Gram
91dba79c48
wasm: fix abi size of c_longdouble
According to https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md
the size of c's long double is 16 bytes for Wasm, rather than 8 bytes
which was the value previously in the compiler. This ensures
we not only pass the correct value, but also creates the correct
function signature needed to pass the Wasm validator.

This also adds an additional test case in c_abi tests.
2022-08-26 21:01:05 +02:00
Jakub Konka
02e6960966 coff: do not pull in std.log into coff.zig definitions 2022-08-26 16:14:44 +02:00
martinhath
3fa5415253
Sema: ensure resolveTypeFields is called for optional and error union types
We call `sema.resolveTypeFields` in order to get the fields of structs
and unions inserted into their data structures. If it isn't called, it
can happen that the fields of a type is queried before those fields are
inserted into (for instance) `Module.Union.fields`, which would result in
a wrong 'no field named' error.

Fixes: #12486
2022-08-26 11:37:17 +03:00
Evan Haas
bcaa9df5b4 translate-c: Don't add self-defined macros to global name table
A self-defined macro is one of the form `#define FOO FOO`

Those types of macros have never been translated; this change will cause
any macros which refer to them to be translated as `@compileError` instead
of referring to a non-existent identifier.

Closes #12471
2022-08-26 11:24:57 +03:00
David Gonzalez Martin
d6bb9af18d stage2: Reference to void constants
Closes #7567
2022-08-26 00:00:22 -04:00
Andrew Kelley
d2ad8afff4 LLVM: fix missing alignment on wrapping instructions
Previously, when lowering AIR instructions `wrap_errunion_payload`,
`wrap_errunion_err`, and `wrap_optional`, the LLVM backend would create
an alloca instruction to store the result, but did not set the alignment
on it. This caused UB which went undetected for a long time until we
started enabling the stack protector.

Closes #12594
Unblocks #12508
Inspires #12634

Tests passed locally:
 * test-behavior
 * test-cases
2022-08-25 16:15:48 -07:00
Jakub Konka
ba346ecfe9 run_translated_c: disable failing test on Windows
ziglang/zig#12630
2022-08-25 17:01:49 +02:00
Veikka Tuominen
4405188cf7 Sema: ignore comptime params in partial func type check
This fixes a bug exposed by cd1833044ab7505bc101c85f59889bd3ea3fac80
where a function type would be converted to generic_poison even after
being instantiated due to containing comptime only types.

This could also be fixed by just checking `is_generic_instantiation`
but this way also provides better type names.

Closes #12625
2022-08-25 16:29:23 +03:00
Andrew Kelley
7453f56e67 stage2: explicitly tagged enums no longer have one possible value
Previously, Zig had inconsistent semantics for an enum like this:

`enum(u8){zero = 0}`

Although in theory this can only hold one possible value, the tag
`zero`, Zig no longer will treat the type this way. It will do loads and
stores, as if the type has runtime bits.

Closes #12619

Tests passed locally:
 * test-behavior
 * test-cases
2022-08-24 22:20:31 -07:00
Andrew Kelley
7a881435ed
Merge pull request #12623 from Vexu/stage2-fixes
Stage2 fixes
2022-08-24 15:59:46 -04:00
Andrew Kelley
2a96209c40
Merge pull request #12574 from Vexu/remove-bit-op-type-param
stage2+stage1: remove type parameter from bit builtins
2022-08-24 15:57:44 -04:00
Andrew Kelley
80b8294bcc test-stack-traces: restore test coverage
reverts 1ce71c86bff351a4ade4321e188a13c9d3cff8b4
2022-08-24 12:57:31 -07:00
Veikka Tuominen
69a3c4e279 Sema: correctly reset inst_map for analyzeInlineCallArg
Closes #12622
2022-08-24 21:31:02 +03:00
Veikka Tuominen
f49dff64c6 Sema: check one possible value earlier in zirValidateArrayInit
Closes #12566
2022-08-24 21:31:02 +03:00
Veikka Tuominen
1d0b729f28 Sema: fix crash on slice of non-array type
Closes #12621
2022-08-24 21:31:02 +03:00
Veikka Tuominen
cd1833044a Sema: do not construct nested partial function types
Closes #12616
2022-08-24 21:31:02 +03:00
Jakub Konka
abfe21a4fe skip failing f80 behavior tests on Windows 2022-08-23 22:43:19 +02:00
Andrew Kelley
1ce71c86bf std.debug: implement support for DWARFv5 2022-08-23 00:28:45 -07:00
Andrew Kelley
9043e665a5 add behavior test for copying array of vectors
closes #12026
2022-08-22 18:37:42 -07:00