Skip to content

Commit e84db5a

Browse files
committed
Transate NULL in C
1 parent 20f0e00 commit e84db5a

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

cpp2rust/converter/models/converter_refcount.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,9 +1047,12 @@ bool ConverterRefCount::VisitImplicitCastExpr(clang::ImplicitCastExpr *expr) {
10471047
}
10481048
}
10491049

1050-
if (expr->getCastKind() == clang::CastKind::CK_NullToPointer &&
1051-
expr->getType()->isFunctionPointerType()) {
1052-
StrCat("FnPtr::null()");
1050+
if (expr->getCastKind() == clang::CastKind::CK_NullToPointer) {
1051+
if (expr->getType()->isFunctionPointerType()) {
1052+
StrCat("FnPtr::null()");
1053+
} else {
1054+
StrCat("Default::default()");
1055+
}
10531056
computed_expr_type_ = ComputedExprType::FreshPointer;
10541057
return false;
10551058
}
@@ -1138,6 +1141,11 @@ bool ConverterRefCount::VisitExplicitCastExpr(clang::ExplicitCastExpr *expr) {
11381141
}
11391142
return false;
11401143
}
1144+
if (expr->getCastKind() == clang::CK_NullToPointer) {
1145+
StrCat("Default::default()");
1146+
computed_expr_type_ = ComputedExprType::FreshPointer;
1147+
return false;
1148+
}
11411149
switch (expr->getStmtClass()) {
11421150
case clang::Stmt::CXXReinterpretCastExprClass:
11431151
assert(expr->getType()->isPointerType() &&

0 commit comments

Comments
 (0)