if (expression->kind == EXPR_UNARY_CAST_IMPLICIT && !print_implicit_casts) {
expression = expression->unary.value;
}
- unsigned prec = get_expression_precedence(expression->base.kind);
- if (print_parenthesis && top_prec != PREC_BOTTOM)
- top_prec = PREC_TOP;
- if (top_prec > prec)
+
+ bool parenthesized =
+ expression->base.parenthesized ||
+ (print_parenthesis && top_prec != PREC_BOTTOM) ||
+ top_prec > get_expression_precedence(expression->base.kind);
+
+ if (parenthesized)
fputc('(', out);
switch (expression->kind) {
case EXPR_UNKNOWN:
fprintf(out, "some expression of type %d", (int)expression->kind);
break;
}
- if (top_prec > prec)
+ if (parenthesized)
fputc(')', out);
}
switch (initializer->kind) {
case INITIALIZER_VALUE: {
const initializer_value_t *value = &initializer->value;
- print_expression(value->value);
+ print_assignment_expression(value->value);
return;
}
case INITIALIZER_LIST: {