| ... | @@ -224,8 +224,7 @@ const Scope = struct { | ... | @@ -224,8 +224,7 @@ const Scope = struct { |
| 224 | } | 224 | } |
| 225 | } | 225 | } |
| 226 | | 226 | |
| 227 | fn findBlockReturnType(inner: *Scope, c: *Context) clang.QualType { | 227 | fn findBlockReturnType(inner: *Scope) clang.QualType { |
| 228 | _ = c; | | |
| 229 | var scope = inner; | 228 | var scope = inner; |
| 230 | while (true) { | 229 | while (true) { |
| 231 | switch (scope.id) { | 230 | switch (scope.id) { |
| ... | @@ -833,7 +832,7 @@ fn visitVarDecl(c: *Context, var_decl: *const clang.VarDecl, mangled_name: ?[]co | ... | @@ -833,7 +832,7 @@ fn visitVarDecl(c: *Context, var_decl: *const clang.VarDecl, mangled_name: ?[]co |
| 833 | if (has_init) trans_init: { | 832 | if (has_init) trans_init: { |
| 834 | if (decl_init) |expr| { | 833 | if (decl_init) |expr| { |
| 835 | const node_or_error = if (expr.getStmtClass() == .StringLiteralClass) | 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 | else | 836 | else |
| 838 | transExprCoercing(c, scope, expr, .used); | 837 | transExprCoercing(c, scope, expr, .used); |
| 839 | init_node = node_or_error catch |err| switch (err) { | 838 | init_node = node_or_error catch |err| switch (err) { |
| ... | @@ -1319,10 +1318,10 @@ fn transStmt( | ... | @@ -1319,10 +1318,10 @@ fn transStmt( |
| 1319 | .StringLiteralClass => return transStringLiteral(c, scope, @ptrCast(*const clang.StringLiteral, stmt), result_used), | 1318 | .StringLiteralClass => return transStringLiteral(c, scope, @ptrCast(*const clang.StringLiteral, stmt), result_used), |
| 1320 | .ParenExprClass => { | 1319 | .ParenExprClass => { |
| 1321 | const expr = try transExpr(c, scope, @ptrCast(*const clang.ParenExpr, stmt).getSubExpr(), .used); | 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 | .InitListExprClass => return transInitListExpr(c, scope, @ptrCast(*const clang.InitListExpr, stmt), result_used), | 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 | .IfStmtClass => return transIfStmt(c, scope, @ptrCast(*const clang.IfStmt, stmt)), | 1325 | .IfStmtClass => return transIfStmt(c, scope, @ptrCast(*const clang.IfStmt, stmt)), |
| 1327 | .WhileStmtClass => return transWhileLoop(c, scope, @ptrCast(*const clang.WhileStmt, stmt)), | 1326 | .WhileStmtClass => return transWhileLoop(c, scope, @ptrCast(*const clang.WhileStmt, stmt)), |
| 1328 | .DoStmtClass => return transDoWhileLoop(c, scope, @ptrCast(*const clang.DoStmt, stmt)), | 1327 | .DoStmtClass => return transDoWhileLoop(c, scope, @ptrCast(*const clang.DoStmt, stmt)), |
| ... | @@ -1332,7 +1331,7 @@ fn transStmt( | ... | @@ -1332,7 +1331,7 @@ fn transStmt( |
| 1332 | .ContinueStmtClass => return Tag.@"continue".init(), | 1331 | .ContinueStmtClass => return Tag.@"continue".init(), |
| 1333 | .BreakStmtClass => return Tag.@"break".init(), | 1332 | .BreakStmtClass => return Tag.@"break".init(), |
| 1334 | .ForStmtClass => return transForLoop(c, scope, @ptrCast(*const clang.ForStmt, stmt)), | 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 | .ConditionalOperatorClass => { | 1335 | .ConditionalOperatorClass => { |
| 1337 | return transConditionalOperator(c, scope, @ptrCast(*const clang.ConditionalOperator, stmt), result_used); | 1336 | return transConditionalOperator(c, scope, @ptrCast(*const clang.ConditionalOperator, stmt), result_used); |
| 1338 | }, | 1337 | }, |
| ... | @@ -1356,9 +1355,9 @@ fn transStmt( | ... | @@ -1356,9 +1355,9 @@ fn transStmt( |
| 1356 | .OpaqueValueExprClass => { | 1355 | .OpaqueValueExprClass => { |
| 1357 | const source_expr = @ptrCast(*const clang.OpaqueValueExpr, stmt).getSourceExpr().?; | 1356 | const source_expr = @ptrCast(*const clang.OpaqueValueExpr, stmt).getSourceExpr().?; |
| 1358 | const expr = try transExpr(c, scope, source_expr, .used); | 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 | .CompoundLiteralExprClass => { | 1361 | .CompoundLiteralExprClass => { |
| 1363 | const compound_literal = @ptrCast(*const clang.CompoundLiteralExpr, stmt); | 1362 | const compound_literal = @ptrCast(*const clang.CompoundLiteralExpr, stmt); |
| 1364 | return transExpr(c, scope, compound_literal.getInitializer(), result_used); | 1363 | return transExpr(c, scope, compound_literal.getInitializer(), result_used); |
| ... | @@ -1369,13 +1368,13 @@ fn transStmt( | ... | @@ -1369,13 +1368,13 @@ fn transStmt( |
| 1369 | }, | 1368 | }, |
| 1370 | .ConvertVectorExprClass => { | 1369 | .ConvertVectorExprClass => { |
| 1371 | const conv_vec = @ptrCast(*const clang.ConvertVectorExpr, stmt); | 1370 | const conv_vec = @ptrCast(*const clang.ConvertVectorExpr, stmt); |
| 1372 | const conv_vec_node = try transConvertVectorExpr(c, scope, stmt.getBeginLoc(), conv_vec); | 1371 | const conv_vec_node = try transConvertVectorExpr(c, scope, conv_vec); |
| 1373 | return maybeSuppressResult(c, scope, result_used, conv_vec_node); | 1372 | return maybeSuppressResult(c, result_used, conv_vec_node); |
| 1374 | }, | 1373 | }, |
| 1375 | .ShuffleVectorExprClass => { | 1374 | .ShuffleVectorExprClass => { |
| 1376 | const shuffle_vec_expr = @ptrCast(*const clang.ShuffleVectorExpr, stmt); | 1375 | const shuffle_vec_expr = @ptrCast(*const clang.ShuffleVectorExpr, stmt); |
| 1377 | const shuffle_vec_node = try transShuffleVectorExpr(c, scope, shuffle_vec_expr); | 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 | .ChooseExprClass => { | 1379 | .ChooseExprClass => { |
| 1381 | const choose_expr = @ptrCast(*const clang.ChooseExpr, stmt); | 1380 | const choose_expr = @ptrCast(*const clang.ChooseExpr, stmt); |
| ... | @@ -1402,10 +1401,8 @@ fn transStmt( | ... | @@ -1402,10 +1401,8 @@ fn transStmt( |
| 1402 | fn transConvertVectorExpr( | 1401 | fn transConvertVectorExpr( |
| 1403 | c: *Context, | 1402 | c: *Context, |
| 1404 | scope: *Scope, | 1403 | scope: *Scope, |
| 1405 | source_loc: clang.SourceLocation, | | |
| 1406 | expr: *const clang.ConvertVectorExpr, | 1404 | expr: *const clang.ConvertVectorExpr, |
| 1407 | ) TransError!Node { | 1405 | ) TransError!Node { |
| 1408 | _ = source_loc; | | |
| 1409 | const base_stmt = @ptrCast(*const clang.Stmt, expr); | 1406 | const base_stmt = @ptrCast(*const clang.Stmt, expr); |
| 1410 | | 1407 | |
| 1411 | var block_scope = try Scope.Block.init(c, scope, true); | 1408 | var block_scope = try Scope.Block.init(c, scope, true); |
| ... | @@ -1521,12 +1518,7 @@ fn transShuffleVectorExpr( | ... | @@ -1521,12 +1518,7 @@ fn transShuffleVectorExpr( |
| 1521 | | 1518 | |
| 1522 | /// Translate a "simple" offsetof expression containing exactly one component, | 1519 | /// Translate a "simple" offsetof expression containing exactly one component, |
| 1523 | /// when that component is of kind .Field - e.g. offsetof(mytype, myfield) | 1520 | /// when that component is of kind .Field - e.g. offsetof(mytype, myfield) |
| 1524 | fn transSimpleOffsetOfExpr( | 1521 | fn transSimpleOffsetOfExpr(c: *Context, expr: *const clang.OffsetOfExpr) TransError!Node { |
| 1525 | c: *Context, | | |
| 1526 | scope: *Scope, | | |
| 1527 | expr: *const clang.OffsetOfExpr, | | |
| 1528 | ) TransError!Node { | | |
| 1529 | _ = scope; | | |
| 1530 | assert(expr.getNumComponents() == 1); | 1522 | assert(expr.getNumComponents() == 1); |
| 1531 | const component = expr.getComponent(0); | 1523 | const component = expr.getComponent(0); |
| 1532 | if (component.getKind() == .Field) { | 1524 | if (component.getKind() == .Field) { |
| ... | @@ -1551,13 +1543,12 @@ fn transSimpleOffsetOfExpr( | ... | @@ -1551,13 +1543,12 @@ fn transSimpleOffsetOfExpr( |
| 1551 | | 1543 | |
| 1552 | fn transOffsetOfExpr( | 1544 | fn transOffsetOfExpr( |
| 1553 | c: *Context, | 1545 | c: *Context, |
| 1554 | scope: *Scope, | | |
| 1555 | expr: *const clang.OffsetOfExpr, | 1546 | expr: *const clang.OffsetOfExpr, |
| 1556 | result_used: ResultUsed, | 1547 | result_used: ResultUsed, |
| 1557 | ) TransError!Node { | 1548 | ) TransError!Node { |
| 1558 | if (expr.getNumComponents() == 1) { | 1549 | if (expr.getNumComponents() == 1) { |
| 1559 | const offsetof_expr = try transSimpleOffsetOfExpr(c, scope, expr); | 1550 | const offsetof_expr = try transSimpleOffsetOfExpr(c, expr); |
| 1560 | return maybeSuppressResult(c, scope, result_used, offsetof_expr); | 1551 | return maybeSuppressResult(c, result_used, offsetof_expr); |
| 1561 | } | 1552 | } |
| 1562 | | 1553 | |
| 1563 | // TODO implement OffsetOfExpr with more than 1 component | 1554 | // TODO implement OffsetOfExpr with more than 1 component |
| ... | @@ -1613,7 +1604,6 @@ fn transCreatePointerArithmeticSignedOp( | ... | @@ -1613,7 +1604,6 @@ fn transCreatePointerArithmeticSignedOp( |
| 1613 | | 1604 | |
| 1614 | return transCreateNodeInfixOp( | 1605 | return transCreateNodeInfixOp( |
| 1615 | c, | 1606 | c, |
| 1616 | scope, | | |
| 1617 | if (is_add) .add else .sub, | 1607 | if (is_add) .add else .sub, |
| 1618 | lhs_node, | 1608 | lhs_node, |
| 1619 | bitcast_node, | 1609 | bitcast_node, |
| ... | @@ -1629,7 +1619,7 @@ fn transBinaryOperator( | ... | @@ -1629,7 +1619,7 @@ fn transBinaryOperator( |
| 1629 | ) TransError!Node { | 1619 | ) TransError!Node { |
| 1630 | const op = stmt.getOpcode(); | 1620 | const op = stmt.getOpcode(); |
| 1631 | const qt = stmt.getType(); | 1621 | const qt = stmt.getType(); |
| 1632 | const isPointerDiffExpr = cIsPointerDiffExpr(c, stmt); | 1622 | const isPointerDiffExpr = cIsPointerDiffExpr(stmt); |
| 1633 | switch (op) { | 1623 | switch (op) { |
| 1634 | .Assign => return try transCreateNodeAssign(c, scope, result_used, stmt.getLHS(), stmt.getRHS()), | 1624 | .Assign => return try transCreateNodeAssign(c, scope, result_used, stmt.getLHS(), stmt.getRHS()), |
| 1635 | .Comma => { | 1625 | .Comma => { |
| ... | @@ -1646,7 +1636,7 @@ fn transBinaryOperator( | ... | @@ -1646,7 +1636,7 @@ fn transBinaryOperator( |
| 1646 | }); | 1636 | }); |
| 1647 | try block_scope.statements.append(break_node); | 1637 | try block_scope.statements.append(break_node); |
| 1648 | const block_node = try block_scope.complete(c); | 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 | .Div => { | 1641 | .Div => { |
| 1652 | if (cIsSignedInteger(qt)) { | 1642 | if (cIsSignedInteger(qt)) { |
| ... | @@ -1654,7 +1644,7 @@ fn transBinaryOperator( | ... | @@ -1654,7 +1644,7 @@ fn transBinaryOperator( |
| 1654 | const lhs = try transExpr(c, scope, stmt.getLHS(), .used); | 1644 | const lhs = try transExpr(c, scope, stmt.getLHS(), .used); |
| 1655 | const rhs = try transExpr(c, scope, stmt.getRHS(), .used); | 1645 | const rhs = try transExpr(c, scope, stmt.getRHS(), .used); |
| 1656 | const div_trunc = try Tag.div_trunc.create(c.arena, .{ .lhs = lhs, .rhs = rhs }); | 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 | .Rem => { | 1650 | .Rem => { |
| ... | @@ -1663,7 +1653,7 @@ fn transBinaryOperator( | ... | @@ -1663,7 +1653,7 @@ fn transBinaryOperator( |
| 1663 | const lhs = try transExpr(c, scope, stmt.getLHS(), .used); | 1653 | const lhs = try transExpr(c, scope, stmt.getLHS(), .used); |
| 1664 | const rhs = try transExpr(c, scope, stmt.getRHS(), .used); | 1654 | const rhs = try transExpr(c, scope, stmt.getRHS(), .used); |
| 1665 | const rem = try Tag.signed_remainder.create(c.arena, .{ .lhs = lhs, .rhs = rhs }); | 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 | .Shl => { | 1659 | .Shl => { |
| ... | @@ -1764,7 +1754,7 @@ fn transBinaryOperator( | ... | @@ -1764,7 +1754,7 @@ fn transBinaryOperator( |
| 1764 | else | 1754 | else |
| 1765 | rhs_uncasted; | 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 | if (isPointerDiffExpr) { | 1758 | if (isPointerDiffExpr) { |
| 1769 | // @divExact(@bitCast(<platform-ptrdiff_t>, @ptrToInt(lhs) -% @ptrToInt(rhs)), @sizeOf(<lhs target type>)) | 1759 | // @divExact(@bitCast(<platform-ptrdiff_t>, @ptrToInt(lhs) -% @ptrToInt(rhs)), @sizeOf(<lhs target type>)) |
| 1770 | const ptrdiff_type = try transQualTypeIntWidthOf(c, qt, true); | 1760 | const ptrdiff_type = try transQualTypeIntWidthOf(c, qt, true); |
| ... | @@ -1843,7 +1833,7 @@ fn transCStyleCastExprClass( | ... | @@ -1843,7 +1833,7 @@ fn transCStyleCastExprClass( |
| 1843 | src_type, | 1833 | src_type, |
| 1844 | sub_expr_node, | 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 | /// The alignment of a variable or field | 1839 | /// The alignment of a variable or field |
| ... | @@ -1933,7 +1923,7 @@ fn transDeclStmtOne( | ... | @@ -1933,7 +1923,7 @@ fn transDeclStmtOne( |
| 1933 | | 1923 | |
| 1934 | var init_node = if (decl_init) |expr| | 1924 | var init_node = if (decl_init) |expr| |
| 1935 | if (expr.getStmtClass() == .StringLiteralClass) | 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 | else | 1927 | else |
| 1938 | try transExprCoercing(c, scope, expr, .used) | 1928 | try transExprCoercing(c, scope, expr, .used) |
| 1939 | else if (is_static_local) | 1929 | else if (is_static_local) |
| ... | @@ -2051,21 +2041,21 @@ fn transImplicitCastExpr( | ... | @@ -2051,21 +2041,21 @@ fn transImplicitCastExpr( |
| 2051 | .BitCast, .FloatingCast, .FloatingToIntegral, .IntegralToFloating, .IntegralCast, .PointerToIntegral, .IntegralToPointer => { | 2041 | .BitCast, .FloatingCast, .FloatingToIntegral, .IntegralToFloating, .IntegralCast, .PointerToIntegral, .IntegralToPointer => { |
| 2052 | const sub_expr_node = try transExpr(c, scope, sub_expr, .used); | 2042 | const sub_expr_node = try transExpr(c, scope, sub_expr, .used); |
| 2053 | const casted = try transCCast(c, scope, expr.getBeginLoc(), dest_type, src_type, sub_expr_node); | 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 | .LValueToRValue, .NoOp, .FunctionToPointerDecay => { | 2046 | .LValueToRValue, .NoOp, .FunctionToPointerDecay => { |
| 2057 | const sub_expr_node = try transExpr(c, scope, sub_expr, .used); | 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 | .ArrayToPointerDecay => { | 2050 | .ArrayToPointerDecay => { |
| 2061 | const sub_expr_node = try transExpr(c, scope, sub_expr, .used); | 2051 | const sub_expr_node = try transExpr(c, scope, sub_expr, .used); |
| 2062 | if (exprIsNarrowStringLiteral(sub_expr) or exprIsFlexibleArrayRef(c, sub_expr)) { | 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 | const addr = try Tag.address_of.create(c.arena, sub_expr_node); | 2056 | const addr = try Tag.address_of.create(c.arena, sub_expr_node); |
| 2067 | const casted = try transCPtrCast(c, scope, expr.getBeginLoc(), dest_type, src_type, addr); | 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 | .NullToPointer => { | 2060 | .NullToPointer => { |
| 2071 | return Tag.null_literal.init(); | 2061 | return Tag.null_literal.init(); |
| ... | @@ -2076,18 +2066,18 @@ fn transImplicitCastExpr( | ... | @@ -2076,18 +2066,18 @@ fn transImplicitCastExpr( |
| 2076 | const ptr_to_int = try Tag.ptr_to_int.create(c.arena, ptr_node); | 2066 | const ptr_to_int = try Tag.ptr_to_int.create(c.arena, ptr_node); |
| 2077 | | 2067 | |
| 2078 | const ne = try Tag.not_equal.create(c.arena, .{ .lhs = ptr_to_int, .rhs = Tag.zero_literal.init() }); | 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 | .IntegralToBoolean, .FloatingToBoolean => { | 2071 | .IntegralToBoolean, .FloatingToBoolean => { |
| 2082 | const sub_expr_node = try transExpr(c, scope, sub_expr, .used); | 2072 | const sub_expr_node = try transExpr(c, scope, sub_expr, .used); |
| 2083 | | 2073 | |
| 2084 | // The expression is already a boolean one, return it as-is | 2074 | // The expression is already a boolean one, return it as-is |
| 2085 | if (isBoolRes(sub_expr_node)) | 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 | // val != 0 | 2078 | // val != 0 |
| 2089 | const ne = try Tag.not_equal.create(c.arena, .{ .lhs = sub_expr_node, .rhs = Tag.zero_literal.init() }); | 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 | .BuiltinFnToFnPtr => { | 2082 | .BuiltinFnToFnPtr => { |
| 2093 | return transBuiltinFnExpr(c, scope, sub_expr, result_used); | 2083 | return transBuiltinFnExpr(c, scope, sub_expr, result_used); |
| ... | @@ -2140,13 +2130,13 @@ fn transBoolExpr( | ... | @@ -2140,13 +2130,13 @@ fn transBoolExpr( |
| 2140 | | 2130 | |
| 2141 | var res = try transExpr(c, scope, expr, used); | 2131 | var res = try transExpr(c, scope, expr, used); |
| 2142 | if (isBoolRes(res)) { | 2132 | if (isBoolRes(res)) { |
| 2143 | return maybeSuppressResult(c, scope, used, res); | 2133 | return maybeSuppressResult(c, used, res); |
| 2144 | } | 2134 | } |
| 2145 | | 2135 | |
| 2146 | const ty = getExprQualType(c, expr).getTypePtr(); | 2136 | const ty = getExprQualType(c, expr).getTypePtr(); |
| 2147 | const node = try finishBoolExpr(c, scope, expr.getBeginLoc(), ty, res, used); | 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 | fn exprIsBooleanType(expr: *const clang.Expr) bool { | 2142 | fn exprIsBooleanType(expr: *const clang.Expr) bool { |
| ... | @@ -2299,7 +2289,7 @@ fn transIntegerLiteral( | ... | @@ -2299,7 +2289,7 @@ fn transIntegerLiteral( |
| 2299 | | 2289 | |
| 2300 | if (suppress_as == .no_as) { | 2290 | if (suppress_as == .no_as) { |
| 2301 | const int_lit_node = try transCreateNodeAPInt(c, eval_result.Val.getInt()); | 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 | // Integer literals in C have types, and this can matter for several reasons. | 2295 | // Integer literals in C have types, and this can matter for several reasons. |
| ... | @@ -2317,7 +2307,7 @@ fn transIntegerLiteral( | ... | @@ -2317,7 +2307,7 @@ fn transIntegerLiteral( |
| 2317 | const ty_node = try transQualType(c, scope, expr_base.getType(), expr_base.getBeginLoc()); | 2307 | const ty_node = try transQualType(c, scope, expr_base.getType(), expr_base.getBeginLoc()); |
| 2318 | const rhs = try transCreateNodeAPInt(c, eval_result.Val.getInt()); | 2308 | const rhs = try transCreateNodeAPInt(c, eval_result.Val.getInt()); |
| 2319 | const as = try Tag.as.create(c.arena, .{ .lhs = ty_node, .rhs = rhs }); | 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 | fn transReturnStmt( | 2313 | fn transReturnStmt( |
| ... | @@ -2329,7 +2319,7 @@ fn transReturnStmt( | ... | @@ -2329,7 +2319,7 @@ fn transReturnStmt( |
| 2329 | return Tag.return_void.init(); | 2319 | return Tag.return_void.init(); |
| 2330 | | 2320 | |
| 2331 | var rhs = try transExprCoercing(c, scope, val_expr, .used); | 2321 | var rhs = try transExprCoercing(c, scope, val_expr, .used); |
| 2332 | const return_qt = scope.findBlockReturnType(c); | 2322 | const return_qt = scope.findBlockReturnType(); |
| 2333 | if (isBoolRes(rhs) and !qualTypeIsBoolean(return_qt)) { | 2323 | if (isBoolRes(rhs) and !qualTypeIsBoolean(return_qt)) { |
| 2334 | rhs = try Tag.bool_to_int.create(c.arena, rhs); | 2324 | rhs = try Tag.bool_to_int.create(c.arena, rhs); |
| 2335 | } | 2325 | } |
| ... | @@ -2338,7 +2328,6 @@ fn transReturnStmt( | ... | @@ -2338,7 +2328,6 @@ fn transReturnStmt( |
| 2338 | | 2328 | |
| 2339 | fn transNarrowStringLiteral( | 2329 | fn transNarrowStringLiteral( |
| 2340 | c: *Context, | 2330 | c: *Context, |
| 2341 | scope: *Scope, | | |
| 2342 | stmt: *const clang.StringLiteral, | 2331 | stmt: *const clang.StringLiteral, |
| 2343 | result_used: ResultUsed, | 2332 | result_used: ResultUsed, |
| 2344 | ) TransError!Node { | 2333 | ) TransError!Node { |
| ... | @@ -2347,7 +2336,7 @@ fn transNarrowStringLiteral( | ... | @@ -2347,7 +2336,7 @@ fn transNarrowStringLiteral( |
| 2347 | | 2336 | |
| 2348 | const str = try std.fmt.allocPrint(c.arena, "\"{}\"", .{std.zig.fmtEscapes(bytes_ptr[0..len])}); | 2337 | const str = try std.fmt.allocPrint(c.arena, "\"{}\"", .{std.zig.fmtEscapes(bytes_ptr[0..len])}); |
| 2349 | const node = try Tag.string_literal.create(c.arena, str); | 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 | fn transStringLiteral( | 2342 | fn transStringLiteral( |
| ... | @@ -2358,18 +2347,18 @@ fn transStringLiteral( | ... | @@ -2358,18 +2347,18 @@ fn transStringLiteral( |
| 2358 | ) TransError!Node { | 2347 | ) TransError!Node { |
| 2359 | const kind = stmt.getKind(); | 2348 | const kind = stmt.getKind(); |
| 2360 | switch (kind) { | 2349 | switch (kind) { |
| 2361 | .Ascii, .UTF8 => return transNarrowStringLiteral(c, scope, stmt, result_used), | 2350 | .Ascii, .UTF8 => return transNarrowStringLiteral(c, stmt, result_used), |
| 2362 | .UTF16, .UTF32, .Wide => { | 2351 | .UTF16, .UTF32, .Wide => { |
| 2363 | const str_type = @tagName(stmt.getKind()); | 2352 | const str_type = @tagName(stmt.getKind()); |
| 2364 | const name = try std.fmt.allocPrint(c.arena, "zig.{s}_string_{d}", .{ str_type, c.getMangle() }); | 2353 | const name = try std.fmt.allocPrint(c.arena, "zig.{s}_string_{d}", .{ str_type, c.getMangle() }); |
| 2365 | | 2354 | |
| 2366 | const expr_base = @ptrCast(*const clang.Expr, stmt); | 2355 | const expr_base = @ptrCast(*const clang.Expr, stmt); |
| 2367 | const array_type = try transQualTypeInitialized(c, scope, expr_base.getType(), expr_base, expr_base.getBeginLoc()); | 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 | const decl = try Tag.var_simple.create(c.arena, .{ .name = name, .init = lit_array }); | 2358 | const decl = try Tag.var_simple.create(c.arena, .{ .name = name, .init = lit_array }); |
| 2370 | try scope.appendNode(decl); | 2359 | try scope.appendNode(decl); |
| 2371 | const node = try Tag.identifier.create(c.arena, name); | 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,7 +2373,6 @@ fn getArrayPayload(array_type: Node) ast.Payload.Array.ArrayTypeInfo { |
| 2384 | /// the appropriate length, if necessary. | 2373 | /// the appropriate length, if necessary. |
| 2385 | fn transStringLiteralInitializer( | 2374 | fn transStringLiteralInitializer( |
| 2386 | c: *Context, | 2375 | c: *Context, |
| 2387 | scope: *Scope, | | |
| 2388 | stmt: *const clang.StringLiteral, | 2376 | stmt: *const clang.StringLiteral, |
| 2389 | array_type: Node, | 2377 | array_type: Node, |
| 2390 | ) TransError!Node { | 2378 | ) TransError!Node { |
| ... | @@ -2403,7 +2391,7 @@ fn transStringLiteralInitializer( | ... | @@ -2403,7 +2391,7 @@ fn transStringLiteralInitializer( |
| 2403 | const init_node = if (num_inits > 0) blk: { | 2391 | const init_node = if (num_inits > 0) blk: { |
| 2404 | if (is_narrow) { | 2392 | if (is_narrow) { |
| 2405 | // "string literal".* or string literal"[0..num_inits].* | 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 | if (str_length != array_size) str = try Tag.string_slice.create(c.arena, .{ .string = str, .end = num_inits }); | 2395 | if (str_length != array_size) str = try Tag.string_slice.create(c.arena, .{ .string = str, .end = num_inits }); |
| 2408 | break :blk try Tag.deref.create(c.arena, str); | 2396 | break :blk try Tag.deref.create(c.arena, str); |
| 2409 | } else { | 2397 | } else { |
| ... | @@ -2440,8 +2428,7 @@ fn transStringLiteralInitializer( | ... | @@ -2440,8 +2428,7 @@ fn transStringLiteralInitializer( |
| 2440 | /// determine whether `stmt` is a "pointer subtraction expression" - a subtraction where | 2428 | /// determine whether `stmt` is a "pointer subtraction expression" - a subtraction where |
| 2441 | /// both operands resolve to addresses. The C standard requires that both operands | 2429 | /// both operands resolve to addresses. The C standard requires that both operands |
| 2442 | /// point to elements of the same array object, but we do not verify that here. | 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 { | 2431 | fn cIsPointerDiffExpr(stmt: *const clang.BinaryOperator) bool { |
| 2444 | _ = c; | | |
| 2445 | const lhs = @ptrCast(*const clang.Stmt, stmt.getLHS()); | 2432 | const lhs = @ptrCast(*const clang.Stmt, stmt.getLHS()); |
| 2446 | const rhs = @ptrCast(*const clang.Stmt, stmt.getRHS()); | 2433 | const rhs = @ptrCast(*const clang.Stmt, stmt.getRHS()); |
| 2447 | return stmt.getOpcode() == .Sub and | 2434 | return stmt.getOpcode() == .Sub and |
| ... | @@ -2748,9 +2735,7 @@ fn transInitListExprVector( | ... | @@ -2748,9 +2735,7 @@ fn transInitListExprVector( |
| 2748 | scope: *Scope, | 2735 | scope: *Scope, |
| 2749 | loc: clang.SourceLocation, | 2736 | loc: clang.SourceLocation, |
| 2750 | expr: *const clang.InitListExpr, | 2737 | expr: *const clang.InitListExpr, |
| 2751 | ty: *const clang.Type, | | |
| 2752 | ) TransError!Node { | 2738 | ) TransError!Node { |
| 2753 | _ = ty; | | |
| 2754 | const qt = getExprQualType(c, @ptrCast(*const clang.Expr, expr)); | 2739 | const qt = getExprQualType(c, @ptrCast(*const clang.Expr, expr)); |
| 2755 | const vector_ty = @ptrCast(*const clang.VectorType, qualTypeCanon(qt)); | 2740 | const vector_ty = @ptrCast(*const clang.VectorType, qualTypeCanon(qt)); |
| 2756 | | 2741 | |
| ... | @@ -2829,7 +2814,7 @@ fn transInitListExpr( | ... | @@ -2829,7 +2814,7 @@ fn transInitListExpr( |
| 2829 | } | 2814 | } |
| 2830 | | 2815 | |
| 2831 | if (qual_type.isRecordType()) { | 2816 | if (qual_type.isRecordType()) { |
| 2832 | return maybeSuppressResult(c, scope, used, try transInitListExprRecord( | 2817 | return maybeSuppressResult(c, used, try transInitListExprRecord( |
| 2833 | c, | 2818 | c, |
| 2834 | scope, | 2819 | scope, |
| 2835 | source_loc, | 2820 | source_loc, |
| ... | @@ -2837,7 +2822,7 @@ fn transInitListExpr( | ... | @@ -2837,7 +2822,7 @@ fn transInitListExpr( |
| 2837 | qual_type, | 2822 | qual_type, |
| 2838 | )); | 2823 | )); |
| 2839 | } else if (qual_type.isArrayType()) { | 2824 | } else if (qual_type.isArrayType()) { |
| 2840 | return maybeSuppressResult(c, scope, used, try transInitListExprArray( | 2825 | return maybeSuppressResult(c, used, try transInitListExprArray( |
| 2841 | c, | 2826 | c, |
| 2842 | scope, | 2827 | scope, |
| 2843 | source_loc, | 2828 | source_loc, |
| ... | @@ -2845,13 +2830,7 @@ fn transInitListExpr( | ... | @@ -2845,13 +2830,7 @@ fn transInitListExpr( |
| 2845 | qual_type, | 2830 | qual_type, |
| 2846 | )); | 2831 | )); |
| 2847 | } else if (qual_type.isVectorType()) { | 2832 | } else if (qual_type.isVectorType()) { |
| 2848 | return maybeSuppressResult(c, scope, used, try transInitListExprVector( | 2833 | return maybeSuppressResult(c, used, try transInitListExprVector(c, scope, source_loc, expr)); |
| 2849 | c, | | |
| 2850 | scope, | | |
| 2851 | source_loc, | | |
| 2852 | expr, | | |
| 2853 | qual_type, | | |
| 2854 | )); | | |
| 2855 | } else { | 2834 | } else { |
| 2856 | const type_name = try c.str(qual_type.getTypeClassName()); | 2835 | const type_name = try c.str(qual_type.getTypeClassName()); |
| 2857 | return fail(c, error.UnsupportedType, source_loc, "unsupported initlist type: '{s}'", .{type_name}); | 2836 | return fail(c, error.UnsupportedType, source_loc, "unsupported initlist type: '{s}'", .{type_name}); |
| ... | @@ -2912,9 +2891,7 @@ fn transImplicitValueInitExpr( | ... | @@ -2912,9 +2891,7 @@ fn transImplicitValueInitExpr( |
| 2912 | c: *Context, | 2891 | c: *Context, |
| 2913 | scope: *Scope, | 2892 | scope: *Scope, |
| 2914 | expr: *const clang.Expr, | 2893 | expr: *const clang.Expr, |
| 2915 | used: ResultUsed, | | |
| 2916 | ) TransError!Node { | 2894 | ) TransError!Node { |
| 2917 | _ = used; | | |
| 2918 | const source_loc = expr.getBeginLoc(); | 2895 | const source_loc = expr.getBeginLoc(); |
| 2919 | const qt = getExprQualType(c, expr); | 2896 | const qt = getExprQualType(c, expr); |
| 2920 | const ty = qt.getTypePtr(); | 2897 | const ty = qt.getTypePtr(); |
| ... | @@ -3354,7 +3331,7 @@ fn transConstantExpr(c: *Context, scope: *Scope, expr: *const clang.Expr, used: | ... | @@ -3354,7 +3331,7 @@ fn transConstantExpr(c: *Context, scope: *Scope, expr: *const clang.Expr, used: |
| 3354 | .lhs = try transQualType(c, scope, expr_base.getType(), expr_base.getBeginLoc()), | 3331 | .lhs = try transQualType(c, scope, expr_base.getType(), expr_base.getBeginLoc()), |
| 3355 | .rhs = try transCreateNodeAPInt(c, result.Val.getInt()), | 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 | else => |kind| { | 3336 | else => |kind| { |
| 3360 | return fail(c, error.UnsupportedTranslation, expr.getBeginLoc(), "unsupported constant expression kind '{}'", .{kind}); | 3337 | return fail(c, error.UnsupportedTranslation, expr.getBeginLoc(), "unsupported constant expression kind '{}'", .{kind}); |
| ... | @@ -3391,7 +3368,7 @@ fn transCharLiteral( | ... | @@ -3391,7 +3368,7 @@ fn transCharLiteral( |
| 3391 | try transCreateCharLitNode(c, narrow, val); | 3368 | try transCreateCharLitNode(c, narrow, val); |
| 3392 | | 3369 | |
| 3393 | if (suppress_as == .no_as) { | 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 | // See comment in `transIntegerLiteral` for why this code is here. | 3373 | // See comment in `transIntegerLiteral` for why this code is here. |
| 3397 | // @as(T, x) | 3374 | // @as(T, x) |
| ... | @@ -3400,7 +3377,7 @@ fn transCharLiteral( | ... | @@ -3400,7 +3377,7 @@ fn transCharLiteral( |
| 3400 | .lhs = try transQualType(c, scope, expr_base.getType(), expr_base.getBeginLoc()), | 3377 | .lhs = try transQualType(c, scope, expr_base.getType(), expr_base.getBeginLoc()), |
| 3401 | .rhs = int_lit_node, | 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 | fn transStmtExpr(c: *Context, scope: *Scope, stmt: *const clang.StmtExpr, used: ResultUsed) TransError!Node { | 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,7 +3403,7 @@ fn transStmtExpr(c: *Context, scope: *Scope, stmt: *const clang.StmtExpr, used: |
| 3426 | }); | 3403 | }); |
| 3427 | try block_scope.statements.append(break_node); | 3404 | try block_scope.statements.append(break_node); |
| 3428 | const res = try block_scope.complete(c); | 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 | fn transMemberExpr(c: *Context, scope: *Scope, stmt: *const clang.MemberExpr, result_used: ResultUsed) TransError!Node { | 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,7 +3432,7 @@ fn transMemberExpr(c: *Context, scope: *Scope, stmt: *const clang.MemberExpr, re |
| 3455 | if (exprIsFlexibleArrayRef(c, @ptrCast(*const clang.Expr, stmt))) { | 3432 | if (exprIsFlexibleArrayRef(c, @ptrCast(*const clang.Expr, stmt))) { |
| 3456 | node = try Tag.call.create(c.arena, .{ .lhs = node, .args = &.{} }); | 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 | /// ptr[subscr] (`subscr` is a signed integer expression, `ptr` a pointer) becomes: | 3438 | /// ptr[subscr] (`subscr` is a signed integer expression, `ptr` a pointer) becomes: |
| ... | @@ -3533,7 +3510,7 @@ fn transSignedArrayAccess( | ... | @@ -3533,7 +3510,7 @@ fn transSignedArrayAccess( |
| 3533 | | 3510 | |
| 3534 | const derefed = try Tag.deref.create(c.arena, block_node); | 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 | fn transArrayAccess(c: *Context, scope: *Scope, stmt: *const clang.ArraySubscriptExpr, result_used: ResultUsed) TransError!Node { | 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,7 +3551,7 @@ fn transArrayAccess(c: *Context, scope: *Scope, stmt: *const clang.ArraySubscrip |
| 3574 | .lhs = container_node, | 3551 | .lhs = container_node, |
| 3575 | .rhs = rhs, | 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 | /// Check if an expression is ultimately a reference to a function declaration | 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,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 | const ClangFunctionType = union(enum) { | 3648 | const ClangFunctionType = union(enum) { |
| ... | @@ -3705,14 +3682,13 @@ fn transUnaryExprOrTypeTraitExpr( | ... | @@ -3705,14 +3682,13 @@ fn transUnaryExprOrTypeTraitExpr( |
| 3705 | stmt: *const clang.UnaryExprOrTypeTraitExpr, | 3682 | stmt: *const clang.UnaryExprOrTypeTraitExpr, |
| 3706 | result_used: ResultUsed, | 3683 | result_used: ResultUsed, |
| 3707 | ) TransError!Node { | 3684 | ) TransError!Node { |
| 3708 | _ = result_used; | | |
| 3709 | const loc = stmt.getBeginLoc(); | 3685 | const loc = stmt.getBeginLoc(); |
| 3710 | const type_node = try transQualType(c, scope, stmt.getTypeOfArgument(), loc); | 3686 | const type_node = try transQualType(c, scope, stmt.getTypeOfArgument(), loc); |
| 3711 | | 3687 | |
| 3712 | const kind = stmt.getKind(); | 3688 | const kind = stmt.getKind(); |
| 3713 | switch (kind) { | 3689 | const node = switch (kind) { |
| 3714 | .SizeOf => return Tag.sizeof.create(c.arena, type_node), | 3690 | .SizeOf => try Tag.sizeof.create(c.arena, type_node), |
| 3715 | .AlignOf => return Tag.alignof.create(c.arena, type_node), | 3691 | .AlignOf => try Tag.alignof.create(c.arena, type_node), |
| 3716 | .PreferredAlignOf, | 3692 | .PreferredAlignOf, |
| 3717 | .VecStep, | 3693 | .VecStep, |
| 3718 | .OpenMPRequiredSimdAlign, | 3694 | .OpenMPRequiredSimdAlign, |
| ... | @@ -3723,7 +3699,8 @@ fn transUnaryExprOrTypeTraitExpr( | ... | @@ -3723,7 +3699,8 @@ fn transUnaryExprOrTypeTraitExpr( |
| 3723 | "unsupported type trait kind {}", | 3699 | "unsupported type trait kind {}", |
| 3724 | .{kind}, | 3700 | .{kind}, |
| 3725 | ), | 3701 | ), |
| 3726 | } | 3702 | }; |
| | 3703 | return maybeSuppressResult(c, result_used, node); |
| 3727 | } | 3704 | } |
| 3728 | | 3705 | |
| 3729 | fn qualTypeHasWrappingOverflow(qt: clang.QualType) bool { | 3706 | fn qualTypeHasWrappingOverflow(qt: clang.QualType) bool { |
| ... | @@ -3812,7 +3789,7 @@ fn transCreatePreCrement( | ... | @@ -3812,7 +3789,7 @@ fn transCreatePreCrement( |
| 3812 | // zig: expr += 1 | 3789 | // zig: expr += 1 |
| 3813 | const lhs = try transExpr(c, scope, op_expr, .used); | 3790 | const lhs = try transExpr(c, scope, op_expr, .used); |
| 3814 | const rhs = Tag.one_literal.init(); | 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 | // worst case | 3794 | // worst case |
| 3818 | // c: ++expr | 3795 | // c: ++expr |
| ... | @@ -3832,7 +3809,7 @@ fn transCreatePreCrement( | ... | @@ -3832,7 +3809,7 @@ fn transCreatePreCrement( |
| 3832 | | 3809 | |
| 3833 | const lhs_node = try Tag.identifier.create(c.arena, ref); | 3810 | const lhs_node = try Tag.identifier.create(c.arena, ref); |
| 3834 | const ref_node = try Tag.deref.create(c.arena, lhs_node); | 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 | try block_scope.statements.append(node); | 3813 | try block_scope.statements.append(node); |
| 3837 | | 3814 | |
| 3838 | const break_node = try Tag.break_val.create(c.arena, .{ | 3815 | const break_node = try Tag.break_val.create(c.arena, .{ |
| ... | @@ -3858,7 +3835,7 @@ fn transCreatePostCrement( | ... | @@ -3858,7 +3835,7 @@ fn transCreatePostCrement( |
| 3858 | // zig: expr += 1 | 3835 | // zig: expr += 1 |
| 3859 | const lhs = try transExpr(c, scope, op_expr, .used); | 3836 | const lhs = try transExpr(c, scope, op_expr, .used); |
| 3860 | const rhs = Tag.one_literal.init(); | 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 | // worst case | 3840 | // worst case |
| 3864 | // c: expr++ | 3841 | // c: expr++ |
| ... | @@ -3884,7 +3861,7 @@ fn transCreatePostCrement( | ... | @@ -3884,7 +3861,7 @@ fn transCreatePostCrement( |
| 3884 | const tmp_decl = try Tag.var_simple.create(c.arena, .{ .name = tmp, .init = ref_node }); | 3861 | const tmp_decl = try Tag.var_simple.create(c.arena, .{ .name = tmp, .init = ref_node }); |
| 3885 | try block_scope.statements.append(tmp_decl); | 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 | try block_scope.statements.append(node); | 3865 | try block_scope.statements.append(node); |
| 3889 | | 3866 | |
| 3890 | const break_node = try Tag.break_val.create(c.arena, .{ | 3867 | const break_node = try Tag.break_val.create(c.arena, .{ |
| ... | @@ -3965,7 +3942,7 @@ fn transCreateCompoundAssign( | ... | @@ -3965,7 +3942,7 @@ fn transCreateCompoundAssign( |
| 3965 | else | 3942 | else |
| 3966 | try Tag.div_trunc.create(c.arena, operands); | 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 | if (is_shift) { | 3948 | if (is_shift) { |
| ... | @@ -3974,7 +3951,7 @@ fn transCreateCompoundAssign( | ... | @@ -3974,7 +3951,7 @@ fn transCreateCompoundAssign( |
| 3974 | } else if (requires_int_cast) { | 3951 | } else if (requires_int_cast) { |
| 3975 | rhs_node = try transCCast(c, scope, loc, lhs_qt, rhs_qt, rhs_node); | 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 | // worst case | 3956 | // worst case |
| 3980 | // c: lhs += rhs | 3957 | // c: lhs += rhs |
| ... | @@ -4005,7 +3982,7 @@ fn transCreateCompoundAssign( | ... | @@ -4005,7 +3982,7 @@ fn transCreateCompoundAssign( |
| 4005 | else | 3982 | else |
| 4006 | try Tag.div_trunc.create(c.arena, operands); | 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 | try block_scope.statements.append(assign); | 3986 | try block_scope.statements.append(assign); |
| 4010 | } else { | 3987 | } else { |
| 4011 | if (is_shift) { | 3988 | if (is_shift) { |
| ... | @@ -4015,7 +3992,7 @@ fn transCreateCompoundAssign( | ... | @@ -4015,7 +3992,7 @@ fn transCreateCompoundAssign( |
| 4015 | rhs_node = try transCCast(c, &block_scope.base, loc, lhs_qt, rhs_qt, rhs_node); | 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 | try block_scope.statements.append(assign); | 3996 | try block_scope.statements.append(assign); |
| 4020 | } | 3997 | } |
| 4021 | | 3998 | |
| ... | @@ -4071,7 +4048,7 @@ fn transCPtrCast( | ... | @@ -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 | switch (expr.getRawSemantics()) { | 4052 | switch (expr.getRawSemantics()) { |
| 4076 | .IEEEhalf, // f16 | 4053 | .IEEEhalf, // f16 |
| 4077 | .IEEEsingle, // f32 | 4054 | .IEEEsingle, // f32 |
| ... | @@ -4095,7 +4072,7 @@ fn transFloatingLiteral(c: *Context, scope: *Scope, expr: *const clang.FloatingL | ... | @@ -4095,7 +4072,7 @@ fn transFloatingLiteral(c: *Context, scope: *Scope, expr: *const clang.FloatingL |
| 4095 | try std.fmt.allocPrint(c.arena, "{d}", .{dbl}); | 4072 | try std.fmt.allocPrint(c.arena, "{d}", .{dbl}); |
| 4096 | var node = try Tag.float_literal.create(c.arena, str); | 4073 | var node = try Tag.float_literal.create(c.arena, str); |
| 4097 | if (is_negative) node = try Tag.negate.create(c.arena, node); | 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 | fn transBinaryConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang.BinaryConditionalOperator, used: ResultUsed) TransError!Node { | 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,7 +4128,7 @@ fn transBinaryConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang |
| 4151 | }); | 4128 | }); |
| 4152 | try block_scope.statements.append(break_node); | 4129 | try block_scope.statements.append(break_node); |
| 4153 | const res = try block_scope.complete(c); | 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 | fn transConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang.ConditionalOperator, used: ResultUsed) TransError!Node { | 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,13 +4168,7 @@ fn transConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang.Condi |
| 4191 | return if_node; | 4168 | return if_node; |
| 4192 | } | 4169 | } |
| 4193 | | 4170 | |
| 4194 | fn maybeSuppressResult( | 4171 | fn maybeSuppressResult(c: *Context, used: ResultUsed, result: Node) TransError!Node { |
| 4195 | c: *Context, | | |
| 4196 | scope: *Scope, | | |
| 4197 | used: ResultUsed, | | |
| 4198 | result: Node, | | |
| 4199 | ) TransError!Node { | | |
| 4200 | _ = scope; | | |
| 4201 | if (used == .used) return result; | 4172 | if (used == .used) return result; |
| 4202 | return Tag.discard.create(c.arena, .{ .should_skip = false, .value = result }); | 4173 | return Tag.discard.create(c.arena, .{ .should_skip = false, .value = result }); |
| 4203 | } | 4174 | } |
| ... | @@ -4551,7 +4522,7 @@ fn transCreateNodeAssign( | ... | @@ -4551,7 +4522,7 @@ fn transCreateNodeAssign( |
| 4551 | if (!exprIsBooleanType(lhs) and isBoolRes(rhs_node)) { | 4522 | if (!exprIsBooleanType(lhs) and isBoolRes(rhs_node)) { |
| 4552 | rhs_node = try Tag.bool_to_int.create(c.arena, rhs_node); | 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 | // worst case | 4528 | // worst case |
| ... | @@ -4571,7 +4542,7 @@ fn transCreateNodeAssign( | ... | @@ -4571,7 +4542,7 @@ fn transCreateNodeAssign( |
| 4571 | | 4542 | |
| 4572 | const lhs_node = try transExpr(c, &block_scope.base, lhs, .used); | 4543 | const lhs_node = try transExpr(c, &block_scope.base, lhs, .used); |
| 4573 | const tmp_ident = try Tag.identifier.create(c.arena, tmp); | 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 | try block_scope.statements.append(assign); | 4546 | try block_scope.statements.append(assign); |
| 4576 | | 4547 | |
| 4577 | const break_node = try Tag.break_val.create(c.arena, .{ | 4548 | const break_node = try Tag.break_val.create(c.arena, .{ |
| ... | @@ -4584,7 +4555,6 @@ fn transCreateNodeAssign( | ... | @@ -4584,7 +4555,6 @@ fn transCreateNodeAssign( |
| 4584 | | 4555 | |
| 4585 | fn transCreateNodeInfixOp( | 4556 | fn transCreateNodeInfixOp( |
| 4586 | c: *Context, | 4557 | c: *Context, |
| 4587 | scope: *Scope, | | |
| 4588 | op: Tag, | 4558 | op: Tag, |
| 4589 | lhs: Node, | 4559 | lhs: Node, |
| 4590 | rhs: Node, | 4560 | rhs: Node, |
| ... | @@ -4598,7 +4568,7 @@ fn transCreateNodeInfixOp( | ... | @@ -4598,7 +4568,7 @@ fn transCreateNodeInfixOp( |
| 4598 | .rhs = rhs, | 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 | fn transCreateNodeBoolInfixOp( | 4574 | fn transCreateNodeBoolInfixOp( |
| ... | @@ -4613,7 +4583,7 @@ fn transCreateNodeBoolInfixOp( | ... | @@ -4613,7 +4583,7 @@ fn transCreateNodeBoolInfixOp( |
| 4613 | const lhs = try transBoolExpr(c, scope, stmt.getLHS(), .used); | 4583 | const lhs = try transBoolExpr(c, scope, stmt.getLHS(), .used); |
| 4614 | const rhs = try transBoolExpr(c, scope, stmt.getRHS(), .used); | 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 | fn transCreateNodeAPInt(c: *Context, int: *const clang.APSInt) !Node { | 4589 | fn transCreateNodeAPInt(c: *Context, int: *const clang.APSInt) !Node { |
| ... | @@ -4730,7 +4700,7 @@ fn transCreateNodeShiftOp( | ... | @@ -4730,7 +4700,7 @@ fn transCreateNodeShiftOp( |
| 4730 | const rhs = try transExprCoercing(c, scope, rhs_expr, .used); | 4700 | const rhs = try transExprCoercing(c, scope, rhs_expr, .used); |
| 4731 | const rhs_casted = try Tag.int_cast.create(c.arena, .{ .lhs = rhs_type, .rhs = rhs }); | 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 | fn transType(c: *Context, scope: *Scope, ty: *const clang.Type, source_loc: clang.SourceLocation) TypeError!Node { | 4706 | fn transType(c: *Context, scope: *Scope, ty: *const clang.Type, source_loc: clang.SourceLocation) TypeError!Node { |
| ... | @@ -5681,13 +5651,14 @@ const ParseError = Error || error{ParseError}; | ... | @@ -5681,13 +5651,14 @@ const ParseError = Error || error{ParseError}; |
| 5681 | | 5651 | |
| 5682 | fn parseCExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { | 5652 | fn parseCExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { |
| 5683 | // TODO parseCAssignExpr here | 5653 | // TODO parseCAssignExpr here |
| 5684 | const node = try parseCCondExpr(c, m, scope); | 5654 | var block_scope = try Scope.Block.init(c, scope, true); |
| | 5655 | defer block_scope.deinit(); |
| | 5656 | |
| | 5657 | const node = try parseCCondExpr(c, m, &block_scope.base); |
| 5685 | if (m.next().? != .Comma) { | 5658 | if (m.next().? != .Comma) { |
| 5686 | m.i -= 1; | 5659 | m.i -= 1; |
| 5687 | return node; | 5660 | return node; |
| 5688 | } | 5661 | } |
| 5689 | var block_scope = try Scope.Block.init(c, scope, true); | | |
| 5690 | defer block_scope.deinit(); | | |
| 5691 | | 5662 | |
| 5692 | var last = node; | 5663 | var last = node; |
| 5693 | while (true) { | 5664 | while (true) { |
| ... | @@ -6298,7 +6269,7 @@ fn parseCCastExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { | ... | @@ -6298,7 +6269,7 @@ fn parseCCastExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { |
| 6298 | // allow_fail is set when unsure if we are parsing a type-name | 6269 | // allow_fail is set when unsure if we are parsing a type-name |
| 6299 | fn parseCTypeName(c: *Context, m: *MacroCtx, scope: *Scope, allow_fail: bool) ParseError!?Node { | 6270 | fn parseCTypeName(c: *Context, m: *MacroCtx, scope: *Scope, allow_fail: bool) ParseError!?Node { |
| 6300 | if (try parseCSpecifierQualifierList(c, m, scope, allow_fail)) |node| { | 6271 | if (try parseCSpecifierQualifierList(c, m, scope, allow_fail)) |node| { |
| 6301 | return try parseCAbstractDeclarator(c, m, scope, node); | 6272 | return try parseCAbstractDeclarator(c, m, node); |
| 6302 | } else { | 6273 | } else { |
| 6303 | return null; | 6274 | return null; |
| 6304 | } | 6275 | } |
| ... | @@ -6327,7 +6298,7 @@ fn parseCSpecifierQualifierList(c: *Context, m: *MacroCtx, scope: *Scope, allow_ | ... | @@ -6327,7 +6298,7 @@ fn parseCSpecifierQualifierList(c: *Context, m: *MacroCtx, scope: *Scope, allow_ |
| 6327 | .Keyword_complex, | 6298 | .Keyword_complex, |
| 6328 | => { | 6299 | => { |
| 6329 | m.i -= 1; | 6300 | m.i -= 1; |
| 6330 | return try parseCNumericType(c, m, scope); | 6301 | return try parseCNumericType(c, m); |
| 6331 | }, | 6302 | }, |
| 6332 | .Keyword_enum, .Keyword_struct, .Keyword_union => { | 6303 | .Keyword_enum, .Keyword_struct, .Keyword_union => { |
| 6333 | // struct Foo will be declared as struct_Foo by transRecordDecl | 6304 | // struct Foo will be declared as struct_Foo by transRecordDecl |
| ... | @@ -6349,8 +6320,7 @@ fn parseCSpecifierQualifierList(c: *Context, m: *MacroCtx, scope: *Scope, allow_ | ... | @@ -6349,8 +6320,7 @@ fn parseCSpecifierQualifierList(c: *Context, m: *MacroCtx, scope: *Scope, allow_ |
| 6349 | } | 6320 | } |
| 6350 | } | 6321 | } |
| 6351 | | 6322 | |
| 6352 | fn parseCNumericType(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { | 6323 | fn parseCNumericType(c: *Context, m: *MacroCtx) ParseError!Node { |
| 6353 | _ = scope; | | |
| 6354 | const KwCounter = struct { | 6324 | const KwCounter = struct { |
| 6355 | double: u8 = 0, | 6325 | double: u8 = 0, |
| 6356 | long: u8 = 0, | 6326 | long: u8 = 0, |
| ... | @@ -6451,8 +6421,7 @@ fn parseCNumericType(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { | ... | @@ -6451,8 +6421,7 @@ fn parseCNumericType(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { |
| 6451 | return error.ParseError; | 6421 | return error.ParseError; |
| 6452 | } | 6422 | } |
| 6453 | | 6423 | |
| 6454 | fn parseCAbstractDeclarator(c: *Context, m: *MacroCtx, scope: *Scope, node: Node) ParseError!Node { | 6424 | fn parseCAbstractDeclarator(c: *Context, m: *MacroCtx, node: Node) ParseError!Node { |
| 6455 | _ = scope; | | |
| 6456 | switch (m.next().?) { | 6425 | switch (m.next().?) { |
| 6457 | .Asterisk => { | 6426 | .Asterisk => { |
| 6458 | // last token of `node` | 6427 | // last token of `node` |