static void intern_print_type_pre(const type_t *const type, const bool top)
{
switch(type->kind) {
+ case TYPE_ERROR:
+ fputs("<error>", out);
case TYPE_INVALID:
- fputs("invalid", out);
+ fputs("<invalid>", out);
return;
case TYPE_ENUM:
print_type_enum(&type->enumt);
case TYPE_BITFIELD:
print_bitfield_type_post(&type->bitfield);
return;
+ case TYPE_ERROR:
case TYPE_INVALID:
case TYPE_ATOMIC:
case TYPE_ENUM:
case TYPE_TYPEDEF: return sizeof(typedef_type_t);
case TYPE_TYPEOF: return sizeof(typeof_type_t);
case TYPE_BITFIELD: return sizeof(bitfield_type_t);
+ case TYPE_ERROR: panic("error type found");
case TYPE_INVALID: panic("invalid type found");
}
panic("unknown type found");
return is_type_arithmetic(type);
}
+/**
+ * Check if a given type is incomplete
+ */
bool is_type_incomplete(const type_t *type)
{
assert(!is_typeref(type));
declaration_t *declaration = compound_type->declaration;
return !declaration->init.is_defined;
}
+ case TYPE_ENUM: {
+ const enum_type_t *enum_type = &type->enumt;
+ declaration_t *declaration = enum_type->declaration;
+ return !declaration->init.is_defined;
+ }
case TYPE_BITFIELD:
case TYPE_FUNCTION:
return true;
return type->atomic.akind == ATOMIC_TYPE_VOID;
case TYPE_POINTER:
- case TYPE_ENUM:
case TYPE_BUILTIN:
+ case TYPE_ERROR:
return false;
case TYPE_TYPEDEF:
* really need it! */
panic("type compatibility check for bitfield type");
+ case TYPE_ERROR:
+ /* Hmm, the error type should be compatible to all other types */
+ return true;
case TYPE_INVALID:
panic("invalid type found in compatible types");
case TYPE_TYPEDEF:
return true;
}
+/**
+ * Skip all typerefs and return the underlying type.
+ */
type_t *skip_typeref(type_t *type)
{
unsigned qualifiers = TYPE_QUALIFIER_NONE;
while(true) {
switch(type->kind) {
+ case TYPE_ERROR:
+ return type;
case TYPE_TYPEDEF: {
qualifiers |= type->base.qualifiers;
const typedef_type_t *typedef_type = &type->typedeft;