| ... | ... | @@ -1944,8 +1944,23 @@ static AstNode *trans_implicit_cast_expr(Context *c, ResultUsed result_used, Tra |
| 1944 | 1944 | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_VectorSplat"); |
| 1945 | 1945 | return nullptr; |
| 1946 | 1946 | case ZigClangCK_IntegralToBoolean: |
| 1947 | | emit_warning(c, bitcast(stmt->getBeginLoc()), "TODO handle C CK_IntegralToBoolean"); |
| 1948 | | return nullptr; |
| 1947 | { |
| 1948 | const clang::Expr *expr = stmt->getSubExpr(); |
| 1949 | |
| 1950 | bool expr_val; |
| 1951 | if (expr->EvaluateAsBooleanCondition(expr_val, *reinterpret_cast<clang::ASTContext *>(c->ctx))) { |
| 1952 | return trans_create_node_bool(c, expr_val); |
| 1953 | } |
| 1954 | |
| 1955 | AstNode *val = trans_expr(c, ResultUsedYes, scope, bitcast(expr), TransRValue); |
| 1956 | if (val == nullptr) |
| 1957 | return nullptr; |
| 1958 | |
| 1959 | AstNode *zero = trans_create_node_unsigned(c, 0); |
| 1960 | |
| 1961 | // Translate as val != 0 |
| 1962 | return trans_create_node_bin_op(c, val, BinOpTypeCmpNotEq, zero); |
| 1963 | } |
| 1949 | 1964 | case ZigClangCK_IntegralToFloating: |
| 1950 | 1965 | case ZigClangCK_FloatingToIntegral: |
| 1951 | 1966 | { |