| ... | ... | @@ -1334,9 +1334,22 @@ fn transImplicitCastExpr( |
| 1334 | 1334 | .BitCast, .FloatingCast, .FloatingToIntegral, .IntegralToFloating, .IntegralCast, .PointerToIntegral, .IntegralToPointer => { |
| 1335 | 1335 | return transCCast(rp, scope, ZigClangImplicitCastExpr_getBeginLoc(expr), dest_type, src_type, sub_expr_node); |
| 1336 | 1336 | }, |
| 1337 | | .LValueToRValue, .NoOp, .FunctionToPointerDecay, .ArrayToPointerDecay => { |
| 1337 | .LValueToRValue, .NoOp, .FunctionToPointerDecay => { |
| 1338 | 1338 | return maybeSuppressResult(rp, scope, result_used, sub_expr_node); |
| 1339 | 1339 | }, |
| 1340 | .ArrayToPointerDecay => { |
| 1341 | switch (ZigClangExpr_getStmtClass(sub_expr)) { |
| 1342 | .StringLiteralClass, .PredefinedExprClass => { |
| 1343 | return maybeSuppressResult(rp, scope, result_used, sub_expr_node); |
| 1344 | }, |
| 1345 | else => { |
| 1346 | const prefix_op = try transCreateNodePrefixOp(rp.c, .AddressOf, .Ampersand, "&"); |
| 1347 | prefix_op.rhs = sub_expr_node; |
| 1348 | |
| 1349 | return maybeSuppressResult(rp, scope, result_used, &prefix_op.base); |
| 1350 | }, |
| 1351 | } |
| 1352 | }, |
| 1340 | 1353 | .NullToPointer => { |
| 1341 | 1354 | return try transCreateNodeNullLiteral(rp.c); |
| 1342 | 1355 | }, |
| ... | ... | @@ -2469,7 +2482,19 @@ fn transMemberExpr(rp: RestorePoint, scope: *Scope, stmt: *const ZigClangMemberE |
| 2469 | 2482 | } |
| 2470 | 2483 | |
| 2471 | 2484 | fn transArrayAccess(rp: RestorePoint, scope: *Scope, stmt: *const ZigClangArraySubscriptExpr, result_used: ResultUsed) TransError!*ast.Node { |
| 2472 | | const container_node = try transExpr(rp, scope, ZigClangArraySubscriptExpr_getBase(stmt), .used, .r_value); |
| 2485 | var base_stmt = ZigClangArraySubscriptExpr_getBase(stmt); |
| 2486 | |
| 2487 | // Unwrap the base statement if it's an array decayed to a bare pointer type |
| 2488 | // so that we index the array itself |
| 2489 | if (ZigClangStmt_getStmtClass(@ptrCast(*const ZigClangStmt, base_stmt)) == .ImplicitCastExprClass) { |
| 2490 | const implicit_cast = @ptrCast(*const ZigClangImplicitCastExpr, base_stmt); |
| 2491 | |
| 2492 | if (ZigClangImplicitCastExpr_getCastKind(implicit_cast) == .ArrayToPointerDecay) { |
| 2493 | base_stmt = ZigClangImplicitCastExpr_getSubExpr(implicit_cast); |
| 2494 | } |
| 2495 | } |
| 2496 | |
| 2497 | const container_node = try transExpr(rp, scope, base_stmt, .used, .r_value); |
| 2473 | 2498 | const node = try transCreateNodeArrayAccess(rp.c, container_node); |
| 2474 | 2499 | node.op.ArrayAccess = try transExpr(rp, scope, ZigClangArraySubscriptExpr_getIdx(stmt), .used, .r_value); |
| 2475 | 2500 | node.rtoken = try appendToken(rp.c, .RBrace, "]"); |