| ... | ... | @@ -4830,7 +4830,6 @@ fn transPreprocessorEntities(c: *Context, unit: *ZigClangASTUnit) Error!void { |
| 4830 | 4830 | const macro = @ptrCast(*ZigClangMacroDefinitionRecord, entity); |
| 4831 | 4831 | const raw_name = ZigClangMacroDefinitionRecord_getName_getNameStart(macro); |
| 4832 | 4832 | const begin_loc = ZigClangMacroDefinitionRecord_getSourceRange_getBegin(macro); |
| 4833 | | // const end_loc = ZigClangMacroDefinitionRecord_getSourceRange_getEnd(macro); |
| 4834 | 4833 | |
| 4835 | 4834 | const name = try c.str(raw_name); |
| 4836 | 4835 | // TODO https://github.com/ziglang/zig/issues/3756 |
| ... | ... | @@ -4841,8 +4840,6 @@ fn transPreprocessorEntities(c: *Context, unit: *ZigClangASTUnit) Error!void { |
| 4841 | 4840 | } |
| 4842 | 4841 | |
| 4843 | 4842 | const begin_c = ZigClangSourceManager_getCharacterData(c.source_manager, begin_loc); |
| 4844 | | // const end_c = ZigClangSourceManager_getCharacterData(c.source_manager, end_loc); |
| 4845 | | // const slice = begin_c[0 .. @ptrToInt(end_c) - @ptrToInt(begin_c)]; |
| 4846 | 4843 | const slice = begin_c[0..mem.len(u8, begin_c)]; |
| 4847 | 4844 | |
| 4848 | 4845 | tok_list.shrink(0); |
| ... | ... | @@ -5023,7 +5020,7 @@ fn transMacroFnDefine(c: *Context, it: *CTokenList.Iterator, source: []const u8, |
| 5023 | 5020 | const return_expr = try transCreateNodeReturnExpr(c); |
| 5024 | 5021 | const expr = try parseCExpr(c, it, source, source_loc, scope); |
| 5025 | 5022 | const last = it.next().?; |
| 5026 | | if (last.id != .Eof) |
| 5023 | if (last.id != .Eof and last.id != .Nl) |
| 5027 | 5024 | return failDecl( |
| 5028 | 5025 | c, |
| 5029 | 5026 | source_loc, |
| ... | ... | @@ -5122,7 +5119,7 @@ fn parseCNumLit(c: *Context, tok: *CToken, source: []const u8, source_loc: ZigCl |
| 5122 | 5119 | const cast_node = try transCreateNodeBuiltinFnCall(c, "@as"); |
| 5123 | 5120 | try cast_node.params.push(try transCreateNodeIdentifier(c, switch (tok.id.FloatLiteral) { |
| 5124 | 5121 | .F => "f32", |
| 5125 | | .L => "f64", |
| 5122 | .L => "c_longdouble", |
| 5126 | 5123 | else => unreachable, |
| 5127 | 5124 | })); |
| 5128 | 5125 | _ = try appendToken(c, .Comma, ","); |
| ... | ... | @@ -5309,6 +5306,15 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, |
| 5309 | 5306 | .IntegerLiteral, .FloatLiteral => { |
| 5310 | 5307 | return parseCNumLit(c, tok, source, source_loc); |
| 5311 | 5308 | }, |
| 5309 | // eventually this will be replaced by std.c.parse which will handle these correctly |
| 5310 | .Keyword_void, |
| 5311 | .Keyword_bool, |
| 5312 | .Keyword_double, |
| 5313 | .Keyword_long, |
| 5314 | .Keyword_int, |
| 5315 | .Keyword_float, |
| 5316 | .Keyword_short, |
| 5317 | .Keyword_char, |
| 5312 | 5318 | .Identifier => { |
| 5313 | 5319 | const mangled_name = scope.getAlias(source[tok.start..tok.end]); |
| 5314 | 5320 | return transCreateNodeIdentifier(c, mangled_name); |
| ... | ... | @@ -5631,12 +5637,12 @@ fn parseCSuffixOpExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, |
| 5631 | 5637 | }; |
| 5632 | 5638 | node = &and_node.base; |
| 5633 | 5639 | }, |
| 5634 | | .LBrace => { |
| 5640 | .LBracket => { |
| 5635 | 5641 | const arr_node = try transCreateNodeArrayAccess(c, node); |
| 5636 | 5642 | arr_node.op.ArrayAccess = try parseCPrefixOpExpr(c, it, source, source_loc, scope); |
| 5637 | | arr_node.rtoken = try appendToken(c, .RBrace, "]"); |
| 5643 | arr_node.rtoken = try appendToken(c, .RBracket, "]"); |
| 5638 | 5644 | node = &arr_node.base; |
| 5639 | | if (it.next().?.id != .RBrace) { |
| 5645 | if (it.next().?.id != .RBracket) { |
| 5640 | 5646 | const first_tok = it.list.at(0); |
| 5641 | 5647 | try failDecl( |
| 5642 | 5648 | c, |