static void print_conditional(const conditional_expression_t *expression)
{
print_expression_prec(expression->condition, PREC_LOGICAL_OR);
- fputs(" ? ", out);
if (expression->true_expression != NULL) {
+ fputs(" ? ", out);
print_expression_prec(expression->true_expression, PREC_EXPRESSION);
fputs(" : ", out);
} else {
- fputs(": ", out);
+ fputs(" ?: ", out);
}
precedence_t prec = c_mode & _CXX ? PREC_ASSIGNMENT : PREC_CONDITIONAL;
print_expression_prec(expression->false_expression, prec);
set_cur_block(cur_block);
ir_node *const cond_expr = create_condition_evaluation(expression->condition, true_block, false_block);
if (expression->true_expression == NULL) {
- if (cond_expr != NULL) {
+ if (cond_expr != NULL && get_irn_mode(cond_expr) != mode_b) {
true_val = cond_expr;
} else {
- /* Condition ended with a short circuit (&&, ||, !) operation.
- * Generate a "1" as value for the true branch. */
+ /* Condition ended with a short circuit (&&, ||, !) operation or a
+ * comparison. Generate a "1" as value for the true branch. */
true_val = new_Const(get_mode_one(mode_Is));
}
}