File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2624,6 +2624,14 @@ bool Converter::VisitExplicitCastExpr(clang::ExplicitCastExpr *expr) {
26242624 auto type = expr->getTypeAsWritten ();
26252625 auto *sub_expr = expr->getSubExpr ();
26262626 if (type->isVoidType ()) {
2627+ if (auto *assign =
2628+ clang::dyn_cast<clang::BinaryOperator>(sub_expr->IgnoreParens ());
2629+ assign && assign->isAssignmentOp ()) {
2630+ PushBrace brace (*this );
2631+ PushExprKind push (*this , ExprKind::Void);
2632+ Convert (sub_expr);
2633+ return false ;
2634+ }
26272635 StrCat (token::kRef );
26282636 PushParen paren (*this );
26292637 PushExprKind push (*this , ExprKind::Void);
Original file line number Diff line number Diff line change @@ -1568,6 +1568,14 @@ bool ConverterRefCount::VisitFunctionPointerCast(
15681568
15691569bool ConverterRefCount::VisitExplicitCastExpr (clang::ExplicitCastExpr *expr) {
15701570 if (expr->getTypeAsWritten ()->isVoidType ()) {
1571+ if (auto *assign = clang::dyn_cast<clang::BinaryOperator>(
1572+ expr->getSubExpr ()->IgnoreParens ());
1573+ assign && assign->isAssignmentOp ()) {
1574+ PushBrace brace (*this );
1575+ PushExprKind push (*this , ExprKind::Void);
1576+ Convert (expr->getSubExpr ());
1577+ return false ;
1578+ }
15711579 StrCat (token::kRef );
15721580 PushParen paren (*this );
15731581 PushExprKind push (*this , ExprKind::Void);
Original file line number Diff line number Diff line change @@ -65,6 +65,18 @@ int main() {
6565 assert (err == 7 );
6666 assert (chosen == 123 );
6767
68+ (void )(err += 1 );
69+ assert (err == 8 );
70+
71+ Holder assigned{1 };
72+ (void )(assigned = Holder{2 });
73+ assert (assigned.field == 2 );
74+
75+ int target = 0 ;
76+ int *target_ptr = ⌖
77+ (void )(*target_ptr = 5 );
78+ assert (target == 5 );
79+
6880 (void )bump_and_return;
6981 assert (side_effect_counter == 2 );
7082
You can’t perform that action at this time.
0 commit comments