| ... | ... | @@ -224,8 +224,7 @@ const Scope = struct { |
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | | fn findBlockReturnType(inner: *Scope, c: *Context) clang.QualType { |
| 228 | | _ = c; |
| 227 | fn findBlockReturnType(inner: *Scope) clang.QualType { |
| 229 | 228 | var scope = inner; |
| 230 | 229 | while (true) { |
| 231 | 230 | switch (scope.id) { |
| ... | ... | @@ -833,7 +832,7 @@ fn visitVarDecl(c: *Context, var_decl: *const clang.VarDecl, mangled_name: ?[]co |
| 833 | 832 | if (has_init) trans_init: { |
| 834 | 833 | if (decl_init) |expr| { |
| 835 | 834 | const node_or_error = if (expr.getStmtClass() == .StringLiteralClass) |
| 836 | | transStringLiteralInitializer(c, scope, @ptrCast(*const clang.StringLiteral, expr), type_node) |
| 835 | transStringLiteralInitializer(c, @ptrCast(*const clang.StringLiteral, expr), type_node) |
| 837 | 836 | else |
| 838 | 837 | transExprCoercing(c, scope, expr, .used); |
| 839 | 838 | init_node = node_or_error catch |err| switch (err) { |
| ... | ... | @@ -1319,10 +1318,10 @@ fn transStmt( |
| 1319 | 1318 | .StringLiteralClass => return transStringLiteral(c, scope, @ptrCast(*const clang.StringLiteral, stmt), result_used), |
| 1320 | 1319 | .ParenExprClass => { |
| 1321 | 1320 | const expr = try transExpr(c, scope, @ptrCast(*const clang.ParenExpr, stmt).getSubExpr(), .used); |
| 1322 | | return maybeSuppressResult(c, scope, result_used, expr); |
| 1321 | return maybeSuppressResult(c, result_used, expr); |
| 1323 | 1322 | }, |
| 1324 | 1323 | .InitListExprClass => return transInitListExpr(c, scope, @ptrCast(*const clang.InitListExpr, stmt), result_used), |
| 1325 | | .ImplicitValueInitExprClass => return transImplicitValueInitExpr(c, scope, @ptrCast(*const clang.Expr, stmt), result_used), |
| 1324 | .ImplicitValueInitExprClass => return transImplicitValueInitExpr(c, scope, @ptrCast(*const clang.Expr, stmt)), |
| 1326 | 1325 | .IfStmtClass => return transIfStmt(c, scope, @ptrCast(*const clang.IfStmt, stmt)), |
| 1327 | 1326 | .WhileStmtClass => return transWhileLoop(c, scope, @ptrCast(*const clang.WhileStmt, stmt)), |
| 1328 | 1327 | .DoStmtClass => return transDoWhileLoop(c, scope, @ptrCast(*const clang.DoStmt, stmt)), |
| ... | ... | @@ -1332,7 +1331,7 @@ fn transStmt( |
| 1332 | 1331 | .ContinueStmtClass => return Tag.@"continue".init(), |
| 1333 | 1332 | .BreakStmtClass => return Tag.@"break".init(), |
| 1334 | 1333 | .ForStmtClass => return transForLoop(c, scope, @ptrCast(*const clang.ForStmt, stmt)), |
| 1335 | | .FloatingLiteralClass => return transFloatingLiteral(c, scope, @ptrCast(*const clang.FloatingLiteral, stmt), result_used), |
| 1334 | .FloatingLiteralClass => return transFloatingLiteral(c, @ptrCast(*const clang.FloatingLiteral, stmt), result_used), |
| 1336 | 1335 | .ConditionalOperatorClass => { |
| 1337 | 1336 | return transConditionalOperator(c, scope, @ptrCast(*const clang.ConditionalOperator, stmt), result_used); |
| 1338 | 1337 | }, |
| ... | ... | @@ -1356,9 +1355,9 @@ fn transStmt( |
| 1356 | 1355 | .OpaqueValueExprClass => { |
| 1357 | 1356 | const source_expr = @ptrCast(*const clang.OpaqueValueExpr, stmt).getSourceExpr().?; |
| 1358 | 1357 | const expr = try transExpr(c, scope, source_expr, .used); |
| 1359 | | return maybeSuppressResult(c, scope, result_used, expr); |
| 1358 | return maybeSuppressResult(c, result_used, expr); |
| 1360 | 1359 | }, |
| 1361 | | .OffsetOfExprClass => return transOffsetOfExpr(c, scope, @ptrCast(*const clang.OffsetOfExpr, stmt), result_used), |
| 1360 | .OffsetOfExprClass => return transOffsetOfExpr(c, @ptrCast(*const clang.OffsetOfExpr, stmt), result_used), |
| 1362 | 1361 | .CompoundLiteralExprClass => { |
| 1363 | 1362 | const compound_literal = @ptrCast(*const clang.CompoundLiteralExpr, stmt); |
| 1364 | 1363 | return transExpr(c, scope, compound_literal.getInitializer(), result_used); |
| ... | ... | @@ -1369,13 +1368,13 @@ fn transStmt( |
| 1369 | 1368 | }, |
| 1370 | 1369 | .ConvertVectorExprClass => { |
| 1371 | 1370 | const conv_vec = @ptrCast(*const clang.ConvertVectorExpr, stmt); |
| 1372 | | const conv_vec_node = try transConvertVectorExpr(c, scope, stmt.getBeginLoc(), conv_vec); |
| 1373 | | return maybeSuppressResult(c, scope, result_used, conv_vec_node); |
| 1371 | const conv_vec_node = try transConvertVectorExpr(c, scope, conv_vec); |
| 1372 | return maybeSuppressResult(c, result_used, conv_vec_node); |
| 1374 | 1373 | }, |
| 1375 | 1374 | .ShuffleVectorExprClass => { |
| 1376 | 1375 | const shuffle_vec_expr = @ptrCast(*const clang.ShuffleVectorExpr, stmt); |
| 1377 | 1376 | const shuffle_vec_node = try transShuffleVectorExpr(c, scope, shuffle_vec_expr); |
| 1378 | | return maybeSuppressResult(c, scope, result_used, shuffle_vec_node); |
| 1377 | return maybeSuppressResult(c, result_used, shuffle_vec_node); |
| 1379 | 1378 | }, |
| 1380 | 1379 | .ChooseExprClass => { |
| 1381 | 1380 | const choose_expr = @ptrCast(*const clang.ChooseExpr, stmt); |
| ... | ... | @@ -1402,10 +1401,8 @@ fn transStmt( |
| 1402 | 1401 | fn transConvertVectorExpr( |
| 1403 | 1402 | c: *Context, |
| 1404 | 1403 | scope: *Scope, |
| 1405 | | source_loc: clang.SourceLocation, |
| 1406 | 1404 | expr: *const clang.ConvertVectorExpr, |
| 1407 | 1405 | ) TransError!Node { |
| 1408 | | _ = source_loc; |
| 1409 | 1406 | const base_stmt = @ptrCast(*const clang.Stmt, expr); |
| 1410 | 1407 | |
| 1411 | 1408 | var block_scope = try Scope.Block.init(c, scope, true); |
| ... | ... | @@ -1521,12 +1518,7 @@ fn transShuffleVectorExpr( |
| 1521 | 1518 | |
| 1522 | 1519 | /// Translate a "simple" offsetof expression containing exactly one component, |
| 1523 | 1520 | /// when that component is of kind .Field - e.g. offsetof(mytype, myfield) |
| 1524 | | fn transSimpleOffsetOfExpr( |
| 1525 | | c: *Context, |
| 1526 | | scope: *Scope, |
| 1527 | | expr: *const clang.OffsetOfExpr, |
| 1528 | | ) TransError!Node { |
| 1529 | | _ = scope; |
| 1521 | fn transSimpleOffsetOfExpr(c: *Context, expr: *const clang.OffsetOfExpr) TransError!Node { |
| 1530 | 1522 | assert(expr.getNumComponents() == 1); |
| 1531 | 1523 | const component = expr.getComponent(0); |
| 1532 | 1524 | if (component.getKind() == .Field) { |
| ... | ... | @@ -1551,13 +1543,12 @@ fn transSimpleOffsetOfExpr( |
| 1551 | 1543 | |
| 1552 | 1544 | fn transOffsetOfExpr( |
| 1553 | 1545 | c: *Context, |
| 1554 | | scope: *Scope, |
| 1555 | 1546 | expr: *const clang.OffsetOfExpr, |
| 1556 | 1547 | result_used: ResultUsed, |
| 1557 | 1548 | ) TransError!Node { |
| 1558 | 1549 | if (expr.getNumComponents() == 1) { |
| 1559 | | const offsetof_expr = try transSimpleOffsetOfExpr(c, scope, expr); |
| 1560 | | return maybeSuppressResult(c, scope, result_used, offsetof_expr); |
| 1550 | const offsetof_expr = try transSimpleOffsetOfExpr(c, expr); |
| 1551 | return maybeSuppressResult(c, result_used, offsetof_expr); |
| 1561 | 1552 | } |
| 1562 | 1553 | |
| 1563 | 1554 | // TODO implement OffsetOfExpr with more than 1 component |
| ... | ... | @@ -1613,7 +1604,6 @@ fn transCreatePointerArithmeticSignedOp( |
| 1613 | 1604 | |
| 1614 | 1605 | return transCreateNodeInfixOp( |
| 1615 | 1606 | c, |
| 1616 | | scope, |
| 1617 | 1607 | if (is_add) .add else .sub, |
| 1618 | 1608 | lhs_node, |
| 1619 | 1609 | bitcast_node, |
| ... | ... | @@ -1629,7 +1619,7 @@ fn transBinaryOperator( |
| 1629 | 1619 | ) TransError!Node { |
| 1630 | 1620 | const op = stmt.getOpcode(); |
| 1631 | 1621 | const qt = stmt.getType(); |
| 1632 | | const isPointerDiffExpr = cIsPointerDiffExpr(c, stmt); |
| 1622 | const isPointerDiffExpr = cIsPointerDiffExpr(stmt); |
| 1633 | 1623 | switch (op) { |
| 1634 | 1624 | .Assign => return try transCreateNodeAssign(c, scope, result_used, stmt.getLHS(), stmt.getRHS()), |
| 1635 | 1625 | .Comma => { |
| ... | ... | @@ -1646,7 +1636,7 @@ fn transBinaryOperator( |
| 1646 | 1636 | }); |
| 1647 | 1637 | try block_scope.statements.append(break_node); |
| 1648 | 1638 | const block_node = try block_scope.complete(c); |
| 1649 | | return maybeSuppressResult(c, scope, result_used, block_node); |
| 1639 | return maybeSuppressResult(c, result_used, block_node); |
| 1650 | 1640 | }, |
| 1651 | 1641 | .Div => { |
| 1652 | 1642 | if (cIsSignedInteger(qt)) { |
| ... | ... | @@ -1654,7 +1644,7 @@ fn transBinaryOperator( |
| 1654 | 1644 | const lhs = try transExpr(c, scope, stmt.getLHS(), .used); |
| 1655 | 1645 | const rhs = try transExpr(c, scope, stmt.getRHS(), .used); |
| 1656 | 1646 | const div_trunc = try Tag.div_trunc.create(c.arena, .{ .lhs = lhs, .rhs = rhs }); |
| 1657 | | return maybeSuppressResult(c, scope, result_used, div_trunc); |
| 1647 | return maybeSuppressResult(c, result_used, div_trunc); |
| 1658 | 1648 | } |
| 1659 | 1649 | }, |
| 1660 | 1650 | .Rem => { |
| ... | ... | @@ -1663,7 +1653,7 @@ fn transBinaryOperator( |
| 1663 | 1653 | const lhs = try transExpr(c, scope, stmt.getLHS(), .used); |
| 1664 | 1654 | const rhs = try transExpr(c, scope, stmt.getRHS(), .used); |
| 1665 | 1655 | const rem = try Tag.signed_remainder.create(c.arena, .{ .lhs = lhs, .rhs = rhs }); |
| 1666 | | return maybeSuppressResult(c, scope, result_used, rem); |
| 1656 | return maybeSuppressResult(c, result_used, rem); |
| 1667 | 1657 | } |
| 1668 | 1658 | }, |
| 1669 | 1659 | .Shl => { |
| ... | ... | @@ -1764,7 +1754,7 @@ fn transBinaryOperator( |
| 1764 | 1754 | else |
| 1765 | 1755 | rhs_uncasted; |
| 1766 | 1756 | |
| 1767 | | const infixOpNode = try transCreateNodeInfixOp(c, scope, op_id, lhs, rhs, result_used); |
| 1757 | const infixOpNode = try transCreateNodeInfixOp(c, op_id, lhs, rhs, result_used); |
| 1768 | 1758 | if (isPointerDiffExpr) { |
| 1769 | 1759 | // @divExact(@bitCast(<platform-ptrdiff_t>, @ptrToInt(lhs) -% @ptrToInt(rhs)), @sizeOf(<lhs target type>)) |
| 1770 | 1760 | const ptrdiff_type = try transQualTypeIntWidthOf(c, qt, true); |
| ... | ... | @@ -1843,7 +1833,7 @@ fn transCStyleCastExprClass( |
| 1843 | 1833 | src_type, |
| 1844 | 1834 | sub_expr_node, |
| 1845 | 1835 | )); |
| 1846 | | return maybeSuppressResult(c, scope, result_used, cast_node); |
| 1836 | return maybeSuppressResult(c, result_used, cast_node); |
| 1847 | 1837 | } |
| 1848 | 1838 | |
| 1849 | 1839 | /// The alignment of a variable or field |
| ... | ... | @@ -1933,7 +1923,7 @@ fn transDeclStmtOne( |
| 1933 | 1923 | |
| 1934 | 1924 | var init_node = if (decl_init) |expr| |
| 1935 | 1925 | if (expr.getStmtClass() == .StringLiteralClass) |
| 1936 | | try transStringLiteralInitializer(c, scope, @ptrCast(*const clang.StringLiteral, expr), type_node) |
| 1926 | try transStringLiteralInitializer(c, @ptrCast(*const clang.StringLiteral, expr), type_node) |
| 1937 | 1927 | else |
| 1938 | 1928 | try transExprCoercing(c, scope, expr, .used) |
| 1939 | 1929 | else if (is_static_local) |
| ... | ... | @@ -2051,21 +2041,21 @@ fn transImplicitCastExpr( |
| 2051 | 2041 | .BitCast, .FloatingCast, .FloatingToIntegral, .IntegralToFloating, .IntegralCast, .PointerToIntegral, .IntegralToPointer => { |
| 2052 | 2042 | const sub_expr_node = try transExpr(c, scope, sub_expr, .used); |
| 2053 | 2043 | const casted = try transCCast(c, scope, expr.getBeginLoc(), dest_type, src_type, sub_expr_node); |
| 2054 | | return maybeSuppressResult(c, scope, result_used, casted); |
| 2044 | return maybeSuppressResult(c, result_used, casted); |
| 2055 | 2045 | }, |
| 2056 | 2046 | .LValueToRValue, .NoOp, .FunctionToPointerDecay => { |
| 2057 | 2047 | const sub_expr_node = try transExpr(c, scope, sub_expr, .used); |
| 2058 | | return maybeSuppressResult(c, scope, result_used, sub_expr_node); |
| 2048 | return maybeSuppressResult(c, result_used, sub_expr_node); |
| 2059 | 2049 | }, |
| 2060 | 2050 | .ArrayToPointerDecay => { |
| 2061 | 2051 | const sub_expr_node = try transExpr(c, scope, sub_expr, .used); |
| 2062 | 2052 | if (exprIsNarrowStringLiteral(sub_expr) or exprIsFlexibleArrayRef(c, sub_expr)) { |
| 2063 | | return maybeSuppressResult(c, scope, result_used, sub_expr_node); |
| 2053 | return maybeSuppressResult(c, result_used, sub_expr_node); |
| 2064 | 2054 | } |
| 2065 | 2055 | |
| 2066 | 2056 | const addr = try Tag.address_of.create(c.arena, sub_expr_node); |
| 2067 | 2057 | const casted = try transCPtrCast(c, scope, expr.getBeginLoc(), dest_type, src_type, addr); |
| 2068 | | return maybeSuppressResult(c, scope, result_used, casted); |
| 2058 | return maybeSuppressResult(c, result_used, casted); |
| 2069 | 2059 | }, |
| 2070 | 2060 | .NullToPointer => { |
| 2071 | 2061 | return Tag.null_literal.init(); |
| ... | ... | @@ -2076,18 +2066,18 @@ fn transImplicitCastExpr( |
| 2076 | 2066 | const ptr_to_int = try Tag.ptr_to_int.create(c.arena, ptr_node); |
| 2077 | 2067 | |
| 2078 | 2068 | const ne = try Tag.not_equal.create(c.arena, .{ .lhs = ptr_to_int, .rhs = Tag.zero_literal.init() }); |
| 2079 | | return maybeSuppressResult(c, scope, result_used, ne); |
| 2069 | return maybeSuppressResult(c, result_used, ne); |
| 2080 | 2070 | }, |
| 2081 | 2071 | .IntegralToBoolean, .FloatingToBoolean => { |
| 2082 | 2072 | const sub_expr_node = try transExpr(c, scope, sub_expr, .used); |
| 2083 | 2073 | |
| 2084 | 2074 | // The expression is already a boolean one, return it as-is |
| 2085 | 2075 | if (isBoolRes(sub_expr_node)) |
| 2086 | | return maybeSuppressResult(c, scope, result_used, sub_expr_node); |
| 2076 | return maybeSuppressResult(c, result_used, sub_expr_node); |
| 2087 | 2077 | |
| 2088 | 2078 | // val != 0 |
| 2089 | 2079 | const ne = try Tag.not_equal.create(c.arena, .{ .lhs = sub_expr_node, .rhs = Tag.zero_literal.init() }); |
| 2090 | | return maybeSuppressResult(c, scope, result_used, ne); |
| 2080 | return maybeSuppressResult(c, result_used, ne); |
| 2091 | 2081 | }, |
| 2092 | 2082 | .BuiltinFnToFnPtr => { |
| 2093 | 2083 | return transBuiltinFnExpr(c, scope, sub_expr, result_used); |
| ... | ... | @@ -2140,13 +2130,13 @@ fn transBoolExpr( |
| 2140 | 2130 | |
| 2141 | 2131 | var res = try transExpr(c, scope, expr, used); |
| 2142 | 2132 | if (isBoolRes(res)) { |
| 2143 | | return maybeSuppressResult(c, scope, used, res); |
| 2133 | return maybeSuppressResult(c, used, res); |
| 2144 | 2134 | } |
| 2145 | 2135 | |
| 2146 | 2136 | const ty = getExprQualType(c, expr).getTypePtr(); |
| 2147 | 2137 | const node = try finishBoolExpr(c, scope, expr.getBeginLoc(), ty, res, used); |
| 2148 | 2138 | |
| 2149 | | return maybeSuppressResult(c, scope, used, node); |
| 2139 | return maybeSuppressResult(c, used, node); |
| 2150 | 2140 | } |
| 2151 | 2141 | |
| 2152 | 2142 | fn exprIsBooleanType(expr: *const clang.Expr) bool { |
| ... | ... | @@ -2299,7 +2289,7 @@ fn transIntegerLiteral( |
| 2299 | 2289 | |
| 2300 | 2290 | if (suppress_as == .no_as) { |
| 2301 | 2291 | const int_lit_node = try transCreateNodeAPInt(c, eval_result.Val.getInt()); |
| 2302 | | return maybeSuppressResult(c, scope, result_used, int_lit_node); |
| 2292 | return maybeSuppressResult(c, result_used, int_lit_node); |
| 2303 | 2293 | } |
| 2304 | 2294 | |
| 2305 | 2295 | // Integer literals in C have types, and this can matter for several reasons. |
| ... | ... | @@ -2317,7 +2307,7 @@ fn transIntegerLiteral( |
| 2317 | 2307 | const ty_node = try transQualType(c, scope, expr_base.getType(), expr_base.getBeginLoc()); |
| 2318 | 2308 | const rhs = try transCreateNodeAPInt(c, eval_result.Val.getInt()); |
| 2319 | 2309 | const as = try Tag.as.create(c.arena, .{ .lhs = ty_node, .rhs = rhs }); |
| 2320 | | return maybeSuppressResult(c, scope, result_used, as); |
| 2310 | return maybeSuppressResult(c, result_used, as); |
| 2321 | 2311 | } |
| 2322 | 2312 | |
| 2323 | 2313 | fn transReturnStmt( |
| ... | ... | @@ -2329,7 +2319,7 @@ fn transReturnStmt( |
| 2329 | 2319 | return Tag.return_void.init(); |
| 2330 | 2320 | |
| 2331 | 2321 | var rhs = try transExprCoercing(c, scope, val_expr, .used); |
| 2332 | | const return_qt = scope.findBlockReturnType(c); |
| 2322 | const return_qt = scope.findBlockReturnType(); |
| 2333 | 2323 | if (isBoolRes(rhs) and !qualTypeIsBoolean(return_qt)) { |
| 2334 | 2324 | rhs = try Tag.bool_to_int.create(c.arena, rhs); |
| 2335 | 2325 | } |
| ... | ... | @@ -2338,7 +2328,6 @@ fn transReturnStmt( |
| 2338 | 2328 | |
| 2339 | 2329 | fn transNarrowStringLiteral( |
| 2340 | 2330 | c: *Context, |
| 2341 | | scope: *Scope, |
| 2342 | 2331 | stmt: *const clang.StringLiteral, |
| 2343 | 2332 | result_used: ResultUsed, |
| 2344 | 2333 | ) TransError!Node { |
| ... | ... | @@ -2347,7 +2336,7 @@ fn transNarrowStringLiteral( |
| 2347 | 2336 | |
| 2348 | 2337 | const str = try std.fmt.allocPrint(c.arena, "\"{}\"", .{std.zig.fmtEscapes(bytes_ptr[0..len])}); |
| 2349 | 2338 | const node = try Tag.string_literal.create(c.arena, str); |
| 2350 | | return maybeSuppressResult(c, scope, result_used, node); |
| 2339 | return maybeSuppressResult(c, result_used, node); |
| 2351 | 2340 | } |
| 2352 | 2341 | |
| 2353 | 2342 | fn transStringLiteral( |
| ... | ... | @@ -2358,18 +2347,18 @@ fn transStringLiteral( |
| 2358 | 2347 | ) TransError!Node { |
| 2359 | 2348 | const kind = stmt.getKind(); |
| 2360 | 2349 | switch (kind) { |
| 2361 | | .Ascii, .UTF8 => return transNarrowStringLiteral(c, scope, stmt, result_used), |
| 2350 | .Ascii, .UTF8 => return transNarrowStringLiteral(c, stmt, result_used), |
| 2362 | 2351 | .UTF16, .UTF32, .Wide => { |
| 2363 | 2352 | const str_type = @tagName(stmt.getKind()); |
| 2364 | 2353 | const name = try std.fmt.allocPrint(c.arena, "zig.{s}_string_{d}", .{ str_type, c.getMangle() }); |
| 2365 | 2354 | |
| 2366 | 2355 | const expr_base = @ptrCast(*const clang.Expr, stmt); |
| 2367 | 2356 | const array_type = try transQualTypeInitialized(c, scope, expr_base.getType(), expr_base, expr_base.getBeginLoc()); |
| 2368 | | const lit_array = try transStringLiteralInitializer(c, scope, stmt, array_type); |
| 2357 | const lit_array = try transStringLiteralInitializer(c, stmt, array_type); |
| 2369 | 2358 | const decl = try Tag.var_simple.create(c.arena, .{ .name = name, .init = lit_array }); |
| 2370 | 2359 | try scope.appendNode(decl); |
| 2371 | 2360 | const node = try Tag.identifier.create(c.arena, name); |
| 2372 | | return maybeSuppressResult(c, scope, result_used, node); |
| 2361 | return maybeSuppressResult(c, result_used, node); |
| 2373 | 2362 | }, |
| 2374 | 2363 | } |
| 2375 | 2364 | } |
| ... | ... | @@ -2384,7 +2373,6 @@ fn getArrayPayload(array_type: Node) ast.Payload.Array.ArrayTypeInfo { |
| 2384 | 2373 | /// the appropriate length, if necessary. |
| 2385 | 2374 | fn transStringLiteralInitializer( |
| 2386 | 2375 | c: *Context, |
| 2387 | | scope: *Scope, |
| 2388 | 2376 | stmt: *const clang.StringLiteral, |
| 2389 | 2377 | array_type: Node, |
| 2390 | 2378 | ) TransError!Node { |
| ... | ... | @@ -2403,7 +2391,7 @@ fn transStringLiteralInitializer( |
| 2403 | 2391 | const init_node = if (num_inits > 0) blk: { |
| 2404 | 2392 | if (is_narrow) { |
| 2405 | 2393 | // "string literal".* or string literal"[0..num_inits].* |
| 2406 | | var str = try transNarrowStringLiteral(c, scope, stmt, .used); |
| 2394 | var str = try transNarrowStringLiteral(c, stmt, .used); |
| 2407 | 2395 | if (str_length != array_size) str = try Tag.string_slice.create(c.arena, .{ .string = str, .end = num_inits }); |
| 2408 | 2396 | break :blk try Tag.deref.create(c.arena, str); |
| 2409 | 2397 | } else { |
| ... | ... | @@ -2440,8 +2428,7 @@ fn transStringLiteralInitializer( |
| 2440 | 2428 | /// determine whether `stmt` is a "pointer subtraction expression" - a subtraction where |
| 2441 | 2429 | /// both operands resolve to addresses. The C standard requires that both operands |
| 2442 | 2430 | /// point to elements of the same array object, but we do not verify that here. |
| 2443 | | fn cIsPointerDiffExpr(c: *Context, stmt: *const clang.BinaryOperator) bool { |
| 2444 | | _ = c; |
| 2431 | fn cIsPointerDiffExpr(stmt: *const clang.BinaryOperator) bool { |
| 2445 | 2432 | const lhs = @ptrCast(*const clang.Stmt, stmt.getLHS()); |
| 2446 | 2433 | const rhs = @ptrCast(*const clang.Stmt, stmt.getRHS()); |
| 2447 | 2434 | return stmt.getOpcode() == .Sub and |
| ... | ... | @@ -2748,9 +2735,7 @@ fn transInitListExprVector( |
| 2748 | 2735 | scope: *Scope, |
| 2749 | 2736 | loc: clang.SourceLocation, |
| 2750 | 2737 | expr: *const clang.InitListExpr, |
| 2751 | | ty: *const clang.Type, |
| 2752 | 2738 | ) TransError!Node { |
| 2753 | | _ = ty; |
| 2754 | 2739 | const qt = getExprQualType(c, @ptrCast(*const clang.Expr, expr)); |
| 2755 | 2740 | const vector_ty = @ptrCast(*const clang.VectorType, qualTypeCanon(qt)); |
| 2756 | 2741 | |
| ... | ... | @@ -2829,7 +2814,7 @@ fn transInitListExpr( |
| 2829 | 2814 | } |
| 2830 | 2815 | |
| 2831 | 2816 | if (qual_type.isRecordType()) { |
| 2832 | | return maybeSuppressResult(c, scope, used, try transInitListExprRecord( |
| 2817 | return maybeSuppressResult(c, used, try transInitListExprRecord( |
| 2833 | 2818 | c, |
| 2834 | 2819 | scope, |
| 2835 | 2820 | source_loc, |
| ... | ... | @@ -2837,7 +2822,7 @@ fn transInitListExpr( |
| 2837 | 2822 | qual_type, |
| 2838 | 2823 | )); |
| 2839 | 2824 | } else if (qual_type.isArrayType()) { |
| 2840 | | return maybeSuppressResult(c, scope, used, try transInitListExprArray( |
| 2825 | return maybeSuppressResult(c, used, try transInitListExprArray( |
| 2841 | 2826 | c, |
| 2842 | 2827 | scope, |
| 2843 | 2828 | source_loc, |
| ... | ... | @@ -2845,13 +2830,7 @@ fn transInitListExpr( |
| 2845 | 2830 | qual_type, |
| 2846 | 2831 | )); |
| 2847 | 2832 | } else if (qual_type.isVectorType()) { |
| 2848 | | return maybeSuppressResult(c, scope, used, try transInitListExprVector( |
| 2849 | | c, |
| 2850 | | scope, |
| 2851 | | source_loc, |
| 2852 | | expr, |
| 2853 | | qual_type, |
| 2854 | | )); |
| 2833 | return maybeSuppressResult(c, used, try transInitListExprVector(c, scope, source_loc, expr)); |
| 2855 | 2834 | } else { |
| 2856 | 2835 | const type_name = try c.str(qual_type.getTypeClassName()); |
| 2857 | 2836 | return fail(c, error.UnsupportedType, source_loc, "unsupported initlist type: '{s}'", .{type_name}); |
| ... | ... | @@ -2912,9 +2891,7 @@ fn transImplicitValueInitExpr( |
| 2912 | 2891 | c: *Context, |
| 2913 | 2892 | scope: *Scope, |
| 2914 | 2893 | expr: *const clang.Expr, |
| 2915 | | used: ResultUsed, |
| 2916 | 2894 | ) TransError!Node { |
| 2917 | | _ = used; |
| 2918 | 2895 | const source_loc = expr.getBeginLoc(); |
| 2919 | 2896 | const qt = getExprQualType(c, expr); |
| 2920 | 2897 | const ty = qt.getTypePtr(); |
| ... | ... | @@ -3354,7 +3331,7 @@ fn transConstantExpr(c: *Context, scope: *Scope, expr: *const clang.Expr, used: |
| 3354 | 3331 | .lhs = try transQualType(c, scope, expr_base.getType(), expr_base.getBeginLoc()), |
| 3355 | 3332 | .rhs = try transCreateNodeAPInt(c, result.Val.getInt()), |
| 3356 | 3333 | }); |
| 3357 | | return maybeSuppressResult(c, scope, used, as_node); |
| 3334 | return maybeSuppressResult(c, used, as_node); |
| 3358 | 3335 | }, |
| 3359 | 3336 | else => |kind| { |
| 3360 | 3337 | return fail(c, error.UnsupportedTranslation, expr.getBeginLoc(), "unsupported constant expression kind '{}'", .{kind}); |
| ... | ... | @@ -3391,7 +3368,7 @@ fn transCharLiteral( |
| 3391 | 3368 | try transCreateCharLitNode(c, narrow, val); |
| 3392 | 3369 | |
| 3393 | 3370 | if (suppress_as == .no_as) { |
| 3394 | | return maybeSuppressResult(c, scope, result_used, int_lit_node); |
| 3371 | return maybeSuppressResult(c, result_used, int_lit_node); |
| 3395 | 3372 | } |
| 3396 | 3373 | // See comment in `transIntegerLiteral` for why this code is here. |
| 3397 | 3374 | // @as(T, x) |
| ... | ... | @@ -3400,7 +3377,7 @@ fn transCharLiteral( |
| 3400 | 3377 | .lhs = try transQualType(c, scope, expr_base.getType(), expr_base.getBeginLoc()), |
| 3401 | 3378 | .rhs = int_lit_node, |
| 3402 | 3379 | }); |
| 3403 | | return maybeSuppressResult(c, scope, result_used, as_node); |
| 3380 | return maybeSuppressResult(c, result_used, as_node); |
| 3404 | 3381 | } |
| 3405 | 3382 | |
| 3406 | 3383 | fn transStmtExpr(c: *Context, scope: *Scope, stmt: *const clang.StmtExpr, used: ResultUsed) TransError!Node { |
| ... | ... | @@ -3426,7 +3403,7 @@ fn transStmtExpr(c: *Context, scope: *Scope, stmt: *const clang.StmtExpr, used: |
| 3426 | 3403 | }); |
| 3427 | 3404 | try block_scope.statements.append(break_node); |
| 3428 | 3405 | const res = try block_scope.complete(c); |
| 3429 | | return maybeSuppressResult(c, scope, used, res); |
| 3406 | return maybeSuppressResult(c, used, res); |
| 3430 | 3407 | } |
| 3431 | 3408 | |
| 3432 | 3409 | fn transMemberExpr(c: *Context, scope: *Scope, stmt: *const clang.MemberExpr, result_used: ResultUsed) TransError!Node { |
| ... | ... | @@ -3455,7 +3432,7 @@ fn transMemberExpr(c: *Context, scope: *Scope, stmt: *const clang.MemberExpr, re |
| 3455 | 3432 | if (exprIsFlexibleArrayRef(c, @ptrCast(*const clang.Expr, stmt))) { |
| 3456 | 3433 | node = try Tag.call.create(c.arena, .{ .lhs = node, .args = &.{} }); |
| 3457 | 3434 | } |
| 3458 | | return maybeSuppressResult(c, scope, result_used, node); |
| 3435 | return maybeSuppressResult(c, result_used, node); |
| 3459 | 3436 | } |
| 3460 | 3437 | |
| 3461 | 3438 | /// ptr[subscr] (`subscr` is a signed integer expression, `ptr` a pointer) becomes: |
| ... | ... | @@ -3533,7 +3510,7 @@ fn transSignedArrayAccess( |
| 3533 | 3510 | |
| 3534 | 3511 | const derefed = try Tag.deref.create(c.arena, block_node); |
| 3535 | 3512 | |
| 3536 | | return maybeSuppressResult(c, &block_scope.base, result_used, derefed); |
| 3513 | return maybeSuppressResult(c, result_used, derefed); |
| 3537 | 3514 | } |
| 3538 | 3515 | |
| 3539 | 3516 | fn transArrayAccess(c: *Context, scope: *Scope, stmt: *const clang.ArraySubscriptExpr, result_used: ResultUsed) TransError!Node { |
| ... | ... | @@ -3574,7 +3551,7 @@ fn transArrayAccess(c: *Context, scope: *Scope, stmt: *const clang.ArraySubscrip |
| 3574 | 3551 | .lhs = container_node, |
| 3575 | 3552 | .rhs = rhs, |
| 3576 | 3553 | }); |
| 3577 | | return maybeSuppressResult(c, scope, result_used, node); |
| 3554 | return maybeSuppressResult(c, result_used, node); |
| 3578 | 3555 | } |
| 3579 | 3556 | |
| 3580 | 3557 | /// Check if an expression is ultimately a reference to a function declaration |
| ... | ... | @@ -3665,7 +3642,7 @@ fn transCallExpr(c: *Context, scope: *Scope, stmt: *const clang.CallExpr, result |
| 3665 | 3642 | } |
| 3666 | 3643 | } |
| 3667 | 3644 | |
| 3668 | | return maybeSuppressResult(c, scope, result_used, node); |
| 3645 | return maybeSuppressResult(c, result_used, node); |
| 3669 | 3646 | } |
| 3670 | 3647 | |
| 3671 | 3648 | const ClangFunctionType = union(enum) { |
| ... | ... | @@ -3705,14 +3682,13 @@ fn transUnaryExprOrTypeTraitExpr( |
| 3705 | 3682 | stmt: *const clang.UnaryExprOrTypeTraitExpr, |
| 3706 | 3683 | result_used: ResultUsed, |
| 3707 | 3684 | ) TransError!Node { |
| 3708 | | _ = result_used; |
| 3709 | 3685 | const loc = stmt.getBeginLoc(); |
| 3710 | 3686 | const type_node = try transQualType(c, scope, stmt.getTypeOfArgument(), loc); |
| 3711 | 3687 | |
| 3712 | 3688 | const kind = stmt.getKind(); |
| 3713 | | switch (kind) { |
| 3714 | | .SizeOf => return Tag.sizeof.create(c.arena, type_node), |
| 3715 | | .AlignOf => return Tag.alignof.create(c.arena, type_node), |
| 3689 | const node = switch (kind) { |
| 3690 | .SizeOf => try Tag.sizeof.create(c.arena, type_node), |
| 3691 | .AlignOf => try Tag.alignof.create(c.arena, type_node), |
| 3716 | 3692 | .PreferredAlignOf, |
| 3717 | 3693 | .VecStep, |
| 3718 | 3694 | .OpenMPRequiredSimdAlign, |
| ... | ... | @@ -3723,7 +3699,8 @@ fn transUnaryExprOrTypeTraitExpr( |
| 3723 | 3699 | "unsupported type trait kind {}", |
| 3724 | 3700 | .{kind}, |
| 3725 | 3701 | ), |
| 3726 | | } |
| 3702 | }; |
| 3703 | return maybeSuppressResult(c, result_used, node); |
| 3727 | 3704 | } |
| 3728 | 3705 | |
| 3729 | 3706 | fn qualTypeHasWrappingOverflow(qt: clang.QualType) bool { |
| ... | ... | @@ -3812,7 +3789,7 @@ fn transCreatePreCrement( |
| 3812 | 3789 | // zig: expr += 1 |
| 3813 | 3790 | const lhs = try transExpr(c, scope, op_expr, .used); |
| 3814 | 3791 | const rhs = Tag.one_literal.init(); |
| 3815 | | return transCreateNodeInfixOp(c, scope, op, lhs, rhs, .used); |
| 3792 | return transCreateNodeInfixOp(c, op, lhs, rhs, .used); |
| 3816 | 3793 | } |
| 3817 | 3794 | // worst case |
| 3818 | 3795 | // c: ++expr |
| ... | ... | @@ -3832,7 +3809,7 @@ fn transCreatePreCrement( |
| 3832 | 3809 | |
| 3833 | 3810 | const lhs_node = try Tag.identifier.create(c.arena, ref); |
| 3834 | 3811 | const ref_node = try Tag.deref.create(c.arena, lhs_node); |
| 3835 | | const node = try transCreateNodeInfixOp(c, &block_scope.base, op, ref_node, Tag.one_literal.init(), .used); |
| 3812 | const node = try transCreateNodeInfixOp(c, op, ref_node, Tag.one_literal.init(), .used); |
| 3836 | 3813 | try block_scope.statements.append(node); |
| 3837 | 3814 | |
| 3838 | 3815 | const break_node = try Tag.break_val.create(c.arena, .{ |
| ... | ... | @@ -3858,7 +3835,7 @@ fn transCreatePostCrement( |
| 3858 | 3835 | // zig: expr += 1 |
| 3859 | 3836 | const lhs = try transExpr(c, scope, op_expr, .used); |
| 3860 | 3837 | const rhs = Tag.one_literal.init(); |
| 3861 | | return transCreateNodeInfixOp(c, scope, op, lhs, rhs, .used); |
| 3838 | return transCreateNodeInfixOp(c, op, lhs, rhs, .used); |
| 3862 | 3839 | } |
| 3863 | 3840 | // worst case |
| 3864 | 3841 | // c: expr++ |
| ... | ... | @@ -3884,7 +3861,7 @@ fn transCreatePostCrement( |
| 3884 | 3861 | const tmp_decl = try Tag.var_simple.create(c.arena, .{ .name = tmp, .init = ref_node }); |
| 3885 | 3862 | try block_scope.statements.append(tmp_decl); |
| 3886 | 3863 | |
| 3887 | | const node = try transCreateNodeInfixOp(c, &block_scope.base, op, ref_node, Tag.one_literal.init(), .used); |
| 3864 | const node = try transCreateNodeInfixOp(c, op, ref_node, Tag.one_literal.init(), .used); |
| 3888 | 3865 | try block_scope.statements.append(node); |
| 3889 | 3866 | |
| 3890 | 3867 | const break_node = try Tag.break_val.create(c.arena, .{ |
| ... | ... | @@ -3965,7 +3942,7 @@ fn transCreateCompoundAssign( |
| 3965 | 3942 | else |
| 3966 | 3943 | try Tag.div_trunc.create(c.arena, operands); |
| 3967 | 3944 | |
| 3968 | | return transCreateNodeInfixOp(c, scope, .assign, lhs_node, builtin, .used); |
| 3945 | return transCreateNodeInfixOp(c, .assign, lhs_node, builtin, .used); |
| 3969 | 3946 | } |
| 3970 | 3947 | |
| 3971 | 3948 | if (is_shift) { |
| ... | ... | @@ -3974,7 +3951,7 @@ fn transCreateCompoundAssign( |
| 3974 | 3951 | } else if (requires_int_cast) { |
| 3975 | 3952 | rhs_node = try transCCast(c, scope, loc, lhs_qt, rhs_qt, rhs_node); |
| 3976 | 3953 | } |
| 3977 | | return transCreateNodeInfixOp(c, scope, op, lhs_node, rhs_node, .used); |
| 3954 | return transCreateNodeInfixOp(c, op, lhs_node, rhs_node, .used); |
| 3978 | 3955 | } |
| 3979 | 3956 | // worst case |
| 3980 | 3957 | // c: lhs += rhs |
| ... | ... | @@ -4005,7 +3982,7 @@ fn transCreateCompoundAssign( |
| 4005 | 3982 | else |
| 4006 | 3983 | try Tag.div_trunc.create(c.arena, operands); |
| 4007 | 3984 | |
| 4008 | | const assign = try transCreateNodeInfixOp(c, &block_scope.base, .assign, ref_node, builtin, .used); |
| 3985 | const assign = try transCreateNodeInfixOp(c, .assign, ref_node, builtin, .used); |
| 4009 | 3986 | try block_scope.statements.append(assign); |
| 4010 | 3987 | } else { |
| 4011 | 3988 | if (is_shift) { |
| ... | ... | @@ -4015,7 +3992,7 @@ fn transCreateCompoundAssign( |
| 4015 | 3992 | rhs_node = try transCCast(c, &block_scope.base, loc, lhs_qt, rhs_qt, rhs_node); |
| 4016 | 3993 | } |
| 4017 | 3994 | |
| 4018 | | const assign = try transCreateNodeInfixOp(c, &block_scope.base, op, ref_node, rhs_node, .used); |
| 3995 | const assign = try transCreateNodeInfixOp(c, op, ref_node, rhs_node, .used); |
| 4019 | 3996 | try block_scope.statements.append(assign); |
| 4020 | 3997 | } |
| 4021 | 3998 | |
| ... | ... | @@ -4071,7 +4048,7 @@ fn transCPtrCast( |
| 4071 | 4048 | } |
| 4072 | 4049 | } |
| 4073 | 4050 | |
| 4074 | | fn transFloatingLiteral(c: *Context, scope: *Scope, expr: *const clang.FloatingLiteral, used: ResultUsed) TransError!Node { |
| 4051 | fn transFloatingLiteral(c: *Context, expr: *const clang.FloatingLiteral, used: ResultUsed) TransError!Node { |
| 4075 | 4052 | switch (expr.getRawSemantics()) { |
| 4076 | 4053 | .IEEEhalf, // f16 |
| 4077 | 4054 | .IEEEsingle, // f32 |
| ... | ... | @@ -4095,7 +4072,7 @@ fn transFloatingLiteral(c: *Context, scope: *Scope, expr: *const clang.FloatingL |
| 4095 | 4072 | try std.fmt.allocPrint(c.arena, "{d}", .{dbl}); |
| 4096 | 4073 | var node = try Tag.float_literal.create(c.arena, str); |
| 4097 | 4074 | if (is_negative) node = try Tag.negate.create(c.arena, node); |
| 4098 | | return maybeSuppressResult(c, scope, used, node); |
| 4075 | return maybeSuppressResult(c, used, node); |
| 4099 | 4076 | } |
| 4100 | 4077 | |
| 4101 | 4078 | fn transBinaryConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang.BinaryConditionalOperator, used: ResultUsed) TransError!Node { |
| ... | ... | @@ -4151,7 +4128,7 @@ fn transBinaryConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang |
| 4151 | 4128 | }); |
| 4152 | 4129 | try block_scope.statements.append(break_node); |
| 4153 | 4130 | const res = try block_scope.complete(c); |
| 4154 | | return maybeSuppressResult(c, scope, used, res); |
| 4131 | return maybeSuppressResult(c, used, res); |
| 4155 | 4132 | } |
| 4156 | 4133 | |
| 4157 | 4134 | fn transConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang.ConditionalOperator, used: ResultUsed) TransError!Node { |
| ... | ... | @@ -4191,13 +4168,7 @@ fn transConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang.Condi |
| 4191 | 4168 | return if_node; |
| 4192 | 4169 | } |
| 4193 | 4170 | |
| 4194 | | fn maybeSuppressResult( |
| 4195 | | c: *Context, |
| 4196 | | scope: *Scope, |
| 4197 | | used: ResultUsed, |
| 4198 | | result: Node, |
| 4199 | | ) TransError!Node { |
| 4200 | | _ = scope; |
| 4171 | fn maybeSuppressResult(c: *Context, used: ResultUsed, result: Node) TransError!Node { |
| 4201 | 4172 | if (used == .used) return result; |
| 4202 | 4173 | return Tag.discard.create(c.arena, .{ .should_skip = false, .value = result }); |
| 4203 | 4174 | } |
| ... | ... | @@ -4551,7 +4522,7 @@ fn transCreateNodeAssign( |
| 4551 | 4522 | if (!exprIsBooleanType(lhs) and isBoolRes(rhs_node)) { |
| 4552 | 4523 | rhs_node = try Tag.bool_to_int.create(c.arena, rhs_node); |
| 4553 | 4524 | } |
| 4554 | | return transCreateNodeInfixOp(c, scope, .assign, lhs_node, rhs_node, .used); |
| 4525 | return transCreateNodeInfixOp(c, .assign, lhs_node, rhs_node, .used); |
| 4555 | 4526 | } |
| 4556 | 4527 | |
| 4557 | 4528 | // worst case |
| ... | ... | @@ -4571,7 +4542,7 @@ fn transCreateNodeAssign( |
| 4571 | 4542 | |
| 4572 | 4543 | const lhs_node = try transExpr(c, &block_scope.base, lhs, .used); |
| 4573 | 4544 | const tmp_ident = try Tag.identifier.create(c.arena, tmp); |
| 4574 | | const assign = try transCreateNodeInfixOp(c, &block_scope.base, .assign, lhs_node, tmp_ident, .used); |
| 4545 | const assign = try transCreateNodeInfixOp(c, .assign, lhs_node, tmp_ident, .used); |
| 4575 | 4546 | try block_scope.statements.append(assign); |
| 4576 | 4547 | |
| 4577 | 4548 | const break_node = try Tag.break_val.create(c.arena, .{ |
| ... | ... | @@ -4584,7 +4555,6 @@ fn transCreateNodeAssign( |
| 4584 | 4555 | |
| 4585 | 4556 | fn transCreateNodeInfixOp( |
| 4586 | 4557 | c: *Context, |
| 4587 | | scope: *Scope, |
| 4588 | 4558 | op: Tag, |
| 4589 | 4559 | lhs: Node, |
| 4590 | 4560 | rhs: Node, |
| ... | ... | @@ -4598,7 +4568,7 @@ fn transCreateNodeInfixOp( |
| 4598 | 4568 | .rhs = rhs, |
| 4599 | 4569 | }, |
| 4600 | 4570 | }; |
| 4601 | | return maybeSuppressResult(c, scope, used, Node.initPayload(&payload.base)); |
| 4571 | return maybeSuppressResult(c, used, Node.initPayload(&payload.base)); |
| 4602 | 4572 | } |
| 4603 | 4573 | |
| 4604 | 4574 | fn transCreateNodeBoolInfixOp( |
| ... | ... | @@ -4613,7 +4583,7 @@ fn transCreateNodeBoolInfixOp( |
| 4613 | 4583 | const lhs = try transBoolExpr(c, scope, stmt.getLHS(), .used); |
| 4614 | 4584 | const rhs = try transBoolExpr(c, scope, stmt.getRHS(), .used); |
| 4615 | 4585 | |
| 4616 | | return transCreateNodeInfixOp(c, scope, op, lhs, rhs, used); |
| 4586 | return transCreateNodeInfixOp(c, op, lhs, rhs, used); |
| 4617 | 4587 | } |
| 4618 | 4588 | |
| 4619 | 4589 | fn transCreateNodeAPInt(c: *Context, int: *const clang.APSInt) !Node { |
| ... | ... | @@ -4730,7 +4700,7 @@ fn transCreateNodeShiftOp( |
| 4730 | 4700 | const rhs = try transExprCoercing(c, scope, rhs_expr, .used); |
| 4731 | 4701 | const rhs_casted = try Tag.int_cast.create(c.arena, .{ .lhs = rhs_type, .rhs = rhs }); |
| 4732 | 4702 | |
| 4733 | | return transCreateNodeInfixOp(c, scope, op, lhs, rhs_casted, used); |
| 4703 | return transCreateNodeInfixOp(c, op, lhs, rhs_casted, used); |
| 4734 | 4704 | } |
| 4735 | 4705 | |
| 4736 | 4706 | fn transType(c: *Context, scope: *Scope, ty: *const clang.Type, source_loc: clang.SourceLocation) TypeError!Node { |
| ... | ... | @@ -6298,7 +6268,7 @@ fn parseCCastExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { |
| 6298 | 6268 | // allow_fail is set when unsure if we are parsing a type-name |
| 6299 | 6269 | fn parseCTypeName(c: *Context, m: *MacroCtx, scope: *Scope, allow_fail: bool) ParseError!?Node { |
| 6300 | 6270 | if (try parseCSpecifierQualifierList(c, m, scope, allow_fail)) |node| { |
| 6301 | | return try parseCAbstractDeclarator(c, m, scope, node); |
| 6271 | return try parseCAbstractDeclarator(c, m, node); |
| 6302 | 6272 | } else { |
| 6303 | 6273 | return null; |
| 6304 | 6274 | } |
| ... | ... | @@ -6327,7 +6297,7 @@ fn parseCSpecifierQualifierList(c: *Context, m: *MacroCtx, scope: *Scope, allow_ |
| 6327 | 6297 | .Keyword_complex, |
| 6328 | 6298 | => { |
| 6329 | 6299 | m.i -= 1; |
| 6330 | | return try parseCNumericType(c, m, scope); |
| 6300 | return try parseCNumericType(c, m); |
| 6331 | 6301 | }, |
| 6332 | 6302 | .Keyword_enum, .Keyword_struct, .Keyword_union => { |
| 6333 | 6303 | // struct Foo will be declared as struct_Foo by transRecordDecl |
| ... | ... | @@ -6349,8 +6319,7 @@ fn parseCSpecifierQualifierList(c: *Context, m: *MacroCtx, scope: *Scope, allow_ |
| 6349 | 6319 | } |
| 6350 | 6320 | } |
| 6351 | 6321 | |
| 6352 | | fn parseCNumericType(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { |
| 6353 | | _ = scope; |
| 6322 | fn parseCNumericType(c: *Context, m: *MacroCtx) ParseError!Node { |
| 6354 | 6323 | const KwCounter = struct { |
| 6355 | 6324 | double: u8 = 0, |
| 6356 | 6325 | long: u8 = 0, |
| ... | ... | @@ -6451,8 +6420,7 @@ fn parseCNumericType(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { |
| 6451 | 6420 | return error.ParseError; |
| 6452 | 6421 | } |
| 6453 | 6422 | |
| 6454 | | fn parseCAbstractDeclarator(c: *Context, m: *MacroCtx, scope: *Scope, node: Node) ParseError!Node { |
| 6455 | | _ = scope; |
| 6423 | fn parseCAbstractDeclarator(c: *Context, m: *MacroCtx, node: Node) ParseError!Node { |
| 6456 | 6424 | switch (m.next().?) { |
| 6457 | 6425 | .Asterisk => { |
| 6458 | 6426 | // last token of `node` |