Skip to content

Commit 3dee583

Browse files
committed
Zero initialize enum using rule initializer
1 parent 5dd657c commit 3dee583

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

cpp2rust/converter/converter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,6 +1789,11 @@ std::string Converter::getIntegerLiteral(clang::IntegerLiteral *expr,
17891789
auto type_as_string = GetUnsafeTypeAsString(ty);
17901790

17911791
if (ty->isFloatingType() || incl_type) {
1792+
if (expr->getValue().isZero()) {
1793+
if (auto init = Mapper::MapInitializer(ty); !init.empty()) {
1794+
return init;
1795+
}
1796+
}
17921797
return std::format("{}_{}", num_as_string.c_str(), type_as_string);
17931798
}
17941799

0 commit comments

Comments
 (0)