| ... | ... | @@ -4874,7 +4874,7 @@ fn transPreprocessorEntities(c: *Context, unit: *ZigClangASTUnit) Error!void { |
| 4874 | 4874 | |
| 4875 | 4875 | var tok_it = tok_list.iterator(0); |
| 4876 | 4876 | const first_tok = tok_it.next().?; |
| 4877 | | assert(first_tok.id == .Identifier and mem.eql(u8, slice[first_tok.start..first_tok.end], name)); |
| 4877 | assert(mem.eql(u8, slice[first_tok.start..first_tok.end], name)); |
| 4878 | 4878 | |
| 4879 | 4879 | var macro_fn = false; |
| 4880 | 4880 | const next = tok_it.peek().?; |
| ... | ... | @@ -5038,7 +5038,14 @@ fn transMacroFnDefine(c: *Context, it: *CTokenList.Iterator, source: []const u8, |
| 5038 | 5038 | .{last.id}, |
| 5039 | 5039 | ); |
| 5040 | 5040 | _ = try appendToken(c, .Semicolon, ";"); |
| 5041 | | try type_of.params.push(expr); |
| 5041 | const type_of_arg = if (expr.id != .Block) expr else blk: { |
| 5042 | const blk = @fieldParentPtr(ast.Node.Block, "base", expr); |
| 5043 | const blk_last = blk.statements.at(blk.statements.len - 1).*; |
| 5044 | std.debug.assert(blk_last.id == .ControlFlowExpression); |
| 5045 | const br = @fieldParentPtr(ast.Node.ControlFlowExpression, "base", blk_last); |
| 5046 | break :blk br.rhs.?; |
| 5047 | }; |
| 5048 | try type_of.params.push(type_of_arg); |
| 5042 | 5049 | return_expr.rhs = expr; |
| 5043 | 5050 | |
| 5044 | 5051 | block.rbrace = try appendToken(c, .RBrace, "}"); |
| ... | ... | @@ -5073,6 +5080,39 @@ fn parseCExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, source_ |
| 5073 | 5080 | if_node.@"else".?.body = try parseCPrimaryExpr(c, it, source, source_loc, scope); |
| 5074 | 5081 | return &if_node.base; |
| 5075 | 5082 | }, |
| 5083 | .Comma => { |
| 5084 | _ = try appendToken(c, .Semicolon, ";"); |
| 5085 | const block_scope = try Scope.Block.init(c, scope, "blk"); |
| 5086 | block_scope.block_node = try transCreateNodeBlock(c, block_scope.label); |
| 5087 | |
| 5088 | var last = node; |
| 5089 | while (true) { |
| 5090 | // suppress result |
| 5091 | const lhs = try transCreateNodeIdentifier(c, "_"); |
| 5092 | const op_token = try appendToken(c, .Equal, "="); |
| 5093 | const op_node = try c.a().create(ast.Node.InfixOp); |
| 5094 | op_node.* = .{ |
| 5095 | .op_token = op_token, |
| 5096 | .lhs = lhs, |
| 5097 | .op = .Assign, |
| 5098 | .rhs = last, |
| 5099 | }; |
| 5100 | try block_scope.block_node.statements.push(&op_node.base); |
| 5101 | |
| 5102 | last = try parseCPrefixOpExpr(c, it, source, source_loc, scope); |
| 5103 | _ = try appendToken(c, .Semicolon, ";"); |
| 5104 | if (it.next().?.id != .Comma) { |
| 5105 | _ = it.prev(); |
| 5106 | break; |
| 5107 | } |
| 5108 | } |
| 5109 | |
| 5110 | const break_node = try transCreateNodeBreak(c, block_scope.label); |
| 5111 | break_node.rhs = last; |
| 5112 | try block_scope.block_node.statements.push(&break_node.base); |
| 5113 | block_scope.block_node.rbrace = try appendToken(c, .RBrace, "}"); |
| 5114 | return &block_scope.block_node.base; |
| 5115 | }, |
| 5076 | 5116 | else => { |
| 5077 | 5117 | _ = it.prev(); |
| 5078 | 5118 | return node; |