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
Veikka Tuominen
f49dff64c6
Sema: check one possible value earlier in zirValidateArrayInit
...
Closes #12566
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
9043e665a5
add behavior test for copying array of vectors
...
closes #12026
2022-08-22 18:37:42 -07:00
Veikka Tuominen
62ff8871ed
stage2+stage1: remove type parameter from bit builtins
...
Closes #12529
Closes #12511
Closes #6835
2022-08-22 11:19:20 +03:00
Veikka Tuominen
560baf67ce
Sema: fix implicit cast from extern fn to fn ptr
...
Closes #12570
2022-08-22 11:16:36 +03:00
Veikka Tuominen
b0bcd4add2
Sema: allow optional pointers in packed structs
...
Closes #12572
2022-08-22 11:16:36 +03:00
Veikka Tuominen
74c7782c60
Sema: make orelse with C pointers behave like stage1 for now
...
Closes #12537
2022-08-22 11:16:36 +03:00
Veikka Tuominen
c1afe57d70
Sema: resolve lazy values in resolveMaybeUndefValIntable
...
Closes #12512
Closes #12513
2022-08-22 11:16:36 +03:00
Veikka Tuominen
b55a5007fa
Sema: fix parameter of type 'T' must be comptime error
...
Closes #12519
Closes #12505
2022-08-22 11:16:36 +03:00
Veikka Tuominen
20d0018d79
Sema: ignore dbg_block instructions when checking for comptimeness
...
Closes #12514
2022-08-21 12:53:19 +03:00
Veikka Tuominen
d48af541c7
Sema: handle union and enum field order being different
...
Closes #12543
2022-08-21 12:51:40 +03:00
Andrew Kelley
cee82c7ce4
improved ABI alignment/size for >= 128-bit integers
...
* riscv64: adjust alignment and size of 128-bit integers.
* take ofmt=c into account for ABI alignment of 128-bit integers and
structs.
* Type: make packed struct support intInfo
* fix f80 alignment for i386-windows-msvc
2022-08-18 20:34:36 -07:00
Andrew Kelley
6e313eb110
stage2: agree with LLVM that @alignOf(u128) is 8
...
on x86_64 and similar targets.
2022-08-18 17:11:32 -07:00
zooster
4055e6055b
AstGen: disallow leading zeroes in int literals and int types
...
This makes `0123` and `u0123` etc. illegal.
I'm now confident that this is a good change because
I actually caught two C header translation mistakes in `haiku.zig` with this.
Clearly, `0123` being octal in C (TIL) can cause confusion, and we make this easier to read by
requiring `0o` as the prefix and now also disallowing leading zeroes in integers.
For consistency and because it looks weird, we disallow it for integer types too (e.g. `u0123`).
Fixes #11963
Fixes #12417
2022-08-18 19:54:51 +03:00
Veikka Tuominen
b038dba06b
Merge pull request #12462 from Vexu/stage2-noreturn
...
Stage2: improve behavior of noreturn
2022-08-18 17:18:57 +03:00
Martin Hafskjold Thoresen
07f64a2e13
Sema: error on ambiguous coercion of comptime float and ints
...
The following, from the documentation as of the time of writing, illustrates
the problem:
```zig
// Compile time coercion of float to int
test "implicit cast to comptime_int" {
var f: f32 = 54.0 / 5;
_ = f;
}
```
It is not clear how to unify the types of 54.0 and 5 to perform the
division. We can either
- cast 54.0 to comptime_int resulting in @as(comptime_int, 10), which is
casted to @as(f32, 10), or
- cast 5 to comptime_float resulting in @as(comptime_float, 10.8), which
is casted to @as(f32, 10.8)
Since the two resulting values are different, a compiler error is appropriate.
If we know that casting to either type will result in the same value we
don't need to error. For instance, 10.0 / 2 is okay, as is 10 / 2.0.
Fixes : #12364
2022-08-17 14:09:09 -07:00
Veikka Tuominen
233049503a
Sema: allow empty enums and unions
2022-08-17 23:03:04 +03:00
Andrew Kelley
c764640e92
Sema: fix generics with struct literal coerced to tagged union
...
The `Value.eql` function has to test for value equality *as-if* the lhs
value parameter is coerced into the type of the rhs. For tagged unions,
there was a problematic case when the lhs was an anonymous struct,
because in such case the value is empty_struct_value and the type
contains all the value information. But the only type available in the
function was the rhs type.
So the fix involved making `Value.eqlAdvanced` also accept the lhs type,
and then enhancing the logic to handle the case of the `.anon_struct` tag.
closes #12418
Tests run locally:
* test-behavior
* test-cases
2022-08-17 13:02:57 -07:00
Veikka Tuominen
c3d5428cba
Sema: properly handle noreturn fields in unions
2022-08-17 22:07:48 +03:00
Veikka Tuominen
b0a55e1b3b
Sema: make noreturn error union behave correctly
2022-08-17 20:10:18 +03:00
Veikka Tuominen
db0f372da8
Sema: make optional noreturn behave correctly
2022-08-17 20:10:18 +03:00
Veikka Tuominen
c17793b487
Sema: ignore current declaration in ambiguous reference error
...
Closes #12429
2022-08-16 16:37:27 +03:00
Cody Tapscott
7e07f3d4f9
stage2 astgen: Use rl semantics for @Type
...
Resolves #12430 .
2022-08-13 09:22:25 +03:00
Andrew Kelley
4d7f5a1917
stage2: fix crash with comptime vector reduce
2022-08-10 16:45:29 -07:00
Andrew Kelley
3c4e9b5983
disable failing behavior test
...
See #12360
2022-08-10 16:43:47 -07:00
Andrew Kelley
173952f4b8
disable failing behavior test
...
see tracking issue #12396
2022-08-10 16:13:59 -07:00
Andrew Kelley
e0178890ba
Merge pull request #12379 from ifreund/packed-struct-explicit-backing-int
...
stage2: Implement explicit backing integers for packed structs
2022-08-10 19:13:29 -04:00
Veikka Tuominen
40447b25e8
Sema: fix expansion of repeated value
...
Closes #12386
2022-08-10 15:18:09 -04:00
Isaac Freund
0d32b73078
stage2: Implement explicit backing integers for packed structs
...
Now the backing integer of a packed struct type may be explicitly
specified with e.g. `packed struct(u32) { ... }`.
2022-08-10 19:54:45 +02:00
Isaac Freund
bb1c3e8b7e
stage2: Handle lazy values for the % operator
2022-08-10 14:48:27 +02:00
Veikka Tuominen
0fd90749d1
stage2: generate call arguments in separate blocks
2022-08-09 16:19:55 +03:00
Meghan Denny
0879cbeed2
remove 'builtin.stage2_arch', Sema is smart enough now
2022-08-07 16:07:08 -07:00
Veikka Tuominen
eec2978fac
Sema: better safety check on switch on corrupt value
2022-08-05 22:13:57 +03:00
Veikka Tuominen
292906fb23
Sema: fix reify Fn alignment and args
2022-08-02 18:33:03 +03:00
Veikka Tuominen
e47706f344
Sema: validate packed struct field types
2022-08-01 23:59:40 +03:00
Veikka Tuominen
57f9405a8f
Sema: validate bitcast operand type
2022-08-01 23:37:01 +03:00
Veikka Tuominen
4758752e5d
Sema: implement coercion from tuples to tuples
...
Closes #12242
2022-07-30 00:18:08 +03:00
Veikka Tuominen
f43ea43ac9
stage2: fix hashing of struct values
...
Closes #12279
2022-07-30 00:17:49 +03:00
joachimschmidt557
0fc79d602b
stage2 ARM: more support for switch statements
2022-07-28 20:44:32 +00:00
Andrew Kelley
3ba7098a17
LLVM: fix returning extern union with C callconv
2022-07-27 17:56:15 -07:00
Andrew Kelley
6a4df2778e
AstGen: fix ref instruction injection for functions
...
For the expressions regarding return type, alignment,
parameter type, etc.
2022-07-27 16:19:23 -07:00
Andrew Kelley
f880af369d
LLVM: fix lowering byte-aligned packed struct field pointers
2022-07-27 16:19:23 -07:00
Evan Haas
7ba1f9bfb5
translate-c: take address of functions before passing them to @ptrToInt
...
Fixes #12194
2022-07-27 14:03:08 +03:00
Andrew Kelley
a2ab9e36fa
Merge pull request #12143 from Vexu/stage2-safety
...
Stage2 runtime safety progress
2022-07-23 20:09:24 -07:00
Andrew Kelley
9964324856
disable flaky behavior test
...
see #12208
2022-07-23 20:03:50 -07:00
Veikka Tuominen
baf516218e
Sema: don't add union field access safety check for single field unions
2022-07-23 15:40:12 +03:00
Veikka Tuominen
711b656773
Sema: @floatToInt safety
2022-07-23 15:40:11 +03:00