@@ -1869,6 +1869,8 @@ bool Converter::VisitExplicitCastExpr(clang::ExplicitCastExpr *expr) {
18691869 auto type = expr->getTypeAsWritten ();
18701870 auto *sub_expr = expr->getSubExpr ();
18711871 if (type->isVoidType ()) {
1872+ PushExprKind push (*this , ExprKind::Void);
1873+ Convert (expr->getSubExpr ());
18721874 return false ;
18731875 }
18741876 switch (expr->getStmtClass ()) {
@@ -1950,7 +1952,10 @@ bool Converter::VisitBinaryOperator(clang::BinaryOperator *expr) {
19501952 ConvertCast (lhs_type);
19511953 }
19521954 } else if (expr->isCommaOp ()) {
1953- Convert (lhs);
1955+ {
1956+ PushExprKind push (*this , ExprKind::Void);
1957+ Convert (lhs);
1958+ }
19541959 StrCat (token::kSemiColon );
19551960 Convert (rhs);
19561961 } else if (IsUnsignedArithOp (expr)) {
@@ -2248,11 +2253,20 @@ bool Converter::VisitDeclRefExpr(clang::DeclRefExpr *expr) {
22482253}
22492254
22502255bool Converter::VisitParenExpr (clang::ParenExpr *expr) {
2256+ // Comma operator becomes (A, B, C) -> { A; B; C }
2257+ if (auto *bin = clang::dyn_cast<clang::BinaryOperator>(expr->getSubExpr ())) {
2258+ if (bin->isCommaOp ()) {
2259+ PushBrace push (*this );
2260+ Convert (expr->getSubExpr ());
2261+ return false ;
2262+ }
2263+ }
2264+
22512265 // Add cast to avoid ambigous integers. Don't add cast if sub expression is a
22522266 // pointer dereference because we might want to mutate the dereferenced value.
22532267 bool should_add_integral_cast =
22542268 expr->getType ()->isIntegralOrEnumerationType () && !isAddrOf () &&
2255- !clang::isa<clang::UnaryOperator>(expr->getSubExpr ());
2269+ !isVoid () && ! clang::isa<clang::UnaryOperator>(expr->getSubExpr ());
22562270 PushParen outer (*this , should_add_integral_cast);
22572271
22582272 {
@@ -3399,7 +3413,7 @@ void Converter::ConvertUnsignedArithBinaryOperator(clang::BinaryOperator *op,
33993413
34003414void Converter::ConvertAddrOf (clang::Expr *expr, clang::QualType pointer_type) {
34013415 assert (pointer_type->isPointerType ());
3402- if (IsReferenceType (expr)) {
3416+ if (IsReferenceType (expr) || pointer_type-> isFunctionPointerType () ) {
34033417 PushExprKind push (*this , ExprKind::AddrOf);
34043418 Convert (expr);
34053419 } else {
0 commit comments