Skip to content

Commit 8178aa5

Browse files
committed
Push init type in materialize temp
1 parent 2bb3063 commit 8178aa5

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎cpp2rust/converter/converter.cpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,11 @@ std::pair<std::string, std::string>
239239
Converter::MaterializeTemp(const std::string &binding_name,
240240
clang::QualType param_type, clang::Expr *expr) {
241241
auto pointee = param_type.getNonReferenceType();
242-
auto value = ConvertRValue(expr, pointee);
242+
std::string value;
243+
{
244+
PushInitType init_type(*this, pointee);
245+
value = ConvertRValue(expr, pointee);
246+
}
243247
auto type_str = ToStringBase(pointee);
244248
const auto *decl = in_const_initializer_ ? keyword::kStatic : keyword::kLet;
245249

‎tests/unit/06_new_array.cpp‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
static char take(char *&&p) {
2+
p[0] = 9;
3+
char c = p[0];
4+
delete[] p;
5+
return c;
6+
}
7+
18
int main() {
29
int *e = new int[2];
310
e[0] = 6;
411
e[1] = 7;
512
delete[] e;
13+
char c = take(new char[4]);
14+
(void)c;
615
return 0;
716
}

0 commit comments

Comments
 (0)