authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-01-08 16:49:52-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-01-08 16:49:52-05:00
log1ca983dbd7af661d3f1f840138ecba9dc0a6e372
treee492c46a5013f33a1fe11216d3f5871e1153db6c
parent036a49e97d0bc556ece08562c9dd3c75879598cf

translate-c: update to llvm8


1 files changed, 13 insertions(+), 3 deletions(-)

src/translate_c.cpp+13-3
......@@ -129,6 +129,7 @@ static TransScope *trans_stmt(Context *c, TransScope *scope, const Stmt *stmt, A
129129static AstNode *trans_expr(Context *c, ResultUsed result_used, TransScope *scope, const Expr *expr, TransLRValue lrval);
130130static AstNode *trans_qual_type(Context *c, QualType qt, const SourceLocation &source_loc);
131131static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope *scope, const Expr *expr, TransLRValue lrval);
132static AstNode *trans_ap_value(Context *c, APValue *ap_value, QualType qt, const SourceLocation &source_loc);
132133
133134ATTRIBUTE_PRINTF(3, 4)
134135static void emit_warning(Context *c, const SourceLocation &sl, const char *format, ...) {
......@@ -1225,6 +1226,15 @@ static AstNode *trans_integer_literal(Context *c, const IntegerLiteral *stmt) {
12251226 return trans_create_node_apint(c, result.Val.getInt());
12261227}
12271228
1229static AstNode *trans_constant_expr(Context *c, const ConstantExpr *expr) {
1230 Expr::EvalResult result;
1231 if (!expr->EvaluateAsConstantExpr(result, Expr::EvaluateForCodeGen, *c->ctx)) {
1232 emit_warning(c, expr->getBeginLoc(), "invalid constant expression");
1233 return nullptr;
1234 }
1235 return trans_ap_value(c, &result.Val, expr->getType(), expr->getBeginLoc());
1236}
1237
12281238static AstNode *trans_conditional_operator(Context *c, ResultUsed result_used, TransScope *scope,
12291239 const ConditionalOperator *stmt)
12301240{
......@@ -3183,6 +3193,9 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const Stmt *stmt,
31833193 return trans_switch_case(c, scope, (const CaseStmt *)stmt, out_node, out_child_scope);
31843194 case Stmt::DefaultStmtClass:
31853195 return trans_switch_default(c, scope, (const DefaultStmt *)stmt, out_node, out_child_scope);
3196 case Stmt::ConstantExprClass:
3197 return wrap_stmt(out_node, out_child_scope, scope,
3198 trans_constant_expr(c, (const ConstantExpr *)stmt));
31863199 case Stmt::NoStmtClass:
31873200 emit_warning(c, stmt->getBeginLoc(), "TODO handle C NoStmtClass");
31883201 return ErrorUnexpected;
......@@ -3690,9 +3703,6 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const Stmt *stmt,
36903703 case Stmt::FixedPointLiteralClass:
36913704 emit_warning(c, stmt->getBeginLoc(), "TODO handle C FixedPointLiteralClass");
36923705 return ErrorUnexpected;
3693 case Stmt::ConstantExprClass:
3694 emit_warning(c, stmt->getBeginLoc(), "TODO handle C ConstantExprClass");
3695 return ErrorUnexpected;
36963706 }
36973707 zig_unreachable();
36983708}