authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-05-17 23:21:44-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-05-17 23:21:44-04:00
logc38b165db4a16ba6a5c6d13537177db656fc4033
treea8639a11bea5a2fc2b9c5aebf30011f7675f37d7
parent99fc2bd4ddbe36994153f6426f0001d338e90bef

all tests passing with postfix deref syntax


13 files changed, 302 insertions(+), 289 deletions(-)

build.zig+34-25
......@@ -16,7 +16,7 @@ pub fn build(b: &Builder) !void {
1616 var docgen_exe = b.addExecutable("docgen", "doc/docgen.zig");
1717
1818 const rel_zig_exe = try os.path.relative(b.allocator, b.build_root, b.zig_exe);
19 var docgen_cmd = b.addCommand(null, b.env_map, [][]const u8 {
19 var docgen_cmd = b.addCommand(null, b.env_map, [][]const u8{
2020 docgen_exe.getOutputPath(),
2121 rel_zig_exe,
2222 "doc/langref.html.in",
......@@ -30,7 +30,10 @@ pub fn build(b: &Builder) !void {
3030 const test_step = b.step("test", "Run all the tests");
3131
3232 // find the stage0 build artifacts because we're going to re-use config.h and zig_cpp library
33 const build_info = try b.exec([][]const u8{b.zig_exe, "BUILD_INFO"});
33 const build_info = try b.exec([][]const u8{
34 b.zig_exe,
35 "BUILD_INFO",
36 });
3437 var index: usize = 0;
3538 const cmake_binary_dir = nextValue(&index, build_info);
3639 const cxx_compiler = nextValue(&index, build_info);
......@@ -67,7 +70,10 @@ pub fn build(b: &Builder) !void {
6770 dependOnLib(exe, llvm);
6871
6972 if (exe.target.getOs() == builtin.Os.linux) {
70 const libstdcxx_path_padded = try b.exec([][]const u8{cxx_compiler, "-print-file-name=libstdc++.a"});
73 const libstdcxx_path_padded = try b.exec([][]const u8{
74 cxx_compiler,
75 "-print-file-name=libstdc++.a",
76 });
7177 const libstdcxx_path = ??mem.split(libstdcxx_path_padded, "\r\n").next();
7278 if (mem.eql(u8, libstdcxx_path, "libstdc++.a")) {
7379 warn(
......@@ -111,17 +117,11 @@ pub fn build(b: &Builder) !void {
111117
112118 test_step.dependOn(docs_step);
113119
114 test_step.dependOn(tests.addPkgTests(b, test_filter,
115 "test/behavior.zig", "behavior", "Run the behavior tests",
116 with_lldb));
120 test_step.dependOn(tests.addPkgTests(b, test_filter, "test/behavior.zig", "behavior", "Run the behavior tests", with_lldb));
117121
118 test_step.dependOn(tests.addPkgTests(b, test_filter,
119 "std/index.zig", "std", "Run the standard library tests",
120 with_lldb));
122 test_step.dependOn(tests.addPkgTests(b, test_filter, "std/index.zig", "std", "Run the standard library tests", with_lldb));
121123
122 test_step.dependOn(tests.addPkgTests(b, test_filter,
123 "std/special/compiler_rt/index.zig", "compiler-rt", "Run the compiler_rt tests",
124 with_lldb));
124 test_step.dependOn(tests.addPkgTests(b, test_filter, "std/special/compiler_rt/index.zig", "compiler-rt", "Run the compiler_rt tests", with_lldb));
125125
126126 test_step.dependOn(tests.addCompareOutputTests(b, test_filter));
127127 test_step.dependOn(tests.addBuildExampleTests(b, test_filter));
......@@ -149,8 +149,7 @@ fn dependOnLib(lib_exe_obj: &std.build.LibExeObjStep, dep: &const LibraryDep) vo
149149
150150fn addCppLib(b: &Builder, lib_exe_obj: &std.build.LibExeObjStep, cmake_binary_dir: []const u8, lib_name: []const u8) void {
151151 const lib_prefix = if (lib_exe_obj.target.isWindows()) "" else "lib";
152 lib_exe_obj.addObjectFile(os.path.join(b.allocator, cmake_binary_dir, "zig_cpp",
153 b.fmt("{}{}{}", lib_prefix, lib_name, lib_exe_obj.target.libFileExt())) catch unreachable);
152 lib_exe_obj.addObjectFile(os.path.join(b.allocator, cmake_binary_dir, "zig_cpp", b.fmt("{}{}{}", lib_prefix, lib_name, lib_exe_obj.target.libFileExt())) catch unreachable);
154153}
155154
156155const LibraryDep = struct {
......@@ -161,11 +160,21 @@ const LibraryDep = struct {
161160};
162161
163162fn findLLVM(b: &Builder, llvm_config_exe: []const u8) !LibraryDep {
164 const libs_output = try b.exec([][]const u8{llvm_config_exe, "--libs", "--system-libs"});
165 const includes_output = try b.exec([][]const u8{llvm_config_exe, "--includedir"});
166 const libdir_output = try b.exec([][]const u8{llvm_config_exe, "--libdir"});
163 const libs_output = try b.exec([][]const u8{
164 llvm_config_exe,
165 "--libs",
166 "--system-libs",
167 });
168 const includes_output = try b.exec([][]const u8{
169 llvm_config_exe,
170 "--includedir",
171 });
172 const libdir_output = try b.exec([][]const u8{
173 llvm_config_exe,
174 "--libdir",
175 });
167176
168 var result = LibraryDep {
177 var result = LibraryDep{
169178 .libs = ArrayList([]const u8).init(b.allocator),
170179 .system_libs = ArrayList([]const u8).init(b.allocator),
171180 .includes = ArrayList([]const u8).init(b.allocator),
......@@ -227,17 +236,17 @@ pub fn installCHeaders(b: &Builder, c_header_files: []const u8) void {
227236}
228237
229238fn nextValue(index: &usize, build_info: []const u8) []const u8 {
230 const start = *index;
231 while (true) : (*index += 1) {
232 switch (build_info[*index]) {
239 const start = index.*;
240 while (true) : (index.* += 1) {
241 switch (build_info[index.*]) {
233242 '\n' => {
234 const result = build_info[start..*index];
235 *index += 1;
243 const result = build_info[start..index.*];
244 index.* += 1;
236245 return result;
237246 },
238247 '\r' => {
239 const result = build_info[start..*index];
240 *index += 2;
248 const result = build_info[start..index.*];
249 index.* += 2;
241250 return result;
242251 },
243252 else => continue,
doc/langref.html.in+30-30
......@@ -1232,7 +1232,7 @@ mem.eql(u8, pattern, "ababab")</code></pre>
12321232 </td>
12331233 </tr>
12341234 <tr>
1235 <td><pre><code class="zig">*a<code></pre></td>
1235 <td><pre><code class="zig">a.*<code></pre></td>
12361236 <td>
12371237 <ul>
12381238 <li>{#link|Pointers#}</li>
......@@ -1244,7 +1244,7 @@ mem.eql(u8, pattern, "ababab")</code></pre>
12441244 <td>
12451245 <pre><code class="zig">const x: u32 = 1234;
12461246const ptr = &amp;x;
1247*x == 1234</code></pre>
1247x.* == 1234</code></pre>
12481248 </td>
12491249 </tr>
12501250 <tr>
......@@ -1258,7 +1258,7 @@ const ptr = &amp;x;
12581258 <td>
12591259 <pre><code class="zig">const x: u32 = 1234;
12601260const ptr = &amp;x;
1261*x == 1234</code></pre>
1261x.* == 1234</code></pre>
12621262 </td>
12631263 </tr>
12641264 </table>
......@@ -1267,8 +1267,8 @@ const ptr = &amp;x;
12671267 {#header_open|Precedence#}
12681268 <pre><code>x() x[] x.y
12691269a!b
1270!x -x -%x ~x *x &amp;x ?x ??x
1271x{}
1270!x -x -%x ~x &amp;x ?x ??x
1271x{} x.*
12721272! * / % ** *%
12731273+ - ++ +% -%
12741274&lt;&lt; &gt;&gt;
......@@ -1316,7 +1316,7 @@ var some_integers: [100]i32 = undefined;
13161316
13171317test "modify an array" {
13181318 for (some_integers) |*item, i| {
1319 *item = i32(i);
1319 item.* = i32(i);
13201320 }
13211321 assert(some_integers[10] == 10);
13221322 assert(some_integers[99] == 99);
......@@ -1357,7 +1357,7 @@ comptime {
13571357var fancy_array = init: {
13581358 var initial_value: [10]Point = undefined;
13591359 for (initial_value) |*pt, i| {
1360 *pt = Point {
1360 pt.* = Point {
13611361 .x = i32(i),
13621362 .y = i32(i) * 2,
13631363 };
......@@ -1400,7 +1400,7 @@ test "address of syntax" {
14001400 const x_ptr = &x;
14011401
14021402 // Deference a pointer:
1403 assert(*x_ptr == 1234);
1403 assert(x_ptr.* == 1234);
14041404
14051405 // When you get the address of a const variable, you get a const pointer.
14061406 assert(@typeOf(x_ptr) == &const i32);
......@@ -1409,8 +1409,8 @@ test "address of syntax" {
14091409 var y: i32 = 5678;
14101410 const y_ptr = &y;
14111411 assert(@typeOf(y_ptr) == &i32);
1412 *y_ptr += 1;
1413 assert(*y_ptr == 5679);
1412 y_ptr.* += 1;
1413 assert(y_ptr.* == 5679);
14141414}
14151415
14161416test "pointer array access" {
......@@ -1448,9 +1448,9 @@ comptime {
14481448 // @ptrCast.
14491449 var x: i32 = 1;
14501450 const ptr = &x;
1451 *ptr += 1;
1451 ptr.* += 1;
14521452 x += 1;
1453 assert(*ptr == 3);
1453 assert(ptr.* == 3);
14541454}
14551455
14561456test "@ptrToInt and @intToPtr" {
......@@ -1492,7 +1492,7 @@ test "nullable pointers" {
14921492 var x: i32 = 1;
14931493 ptr = &x;
14941494
1495 assert(*??ptr == 1);
1495 assert((??ptr).* == 1);
14961496
14971497 // Nullable pointers are the same size as normal pointers, because pointer
14981498 // value 0 is used as the null value.
......@@ -1505,7 +1505,7 @@ test "pointer casting" {
15051505 // conversions are not possible.
15061506 const bytes align(@alignOf(u32)) = []u8{0x12, 0x12, 0x12, 0x12};
15071507 const u32_ptr = @ptrCast(&const u32, &bytes[0]);
1508 assert(*u32_ptr == 0x12121212);
1508 assert(u32_ptr.* == 0x12121212);
15091509
15101510 // Even this example is contrived - there are better ways to do the above than
15111511 // pointer casting. For example, using a slice narrowing cast:
......@@ -1610,7 +1610,7 @@ fn foo(bytes: []u8) u32 {
16101610 <code>u8</code> can alias any memory.
16111611 </p>
16121612 <p>As an example, this code produces undefined behavior:</p>
1613 <pre><code class="zig">*@ptrCast(&amp;u32, f32(12.34))</code></pre>
1613 <pre><code class="zig">@ptrCast(&amp;u32, f32(12.34)).*</code></pre>
16141614 <p>Instead, use {#link|@bitCast#}:
16151615 <pre><code class="zig">@bitCast(u32, f32(12.34))</code></pre>
16161616 <p>As an added benefit, the <code>@bitcast</code> version works at compile-time.</p>
......@@ -2040,7 +2040,7 @@ const Variant = union(enum) {
20402040 Bool: bool,
20412041
20422042 fn truthy(self: &const Variant) bool {
2043 return switch (*self) {
2043 return switch (self.*) {
20442044 Variant.Int => |x_int| x_int != 0,
20452045 Variant.Bool => |x_bool| x_bool,
20462046 };
......@@ -2151,7 +2151,7 @@ test "switch enum" {
21512151
21522152 // A reference to the matched value can be obtained using `*` syntax.
21532153 Item.C => |*item| blk: {
2154 (*item).x += 1;
2154 item.*.x += 1;
21552155 break :blk 6;
21562156 },
21572157
......@@ -2374,7 +2374,7 @@ test "for reference" {
23742374 // Iterate over the slice by reference by
23752375 // specifying that the capture value is a pointer.
23762376 for (items) |*value| {
2377 *value += 1;
2377 value.* += 1;
23782378 }
23792379
23802380 assert(items[0] == 4);
......@@ -2483,7 +2483,7 @@ test "if nullable" {
24832483 // Access the value by reference using a pointer capture.
24842484 var c: ?u32 = 3;
24852485 if (c) |*value| {
2486 *value = 2;
2486 value.* = 2;
24872487 }
24882488
24892489 if (c) |value| {
......@@ -2524,7 +2524,7 @@ test "if error union" {
25242524 // Access the value by reference using a pointer capture.
25252525 var c: error!u32 = 3;
25262526 if (c) |*value| {
2527 *value = 9;
2527 value.* = 9;
25282528 } else |err| {
25292529 unreachable;
25302530 }
......@@ -3872,7 +3872,7 @@ pub fn main() void {
38723872 {#header_open|@addWithOverflow#}
38733873 <pre><code class="zig">@addWithOverflow(comptime T: type, a: T, b: T, result: &T) -&gt; bool</code></pre>
38743874 <p>
3875 Performs <code>*result = a + b</code>. If overflow or underflow occurs,
3875 Performs <code>result.* = a + b</code>. If overflow or underflow occurs,
38763876 stores the overflowed bits in <code>result</code> and returns <code>true</code>.
38773877 If no overflow or underflow occurs, returns <code>false</code>.
38783878 </p>
......@@ -4073,9 +4073,9 @@ comptime {
40734073 </p>
40744074 {#code_begin|syntax#}
40754075fn cmpxchgStrongButNotAtomic(comptime T: type, ptr: &T, expected_value: T, new_value: T) ?T {
4076 const old_value = *ptr;
4076 const old_value = ptr.*;
40774077 if (old_value == expected_value) {
4078 *ptr = new_value;
4078 ptr.* = new_value;
40794079 return null;
40804080 } else {
40814081 return old_value;
......@@ -4100,9 +4100,9 @@ fn cmpxchgStrongButNotAtomic(comptime T: type, ptr: &T, expected_value: T, new_v
41004100 </p>
41014101 {#code_begin|syntax#}
41024102fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: &T, expected_value: T, new_value: T) ?T {
4103 const old_value = *ptr;
4103 const old_value = ptr.*;
41044104 if (old_value == expected_value and usuallyTrueButSometimesFalse()) {
4105 *ptr = new_value;
4105 ptr.* = new_value;
41064106 return null;
41074107 } else {
41084108 return old_value;
......@@ -4447,7 +4447,7 @@ mem.copy(u8, dest[0...byte_count], source[0...byte_count]);</code></pre>
44474447 This function is a low level intrinsic with no safety mechanisms. Most
44484448 code should not use this function, instead using something like this:
44494449 </p>
4450 <pre><code class="zig">for (dest[0...byte_count]) |*b| *b = c;</code></pre>
4450 <pre><code class="zig">for (dest[0...byte_count]) |*b| b.* = c;</code></pre>
44514451 <p>
44524452 The optimizer is intelligent enough to turn the above snippet into a memset.
44534453 </p>
......@@ -4480,7 +4480,7 @@ mem.set(u8, dest, c);</code></pre>
44804480 {#header_open|@mulWithOverflow#}
44814481 <pre><code class="zig">@mulWithOverflow(comptime T: type, a: T, b: T, result: &T) -&gt; bool</code></pre>
44824482 <p>
4483 Performs <code>*result = a * b</code>. If overflow or underflow occurs,
4483 Performs <code>result.* = a * b</code>. If overflow or underflow occurs,
44844484 stores the overflowed bits in <code>result</code> and returns <code>true</code>.
44854485 If no overflow or underflow occurs, returns <code>false</code>.
44864486 </p>
......@@ -4514,7 +4514,7 @@ fn targetFunction(x: i32) usize {
45144514
45154515 var local_variable: i32 = 42;
45164516 const ptr = &local_variable;
4517 *ptr += 1;
4517 ptr.* += 1;
45184518
45194519 assert(local_variable == 43);
45204520 return @ptrToInt(ptr);
......@@ -4746,7 +4746,7 @@ pub const FloatMode = enum {
47464746 {#header_open|@shlWithOverflow#}
47474747 <pre><code class="zig">@shlWithOverflow(comptime T: type, a: T, shift_amt: Log2T, result: &T) -&gt; bool</code></pre>
47484748 <p>
4749 Performs <code>*result = a &lt;&lt; b</code>. If overflow or underflow occurs,
4749 Performs <code>result.* = a &lt;&lt; b</code>. If overflow or underflow occurs,
47504750 stores the overflowed bits in <code>result</code> and returns <code>true</code>.
47514751 If no overflow or underflow occurs, returns <code>false</code>.
47524752 </p>
......@@ -4790,7 +4790,7 @@ pub const FloatMode = enum {
47904790 {#header_open|@subWithOverflow#}
47914791 <pre><code class="zig">@subWithOverflow(comptime T: type, a: T, b: T, result: &T) -&gt; bool</code></pre>
47924792 <p>
4793 Performs <code>*result = a - b</code>. If overflow or underflow occurs,
4793 Performs <code>result.* = a - b</code>. If overflow or underflow occurs,
47944794 stores the overflowed bits in <code>result</code> and returns <code>true</code>.
47954795 If no overflow or underflow occurs, returns <code>false</code>.
47964796 </p>
src-self-hosted/arg.zig+41-33
......@@ -30,24 +30,22 @@ fn argInAllowedSet(maybe_set: ?[]const []const u8, arg: []const u8) bool {
3030}
3131
3232// Modifies the current argument index during iteration
33fn readFlagArguments(allocator: &Allocator, args: []const []const u8, required: usize,
34 allowed_set: ?[]const []const u8, index: &usize) !FlagArg {
35
33fn readFlagArguments(allocator: &Allocator, args: []const []const u8, required: usize, allowed_set: ?[]const []const u8, index: &usize) !FlagArg {
3634 switch (required) {
37 0 => return FlagArg { .None = undefined }, // TODO: Required to force non-tag but value?
35 0 => return FlagArg{ .None = undefined }, // TODO: Required to force non-tag but value?
3836 1 => {
39 if (*index + 1 >= args.len) {
37 if (index.* + 1 >= args.len) {
4038 return error.MissingFlagArguments;
4139 }
4240
43 *index += 1;
44 const arg = args[*index];
41 index.* += 1;
42 const arg = args[index.*];
4543
4644 if (!argInAllowedSet(allowed_set, arg)) {
4745 return error.ArgumentNotInAllowedSet;
4846 }
4947
50 return FlagArg { .Single = arg };
48 return FlagArg{ .Single = arg };
5149 },
5250 else => |needed| {
5351 var extra = ArrayList([]const u8).init(allocator);
......@@ -55,12 +53,12 @@ fn readFlagArguments(allocator: &Allocator, args: []const []const u8, required:
5553
5654 var j: usize = 0;
5755 while (j < needed) : (j += 1) {
58 if (*index + 1 >= args.len) {
56 if (index.* + 1 >= args.len) {
5957 return error.MissingFlagArguments;
6058 }
6159
62 *index += 1;
63 const arg = args[*index];
60 index.* += 1;
61 const arg = args[index.*];
6462
6563 if (!argInAllowedSet(allowed_set, arg)) {
6664 return error.ArgumentNotInAllowedSet;
......@@ -69,7 +67,7 @@ fn readFlagArguments(allocator: &Allocator, args: []const []const u8, required:
6967 try extra.append(arg);
7068 }
7169
72 return FlagArg { .Many = extra };
70 return FlagArg{ .Many = extra };
7371 },
7472 }
7573}
......@@ -82,7 +80,7 @@ pub const Args = struct {
8280 positionals: ArrayList([]const u8),
8381
8482 pub fn parse(allocator: &Allocator, comptime spec: []const Flag, args: []const []const u8) !Args {
85 var parsed = Args {
83 var parsed = Args{
8684 .flags = HashMapFlags.init(allocator),
8785 .positionals = ArrayList([]const u8).init(allocator),
8886 };
......@@ -116,11 +114,7 @@ pub const Args = struct {
116114 };
117115
118116 if (flag.mergable) {
119 var prev =
120 if (parsed.flags.get(flag_name_trimmed)) |entry|
121 entry.value.Many
122 else
123 ArrayList([]const u8).init(allocator);
117 var prev = if (parsed.flags.get(flag_name_trimmed)) |entry| entry.value.Many else ArrayList([]const u8).init(allocator);
124118
125119 // MergeN creation disallows 0 length flag entry (doesn't make sense)
126120 switch (flag_args) {
......@@ -129,7 +123,7 @@ pub const Args = struct {
129123 FlagArg.Many => |inner| try prev.appendSlice(inner.toSliceConst()),
130124 }
131125
132 _ = try parsed.flags.put(flag_name_trimmed, FlagArg { .Many = prev });
126 _ = try parsed.flags.put(flag_name_trimmed, FlagArg{ .Many = prev });
133127 } else {
134128 _ = try parsed.flags.put(flag_name_trimmed, flag_args);
135129 }
......@@ -163,7 +157,9 @@ pub const Args = struct {
163157 pub fn single(self: &Args, name: []const u8) ?[]const u8 {
164158 if (self.flags.get(name)) |entry| {
165159 switch (entry.value) {
166 FlagArg.Single => |inner| { return inner; },
160 FlagArg.Single => |inner| {
161 return inner;
162 },
167163 else => @panic("attempted to retrieve flag with wrong type"),
168164 }
169165 } else {
......@@ -175,7 +171,9 @@ pub const Args = struct {
175171 pub fn many(self: &Args, name: []const u8) ?[]const []const u8 {
176172 if (self.flags.get(name)) |entry| {
177173 switch (entry.value) {
178 FlagArg.Many => |inner| { return inner.toSliceConst(); },
174 FlagArg.Many => |inner| {
175 return inner.toSliceConst();
176 },
179177 else => @panic("attempted to retrieve flag with wrong type"),
180178 }
181179 } else {
......@@ -207,7 +205,7 @@ pub const Flag = struct {
207205 }
208206
209207 pub fn ArgN(comptime name: []const u8, comptime n: usize) Flag {
210 return Flag {
208 return Flag{
211209 .name = name,
212210 .required = n,
213211 .mergable = false,
......@@ -220,7 +218,7 @@ pub const Flag = struct {
220218 @compileError("n must be greater than 0");
221219 }
222220
223 return Flag {
221 return Flag{
224222 .name = name,
225223 .required = n,
226224 .mergable = true,
......@@ -229,7 +227,7 @@ pub const Flag = struct {
229227 }
230228
231229 pub fn Option(comptime name: []const u8, comptime set: []const []const u8) Flag {
232 return Flag {
230 return Flag{
233231 .name = name,
234232 .required = 1,
235233 .mergable = false,
......@@ -239,26 +237,36 @@ pub const Flag = struct {
239237};
240238
241239test "parse arguments" {
242 const spec1 = comptime []const Flag {
240 const spec1 = comptime []const Flag{
243241 Flag.Bool("--help"),
244242 Flag.Bool("--init"),
245243 Flag.Arg1("--build-file"),
246 Flag.Option("--color", []const []const u8 { "on", "off", "auto" }),
244 Flag.Option("--color", []const []const u8{
245 "on",
246 "off",
247 "auto",
248 }),
247249 Flag.ArgN("--pkg-begin", 2),
248250 Flag.ArgMergeN("--object", 1),
249251 Flag.ArgN("--library", 1),
250252 };
251253
252 const cliargs = []const []const u8 {
254 const cliargs = []const []const u8{
253255 "build",
254256 "--help",
255257 "pos1",
256 "--build-file", "build.zig",
257 "--object", "obj1",
258 "--object", "obj2",
259 "--library", "lib1",
260 "--library", "lib2",
261 "--color", "on",
258 "--build-file",
259 "build.zig",
260 "--object",
261 "obj1",
262 "--object",
263 "obj2",
264 "--library",
265 "lib1",
266 "--library",
267 "lib2",
268 "--color",
269 "on",
262270 "pos2",
263271 };
264272
src-self-hosted/module.zig+9-9
......@@ -96,6 +96,7 @@ pub const Module = struct {
9696 pub const LinkLib = struct {
9797 name: []const u8,
9898 path: ?[]const u8,
99
99100 /// the list of symbols we depend on from this lib
100101 symbols: ArrayList([]u8),
101102 provided_explicitly: bool,
......@@ -130,9 +131,7 @@ pub const Module = struct {
130131 }
131132 };
132133
133 pub fn create(allocator: &mem.Allocator, name: []const u8, root_src_path: ?[]const u8, target: &const Target,
134 kind: Kind, build_mode: builtin.Mode, zig_lib_dir: []const u8, cache_dir: []const u8) !&Module
135 {
134 pub fn create(allocator: &mem.Allocator, name: []const u8, root_src_path: ?[]const u8, target: &const Target, kind: Kind, build_mode: builtin.Mode, zig_lib_dir: []const u8, cache_dir: []const u8) !&Module {
136135 var name_buffer = try Buffer.init(allocator, name);
137136 errdefer name_buffer.deinit();
138137
......@@ -148,14 +147,14 @@ pub const Module = struct {
148147 const module_ptr = try allocator.create(Module);
149148 errdefer allocator.destroy(module_ptr);
150149
151 *module_ptr = Module {
150 module_ptr.* = Module{
152151 .allocator = allocator,
153152 .name = name_buffer,
154153 .root_src_path = root_src_path,
155154 .module = module,
156155 .context = context,
157156 .builder = builder,
158 .target = *target,
157 .target = target.*,
159158 .kind = kind,
160159 .build_mode = build_mode,
161160 .zig_lib_dir = zig_lib_dir,
......@@ -221,8 +220,10 @@ pub const Module = struct {
221220
222221 pub fn build(self: &Module) !void {
223222 if (self.llvm_argv.len != 0) {
224 var c_compatible_args = try std.cstr.NullTerminated2DArray.fromSlices(self.allocator,
225 [][]const []const u8 { [][]const u8{"zig (LLVM option parsing)"}, self.llvm_argv, });
223 var c_compatible_args = try std.cstr.NullTerminated2DArray.fromSlices(self.allocator, [][]const []const u8{
224 [][]const u8{"zig (LLVM option parsing)"},
225 self.llvm_argv,
226 });
226227 defer c_compatible_args.deinit();
227228 c.ZigLLVMParseCommandLineOptions(self.llvm_argv.len + 1, c_compatible_args.ptr);
228229 }
......@@ -261,7 +262,6 @@ pub const Module = struct {
261262
262263 warn("====llvm ir:====\n");
263264 self.dump();
264
265265 }
266266
267267 pub fn link(self: &Module, out_file: ?[]const u8) !void {
......@@ -285,7 +285,7 @@ pub const Module = struct {
285285 }
286286
287287 const link_lib = try self.allocator.create(LinkLib);
288 *link_lib = LinkLib {
288 link_lib.* = LinkLib{
289289 .name = name,
290290 .path = null,
291291 .provided_explicitly = provided_explicitly,
src-self-hosted/target.zig+4-3
......@@ -12,7 +12,7 @@ pub const Target = union(enum) {
1212 Cross: CrossTarget,
1313
1414 pub fn oFileExt(self: &const Target) []const u8 {
15 const environ = switch (*self) {
15 const environ = switch (self.*) {
1616 Target.Native => builtin.environ,
1717 Target.Cross => |t| t.environ,
1818 };
......@@ -30,7 +30,7 @@ pub const Target = union(enum) {
3030 }
3131
3232 pub fn getOs(self: &const Target) builtin.Os {
33 return switch (*self) {
33 return switch (self.*) {
3434 Target.Native => builtin.os,
3535 Target.Cross => |t| t.os,
3636 };
......@@ -38,7 +38,8 @@ pub const Target = union(enum) {
3838
3939 pub fn isDarwin(self: &const Target) bool {
4040 return switch (self.getOs()) {
41 builtin.Os.ios, builtin.Os.macosx => true,
41 builtin.Os.ios,
42 builtin.Os.macosx => true,
4243 else => false,
4344 };
4445 }
std/zig/ast.zig+1
......@@ -1485,6 +1485,7 @@ pub const Node = struct {
14851485 BitNot,
14861486 BoolNot,
14871487 Cancel,
1488 PointerType,
14881489 MaybeType,
14891490 Negation,
14901491 NegationWrap,
std/zig/parse.zig+1-1
......@@ -3134,7 +3134,7 @@ fn tokenIdToPrefixOp(id: @TagType(Token.Id)) ?ast.Node.PrefixOp.Op {
31343134 Token.Id.Minus => ast.Node.PrefixOp.Op{ .Negation = void{} },
31353135 Token.Id.MinusPercent => ast.Node.PrefixOp.Op{ .NegationWrap = void{} },
31363136 Token.Id.Asterisk,
3137 Token.Id.AsteriskAsterisk => ast.Node.PrefixOp.Op{ .Deref = void{} },
3137 Token.Id.AsteriskAsterisk => ast.Node.PrefixOp.Op{ .PointerType = void{} },
31383138 Token.Id.Ampersand => ast.Node.PrefixOp.Op{ .AddrOf = ast.Node.PrefixOp.AddrOfInfo{
31393139 .align_expr = null,
31403140 .bit_offset_start_token = null,
std/zig/render.zig+2-1
......@@ -311,6 +311,7 @@ fn renderExpression(allocator: &mem.Allocator, stream: var, tree: &ast.Tree, ind
311311 ast.Node.PrefixOp.Op.Try => try stream.write("try "),
312312 ast.Node.PrefixOp.Op.UnwrapMaybe => try stream.write("??"),
313313 ast.Node.PrefixOp.Op.MaybeType => try stream.write("?"),
314 ast.Node.PrefixOp.Op.PointerType => try stream.write("*"),
314315 ast.Node.PrefixOp.Op.Await => try stream.write("await "),
315316 ast.Node.PrefixOp.Op.Cancel => try stream.write("cancel "),
316317 ast.Node.PrefixOp.Op.Resume => try stream.write("resume "),
......@@ -350,7 +351,7 @@ fn renderExpression(allocator: &mem.Allocator, stream: var, tree: &ast.Tree, ind
350351 try stream.write("]");
351352 },
352353
353 ast.Node.SuffixOp.Op.SuffixOp => {
354 ast.Node.SuffixOp.Op.Deref => {
354355 try renderExpression(allocator, stream, tree, indent, suffix_op.lhs);
355356 try stream.write(".*");
356357 },
test/compare_output.zig+2-2
......@@ -287,9 +287,9 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
287287 \\export fn compare_fn(a: ?&const c_void, b: ?&const c_void) c_int {
288288 \\ const a_int = @ptrCast(&align(1) const i32, a ?? unreachable);
289289 \\ const b_int = @ptrCast(&align(1) const i32, b ?? unreachable);
290 \\ if (*a_int < *b_int) {
290 \\ if (a_int.* < b_int.*) {
291291 \\ return -1;
292 \\ } else if (*a_int > *b_int) {
292 \\ } else if (a_int.* > b_int.*) {
293293 \\ return 1;
294294 \\ } else {
295295 \\ return 0;
test/compile_errors.zig+15-15
......@@ -4,7 +4,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
44 cases.add("invalid deref on switch target",
55 \\comptime {
66 \\ var tile = Tile.Empty;
7 \\ switch (*tile) {
7 \\ switch (tile.*) {
88 \\ Tile.Empty => {},
99 \\ Tile.Filled => {},
1010 \\ }
......@@ -14,7 +14,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
1414 \\ Filled,
1515 \\};
1616 ,
17 ".tmp_source.zig:3:13: error: invalid deref on switch target");
17 ".tmp_source.zig:3:17: error: invalid deref on switch target");
1818
1919 cases.add("invalid field access in comptime",
2020 \\comptime { var x = doesnt_exist.whatever; }
......@@ -1408,14 +1408,14 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
14081408 \\ Two: i32,
14091409 \\};
14101410 \\fn bad_eql_2(a: &const EnumWithData, b: &const EnumWithData) bool {
1411 \\ return *a == *b;
1411 \\ return a.* == b.*;
14121412 \\}
14131413 \\
14141414 \\export fn entry1() usize { return @sizeOf(@typeOf(bad_eql_1)); }
14151415 \\export fn entry2() usize { return @sizeOf(@typeOf(bad_eql_2)); }
14161416 ,
14171417 ".tmp_source.zig:2:14: error: operator not allowed for type '[]u8'",
1418 ".tmp_source.zig:9:15: error: operator not allowed for type 'EnumWithData'");
1418 ".tmp_source.zig:9:16: error: operator not allowed for type 'EnumWithData'");
14191419
14201420 cases.add("non-const switch number literal",
14211421 \\export fn foo() void {
......@@ -1513,7 +1513,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
15131513 \\var bytes: [ext()]u8 = undefined;
15141514 \\export fn f() void {
15151515 \\ for (bytes) |*b, i| {
1516 \\ *b = u8(i);
1516 \\ b.* = u8(i);
15171517 \\ }
15181518 \\}
15191519 , ".tmp_source.zig:2:13: error: unable to evaluate constant expression");
......@@ -1819,7 +1819,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
18191819 \\}
18201820 \\
18211821 \\fn bar(x: &const u3) u3 {
1822 \\ return *x;
1822 \\ return x.*;
18231823 \\}
18241824 \\
18251825 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
......@@ -1903,12 +1903,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
19031903 \\var s_buffer: [10]u8 = undefined;
19041904 \\pub fn pass(in: []u8) []u8 {
19051905 \\ var out = &s_buffer;
1906 \\ *out[0] = in[0];
1907 \\ return (*out)[0..1];
1906 \\ out[0].* = in[0];
1907 \\ return out.*[0..1];
19081908 \\}
19091909 \\
19101910 \\export fn entry() usize { return @sizeOf(@typeOf(pass)); }
1911 , ".tmp_source.zig:4:5: error: attempt to dereference non pointer type '[10]u8'");
1911 , ".tmp_source.zig:4:11: error: attempt to dereference non pointer type '[10]u8'");
19121912
19131913 cases.add("pass const ptr to mutable ptr fn",
19141914 \\fn foo() bool {
......@@ -2434,7 +2434,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
24342434 \\}
24352435 \\
24362436 \\fn bar(x: &u32) void {
2437 \\ *x += 1;
2437 \\ x.* += 1;
24382438 \\}
24392439 ,
24402440 ".tmp_source.zig:8:13: error: expected type '&u32', found '&align(1) u32'");
......@@ -2461,7 +2461,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
24612461 \\export fn entry() u32 {
24622462 \\ var bytes: [4]u8 = []u8{0x01, 0x02, 0x03, 0x04};
24632463 \\ const ptr = @ptrCast(&u32, &bytes[0]);
2464 \\ return *ptr;
2464 \\ return ptr.*;
24652465 \\}
24662466 ,
24672467 ".tmp_source.zig:3:17: error: cast increases pointer alignment",
......@@ -2540,14 +2540,14 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
25402540 \\
25412541 \\export fn entry(opaque: &Opaque) void {
25422542 \\ var m2 = &2;
2543 \\ const y: u32 = *m2;
2543 \\ const y: u32 = m2.*;
25442544 \\
25452545 \\ var a = undefined;
25462546 \\ var b = 1;
25472547 \\ var c = 1.0;
25482548 \\ var d = this;
25492549 \\ var e = null;
2550 \\ var f = *opaque;
2550 \\ var f = opaque.*;
25512551 \\ var g = i32;
25522552 \\ var h = @import("std");
25532553 \\ var i = (Foo {}).bar;
......@@ -3136,13 +3136,13 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
31363136 \\ foo(a);
31373137 \\}
31383138 \\fn foo(a: &const Payload) void {
3139 \\ switch (*a) {
3139 \\ switch (a.*) {
31403140 \\ Payload.A => {},
31413141 \\ else => unreachable,
31423142 \\ }
31433143 \\}
31443144 ,
3145 ".tmp_source.zig:11:13: error: switch on union which has no attached enum",
3145 ".tmp_source.zig:11:14: error: switch on union which has no attached enum",
31463146 ".tmp_source.zig:1:17: note: consider 'union(enum)' here");
31473147
31483148 cases.add("enum in field count range but not matching tag",
test/standalone/brace_expansion/main.zig+23-20
......@@ -16,7 +16,7 @@ const Token = union(enum) {
1616
1717var global_allocator: &mem.Allocator = undefined;
1818
19fn tokenize(input:[] const u8) !ArrayList(Token) {
19fn tokenize(input: []const u8) !ArrayList(Token) {
2020 const State = enum {
2121 Start,
2222 Word,
......@@ -29,7 +29,8 @@ fn tokenize(input:[] const u8) !ArrayList(Token) {
2929 for (input) |b, i| {
3030 switch (state) {
3131 State.Start => switch (b) {
32 'a'...'z', 'A'...'Z' => {
32 'a' ... 'z',
33 'A' ... 'Z' => {
3334 state = State.Word;
3435 tok_begin = i;
3536 },
......@@ -39,9 +40,12 @@ fn tokenize(input:[] const u8) !ArrayList(Token) {
3940 else => return error.InvalidInput,
4041 },
4142 State.Word => switch (b) {
42 'a'...'z', 'A'...'Z' => {},
43 '{', '}', ',' => {
44 try token_list.append(Token { .Word = input[tok_begin..i] });
43 'a' ... 'z',
44 'A' ... 'Z' => {},
45 '{',
46 '}',
47 ',' => {
48 try token_list.append(Token{ .Word = input[tok_begin..i] });
4549 switch (b) {
4650 '{' => try token_list.append(Token.OpenBrace),
4751 '}' => try token_list.append(Token.CloseBrace),
......@@ -56,7 +60,7 @@ fn tokenize(input:[] const u8) !ArrayList(Token) {
5660 }
5761 switch (state) {
5862 State.Start => {},
59 State.Word => try token_list.append(Token {.Word = input[tok_begin..] }),
63 State.Word => try token_list.append(Token{ .Word = input[tok_begin..] }),
6064 }
6165 try token_list.append(Token.Eof);
6266 return token_list;
......@@ -68,24 +72,24 @@ const Node = union(enum) {
6872 Combine: []Node,
6973};
7074
71const ParseError = error {
75const ParseError = error{
7276 InvalidInput,
7377 OutOfMemory,
7478};
7579
7680fn parse(tokens: &const ArrayList(Token), token_index: &usize) ParseError!Node {
77 const first_token = tokens.items[*token_index];
78 *token_index += 1;
81 const first_token = tokens.items[token_index.*];
82 token_index.* += 1;
7983
8084 const result_node = switch (first_token) {
81 Token.Word => |word| Node { .Scalar = word },
85 Token.Word => |word| Node{ .Scalar = word },
8286 Token.OpenBrace => blk: {
8387 var list = ArrayList(Node).init(global_allocator);
8488 while (true) {
8589 try list.append(try parse(tokens, token_index));
8690
87 const token = tokens.items[*token_index];
88 *token_index += 1;
91 const token = tokens.items[token_index.*];
92 token_index.* += 1;
8993
9094 switch (token) {
9195 Token.CloseBrace => break,
......@@ -93,17 +97,18 @@ fn parse(tokens: &const ArrayList(Token), token_index: &usize) ParseError!Node {
9397 else => return error.InvalidInput,
9498 }
9599 }
96 break :blk Node { .List = list };
100 break :blk Node{ .List = list };
97101 },
98102 else => return error.InvalidInput,
99103 };
100104
101 switch (tokens.items[*token_index]) {
102 Token.Word, Token.OpenBrace => {
105 switch (tokens.items[token_index.*]) {
106 Token.Word,
107 Token.OpenBrace => {
103108 const pair = try global_allocator.alloc(Node, 2);
104109 pair[0] = result_node;
105110 pair[1] = try parse(tokens, token_index);
106 return Node { .Combine = pair };
111 return Node{ .Combine = pair };
107112 },
108113 else => return result_node,
109114 }
......@@ -137,13 +142,11 @@ fn expandString(input: []const u8, output: &Buffer) !void {
137142 }
138143}
139144
140const ExpandNodeError = error {
141 OutOfMemory,
142};
145const ExpandNodeError = error{OutOfMemory};
143146
144147fn expandNode(node: &const Node, output: &ArrayList(Buffer)) ExpandNodeError!void {
145148 assert(output.len == 0);
146 switch (*node) {
149 switch (node.*) {
147150 Node.Scalar => |scalar| {
148151 try output.append(try Buffer.init(global_allocator, scalar));
149152 },
test/tests.zig+90-100
......@@ -27,18 +27,18 @@ const TestTarget = struct {
2727 environ: builtin.Environ,
2828};
2929
30const test_targets = []TestTarget {
31 TestTarget {
30const test_targets = []TestTarget{
31 TestTarget{
3232 .os = builtin.Os.linux,
3333 .arch = builtin.Arch.x86_64,
3434 .environ = builtin.Environ.gnu,
3535 },
36 TestTarget {
36 TestTarget{
3737 .os = builtin.Os.macosx,
3838 .arch = builtin.Arch.x86_64,
3939 .environ = builtin.Environ.unknown,
4040 },
41 TestTarget {
41 TestTarget{
4242 .os = builtin.Os.windows,
4343 .arch = builtin.Arch.x86_64,
4444 .environ = builtin.Environ.msvc,
......@@ -49,7 +49,7 @@ const max_stdout_size = 1 * 1024 * 1024; // 1 MB
4949
5050pub fn addCompareOutputTests(b: &build.Builder, test_filter: ?[]const u8) &build.Step {
5151 const cases = b.allocator.create(CompareOutputContext) catch unreachable;
52 *cases = CompareOutputContext {
52 cases.* = CompareOutputContext{
5353 .b = b,
5454 .step = b.step("test-compare-output", "Run the compare output tests"),
5555 .test_index = 0,
......@@ -63,7 +63,7 @@ pub fn addCompareOutputTests(b: &build.Builder, test_filter: ?[]const u8) &build
6363
6464pub fn addRuntimeSafetyTests(b: &build.Builder, test_filter: ?[]const u8) &build.Step {
6565 const cases = b.allocator.create(CompareOutputContext) catch unreachable;
66 *cases = CompareOutputContext {
66 cases.* = CompareOutputContext{
6767 .b = b,
6868 .step = b.step("test-runtime-safety", "Run the runtime safety tests"),
6969 .test_index = 0,
......@@ -77,7 +77,7 @@ pub fn addRuntimeSafetyTests(b: &build.Builder, test_filter: ?[]const u8) &build
7777
7878pub fn addCompileErrorTests(b: &build.Builder, test_filter: ?[]const u8) &build.Step {
7979 const cases = b.allocator.create(CompileErrorContext) catch unreachable;
80 *cases = CompileErrorContext {
80 cases.* = CompileErrorContext{
8181 .b = b,
8282 .step = b.step("test-compile-errors", "Run the compile error tests"),
8383 .test_index = 0,
......@@ -91,7 +91,7 @@ pub fn addCompileErrorTests(b: &build.Builder, test_filter: ?[]const u8) &build.
9191
9292pub fn addBuildExampleTests(b: &build.Builder, test_filter: ?[]const u8) &build.Step {
9393 const cases = b.allocator.create(BuildExamplesContext) catch unreachable;
94 *cases = BuildExamplesContext {
94 cases.* = BuildExamplesContext{
9595 .b = b,
9696 .step = b.step("test-build-examples", "Build the examples"),
9797 .test_index = 0,
......@@ -105,7 +105,7 @@ pub fn addBuildExampleTests(b: &build.Builder, test_filter: ?[]const u8) &build.
105105
106106pub fn addAssembleAndLinkTests(b: &build.Builder, test_filter: ?[]const u8) &build.Step {
107107 const cases = b.allocator.create(CompareOutputContext) catch unreachable;
108 *cases = CompareOutputContext {
108 cases.* = CompareOutputContext{
109109 .b = b,
110110 .step = b.step("test-asm-link", "Run the assemble and link tests"),
111111 .test_index = 0,
......@@ -119,7 +119,7 @@ pub fn addAssembleAndLinkTests(b: &build.Builder, test_filter: ?[]const u8) &bui
119119
120120pub fn addTranslateCTests(b: &build.Builder, test_filter: ?[]const u8) &build.Step {
121121 const cases = b.allocator.create(TranslateCContext) catch unreachable;
122 *cases = TranslateCContext {
122 cases.* = TranslateCContext{
123123 .b = b,
124124 .step = b.step("test-translate-c", "Run the C transation tests"),
125125 .test_index = 0,
......@@ -133,7 +133,7 @@ pub fn addTranslateCTests(b: &build.Builder, test_filter: ?[]const u8) &build.St
133133
134134pub fn addGenHTests(b: &build.Builder, test_filter: ?[]const u8) &build.Step {
135135 const cases = b.allocator.create(GenHContext) catch unreachable;
136 *cases = GenHContext {
136 cases.* = GenHContext{
137137 .b = b,
138138 .step = b.step("test-gen-h", "Run the C header file generation tests"),
139139 .test_index = 0,
......@@ -145,22 +145,26 @@ pub fn addGenHTests(b: &build.Builder, test_filter: ?[]const u8) &build.Step {
145145 return cases.step;
146146}
147147
148
149pub fn addPkgTests(b: &build.Builder, test_filter: ?[]const u8, root_src: []const u8,
150 name:[] const u8, desc: []const u8, with_lldb: bool) &build.Step
151{
148pub fn addPkgTests(b: &build.Builder, test_filter: ?[]const u8, root_src: []const u8, name: []const u8, desc: []const u8, with_lldb: bool) &build.Step {
152149 const step = b.step(b.fmt("test-{}", name), desc);
153150 for (test_targets) |test_target| {
154151 const is_native = (test_target.os == builtin.os and test_target.arch == builtin.arch);
155 for ([]Mode{Mode.Debug, Mode.ReleaseSafe, Mode.ReleaseFast, Mode.ReleaseSmall}) |mode| {
156 for ([]bool{false, true}) |link_libc| {
152 for ([]Mode{
153 Mode.Debug,
154 Mode.ReleaseSafe,
155 Mode.ReleaseFast,
156 Mode.ReleaseSmall,
157 }) |mode| {
158 for ([]bool{
159 false,
160 true,
161 }) |link_libc| {
157162 if (link_libc and !is_native) {
158163 // don't assume we have a cross-compiling libc set up
159164 continue;
160165 }
161166 const these_tests = b.addTest(root_src);
162 these_tests.setNamePrefix(b.fmt("{}-{}-{}-{}-{} ", name, @tagName(test_target.os),
163 @tagName(test_target.arch), @tagName(mode), if (link_libc) "c" else "bare"));
167 these_tests.setNamePrefix(b.fmt("{}-{}-{}-{}-{} ", name, @tagName(test_target.os), @tagName(test_target.arch), @tagName(mode), if (link_libc) "c" else "bare"));
164168 these_tests.setFilter(test_filter);
165169 these_tests.setBuildMode(mode);
166170 if (!is_native) {
......@@ -171,7 +175,15 @@ pub fn addPkgTests(b: &build.Builder, test_filter: ?[]const u8, root_src: []cons
171175 }
172176 if (with_lldb) {
173177 these_tests.setExecCmd([]?[]const u8{
174 "lldb", null, "-o", "run", "-o", "bt", "-o", "exit"});
178 "lldb",
179 null,
180 "-o",
181 "run",
182 "-o",
183 "bt",
184 "-o",
185 "exit",
186 });
175187 }
176188 step.dependOn(&these_tests.step);
177189 }
......@@ -206,7 +218,7 @@ pub const CompareOutputContext = struct {
206218 };
207219
208220 pub fn addSourceFile(self: &TestCase, filename: []const u8, source: []const u8) void {
209 self.sources.append(SourceFile {
221 self.sources.append(SourceFile{
210222 .filename = filename,
211223 .source = source,
212224 }) catch unreachable;
......@@ -226,13 +238,10 @@ pub const CompareOutputContext = struct {
226238 test_index: usize,
227239 cli_args: []const []const u8,
228240
229 pub fn create(context: &CompareOutputContext, exe_path: []const u8,
230 name: []const u8, expected_output: []const u8,
231 cli_args: []const []const u8) &RunCompareOutputStep
232 {
241 pub fn create(context: &CompareOutputContext, exe_path: []const u8, name: []const u8, expected_output: []const u8, cli_args: []const []const u8) &RunCompareOutputStep {
233242 const allocator = context.b.allocator;
234243 const ptr = allocator.create(RunCompareOutputStep) catch unreachable;
235 *ptr = RunCompareOutputStep {
244 ptr.* = RunCompareOutputStep{
236245 .context = context,
237246 .exe_path = exe_path,
238247 .name = name,
......@@ -258,7 +267,7 @@ pub const CompareOutputContext = struct {
258267 args.append(arg) catch unreachable;
259268 }
260269
261 warn("Test {}/{} {}...", self.test_index+1, self.context.test_index, self.name);
270 warn("Test {}/{} {}...", self.test_index + 1, self.context.test_index, self.name);
262271
263272 const child = os.ChildProcess.init(args.toSliceConst(), b.allocator) catch unreachable;
264273 defer child.deinit();
......@@ -295,7 +304,6 @@ pub const CompareOutputContext = struct {
295304 },
296305 }
297306
298
299307 if (!mem.eql(u8, self.expected_output, stdout.toSliceConst())) {
300308 warn(
301309 \\
......@@ -318,12 +326,10 @@ pub const CompareOutputContext = struct {
318326 name: []const u8,
319327 test_index: usize,
320328
321 pub fn create(context: &CompareOutputContext, exe_path: []const u8,
322 name: []const u8) &RuntimeSafetyRunStep
323 {
329 pub fn create(context: &CompareOutputContext, exe_path: []const u8, name: []const u8) &RuntimeSafetyRunStep {
324330 const allocator = context.b.allocator;
325331 const ptr = allocator.create(RuntimeSafetyRunStep) catch unreachable;
326 *ptr = RuntimeSafetyRunStep {
332 ptr.* = RuntimeSafetyRunStep{
327333 .context = context,
328334 .exe_path = exe_path,
329335 .name = name,
......@@ -340,7 +346,7 @@ pub const CompareOutputContext = struct {
340346
341347 const full_exe_path = b.pathFromRoot(self.exe_path);
342348
343 warn("Test {}/{} {}...", self.test_index+1, self.context.test_index, self.name);
349 warn("Test {}/{} {}...", self.test_index + 1, self.context.test_index, self.name);
344350
345351 const child = os.ChildProcess.init([][]u8{full_exe_path}, b.allocator) catch unreachable;
346352 defer child.deinit();
......@@ -358,19 +364,16 @@ pub const CompareOutputContext = struct {
358364 switch (term) {
359365 Term.Exited => |code| {
360366 if (code != expected_exit_code) {
361 warn("\nProgram expected to exit with code {} " ++
362 "but exited with code {}\n", expected_exit_code, code);
367 warn("\nProgram expected to exit with code {} " ++ "but exited with code {}\n", expected_exit_code, code);
363368 return error.TestFailed;
364369 }
365370 },
366371 Term.Signal => |sig| {
367 warn("\nProgram expected to exit with code {} " ++
368 "but instead signaled {}\n", expected_exit_code, sig);
372 warn("\nProgram expected to exit with code {} " ++ "but instead signaled {}\n", expected_exit_code, sig);
369373 return error.TestFailed;
370374 },
371375 else => {
372 warn("\nProgram expected to exit with code {}" ++
373 " but exited in an unexpected way\n", expected_exit_code);
376 warn("\nProgram expected to exit with code {}" ++ " but exited in an unexpected way\n", expected_exit_code);
374377 return error.TestFailed;
375378 },
376379 }
......@@ -379,10 +382,8 @@ pub const CompareOutputContext = struct {
379382 }
380383 };
381384
382 pub fn createExtra(self: &CompareOutputContext, name: []const u8, source: []const u8,
383 expected_output: []const u8, special: Special) TestCase
384 {
385 var tc = TestCase {
385 pub fn createExtra(self: &CompareOutputContext, name: []const u8, source: []const u8, expected_output: []const u8, special: Special) TestCase {
386 var tc = TestCase{
386387 .name = name,
387388 .sources = ArrayList(TestCase.SourceFile).init(self.b.allocator),
388389 .expected_output = expected_output,
......@@ -395,9 +396,7 @@ pub const CompareOutputContext = struct {
395396 return tc;
396397 }
397398
398 pub fn create(self: &CompareOutputContext, name: []const u8, source: []const u8,
399 expected_output: []const u8) TestCase
400 {
399 pub fn create(self: &CompareOutputContext, name: []const u8, source: []const u8, expected_output: []const u8) TestCase {
401400 return createExtra(self, name, source, expected_output, Special.None);
402401 }
403402
......@@ -431,8 +430,7 @@ pub const CompareOutputContext = struct {
431430 Special.Asm => {
432431 const annotated_case_name = fmt.allocPrint(self.b.allocator, "assemble-and-link {}", case.name) catch unreachable;
433432 if (self.test_filter) |filter| {
434 if (mem.indexOf(u8, annotated_case_name, filter) == null)
435 return;
433 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
436434 }
437435
438436 const exe = b.addExecutable("test", null);
......@@ -444,19 +442,21 @@ pub const CompareOutputContext = struct {
444442 exe.step.dependOn(&write_src.step);
445443 }
446444
447 const run_and_cmp_output = RunCompareOutputStep.create(self, exe.getOutputPath(), annotated_case_name,
448 case.expected_output, case.cli_args);
445 const run_and_cmp_output = RunCompareOutputStep.create(self, exe.getOutputPath(), annotated_case_name, case.expected_output, case.cli_args);
449446 run_and_cmp_output.step.dependOn(&exe.step);
450447
451448 self.step.dependOn(&run_and_cmp_output.step);
452449 },
453450 Special.None => {
454 for ([]Mode{Mode.Debug, Mode.ReleaseSafe, Mode.ReleaseFast, Mode.ReleaseSmall}) |mode| {
455 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {} ({})",
456 "compare-output", case.name, @tagName(mode)) catch unreachable;
451 for ([]Mode{
452 Mode.Debug,
453 Mode.ReleaseSafe,
454 Mode.ReleaseFast,
455 Mode.ReleaseSmall,
456 }) |mode| {
457 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {} ({})", "compare-output", case.name, @tagName(mode)) catch unreachable;
457458 if (self.test_filter) |filter| {
458 if (mem.indexOf(u8, annotated_case_name, filter) == null)
459 continue;
459 if (mem.indexOf(u8, annotated_case_name, filter) == null) continue;
460460 }
461461
462462 const exe = b.addExecutable("test", root_src);
......@@ -471,8 +471,7 @@ pub const CompareOutputContext = struct {
471471 exe.step.dependOn(&write_src.step);
472472 }
473473
474 const run_and_cmp_output = RunCompareOutputStep.create(self, exe.getOutputPath(),
475 annotated_case_name, case.expected_output, case.cli_args);
474 const run_and_cmp_output = RunCompareOutputStep.create(self, exe.getOutputPath(), annotated_case_name, case.expected_output, case.cli_args);
476475 run_and_cmp_output.step.dependOn(&exe.step);
477476
478477 self.step.dependOn(&run_and_cmp_output.step);
......@@ -481,8 +480,7 @@ pub const CompareOutputContext = struct {
481480 Special.RuntimeSafety => {
482481 const annotated_case_name = fmt.allocPrint(self.b.allocator, "safety {}", case.name) catch unreachable;
483482 if (self.test_filter) |filter| {
484 if (mem.indexOf(u8, annotated_case_name, filter) == null)
485 return;
483 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
486484 }
487485
488486 const exe = b.addExecutable("test", root_src);
......@@ -524,7 +522,7 @@ pub const CompileErrorContext = struct {
524522 };
525523
526524 pub fn addSourceFile(self: &TestCase, filename: []const u8, source: []const u8) void {
527 self.sources.append(SourceFile {
525 self.sources.append(SourceFile{
528526 .filename = filename,
529527 .source = source,
530528 }) catch unreachable;
......@@ -543,12 +541,10 @@ pub const CompileErrorContext = struct {
543541 case: &const TestCase,
544542 build_mode: Mode,
545543
546 pub fn create(context: &CompileErrorContext, name: []const u8,
547 case: &const TestCase, build_mode: Mode) &CompileCmpOutputStep
548 {
544 pub fn create(context: &CompileErrorContext, name: []const u8, case: &const TestCase, build_mode: Mode) &CompileCmpOutputStep {
549545 const allocator = context.b.allocator;
550546 const ptr = allocator.create(CompileCmpOutputStep) catch unreachable;
551 *ptr = CompileCmpOutputStep {
547 ptr.* = CompileCmpOutputStep{
552548 .step = build.Step.init("CompileCmpOutput", allocator, make),
553549 .context = context,
554550 .name = name,
......@@ -586,7 +582,7 @@ pub const CompileErrorContext = struct {
586582 Mode.ReleaseSmall => zig_args.append("--release-small") catch unreachable,
587583 }
588584
589 warn("Test {}/{} {}...", self.test_index+1, self.context.test_index, self.name);
585 warn("Test {}/{} {}...", self.test_index + 1, self.context.test_index, self.name);
590586
591587 if (b.verbose) {
592588 printInvocation(zig_args.toSliceConst());
......@@ -626,7 +622,6 @@ pub const CompileErrorContext = struct {
626622 },
627623 }
628624
629
630625 const stdout = stdout_buf.toSliceConst();
631626 const stderr = stderr_buf.toSliceConst();
632627
......@@ -666,11 +661,9 @@ pub const CompileErrorContext = struct {
666661 warn("\n");
667662 }
668663
669 pub fn create(self: &CompileErrorContext, name: []const u8, source: []const u8,
670 expected_lines: ...) &TestCase
671 {
664 pub fn create(self: &CompileErrorContext, name: []const u8, source: []const u8, expected_lines: ...) &TestCase {
672665 const tc = self.b.allocator.create(TestCase) catch unreachable;
673 *tc = TestCase {
666 tc.* = TestCase{
674667 .name = name,
675668 .sources = ArrayList(TestCase.SourceFile).init(self.b.allocator),
676669 .expected_errors = ArrayList([]const u8).init(self.b.allocator),
......@@ -705,12 +698,13 @@ pub const CompileErrorContext = struct {
705698 pub fn addCase(self: &CompileErrorContext, case: &const TestCase) void {
706699 const b = self.b;
707700
708 for ([]Mode{Mode.Debug, Mode.ReleaseFast}) |mode| {
709 const annotated_case_name = fmt.allocPrint(self.b.allocator, "compile-error {} ({})",
710 case.name, @tagName(mode)) catch unreachable;
701 for ([]Mode{
702 Mode.Debug,
703 Mode.ReleaseFast,
704 }) |mode| {
705 const annotated_case_name = fmt.allocPrint(self.b.allocator, "compile-error {} ({})", case.name, @tagName(mode)) catch unreachable;
711706 if (self.test_filter) |filter| {
712 if (mem.indexOf(u8, annotated_case_name, filter) == null)
713 continue;
707 if (mem.indexOf(u8, annotated_case_name, filter) == null) continue;
714708 }
715709
716710 const compile_and_cmp_errors = CompileCmpOutputStep.create(self, annotated_case_name, case, mode);
......@@ -744,8 +738,7 @@ pub const BuildExamplesContext = struct {
744738
745739 const annotated_case_name = b.fmt("build {} (Debug)", build_file);
746740 if (self.test_filter) |filter| {
747 if (mem.indexOf(u8, annotated_case_name, filter) == null)
748 return;
741 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
749742 }
750743
751744 var zig_args = ArrayList([]const u8).init(b.allocator);
......@@ -773,12 +766,15 @@ pub const BuildExamplesContext = struct {
773766 pub fn addAllArgs(self: &BuildExamplesContext, root_src: []const u8, link_libc: bool) void {
774767 const b = self.b;
775768
776 for ([]Mode{Mode.Debug, Mode.ReleaseSafe, Mode.ReleaseFast, Mode.ReleaseSmall}) |mode| {
777 const annotated_case_name = fmt.allocPrint(self.b.allocator, "build {} ({})",
778 root_src, @tagName(mode)) catch unreachable;
769 for ([]Mode{
770 Mode.Debug,
771 Mode.ReleaseSafe,
772 Mode.ReleaseFast,
773 Mode.ReleaseSmall,
774 }) |mode| {
775 const annotated_case_name = fmt.allocPrint(self.b.allocator, "build {} ({})", root_src, @tagName(mode)) catch unreachable;
779776 if (self.test_filter) |filter| {
780 if (mem.indexOf(u8, annotated_case_name, filter) == null)
781 continue;
777 if (mem.indexOf(u8, annotated_case_name, filter) == null) continue;
782778 }
783779
784780 const exe = b.addExecutable("test", root_src);
......@@ -813,7 +809,7 @@ pub const TranslateCContext = struct {
813809 };
814810
815811 pub fn addSourceFile(self: &TestCase, filename: []const u8, source: []const u8) void {
816 self.sources.append(SourceFile {
812 self.sources.append(SourceFile{
817813 .filename = filename,
818814 .source = source,
819815 }) catch unreachable;
......@@ -834,7 +830,7 @@ pub const TranslateCContext = struct {
834830 pub fn create(context: &TranslateCContext, name: []const u8, case: &const TestCase) &TranslateCCmpOutputStep {
835831 const allocator = context.b.allocator;
836832 const ptr = allocator.create(TranslateCCmpOutputStep) catch unreachable;
837 *ptr = TranslateCCmpOutputStep {
833 ptr.* = TranslateCCmpOutputStep{
838834 .step = build.Step.init("ParseCCmpOutput", allocator, make),
839835 .context = context,
840836 .name = name,
......@@ -857,7 +853,7 @@ pub const TranslateCContext = struct {
857853 zig_args.append("translate-c") catch unreachable;
858854 zig_args.append(b.pathFromRoot(root_src)) catch unreachable;
859855
860 warn("Test {}/{} {}...", self.test_index+1, self.context.test_index, self.name);
856 warn("Test {}/{} {}...", self.test_index + 1, self.context.test_index, self.name);
861857
862858 if (b.verbose) {
863859 printInvocation(zig_args.toSliceConst());
......@@ -939,11 +935,9 @@ pub const TranslateCContext = struct {
939935 warn("\n");
940936 }
941937
942 pub fn create(self: &TranslateCContext, allow_warnings: bool, filename: []const u8, name: []const u8,
943 source: []const u8, expected_lines: ...) &TestCase
944 {
938 pub fn create(self: &TranslateCContext, allow_warnings: bool, filename: []const u8, name: []const u8, source: []const u8, expected_lines: ...) &TestCase {
945939 const tc = self.b.allocator.create(TestCase) catch unreachable;
946 *tc = TestCase {
940 tc.* = TestCase{
947941 .name = name,
948942 .sources = ArrayList(TestCase.SourceFile).init(self.b.allocator),
949943 .expected_lines = ArrayList([]const u8).init(self.b.allocator),
......@@ -977,8 +971,7 @@ pub const TranslateCContext = struct {
977971
978972 const annotated_case_name = fmt.allocPrint(self.b.allocator, "translate-c {}", case.name) catch unreachable;
979973 if (self.test_filter) |filter| {
980 if (mem.indexOf(u8, annotated_case_name, filter) == null)
981 return;
974 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
982975 }
983976
984977 const translate_c_and_cmp = TranslateCCmpOutputStep.create(self, annotated_case_name, case);
......@@ -1009,7 +1002,7 @@ pub const GenHContext = struct {
10091002 };
10101003
10111004 pub fn addSourceFile(self: &TestCase, filename: []const u8, source: []const u8) void {
1012 self.sources.append(SourceFile {
1005 self.sources.append(SourceFile{
10131006 .filename = filename,
10141007 .source = source,
10151008 }) catch unreachable;
......@@ -1031,7 +1024,7 @@ pub const GenHContext = struct {
10311024 pub fn create(context: &GenHContext, h_path: []const u8, name: []const u8, case: &const TestCase) &GenHCmpOutputStep {
10321025 const allocator = context.b.allocator;
10331026 const ptr = allocator.create(GenHCmpOutputStep) catch unreachable;
1034 *ptr = GenHCmpOutputStep {
1027 ptr.* = GenHCmpOutputStep{
10351028 .step = build.Step.init("ParseCCmpOutput", allocator, make),
10361029 .context = context,
10371030 .h_path = h_path,
......@@ -1047,7 +1040,7 @@ pub const GenHContext = struct {
10471040 const self = @fieldParentPtr(GenHCmpOutputStep, "step", step);
10481041 const b = self.context.b;
10491042
1050 warn("Test {}/{} {}...", self.test_index+1, self.context.test_index, self.name);
1043 warn("Test {}/{} {}...", self.test_index + 1, self.context.test_index, self.name);
10511044
10521045 const full_h_path = b.pathFromRoot(self.h_path);
10531046 const actual_h = try io.readFileAlloc(b.allocator, full_h_path);
......@@ -1076,11 +1069,9 @@ pub const GenHContext = struct {
10761069 warn("\n");
10771070 }
10781071
1079 pub fn create(self: &GenHContext, filename: []const u8, name: []const u8,
1080 source: []const u8, expected_lines: ...) &TestCase
1081 {
1072 pub fn create(self: &GenHContext, filename: []const u8, name: []const u8, source: []const u8, expected_lines: ...) &TestCase {
10821073 const tc = self.b.allocator.create(TestCase) catch unreachable;
1083 *tc = TestCase {
1074 tc.* = TestCase{
10841075 .name = name,
10851076 .sources = ArrayList(TestCase.SourceFile).init(self.b.allocator),
10861077 .expected_lines = ArrayList([]const u8).init(self.b.allocator),
......@@ -1105,8 +1096,7 @@ pub const GenHContext = struct {
11051096 const mode = builtin.Mode.Debug;
11061097 const annotated_case_name = fmt.allocPrint(self.b.allocator, "gen-h {} ({})", case.name, @tagName(mode)) catch unreachable;
11071098 if (self.test_filter) |filter| {
1108 if (mem.indexOf(u8, annotated_case_name, filter) == null)
1109 return;
1099 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
11101100 }
11111101
11121102 const obj = b.addObject("test", root_src);
test/translate_c.zig+50-50
......@@ -720,43 +720,43 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
720720 \\ var a: c_int = 0;
721721 \\ a += x: {
722722 \\ const _ref = &a;
723 \\ (*_ref) = ((*_ref) + 1);
724 \\ break :x *_ref;
723 \\ _ref.* = (_ref.* + 1);
724 \\ break :x _ref.*;
725725 \\ };
726726 \\ a -= x: {
727727 \\ const _ref = &a;
728 \\ (*_ref) = ((*_ref) - 1);
729 \\ break :x *_ref;
728 \\ _ref.* = (_ref.* - 1);
729 \\ break :x _ref.*;
730730 \\ };
731731 \\ a *= x: {
732732 \\ const _ref = &a;
733 \\ (*_ref) = ((*_ref) * 1);
734 \\ break :x *_ref;
733 \\ _ref.* = (_ref.* * 1);
734 \\ break :x _ref.*;
735735 \\ };
736736 \\ a &= x: {
737737 \\ const _ref = &a;
738 \\ (*_ref) = ((*_ref) & 1);
739 \\ break :x *_ref;
738 \\ _ref.* = (_ref.* & 1);
739 \\ break :x _ref.*;
740740 \\ };
741741 \\ a |= x: {
742742 \\ const _ref = &a;
743 \\ (*_ref) = ((*_ref) | 1);
744 \\ break :x *_ref;
743 \\ _ref.* = (_ref.* | 1);
744 \\ break :x _ref.*;
745745 \\ };
746746 \\ a ^= x: {
747747 \\ const _ref = &a;
748 \\ (*_ref) = ((*_ref) ^ 1);
749 \\ break :x *_ref;
748 \\ _ref.* = (_ref.* ^ 1);
749 \\ break :x _ref.*;
750750 \\ };
751751 \\ a >>= @import("std").math.Log2Int(c_int)(x: {
752752 \\ const _ref = &a;
753 \\ (*_ref) = ((*_ref) >> @import("std").math.Log2Int(c_int)(1));
754 \\ break :x *_ref;
753 \\ _ref.* = (_ref.* >> @import("std").math.Log2Int(c_int)(1));
754 \\ break :x _ref.*;
755755 \\ });
756756 \\ a <<= @import("std").math.Log2Int(c_int)(x: {
757757 \\ const _ref = &a;
758 \\ (*_ref) = ((*_ref) << @import("std").math.Log2Int(c_int)(1));
759 \\ break :x *_ref;
758 \\ _ref.* = (_ref.* << @import("std").math.Log2Int(c_int)(1));
759 \\ break :x _ref.*;
760760 \\ });
761761 \\}
762762 );
......@@ -778,43 +778,43 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
778778 \\ var a: c_uint = c_uint(0);
779779 \\ a +%= x: {
780780 \\ const _ref = &a;
781 \\ (*_ref) = ((*_ref) +% c_uint(1));
782 \\ break :x *_ref;
781 \\ _ref.* = (_ref.* +% c_uint(1));
782 \\ break :x _ref.*;
783783 \\ };
784784 \\ a -%= x: {
785785 \\ const _ref = &a;
786 \\ (*_ref) = ((*_ref) -% c_uint(1));
787 \\ break :x *_ref;
786 \\ _ref.* = (_ref.* -% c_uint(1));
787 \\ break :x _ref.*;
788788 \\ };
789789 \\ a *%= x: {
790790 \\ const _ref = &a;
791 \\ (*_ref) = ((*_ref) *% c_uint(1));
792 \\ break :x *_ref;
791 \\ _ref.* = (_ref.* *% c_uint(1));
792 \\ break :x _ref.*;
793793 \\ };
794794 \\ a &= x: {
795795 \\ const _ref = &a;
796 \\ (*_ref) = ((*_ref) & c_uint(1));
797 \\ break :x *_ref;
796 \\ _ref.* = (_ref.* & c_uint(1));
797 \\ break :x _ref.*;
798798 \\ };
799799 \\ a |= x: {
800800 \\ const _ref = &a;
801 \\ (*_ref) = ((*_ref) | c_uint(1));
802 \\ break :x *_ref;
801 \\ _ref.* = (_ref.* | c_uint(1));
802 \\ break :x _ref.*;
803803 \\ };
804804 \\ a ^= x: {
805805 \\ const _ref = &a;
806 \\ (*_ref) = ((*_ref) ^ c_uint(1));
807 \\ break :x *_ref;
806 \\ _ref.* = (_ref.* ^ c_uint(1));
807 \\ break :x _ref.*;
808808 \\ };
809809 \\ a >>= @import("std").math.Log2Int(c_uint)(x: {
810810 \\ const _ref = &a;
811 \\ (*_ref) = ((*_ref) >> @import("std").math.Log2Int(c_uint)(1));
812 \\ break :x *_ref;
811 \\ _ref.* = (_ref.* >> @import("std").math.Log2Int(c_uint)(1));
812 \\ break :x _ref.*;
813813 \\ });
814814 \\ a <<= @import("std").math.Log2Int(c_uint)(x: {
815815 \\ const _ref = &a;
816 \\ (*_ref) = ((*_ref) << @import("std").math.Log2Int(c_uint)(1));
817 \\ break :x *_ref;
816 \\ _ref.* = (_ref.* << @import("std").math.Log2Int(c_uint)(1));
817 \\ break :x _ref.*;
818818 \\ });
819819 \\}
820820 );
......@@ -853,26 +853,26 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
853853 \\ u -%= 1;
854854 \\ i = x: {
855855 \\ const _ref = &i;
856 \\ const _tmp = *_ref;
857 \\ (*_ref) += 1;
856 \\ const _tmp = _ref.*;
857 \\ _ref.* += 1;
858858 \\ break :x _tmp;
859859 \\ };
860860 \\ i = x: {
861861 \\ const _ref = &i;
862 \\ const _tmp = *_ref;
863 \\ (*_ref) -= 1;
862 \\ const _tmp = _ref.*;
863 \\ _ref.* -= 1;
864864 \\ break :x _tmp;
865865 \\ };
866866 \\ u = x: {
867867 \\ const _ref = &u;
868 \\ const _tmp = *_ref;
869 \\ (*_ref) +%= 1;
868 \\ const _tmp = _ref.*;
869 \\ _ref.* +%= 1;
870870 \\ break :x _tmp;
871871 \\ };
872872 \\ u = x: {
873873 \\ const _ref = &u;
874 \\ const _tmp = *_ref;
875 \\ (*_ref) -%= 1;
874 \\ const _tmp = _ref.*;
875 \\ _ref.* -%= 1;
876876 \\ break :x _tmp;
877877 \\ };
878878 \\}
......@@ -901,23 +901,23 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
901901 \\ u -%= 1;
902902 \\ i = x: {
903903 \\ const _ref = &i;
904 \\ (*_ref) += 1;
905 \\ break :x *_ref;
904 \\ _ref.* += 1;
905 \\ break :x _ref.*;
906906 \\ };
907907 \\ i = x: {
908908 \\ const _ref = &i;
909 \\ (*_ref) -= 1;
910 \\ break :x *_ref;
909 \\ _ref.* -= 1;
910 \\ break :x _ref.*;
911911 \\ };
912912 \\ u = x: {
913913 \\ const _ref = &u;
914 \\ (*_ref) +%= 1;
915 \\ break :x *_ref;
914 \\ _ref.* +%= 1;
915 \\ break :x _ref.*;
916916 \\ };
917917 \\ u = x: {
918918 \\ const _ref = &u;
919 \\ (*_ref) -%= 1;
920 \\ break :x *_ref;
919 \\ _ref.* -%= 1;
920 \\ break :x _ref.*;
921921 \\ };
922922 \\}
923923 );
......@@ -985,7 +985,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
985985 \\}
986986 ,
987987 \\pub export fn foo(x: ?&c_int) void {
988 \\ (*??x) = 1;
988 \\ (??x).* = 1;
989989 \\}
990990 );
991991
......@@ -1013,7 +1013,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
10131013 \\pub fn foo() c_int {
10141014 \\ var x: c_int = 1234;
10151015 \\ var ptr: ?&c_int = &x;
1016 \\ return *??ptr;
1016 \\ return (??ptr).*;
10171017 \\}
10181018 );
10191019