Skip to content

Commit cd57b02

Browse files
committed
Fix converter crashes around freshness
1 parent 2bb3063 commit cd57b02

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎cpp2rust/converter/converter.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3138,6 +3138,7 @@ bool Converter::VisitStmtExpr(clang::StmtExpr *expr) {
31383138
Convert(s);
31393139
}
31403140
}
3141+
SetFreshType(expr->getType());
31413142
return false;
31423143
}
31433144

‎cpp2rust/converter/models/converter_refcount.cpp‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,9 +1770,7 @@ bool ConverterRefCount::VisitReturnStmt(clang::ReturnStmt *stmt) {
17701770

17711771
bool ConverterRefCount::VisitStmtExpr(clang::StmtExpr *expr) {
17721772
PushConversionKind push(*this, ConversionKind::FullRefCount);
1773-
Converter::VisitStmtExpr(expr);
1774-
SetFreshType(expr->getType());
1775-
return false;
1773+
return Converter::VisitStmtExpr(expr);
17761774
}
17771775

17781776
void ConverterRefCount::ConvertBinaryOperator(clang::BinaryOperator *expr) {

‎tests/unit/stmt_expr.cpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,13 @@ int main() {
3232
});
3333
inner;
3434
}) == 100);
35+
36+
({ counter++; });
37+
__extension__({
38+
if (counter != 2) {
39+
counter = 2;
40+
}
41+
});
42+
assert(counter == 2);
3543
return 0;
3644
}

0 commit comments

Comments
 (0)