type default_conversion(expression e) { type from = e->type; if (type_enum(from)) from = type_tag(from)->reptype; if (type_smallerthanint(from)) { /* Traditionally, unsignedness is preserved in default promotions. */ if (flag_traditional && type_unsigned(from)) return unsigned_int_type; else return int_type; } if (flag_traditional && !flag_allow_single_precision && type_float(from)) return double_type; if (type_void(from)) { error("void value not ignored as it ought to be"); return error_type; } if (type_function(from)) { assert(!e->cst); e->cst = e->static_address; return make_pointer_type(from); } if (type_array(from)) { if (!e->lvalue) { error("invalid use of non-lvalue array"); return error_type; } assert(!e->cst); e->cst = e->static_address; /* It's being used as a pointer, so is not an lvalue */ e->lvalue = FALSE; return make_pointer_type(type_array_of(from)); } return from; }
static void dump_type(type t) { if (type_complex(t)) { printf("C"); t = make_base_type(t); } if (type_network_base_type(t)) printf("N%s", type_networkdef(t)->name); /* Enums treated as ints for now */ else if (type_integer(t)) if (type_unsigned(t)) printf("U"); else printf("I"); else if (type_float(t)) printf("F"); else if (type_double(t)) printf("D"); else if (type_long_double(t)) printf("LD"); else if (type_union(t)) if (type_network(t)) printf("ANU"); else printf("AU"); else if (type_struct(t)) if (type_network(t)) printf("ANS"); else printf("AS"); else if (type_pointer(t)) printf("U"); else assert(0); }