| ... | ... | @@ -5341,12 +5341,27 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, |
| 5341 | 5341 | .LParen => { |
| 5342 | 5342 | const inner_node = try parseCExpr(c, it, source, source_loc, scope); |
| 5343 | 5343 | |
| 5344 | | if (it.peek().?.id == .RParen) { |
| 5345 | | _ = it.next(); |
| 5346 | | if (it.peek().?.id != .LParen) { |
| 5347 | | return inner_node; |
| 5348 | | } |
| 5349 | | _ = it.next(); |
| 5344 | if (it.next().?.id != .RParen) { |
| 5345 | const first_tok = it.list.at(0); |
| 5346 | try failDecl( |
| 5347 | c, |
| 5348 | source_loc, |
| 5349 | source[first_tok.start..first_tok.end], |
| 5350 | "unable to translate C expr: expected ')'' here", |
| 5351 | .{}, |
| 5352 | ); |
| 5353 | return error.ParseError; |
| 5354 | } |
| 5355 | var saw_l_paren = false; |
| 5356 | switch (it.peek().?.id) { |
| 5357 | // (type)(to_cast) |
| 5358 | .LParen => { |
| 5359 | saw_l_paren = true; |
| 5360 | _ = it.next(); |
| 5361 | }, |
| 5362 | // (type)identifier |
| 5363 | .Identifier => {}, |
| 5364 | else => return inner_node, |
| 5350 | 5365 | } |
| 5351 | 5366 | |
| 5352 | 5367 | // hack to get zig fmt to render a comma in builtin calls |
| ... | ... | @@ -5354,7 +5369,7 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, |
| 5354 | 5369 | |
| 5355 | 5370 | const node_to_cast = try parseCExpr(c, it, source, source_loc, scope); |
| 5356 | 5371 | |
| 5357 | | if (it.next().?.id != .RParen) { |
| 5372 | if (saw_l_paren and it.next().?.id != .RParen) { |
| 5358 | 5373 | const first_tok = it.list.at(0); |
| 5359 | 5374 | try failDecl( |
| 5360 | 5375 | c, |