Skip to content

Commit ed9ff32

Browse files
committed
Convert operands of ternary in lvalue context
1 parent 0fdea09 commit ed9ff32

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎cpp2rust/converter/converter.cpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4186,6 +4186,18 @@ void Converter::ConvertVarInit(clang::QualType qual_type, clang::Expr *expr) {
41864186
StrCat(EmitMaterializedTempBinding(qual_type, expr));
41874187
return;
41884188
}
4189+
if (auto *cond = clang::dyn_cast<clang::ConditionalOperator>(
4190+
expr->IgnoreParenImpCasts());
4191+
cond && cond->isLValue()) {
4192+
{
4193+
PushExprKind push(*this, ExprKind::LValue);
4194+
PushInitType init_type(*this, qual_type);
4195+
Convert(cond);
4196+
}
4197+
StrCat(keyword::kAs);
4198+
Convert(qual_type);
4199+
return;
4200+
}
41894201
StrCat(token::kRef);
41904202
if (IsMut(qual_type)) {
41914203
StrCat(keyword_mut_);

0 commit comments

Comments
 (0)