aboutsummaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2023-09-23spirv: fix blocks that return no valueRobin Voetter
2023-09-23spirv: enable passing testsRobin Voetter
2023-09-23spirv: constant elem ptrRobin Voetter
2023-09-23spirv: air wrap_errunion_payloadRobin Voetter
2023-09-23spirv: generate module initializerRobin Voetter
2023-09-23spirv: air array_elem_val using hackRobin Voetter
SPIR-V doesn't support true element indexing, so we probably need to switch over to isByRef like in llvm for this to work properly. Currently a temporary is used, which at least seems to work.
2023-09-23spirv: air array_to_sliceRobin Voetter
2023-09-23spirv: air sub_with_overflowRobin Voetter
2023-09-23spirv: air union_initRobin Voetter
2023-09-23spirv: air set_union_tag + improve load()/store()Robin Voetter
2023-09-23spirv: air struct_field_ptr for unionsRobin Voetter
2023-09-23spirv: air struct_field_val for unionsRobin Voetter
2023-09-23spirv: disable failing testsRobin Voetter
2023-09-23Sema: refactor detection of comptime-known constsmlugg
This was previously implemented by analyzing the AIR prior to the ZIR `make_ptr_const` instruction. This solution was highly delicate, and in particular broke down whenever there was a second `alloc` between the `store` and `alloc` instructions, which is especially common in destructure statements. Sema now uses a different strategy to detect whether a `const` is comptime-known. When the `alloc` is created, Sema begins tracking all pointers and stores which refer to that allocation in temporary local state. If any store is not comptime-known or has a higher runtime index than the allocation, the allocation is marked as being runtime-known. When we reach the `make_ptr_const` instruction, if the allocation is not marked as runtime-known, it must be comptime-known. Sema will use the set of `store` instructions to re-initialize the value in comptime memory. We optimize for the common case of a single `store` instruction by not creating a comptime alloc in this case, instead directly plucking the result value from the instruction. Resolves: #16083
2023-09-22AstGen: fix @export with undeclared identifier crashingWooster
This required a third `if (found_already == null)` in another place in AstGen.zig for this special case of `@export`. Fixes #17188
2023-09-22Merge pull request #17069 from squeek502/resinatorAndrew Kelley
Add a `.rc` -> `.res` compiler to the Zig compiler
2023-09-21InternPool,Sema,type,llvm: alignment fixesmlugg
This changeset fixes the handling of alignment in several places. The new rules are: * `@alignOf(T)` where `T` is a runtime zero-bit type is at least 1, maybe greater. * Zero-bit fields in `extern` structs *do* force alignment, potentially offsetting following fields. * Zero-bit fields *do* have addresses within structs which can be observed and are consistent with `@offsetOf`. These are not necessarily all implemented correctly yet (see disabled test), but this commit fixes all regressions compared to master, and makes one new test pass.
2023-09-19disable failing test: standalone.c_compiler on aarch64-windowsAndrew Kelley
Regressed by LLVM 17 Tracked by #16965
2023-09-19c_compiler standalone test: use more descriptive exe namesAndrew Kelley
2023-09-19langref: disable var args example on aarch64-windowsAndrew Kelley
See tracking issues #14096 and #16961. Also, any time a test is skipped it should link to the open bug report for it.
2023-09-19disable failing test: standalone.load_dynamic_library on aarch64-windowsAndrew Kelley
Regressed by LLVM 17 Tracked by #16960
2023-09-19disable failing test: standalone.shared_library on aarch64-windowsAndrew Kelley
Regressed by LLVM 17 Tracked by #16959
2023-09-19skip all mips tests due to LLVM 17 regressionsAndrew Kelley
Tracked by #16846
2023-09-19re-enable passing behavior testAndrew Kelley
See #16797 - it was fixed in the most recent LLVM 17 release candidate.
2023-09-19disable failing wasm linking testsAndrew Kelley
These started failing after the LLVM 17 upgrade. See tracking issues #16937 and #16938
2023-09-19disable failing mips tests due to LLVM 17 regressionsAndrew Kelley
tracked by #16846
2023-09-19behavior: disable another test regressed by LLVM 17 for mipsJacob Young
Tracked by #16846
2023-09-19compiler_rt: fix arm hard-float f16 abiJacob Young
Closes #16848
2023-09-19compiler_rt: fix fp sub being optimized to call itselfJacob Young
Closes #16844 Reduces #16846
2023-09-19disable behavior tests regressed by LLVM 17Andrew Kelley
See #16844 See #16845 See #16846 See #16848
2023-09-19behavior: disable test that regressed with LLVM 17Jacob Young
Tracking issue #16797
2023-09-19write function types consistently with a space before `fn` keywordr00ster91
Currently, the compiler (like @typeName) writes it `fn(...) Type` but zig fmt writes it `fn (...) Type` (notice the space after `fn`). This inconsistency is now resolved and function types are consistently written the zig fmt way. Before this there were more `fn (...) Type` occurrences than `fn(...) Type` already.
2023-09-19x86 backend: don't read bogus safety flagAndrew Kelley
Safety is not a global flag that should be enabled or disabled for all stores - it's lowered by the frontend directly into AIR instruction semantics. The flag for this is communicated via the `store` vs `store_safe` AIR instructions, and whether to write 0xaa bytes or not should be decided in `airStore` and passed down via function parameters. This commit is a step backwards since it removes functionality but it aims our feet towards a better mountain to climb.
2023-09-18translate-c: Struct fields default to zero valueJay Petacat
C99 introduced designated initializers for structs. Omitted fields are implicitly initialized to zero. Some C APIs are designed with this in mind. Defaulting to zero values for translated struct fields permits Zig code to comfortably use such an API. Closes #8165
2023-09-18translate-c: prevent variable names conflicting with type namesmlugg
This introduces the concept of a "weak global name" into translate-c. translate-c consists of two passes. The first is important, because it discovers all global names, which are used to prevent naming conflicts: whenever we see an identifier in the second pass, we can mangle it if it conflicts with any global or any other in-scope identifier. Unfortunately, this is a bit tricky for structs, unions, and enums. In C, these types are not represented by normal identifers, but by separate tags - `struct foo` does not prevent an unrelated identifier `foo` existing. In general, we want to translate type names to user-friendly ones such as `struct_foo` and `foo` where possible, but we can't guarantee such names will not conflict with real variable names. This is where weak global names come in. In the initial pass, when a global type declaration is seen, `struct_foo` and `foo` are both added as weak global names. This essentially means that we will use these names for the type *if possible*, but if there is another global with the same name, we will mangle the type name instead. Then, when actually translating the declaration, we check whether there's a "true" global with a conflicting name, in which case we mangle our name. If the user-friendly alias `foo` conflicts, we do not attempt to mangle it: we just don't emit it, because a mangled alias isn't particularly helpful.
2023-09-18std.zig.c_translation.zig: fix L suffix with sized intsBanacial
Closes #15066
2023-09-17Fix rc preprocessing when using the MinGW includes and targeting the GNU abiRyan Liptak
Also update the standalone test so that this failure would have been detected on any host system.
2023-09-17translate-c: do not translate macros which use arguments as ↵mlugg
struct/union/enum names Consider this C macro: ```c #define FOO(x) struct x ``` Previously, translate-c did not detect that the `x` in the body referred to the argument, so wrongly translated this code as using the nonexistent `struct_x`. Since undefined identifiers are noticed in AstGen, this prevents the translated file from being usable at all. translate-c now instead detects this case and emits an appropriate compile error in the macro's place.
2023-09-17AstGen: allow closure over known-runtime values within @TypeOfmlugg
AstGen emits an error when a closure over a known-runtime value crosses a namespace boundary. This usually makes sense: however, this usage is actually valid if the capture is within a `@TypeOf` operand. Sema already has a special case to allow such closure within `@TypeOf` when AstGen could not determine a value to be runtime-known. This commit simply introduces analagous logic to AstGen to allow `var`s to cross namespace boundaries within `@TypeOf`.
2023-09-17Add a standalone test for Windows resource file compilationRyan Liptak
2023-09-17Merge pull request #16929 from truemedian/more-httpAndrew Kelley
std.http: handle Expect: 100-continue, improve redirect logic, add Client.fetch for simple requests
2023-09-15Sema: mark pointers to inline functions as comptime-onlymlugg
This is supposed to be the case, similar to how pointers to generic functions are comptime-only (several pieces of logic already assumed this). These types being considered runtime was causing `dbg_var_val` AIR instructions to be wrongly emitted for such values, causing codegen backends to create a runtime reference to the inline function, which (at least on the LLVM backend) triggers an error. Resolves: #38
2023-09-15compiler: implement destructuring syntaxmlugg
This change implements the following syntax into the compiler: ```zig const x: u32, var y, foo.bar = .{ 1, 2, 3 }; ``` A destructure expression may only appear within a block (i.e. not at comtainer scope). The LHS consists of a sequence of comma-separated var decls and/or lvalue expressions. The RHS is a normal expression. A new result location type, `destructure`, is used, which contains result pointers for each component of the destructure. This means that when the RHS is a more complicated expression, peer type resolution is not used: each result value is individually destructured and written to the result pointers. RLS is always used for destructure expressions, meaning every `const` on the LHS of such an expression creates a true stack allocation. Aside from anonymous array literals, Sema is capable of destructuring the following types: * Tuples * Arrays * Vectors A destructure may be prefixed with the `comptime` keyword, in which case the entire destructure is evaluated at comptime: this means all `var`s in the LHS are `comptime var`s, every lvalue expression is evaluated at comptime, and the RHS is evaluated at comptime. If every LHS is a `const`, this is not allowed: as with single declarations, the user should instead mark the RHS as `comptime`. There are a few subtleties in the grammar changes here. For one thing, if every LHS is an lvalue expression (rather than a var decl), a destructure is considered an expression. This makes, for instance, `if (cond) x, y = .{ 1, 2 };` valid Zig code. A destructure is allowed in almost every context where a standard assignment expression is permitted. The exception is `switch` prongs, which cannot be destructures as the comma is ambiguous with the end of the prong. A follow-up commit will begin utilizing this syntax in the Zig compiler. Resolves: #498
2023-09-15AstGen: do not forward result pointers through @asmlugg
The `coerce_result_ptr` instruction is highly problematic and leads to unintentional memory reinterpretation in some cases. It is more correct to simply not forward result pointers through this builtin. `coerce_result_ptr` is still used for struct and array initializations, where it can still cause issues. Eliminating this usage will be a future change. Resolves: #16991
2023-09-11Merge pull request #17081 from Techatrix/wasm-float-opJakub Konka
wasm: implement more float operations on f80 and f128
2023-09-10wasm: enable successful behavior testsTechatrix
2023-09-07AstGen: fix missing array type validationVeikka Tuominen
Closes #17084
2023-09-06translate-c: fix panic when translating long double literalsCarl Åstholm
2023-09-05AstGen: fix error on missing function prototype nameVeikka Tuominen
Closes #17070
2023-08-30Sema: cleanup `coerceExtra`Jacob Young
* remove unreachable code * remove already handled cases * avoid `InternPool.getCoerced` * add some undef checks * error when converting undef int to float Closes #16987