Skip to content

Commit 5f66c7d

Browse files
committed
Zero initialize enum using rule initializer
1 parent 023e928 commit 5f66c7d

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
@@ -1808,6 +1808,11 @@ std::string Converter::getIntegerLiteral(clang::IntegerLiteral *expr,
18081808
auto type_as_string = GetUnsafeTypeAsString(ty);
18091809

18101810
if (ty->isFloatingType() || incl_type) {
1811+
if (expr->getValue().isZero()) {
1812+
if (auto init = Mapper::MapInitializer(ty); !init.empty()) {
1813+
return init;
1814+
}
1815+
}
18111816
return std::format("{}_{}", num_as_string.c_str(), type_as_string);
18121817
}
18131818

0 commit comments

Comments
 (0)