| author | |
| committer | |
| log | be551d85b7610a7e0570023934f9b92ddf129966 |
| tree | f3e4e1fcabc054a43b26d12fba7449d33969685b |
| parent | 63304a871e3837f407943ac8eb63073fdc89f0fd |
2 files changed, 18 insertions(+), 2 deletions(-)
src/translate_c/ast.zig+2-2| ... | ... | @@ -1728,7 +1728,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex { |
| 1728 | 1728 | }, |
| 1729 | 1729 | .field_access => { |
| 1730 | 1730 | const payload = node.castTag(.field_access).?.data; |
| 1731 | const lhs = try renderNode(c, payload.lhs); | |
| 1731 | const lhs = try renderNodeGrouped(c, payload.lhs); | |
| 1732 | 1732 | return renderFieldAccess(c, lhs, payload.field_name); |
| 1733 | 1733 | }, |
| 1734 | 1734 | .@"struct", .@"union" => return renderRecord(c, node), |
| ... | ... | @@ -2073,7 +2073,7 @@ fn renderNullSentinelArrayType(c: *Context, len: usize, elem_type: Node) !NodeIn |
| 2073 | 2073 | .main_token = l_bracket, |
| 2074 | 2074 | .data = .{ |
| 2075 | 2075 | .lhs = len_expr, |
| 2076 | .rhs = try c.addExtra(std.zig.ast.Node.ArrayTypeSentinel { | |
| 2076 | .rhs = try c.addExtra(std.zig.ast.Node.ArrayTypeSentinel{ | |
| 2077 | 2077 | .sentinel = sentinel_expr, |
| 2078 | 2078 | .elem_type = elem_type_expr, |
| 2079 | 2079 | }), |
test/translate_c.zig+16| ... | ... | @@ -3,6 +3,22 @@ const std = @import("std"); |
| 3 | 3 | const CrossTarget = std.zig.CrossTarget; |
| 4 | 4 | |
| 5 | 5 | pub fn addCases(cases: *tests.TranslateCContext) void { |
| 6 | cases.add("field access is grouped if necessary", | |
| 7 | \\unsigned long foo(unsigned long x) { | |
| 8 | \\ return ((union{unsigned long _x}){x})._x; | |
| 9 | \\} | |
| 10 | , &[_][]const u8{ | |
| 11 | \\pub export fn foo(arg_x: c_ulong) c_ulong { | |
| 12 | \\ var x = arg_x; | |
| 13 | \\ const union_unnamed_1 = extern union { | |
| 14 | \\ _x: c_ulong, | |
| 15 | \\ }; | |
| 16 | \\ return (union_unnamed_1{ | |
| 17 | \\ ._x = x, | |
| 18 | \\ })._x; | |
| 19 | \\} | |
| 20 | }); | |
| 21 | ||
| 6 | 22 | cases.add("unnamed child types of typedef receive typedef's name", |
| 7 | 23 | \\typedef enum { |
| 8 | 24 | \\ FooA, |