authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2023-11-10 08:04:39+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2023-11-19 09:55:07+00:00
log2c1acb618027939c0812bc87a432b51632127717
treef7f527b79797a2d7349d951f567e2385da902f3e
parent51595d6b75d8ac2443a2c142c71f2a617c12fe96
signaturelock-open Commit is signed but in an unrecognized format.

test: update translate-c tests to match new discard format


1 files changed, 59 insertions(+), 59 deletions(-)

test/translate_c.zig+59-59
......@@ -123,10 +123,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
123123 \\pub export fn foo() void {
124124 \\ while (true) if (true) {
125125 \\ var a: c_int = 1;
126 \\ _ = @TypeOf(a);
126 \\ _ = &a;
127127 \\ } else {
128128 \\ var b: c_int = 2;
129 \\ _ = @TypeOf(b);
129 \\ _ = &b;
130130 \\ };
131131 \\ if (true) if (true) {};
132132 \\}
......@@ -199,7 +199,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
199199 \\ .B = 0,
200200 \\ .C = 0,
201201 \\ };
202 \\ _ = @TypeOf(a);
202 \\ _ = &a;
203203 \\ {
204204 \\ const struct_Foo_1 = extern struct {
205205 \\ A: c_int = @import("std").mem.zeroes(c_int),
......@@ -211,7 +211,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
211211 \\ .B = 0,
212212 \\ .C = 0,
213213 \\ };
214 \\ _ = @TypeOf(a_2);
214 \\ _ = &a_2;
215215 \\ }
216216 \\}
217217 });
......@@ -240,24 +240,24 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
240240 \\ B: c_int,
241241 \\ C: c_int,
242242 \\ };
243 \\ _ = @TypeOf(union_unnamed_1);
243 \\ _ = &union_unnamed_1;
244244 \\ const Foo = union_unnamed_1;
245245 \\ var a: Foo = Foo{
246246 \\ .A = @as(c_int, 0),
247247 \\ };
248 \\ _ = @TypeOf(a);
248 \\ _ = &a;
249249 \\ {
250250 \\ const union_unnamed_2 = extern union {
251251 \\ A: c_int,
252252 \\ B: c_int,
253253 \\ C: c_int,
254254 \\ };
255 \\ _ = @TypeOf(union_unnamed_2);
255 \\ _ = &union_unnamed_2;
256256 \\ const Foo_1 = union_unnamed_2;
257257 \\ var a_2: Foo_1 = Foo_1{
258258 \\ .A = @as(c_int, 0),
259259 \\ };
260 \\ _ = @TypeOf(a_2);
260 \\ _ = &a_2;
261261 \\ }
262262 \\}
263263 });
......@@ -325,7 +325,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
325325 \\ const bar_1 = struct {
326326 \\ threadlocal var static: c_int = 2;
327327 \\ };
328 \\ _ = @TypeOf(bar_1);
328 \\ _ = &bar_1;
329329 \\ return 0;
330330 \\}
331331 });
......@@ -344,7 +344,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
344344 \\}
345345 \\pub export fn bar() c_int {
346346 \\ var a: c_int = 2;
347 \\ _ = @TypeOf(a);
347 \\ _ = &a;
348348 \\ return 0;
349349 \\}
350350 \\pub export fn baz() c_int {
......@@ -359,7 +359,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
359359 , &[_][]const u8{
360360 \\pub export fn main() void {
361361 \\ var a: c_int = @as(c_int, @bitCast(@as(c_uint, @truncate(@alignOf(c_int)))));
362 \\ _ = @TypeOf(a);
362 \\ _ = &a;
363363 \\}
364364 });
365365
......@@ -507,7 +507,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
507507 \\#define bar(x) (&x, +3, 4 == 4, 5 * 6, baz(1, 2), 2 % 2, baz(1,2))
508508 , &[_][]const u8{
509509 \\pub const foo = blk_1: {
510 \\ _ = @TypeOf(foo);
510 \\ _ = &foo;
511511 \\ break :blk_1 bar;
512512 \\};
513513 ,
......@@ -729,7 +729,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
729729 \\pub export fn function(arg_opaque_1: ?*struct_opaque) void {
730730 \\ var opaque_1 = arg_opaque_1;
731731 \\ var cast: ?*struct_opaque_2 = @as(?*struct_opaque_2, @ptrCast(opaque_1));
732 \\ _ = @TypeOf(cast);
732 \\ _ = &cast;
733733 \\}
734734 });
735735
......@@ -764,7 +764,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
764764 \\pub export fn my_fn() align(128) void {}
765765 \\pub export fn other_fn() void {
766766 \\ var ARR: [16]u8 align(16) = undefined;
767 \\ _ = @TypeOf(ARR);
767 \\ _ = &ARR;
768768 \\}
769769 });
770770 }
......@@ -801,17 +801,17 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
801801 , &[_][]const u8{
802802 \\pub export fn foo() void {
803803 \\ var a: c_int = undefined;
804 \\ _ = @TypeOf(a);
804 \\ _ = &a;
805805 \\ var b: u8 = 123;
806 \\ _ = @TypeOf(b);
806 \\ _ = &b;
807807 \\ const c: c_int = undefined;
808 \\ _ = @TypeOf(c);
808 \\ _ = &c;
809809 \\ const d: c_uint = @as(c_uint, @bitCast(@as(c_int, 440)));
810 \\ _ = @TypeOf(d);
810 \\ _ = &d;
811811 \\ var e: c_int = 10;
812 \\ _ = @TypeOf(e);
812 \\ _ = &e;
813813 \\ var f: c_uint = 10;
814 \\ _ = @TypeOf(f);
814 \\ _ = &f;
815815 \\}
816816 });
817817
......@@ -870,7 +870,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
870870 \\ const v2 = struct {
871871 \\ const static: [5:0]u8 = "2.2.2".*;
872872 \\ };
873 \\ _ = @TypeOf(v2);
873 \\ _ = &v2;
874874 \\}
875875 });
876876
......@@ -913,7 +913,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
913913 \\pub export fn bar() void {
914914 \\ var func_ptr: ?*anyopaque = @as(?*anyopaque, @ptrCast(&foo));
915915 \\ var typed_func_ptr: ?*const fn () callconv(.C) void = @as(?*const fn () callconv(.C) void, @ptrFromInt(@as(c_ulong, @intCast(@intFromPtr(func_ptr)))));
916 \\ _ = @TypeOf(typed_func_ptr);
916 \\ _ = &typed_func_ptr;
917917 \\}
918918 });
919919
......@@ -1360,7 +1360,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
13601360 , &[_][]const u8{
13611361 \\pub export fn foo() void {
13621362 \\ var a: c_int = undefined;
1363 \\ _ = @TypeOf(a);
1363 \\ _ = &a;
13641364 \\}
13651365 });
13661366
......@@ -1599,23 +1599,23 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
15991599 \\ var p: ?*anyopaque = undefined;
16001600 \\ {
16011601 \\ var to_char: [*c]u8 = @as([*c]u8, @ptrCast(@alignCast(p)));
1602 \\ _ = @TypeOf(to_char);
1602 \\ _ = &to_char;
16031603 \\ var to_short: [*c]c_short = @as([*c]c_short, @ptrCast(@alignCast(p)));
1604 \\ _ = @TypeOf(to_short);
1604 \\ _ = &to_short;
16051605 \\ var to_int: [*c]c_int = @as([*c]c_int, @ptrCast(@alignCast(p)));
1606 \\ _ = @TypeOf(to_int);
1606 \\ _ = &to_int;
16071607 \\ var to_longlong: [*c]c_longlong = @as([*c]c_longlong, @ptrCast(@alignCast(p)));
1608 \\ _ = @TypeOf(to_longlong);
1608 \\ _ = &to_longlong;
16091609 \\ }
16101610 \\ {
16111611 \\ var to_char: [*c]u8 = @as([*c]u8, @ptrCast(@alignCast(p)));
1612 \\ _ = @TypeOf(to_char);
1612 \\ _ = &to_char;
16131613 \\ var to_short: [*c]c_short = @as([*c]c_short, @ptrCast(@alignCast(p)));
1614 \\ _ = @TypeOf(to_short);
1614 \\ _ = &to_short;
16151615 \\ var to_int: [*c]c_int = @as([*c]c_int, @ptrCast(@alignCast(p)));
1616 \\ _ = @TypeOf(to_int);
1616 \\ _ = &to_int;
16171617 \\ var to_longlong: [*c]c_longlong = @as([*c]c_longlong, @ptrCast(@alignCast(p)));
1618 \\ _ = @TypeOf(to_longlong);
1618 \\ _ = &to_longlong;
16191619 \\ }
16201620 \\}
16211621 });
......@@ -1859,11 +1859,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
18591859 \\ var arr: [10]u8 = [1]u8{
18601860 \\ 1,
18611861 \\ } ++ [1]u8{0} ** 9;
1862 \\ _ = @TypeOf(arr);
1862 \\ _ = &arr;
18631863 \\ var arr1: [10][*c]u8 = [1][*c]u8{
18641864 \\ null,
18651865 \\ } ++ [1][*c]u8{null} ** 9;
1866 \\ _ = @TypeOf(arr1);
1866 \\ _ = &arr1;
18671867 \\}
18681868 });
18691869
......@@ -2107,16 +2107,16 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
21072107 \\pub var c: c_int = 4;
21082108 \\pub export fn foo(arg_c_1: u8) void {
21092109 \\ var c_1 = arg_c_1;
2110 \\ _ = @TypeOf(c_1);
2110 \\ _ = &c_1;
21112111 \\ var a_2: c_int = undefined;
21122112 \\ var b_3: u8 = 123;
21132113 \\ b_3 = @as(u8, @bitCast(@as(i8, @truncate(a_2))));
21142114 \\ {
21152115 \\ var d: c_int = 5;
2116 \\ _ = @TypeOf(d);
2116 \\ _ = &d;
21172117 \\ }
21182118 \\ var d: c_uint = @as(c_uint, @bitCast(@as(c_int, 440)));
2119 \\ _ = @TypeOf(d);
2119 \\ _ = &d;
21202120 \\}
21212121 });
21222122
......@@ -2215,7 +2215,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
22152215 \\ {
22162216 \\ var i: c_int = 2;
22172217 \\ var b: c_int = 4;
2218 \\ _ = @TypeOf(b);
2218 \\ _ = &b;
22192219 \\ while ((i + @as(c_int, 2)) != 0) : (i = 2) {
22202220 \\ var a: c_int = 2;
22212221 \\ _ = blk: {
......@@ -2228,7 +2228,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
22282228 \\ }
22292229 \\ }
22302230 \\ var i: u8 = 2;
2231 \\ _ = @TypeOf(i);
2231 \\ _ = &i;
22322232 \\}
22332233 });
22342234
......@@ -2465,27 +2465,27 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
24652465 , &[_][]const u8{
24662466 \\pub export fn escapes() [*c]const u8 {
24672467 \\ var a: u8 = '\'';
2468 \\ _ = @TypeOf(a);
2468 \\ _ = &a;
24692469 \\ var b: u8 = '\\';
2470 \\ _ = @TypeOf(b);
2470 \\ _ = &b;
24712471 \\ var c: u8 = '\x07';
2472 \\ _ = @TypeOf(c);
2472 \\ _ = &c;
24732473 \\ var d: u8 = '\x08';
2474 \\ _ = @TypeOf(d);
2474 \\ _ = &d;
24752475 \\ var e: u8 = '\x0c';
2476 \\ _ = @TypeOf(e);
2476 \\ _ = &e;
24772477 \\ var f: u8 = '\n';
2478 \\ _ = @TypeOf(f);
2478 \\ _ = &f;
24792479 \\ var g: u8 = '\r';
2480 \\ _ = @TypeOf(g);
2480 \\ _ = &g;
24812481 \\ var h: u8 = '\t';
2482 \\ _ = @TypeOf(h);
2482 \\ _ = &h;
24832483 \\ var i: u8 = '\x0b';
2484 \\ _ = @TypeOf(i);
2484 \\ _ = &i;
24852485 \\ var j: u8 = '\x00';
2486 \\ _ = @TypeOf(j);
2486 \\ _ = &j;
24872487 \\ var k: u8 = '"';
2488 \\ _ = @TypeOf(k);
2488 \\ _ = &k;
24892489 \\ return "'\\\x07\x08\x0c\n\r\t\x0b\x00\"";
24902490 \\}
24912491 });
......@@ -2681,7 +2681,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
26812681 \\pub export fn foo() c_int {
26822682 \\ return blk: {
26832683 \\ var a: c_int = 1;
2684 \\ _ = @TypeOf(a);
2684 \\ _ = &a;
26852685 \\ break :blk a;
26862686 \\ };
26872687 \\}
......@@ -2785,7 +2785,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
27852785 \\int bar(void) { return 0; }
27862786 , &[_][]const u8{
27872787 \\pub inline fn CALL(arg: anytype) @TypeOf(bar()) {
2788 \\ _ = @TypeOf(arg);
2788 \\ _ = &arg;
27892789 \\ return bar();
27902790 \\}
27912791 });
......@@ -2844,14 +2844,14 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
28442844 \\pub export fn foo() void {
28452845 \\ if (true) {
28462846 \\ var a: c_int = 2;
2847 \\ _ = @TypeOf(a);
2847 \\ _ = &a;
28482848 \\ }
28492849 \\ if ((blk: {
28502850 \\ _ = @as(c_int, 2);
28512851 \\ break :blk @as(c_int, 5);
28522852 \\ }) != 0) {
28532853 \\ var a: c_int = 2;
2854 \\ _ = @TypeOf(a);
2854 \\ _ = &a;
28552855 \\ }
28562856 \\}
28572857 });
......@@ -3331,7 +3331,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
33313331 \\#define a 2
33323332 , &[_][]const u8{
33333333 \\pub inline fn FOO(bar: anytype) @TypeOf(baz(@import("std").zig.c_translation.cast(?*anyopaque, baz))) {
3334 \\ _ = @TypeOf(bar);
3334 \\ _ = &bar;
33353335 \\ return baz(@import("std").zig.c_translation.cast(?*anyopaque, baz));
33363336 \\}
33373337 ,
......@@ -3471,7 +3471,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
34713471 , &[_][]const u8{
34723472 \\pub export fn foo(arg_a: [*c]c_int) void {
34733473 \\ var a = arg_a;
3474 \\ _ = @TypeOf(a);
3474 \\ _ = &a;
34753475 \\}
34763476 \\pub export fn bar(arg_a: [*c]const c_int) void {
34773477 \\ var a = arg_a;
......@@ -3831,12 +3831,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
38313831 \\pub export fn bar(arg_x: c_int, arg_y: c_int) c_int {
38323832 \\ var x = arg_x;
38333833 \\ var y = arg_y;
3834 \\ _ = @TypeOf(y);
3834 \\ _ = &y;
38353835 \\ return x;
38363836 \\}
38373837 ,
38383838 \\pub inline fn FOO(A: anytype, B: anytype) @TypeOf(A) {
3839 \\ _ = @TypeOf(B);
3839 \\ _ = &B;
38403840 \\ return A;
38413841 \\}
38423842 });
......@@ -3931,7 +3931,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
39313931 \\ var a: S = undefined;
39323932 \\ var b: S = undefined;
39333933 \\ var c: c_longlong = @divExact(@as(c_longlong, @bitCast(@intFromPtr(a) -% @intFromPtr(b))), @sizeOf(u8));
3934 \\ _ = @TypeOf(c);
3934 \\ _ = &c;
39353935 \\}
39363936 });
39373937 } else {
......@@ -3946,7 +3946,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
39463946 \\ var a: S = undefined;
39473947 \\ var b: S = undefined;
39483948 \\ var c: c_long = @divExact(@as(c_long, @bitCast(@intFromPtr(a) -% @intFromPtr(b))), @sizeOf(u8));
3949 \\ _ = @TypeOf(c);
3949 \\ _ = &c;
39503950 \\}
39513951 });
39523952 }