| ... | @@ -2237,7 +2237,6 @@ fn transWhileLoop( | ... | @@ -2237,7 +2237,6 @@ fn transWhileLoop( |
| 2237 | .id = .Loop, | 2237 | .id = .Loop, |
| 2238 | }; | 2238 | }; |
| 2239 | while_node.body = try transStmt(rp, &loop_scope, ZigClangWhileStmt_getBody(stmt), .unused, .r_value); | 2239 | while_node.body = try transStmt(rp, &loop_scope, ZigClangWhileStmt_getBody(stmt), .unused, .r_value); |
| 2240 | _ = try appendToken(rp.c, .Semicolon, ";"); | | |
| 2241 | return &while_node.base; | 2240 | return &while_node.base; |
| 2242 | } | 2241 | } |
| 2243 | | 2242 | |
| ... | @@ -2347,10 +2346,8 @@ fn transForLoop( | ... | @@ -2347,10 +2346,8 @@ fn transForLoop( |
| 2347 | try block_scope.?.block_node.statements.push(&while_node.base); | 2346 | try block_scope.?.block_node.statements.push(&while_node.base); |
| 2348 | block_scope.?.block_node.rbrace = try appendToken(rp.c, .RBrace, "}"); | 2347 | block_scope.?.block_node.rbrace = try appendToken(rp.c, .RBrace, "}"); |
| 2349 | return &block_scope.?.block_node.base; | 2348 | return &block_scope.?.block_node.base; |
| 2350 | } else { | 2349 | } else |
| 2351 | _ = try appendToken(rp.c, .Semicolon, ";"); | | |
| 2352 | return &while_node.base; | 2350 | return &while_node.base; |
| 2353 | } | | |
| 2354 | } | 2351 | } |
| 2355 | | 2352 | |
| 2356 | fn transSwitch( | 2353 | fn transSwitch( |
| ... | @@ -5579,7 +5576,14 @@ fn parseCSuffixOpExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, | ... | @@ -5579,7 +5576,14 @@ fn parseCSuffixOpExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, |
| 5579 | ); | 5576 | ); |
| 5580 | return error.ParseError; | 5577 | return error.ParseError; |
| 5581 | } | 5578 | } |
| 5582 | const deref = try transCreateNodePtrDeref(c, node); | 5579 | // deref is often used together with casts so we group the lhs expression |
| | 5580 | const group = try c.a().create(ast.Node.GroupedExpression); |
| | 5581 | group.* = .{ |
| | 5582 | .lparen = try appendToken(c, .LParen, "("), |
| | 5583 | .expr = node, |
| | 5584 | .rparen = try appendToken(c, .RParen, ")"), |
| | 5585 | }; |
| | 5586 | const deref = try transCreateNodePtrDeref(c, &group.base); |
| 5583 | node = try transCreateNodeFieldAccess(c, deref, source[name_tok.start..name_tok.end]); | 5587 | node = try transCreateNodeFieldAccess(c, deref, source[name_tok.start..name_tok.end]); |
| 5584 | continue; | 5588 | continue; |
| 5585 | }, | 5589 | }, |
| ... | @@ -5623,7 +5627,7 @@ fn parseCSuffixOpExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, | ... | @@ -5623,7 +5627,7 @@ fn parseCSuffixOpExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, |
| 5623 | }, | 5627 | }, |
| 5624 | .Ampersand => { | 5628 | .Ampersand => { |
| 5625 | op_token = try appendToken(c, .Ampersand, "&"); | 5629 | op_token = try appendToken(c, .Ampersand, "&"); |
| 5626 | op_id = .BitAnd; | 5630 | op_id .BitAnd; |
| 5627 | }, | 5631 | }, |
| 5628 | .Plus => { | 5632 | .Plus => { |
| 5629 | op_token = try appendToken(c, .Plus, "+"); | 5633 | op_token = try appendToken(c, .Plus, "+"); |
| ... | @@ -5631,7 +5635,7 @@ fn parseCSuffixOpExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, | ... | @@ -5631,7 +5635,7 @@ fn parseCSuffixOpExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, |
| 5631 | }, | 5635 | }, |
| 5632 | .Minus => { | 5636 | .Minus => { |
| 5633 | op_token = try appendToken(c, .Minus, "-"); | 5637 | op_token = try appendToken(c, .Minus, "-"); |
| 5634 | op_id = .Sub; | 5638 | op_id .Sub; |
| 5635 | }, | 5639 | }, |
| 5636 | .AmpersandAmpersand => { | 5640 | .AmpersandAmpersand => { |
| 5637 | op_token = try appendToken(c, .Keyword_and, "and"); | 5641 | op_token = try appendToken(c, .Keyword_and, "and"); |
| ... | @@ -5703,7 +5707,7 @@ fn parseCSuffixOpExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, | ... | @@ -5703,7 +5707,7 @@ fn parseCSuffixOpExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, |
| 5703 | }, | 5707 | }, |
| 5704 | .BangEqual => { | 5708 | .BangEqual => { |
| 5705 | op_token = try appendToken(c, .BangEqual, "!="); | 5709 | op_token = try appendToken(c, .BangEqual, "!="); |
| 5706 | op_id = .BangEqual; | 5710 | op_id = .BangEqual; |
| 5707 | }, | 5711 | }, |
| 5708 | .EqualEqual => { | 5712 | .EqualEqual => { |
| 5709 | op_token = try appendToken(c, .EqualEqual, "=="); | 5713 | op_token = try appendToken(c, .EqualEqual, "=="); |
| ... | @@ -5756,12 +5760,25 @@ fn parseCPrefixOpExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, | ... | @@ -5756,12 +5760,25 @@ fn parseCPrefixOpExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, |
| 5756 | return &node.base; | 5760 | return &node.base; |
| 5757 | }, | 5761 | }, |
| 5758 | .Asterisk => { | 5762 | .Asterisk => { |
| 5759 | const node = try parseCPrefixOpExpr(c, it, source, source_loc, scope); | 5763 | // deref is often used together with casts so we group the lhs expression |
| 5760 | return try transCreateNodePtrDeref(c, node); | 5764 | const group = try c.a().create(ast.Node.GroupedExpression); |
| | 5765 | group.* = .{ |
| | 5766 | .lparen = try appendToken(c, .LParen, "("), |
| | 5767 | .expr = try parseCPrefixOpExpr(c, it, source, source_loc, scope), |
| | 5768 | .rparen = try appendToken(c, .RParen, ")"), |
| | 5769 | }; |
| | 5770 | return try transCreateNodePtrDeref(c, &group.base); |
| 5761 | }, | 5771 | }, |
| 5762 | .Ampersand => { | 5772 | .Ampersand => { |
| | 5773 | // address of is often used together with casts so we group the rhs expression |
| 5763 | const node = try transCreateNodePrefixOp(c, .AddressOf, .Ampersand, "&"); | 5774 | const node = try transCreateNodePrefixOp(c, .AddressOf, .Ampersand, "&"); |
| 5764 | node.rhs = try parseCPrefixOpExpr(c, it, source, source_loc, scope); | 5775 | const group = try c.a().create(ast.Node.GroupedExpression); |
| | 5776 | group.* = .{ |
| | 5777 | .lparen = try appendToken(c, .LParen, "("), |
| | 5778 | .expr = try parseCPrefixOpExpr(c, it, source, source_loc, scope), |
| | 5779 | .rparen = try appendToken(c, .RParen, ")"), |
| | 5780 | }; |
| | 5781 | node.rhs = &group.base; |
| 5765 | return &node.base; | 5782 | return &node.base; |
| 5766 | }, | 5783 | }, |
| 5767 | else => { | 5784 | else => { |