Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cpp2rust/converter/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3138,6 +3138,7 @@ bool Converter::VisitStmtExpr(clang::StmtExpr *expr) {
Convert(s);
}
}
SetFreshType(expr->getType());
return false;
}

Expand Down
4 changes: 1 addition & 3 deletions cpp2rust/converter/models/converter_refcount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1770,9 +1770,7 @@ bool ConverterRefCount::VisitReturnStmt(clang::ReturnStmt *stmt) {

bool ConverterRefCount::VisitStmtExpr(clang::StmtExpr *expr) {
PushConversionKind push(*this, ConversionKind::FullRefCount);
Converter::VisitStmtExpr(expr);
SetFreshType(expr->getType());
return false;
return Converter::VisitStmtExpr(expr);
}

void ConverterRefCount::ConvertBinaryOperator(clang::BinaryOperator *expr) {
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/out/refcount/stmt_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ fn main_0() -> i32 {
inner
} == 100)
);
{
counter.postfix_inc()
};
{
if (counter != 2) {
counter = 2;
}
};
assert!((counter == 2));
return 0;
}
pub fn __cpp2rust_init_globals() {}
9 changes: 9 additions & 0 deletions tests/unit/out/unsafe/stmt_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ unsafe fn main_0() -> i32 {
inner
}) == (100))
);
{
counter.postfix_inc()
};
{
if ((counter) != (2)) {
counter = 2;
}
};
assert!(((counter) == (2)));
return 0;
}
pub unsafe fn __cpp2rust_init_globals() {}
8 changes: 8 additions & 0 deletions tests/unit/stmt_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,13 @@ int main() {
});
inner;
}) == 100);

({ counter++; });
__extension__({
if (counter != 2) {
counter = 2;
}
});
assert(counter == 2);
return 0;
}
Loading