diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-01-29 21:47:26 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-01-29 22:30:30 -0500 |
| commit | 581edd643fb18a66c472f77e2f8cd3f4cea524a2 (patch) | |
| tree | a03f6a3ade952729456b94584f21d4beb51a4802 /test/cases/syntax.zig | |
| parent | 9c328b42916d463465b134457c7f13b5c65da406 (diff) | |
| download | zig-581edd643fb18a66c472f77e2f8cd3f4cea524a2.tar.gz zig-581edd643fb18a66c472f77e2f8cd3f4cea524a2.zip | |
backport copy elision changes
This commit contains everything from the copy-elision-2
branch that does not have to do with copy elision directly,
but is generally useful for master branch.
* All const values know their parents, when applicable, not
just structs and unions.
* Null pointers in const values are represented explicitly,
rather than as a HardCodedAddr value of 0.
* Rename "maybe" to "optional" in various code locations.
* Separate DeclVarSrc and DeclVarGen
* Separate PtrCastSrc and PtrCastGen
* Separate CmpxchgSrc and CmpxchgGen
* Represent optional error set as an integer, using the 0 value.
In a const value, it uses nullptr.
* Introduce type_has_one_possible_value and use it where applicable.
* Fix debug builds not setting memory to 0xaa when storing
undefined.
* Separate the type of a variable from the const value of a variable.
* Use copy_const_val where appropriate.
* Rearrange structs to pack data more efficiently.
* Move test/cases/* to test/behavior/*
* Use `std.debug.assertOrPanic` in behavior tests instead of
`std.debug.assert`.
* Fix outdated slice syntax in docs.
Diffstat (limited to 'test/cases/syntax.zig')
| -rw-r--r-- | test/cases/syntax.zig | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/test/cases/syntax.zig b/test/cases/syntax.zig deleted file mode 100644 index 0c8c3c5ed3..0000000000 --- a/test/cases/syntax.zig +++ /dev/null @@ -1,59 +0,0 @@ -// Test trailing comma syntax -// zig fmt: off - -const struct_trailing_comma = struct { x: i32, y: i32, }; -const struct_no_comma = struct { x: i32, y: i32 }; -const struct_fn_no_comma = struct { fn m() void {} y: i32 }; - -const enum_no_comma = enum { A, B }; - -fn container_init() void { - const S = struct { x: i32, y: i32 }; - _ = S { .x = 1, .y = 2 }; - _ = S { .x = 1, .y = 2, }; -} - -fn type_expr_return1() if (true) A {} -fn type_expr_return2() for (true) |_| A {} -fn type_expr_return3() while (true) A {} -fn type_expr_return4() comptime A {} - -fn switch_cases(x: i32) void { - switch (x) { - 1,2,3 => {}, - 4,5, => {}, - 6...8, => {}, - else => {}, - } -} - -fn switch_prongs(x: i32) void { - switch (x) { - 0 => {}, - else => {}, - } - switch (x) { - 0 => {}, - else => {} - } -} - -const fn_no_comma = fn(i32, i32)void; -const fn_trailing_comma = fn(i32, i32,)void; - -fn fn_calls() void { - fn add(x: i32, y: i32,) i32 { x + y }; - _ = add(1, 2); - _ = add(1, 2,); -} - -fn asm_lists() void { - if (false) { // Build AST but don't analyze - asm ("not real assembly" - :[a] "x" (x),); - asm ("not real assembly" - :[a] "x" (->i32),:[a] "x" (1),); - asm ("still not real assembly" - :::"a","b",); - } -} |
