| ... | @@ -189,20 +189,20 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -189,20 +189,20 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 189 | \\} outer; | 189 | \\} outer; |
| 190 | \\void foo(outer *x) { x->y = x->x; } | 190 | \\void foo(outer *x) { x->y = x->x; } |
| 191 | , &[_][]const u8{ | 191 | , &[_][]const u8{ |
| 192 | \\const struct_unnamed_5 = extern struct { | 192 | \\const struct_unnamed_3 = extern struct { |
| 193 | \\ y: c_int, | 193 | \\ y: c_int, |
| 194 | \\}; | 194 | \\}; |
| 195 | \\const union_unnamed_3 = extern union { | 195 | \\const union_unnamed_2 = extern union { |
| 196 | \\ x: u8, | 196 | \\ x: u8, |
| 197 | \\ unnamed_4: struct_unnamed_5, | 197 | \\ unnamed_0: struct_unnamed_3, |
| 198 | \\}; | 198 | \\}; |
| 199 | \\const struct_unnamed_1 = extern struct { | 199 | \\const struct_unnamed_1 = extern struct { |
| 200 | \\ unnamed_2: union_unnamed_3, | 200 | \\ unnamed_0: union_unnamed_2, |
| 201 | \\}; | 201 | \\}; |
| 202 | \\pub const outer = struct_unnamed_1; | 202 | \\pub const outer = struct_unnamed_1; |
| 203 | \\pub export fn foo(arg_x: [*c]outer) void { | 203 | \\pub export fn foo(arg_x: [*c]outer) void { |
| 204 | \\ var x = arg_x; | 204 | \\ var x = arg_x; |
| 205 | \\ x.*.unnamed_2.unnamed_4.y = @bitCast(c_int, @as(c_uint, x.*.unnamed_2.x)); | 205 | \\ x.*.unnamed_0.unnamed_0.y = @bitCast(c_int, @as(c_uint, x.*.unnamed_0.x)); |
| 206 | \\} | 206 | \\} |
| 207 | }); | 207 | }); |
| 208 | | 208 | |
| ... | @@ -2922,7 +2922,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2922,7 +2922,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2922 | \\}; | 2922 | \\}; |
| 2923 | \\pub const NAMED = struct_NAMED; | 2923 | \\pub const NAMED = struct_NAMED; |
| 2924 | \\pub const struct_ONENAMEWITHSTRUCT = extern struct { | 2924 | \\pub const struct_ONENAMEWITHSTRUCT = extern struct { |
| 2925 | \\ unnamed_1: struct_NAMED, | 2925 | \\ unnamed_0: struct_NAMED, |
| 2926 | \\ b: c_long, | 2926 | \\ b: c_long, |
| 2927 | \\}; | 2927 | \\}; |
| 2928 | }); | 2928 | }); |
| ... | @@ -2948,4 +2948,22 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2948,4 +2948,22 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2948 | \\}; | 2948 | \\}; |
| 2949 | }); | 2949 | }); |
| 2950 | } | 2950 | } |
| | 2951 | |
| | 2952 | cases.add("unnamed fields have predictabile names", |
| | 2953 | \\struct a { |
| | 2954 | \\ struct {}; |
| | 2955 | \\}; |
| | 2956 | \\struct b { |
| | 2957 | \\ struct {}; |
| | 2958 | \\}; |
| | 2959 | , &[_][]const u8{ |
| | 2960 | \\const struct_unnamed_1 = extern struct {}; |
| | 2961 | \\pub const struct_a = extern struct { |
| | 2962 | \\ unnamed_0: struct_unnamed_1, |
| | 2963 | \\}; |
| | 2964 | \\const struct_unnamed_2 = extern struct {}; |
| | 2965 | \\pub const struct_b = extern struct { |
| | 2966 | \\ unnamed_0: struct_unnamed_2, |
| | 2967 | \\}; |
| | 2968 | }); |
| 2951 | } | 2969 | } |