| ... | ... | @@ -1334,6 +1334,17 @@ static AstNode *trans_floating_literal(Context *c, ResultUsed result_used, const |
| 1334 | 1334 | return maybe_suppress_result(c, result_used, node); |
| 1335 | 1335 | } |
| 1336 | 1336 | |
| 1337 | static AstNode *trans_character_literal(Context *c, ResultUsed result_used, const clang::CharacterLiteral *stmt) { |
| 1338 | clang::Expr::EvalResult result; |
| 1339 | if (!stmt->EvaluateAsInt(result, *reinterpret_cast<clang::ASTContext *>(c->ctx))) { |
| 1340 | emit_warning(c, bitcast(stmt->getBeginLoc()), "invalid character literal"); |
| 1341 | return nullptr; |
| 1342 | } |
| 1343 | AstNode *node = trans_create_node(c, NodeTypeCharLiteral); |
| 1344 | node->data.char_literal.value = result.Val.getInt().getExtValue(); |
| 1345 | return maybe_suppress_result(c, result_used, node); |
| 1346 | } |
| 1347 | |
| 1337 | 1348 | static AstNode *trans_constant_expr(Context *c, ResultUsed result_used, const clang::ConstantExpr *expr) { |
| 1338 | 1349 | clang::Expr::EvalResult result; |
| 1339 | 1350 | if (!expr->EvaluateAsConstantExpr(result, clang::Expr::EvaluateForCodeGen, |
| ... | ... | @@ -3531,7 +3542,8 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const ZigClangStmt *s |
| 3531 | 3542 | emit_warning(c, ZigClangStmt_getBeginLoc(stmt), "TODO handle C ObjCBridgedCastExprClass"); |
| 3532 | 3543 | return ErrorUnexpected; |
| 3533 | 3544 | case ZigClangStmt_CharacterLiteralClass: |
| 3534 | | emit_warning(c, ZigClangStmt_getBeginLoc(stmt), "TODO handle C CharacterLiteralClass"); |
| 3545 | return wrap_stmt(out_node, out_child_scope, scope, |
| 3546 | trans_character_literal(c, result_used, (const clang::CharacterLiteral *)stmt)); |
| 3535 | 3547 | return ErrorUnexpected; |
| 3536 | 3548 | case ZigClangStmt_ChooseExprClass: |
| 3537 | 3549 | emit_warning(c, ZigClangStmt_getBeginLoc(stmt), "TODO handle C ChooseExprClass"); |