[EXPR_UNARY_PREFIX_INCREMENT] = PREC_UNARY,
[EXPR_UNARY_PREFIX_DECREMENT] = PREC_UNARY,
[EXPR_UNARY_CAST] = PREC_UNARY,
- [EXPR_UNARY_CAST_IMPLICIT] = PREC_UNARY,
[EXPR_UNARY_ASSUME] = PREC_PRIMARY,
[EXPR_UNARY_DELETE] = PREC_UNARY,
[EXPR_UNARY_DELETE_ARRAY] = PREC_UNARY,
print_expression_prec(unexpr->value, prec);
print_string("--");
return;
- case EXPR_UNARY_CAST_IMPLICIT:
case EXPR_UNARY_CAST:
print_string("(");
print_type(unexpr->base.type);
*/
static void print_expression_prec(const expression_t *expression, unsigned top_prec)
{
- if (expression->kind == EXPR_UNARY_CAST_IMPLICIT && !print_implicit_casts) {
+ if (expression->kind == EXPR_UNARY_CAST
+ && expression->base.implicit && !print_implicit_casts) {
expression = expression->unary.value;
}
case EXPR_UNARY_NOT:
return is_constant_expression(expression->unary.value);
- case EXPR_UNARY_CAST:
- case EXPR_UNARY_CAST_IMPLICIT: {
+ case EXPR_UNARY_CAST: {
type_t *const type = skip_typeref(expression->base.type);
if (is_type_scalar(type))
return is_constant_expression(expression->unary.value);
case EXPR_UNARY_PREFIX_INCREMENT:
case EXPR_UNARY_PREFIX_DECREMENT:
return create_incdec(expression);
- case EXPR_UNARY_CAST_IMPLICIT:
case EXPR_UNARY_CAST: {
ir_node *value_node = expression_to_firm(value);
type_t *from_type = value->base.type;
type_t *skipped = skip_typeref(type);
if (skipped->kind == TYPE_BITFIELD) {
/* remove the bitfield cast... */
- assert(expr->kind == EXPR_UNARY_CAST_IMPLICIT);
+ assert(expr->kind == EXPR_UNARY_CAST && expr->base.implicit);
expr = expr->unary.value;
type = skipped->bitfield.base_type;
}
EXPR_UNARY_PREFIX_INCREMENT,
EXPR_UNARY_PREFIX_DECREMENT,
EXPR_UNARY_CAST,
- EXPR_UNARY_CAST_IMPLICIT, /**< compiler generated cast */
EXPR_UNARY_ASSUME, /**< MS __assume() */
EXPR_UNARY_DELETE,
EXPR_UNARY_DELETE_ARRAY,
case EXPR_UNARY_PREFIX_INCREMENT: \
case EXPR_UNARY_PREFIX_DECREMENT: \
case EXPR_UNARY_CAST: \
- case EXPR_UNARY_CAST_IMPLICIT: \
case EXPR_UNARY_ASSUME: \
case EXPR_UNARY_DELETE: \
case EXPR_UNARY_DELETE_ARRAY:
#ifndef NDEBUG
bool transformed : 1; /**< Set if this expression was transformed. */
#endif
+ bool implicit : 1; /**< compiler generated expression.
+ Examples:
+ select into anonymous structs
+ implicit casts
+ */
};
/**
expression_base_t base;
expression_t *compound;
entity_t *compound_entry;
- bool implicit : 1; /**< compiler generated select
- (for anonymous struct/union) */
};
struct array_access_expression_t {
const call_argument_t *arg,
const format_spec_t *spec)
{
- while (fmt_expr->kind == EXPR_UNARY_CAST_IMPLICIT) {
+ while (fmt_expr->kind == EXPR_UNARY_CAST) {
fmt_expr = fmt_expr->unary.value;
}
}
} else if (get_unqualified_type(arg_skip) == expected_type_skip) {
goto next_arg;
- } else if (arg->expression->kind == EXPR_UNARY_CAST_IMPLICIT) {
+ } else if (arg->expression->kind == EXPR_UNARY_CAST) {
expression_t const *const expr = arg->expression->unary.value;
type_t *const unprom_type = skip_typeref(expr->base.type);
if (get_unqualified_type(unprom_type) == expected_type_skip) {
}
const expression_t *fmt_expr = arg->expression;
- if (fmt_expr->kind == EXPR_UNARY_CAST_IMPLICIT) {
+ if (fmt_expr->kind == EXPR_UNARY_CAST) {
fmt_expr = fmt_expr->unary.value;
}
return type;
}
-/**
- * Create a cast expression.
- *
- * @param expression the expression to cast
- * @param dest_type the destination type
- */
-static expression_t *create_cast_expression(expression_t *expression,
- type_t *dest_type)
-{
- expression_t *cast = allocate_expression_zero(EXPR_UNARY_CAST_IMPLICIT);
-
- cast->unary.value = expression;
- cast->base.type = dest_type;
-
- return cast;
-}
-
/**
* Check if a given expression represents a null pointer constant.
*
static bool is_null_pointer_constant(const expression_t *expression)
{
/* skip void* cast */
- if (expression->kind == EXPR_UNARY_CAST ||
- expression->kind == EXPR_UNARY_CAST_IMPLICIT) {
+ if (expression->kind == EXPR_UNARY_CAST) {
type_t *const type = skip_typeref(expression->base.type);
if (types_compatible(type, type_void_ptr))
expression = expression->unary.value;
if (source_type == dest_type)
return expression;
- return create_cast_expression(expression, dest_type);
+ expression_t *cast = allocate_expression_zero(EXPR_UNARY_CAST);
+ cast->unary.value = expression;
+ cast->base.type = dest_type;
+ cast->base.implicit = true;
+
+ return cast;
}
typedef enum assign_error_t {
case EXPR_UNARY_POSTFIX_DECREMENT:
case EXPR_UNARY_PREFIX_INCREMENT:
case EXPR_UNARY_PREFIX_DECREMENT:
- case EXPR_UNARY_CAST_IMPLICIT:
case EXPR_UNARY_ASSUME:
unary:
mark_vars_read(expr->unary.value, lhs_ent);
expression_t *sub_addr = create_select(pos, addr, qualifiers, iter);
sub_addr->base.source_position = *pos;
- sub_addr->select.implicit = true;
+ sub_addr->base.implicit = true;
return find_create_select(pos, sub_addr, qualifiers, sub_compound,
symbol);
}
return is_type_atomic(type, ATOMIC_TYPE_VOID);
}
- case EXPR_UNARY_CAST_IMPLICIT: return true;
case EXPR_UNARY_ASSUME: return true;
case EXPR_UNARY_DELETE: return true;
case EXPR_UNARY_DELETE_ARRAY: return true;
/* skip the implicit cast */
expression_t *expression = entry->enum_value.value;
- if (expression->kind == EXPR_UNARY_CAST_IMPLICIT) {
- expression = expression->unary.value;
- }
print_expression(expression);
}
print_string(",\n");
case EXPR_UNARY_NOT:
fputc('!', out);
break;
- case EXPR_UNARY_CAST_IMPLICIT:
+ case EXPR_UNARY_CAST:
write_expression(expression->value);
return;
default: