*/
static void print_typeprop_expression(const typeprop_expression_t *expression)
{
- if (expression->base.kind == EXPR_SIZEOF) {
- print_string("sizeof");
- } else {
- assert(expression->base.kind == EXPR_ALIGNOF);
- print_string("__alignof__");
+ switch (expression->base.kind) {
+ case EXPR_SIZEOF: print_string("sizeof"); break;
+ case EXPR_ALIGNOF: print_string("__alignof__"); break;
+ default: panic("invalid typeprop kind");
}
if (expression->tp_expression != NULL) {
/* PREC_TOP: always print the '()' here, sizeof x is right but unusual */
return;
}
case INITIALIZER_LIST: {
- assert(initializer->kind == INITIALIZER_LIST);
print_string("{ ");
const initializer_list_t *list = &initializer->list;
unsigned size = get_atomic_type_size(kind);
if ((flags & ATOMIC_TYPE_FLAG_FLOAT)
&& !(flags & ATOMIC_TYPE_FLAG_COMPLEX)) {
- if (size == 4) {
- return get_modeF();
- } else if (size == 8) {
- return get_modeD();
- } else {
- panic("unexpected kind");
+ switch (size) {
+ case 4: return get_modeF();
+ case 8: return get_modeD();
+ default: panic("unexpected kind");
}
} else if (flags & ATOMIC_TYPE_FLAG_INTEGER) {
char name[64];
{
assert(entity->kind == ENTITY_COMPOUND_MEMBER);
type_t *base = skip_typeref(entity->declaration.type);
- assert(base->kind == TYPE_ATOMIC || base->kind == TYPE_ENUM);
+ assert(is_type_integer(base));
ir_type *irbase = get_ir_type(base);
unsigned bit_size = entity->compound_member.bit_size;
- assert(!is_type_float(base));
if (is_type_signed(base)) {
return get_signed_int_type_for_bit_size(irbase, bit_size, base);
} else {
/* anonymous bitfield member, skip */
if (entry->compound_member.bitfield)
continue;
- assert(entry_type->kind == TYPE_COMPOUND_STRUCT
- || entry_type->kind == TYPE_COMPOUND_UNION);
+ assert(is_type_compound(entry_type));
ident = id_unique("anon.%u");
} else {
ident = new_id_from_str(symbol->string);
static ir_type *get_ir_type_incomplete(type_t *type)
{
- assert(type != NULL);
type = skip_typeref(type);
if (type->base.firm_type != NULL) {
ir_type *get_ir_type(type_t *type)
{
- assert(type != NULL);
-
type = skip_typeref(type);
if (type->base.firm_type != NULL) {
default:
break;
}
- panic("trying to get pn_Cmp from non-comparison binexpr type");
+ panic("trying to get ir_relation from non-comparison binexpr type");
}
/**
case EXPR_BINARY_MOD:
case EXPR_BINARY_MOD_ASSIGN: {
ir_node *pin = new_Pin(new_NoMem());
- assert(!mode_is_float(mode));
ir_node *op = new_d_Mod(dbgi, pin, left, right, mode,
op_pin_state_floats);
ir_node *res = new_d_Proj(dbgi, op, mode, pn_Mod_res);
case EXPR_BINARY_SHIFTRIGHT_ASSIGN:
return create_assign_binop(expression);
default:
- panic("TODO binexpr type");
+ panic("invalid binexpr type");
}
}
compound_t *compound = type->compound.compound;
entity_t *iter = compound->members.entities;
- for ( ; iter != NULL; iter = iter->base.next) {
- if (iter->base.symbol == symbol) {
- break;
- }
- }
- assert(iter != NULL);
+ for (; iter->base.symbol != symbol; iter = iter->base.next) {}
assert(iter->kind == ENTITY_COMPOUND_MEMBER);
assert(iter->declaration.kind == DECLARATION_KIND_COMPOUND_MEMBER);
compound_t *compound = type->compound.compound;
entity_t *iter = compound->members.entities;
- for ( ; iter != NULL; iter = iter->base.next, ++index) {
- if (iter->base.symbol == symbol) {
- assert(iter->kind == ENTITY_COMPOUND_MEMBER);
- break;
- }
- }
- assert(iter != NULL);
+ for (; iter->base.symbol != symbol; iter = iter->base.next, ++index) {}
+ assert(iter->kind == ENTITY_COMPOUND_MEMBER);
/* revert previous initialisations of other union elements */
if (type->kind == TYPE_COMPOUND_UNION) {
orig_type = iter->declaration.type;
} else {
expression_t *array_index = designator->array_index;
- assert(designator->array_index != NULL);
assert(is_type_array(type));
long index = fold_constant_to_int(array_index);
- assert(index >= 0);
-#ifndef NDEBUG
- if (type->array.size_constant) {
- long array_size = type->array.size;
- assert(index < array_size);
- }
-#endif
+ assert(0 <= index && (!type->array.size_constant || (size_t)index < type->array.size));
top->type = orig_type;
top->index = (size_t) index;