static void incomplete_type_error(expression e, type t) { /* Avoid duplicate error message. */ if (t == error_type) return; if (e && is_identifier(e)) error("`%s' has an incomplete type", CAST(identifier, e)->cstring.data); else { while (type_array(t) && type_array_size(t)) t = type_array_of(t); if (type_struct(t)) error("invalid use of undefined type `struct %s'", type_tag(t)->name); else if (type_union(t)) error("invalid use of undefined type `union %s'", type_tag(t)->name); else if (type_enum(t)) error("invalid use of undefined type `enum %s'", type_tag(t)->name); else if (type_void(t)) error("invalid use of void expression"); else if (type_array(t)) error("invalid use of array with unspecified bounds"); else assert(0); /* XXX: Missing special message for typedef's */ } }
int type_isdependent(type *t) { Symbol *stempl; type *tstart; //printf("type_isdependent(%p)\n", t); //type_print(t); for (tstart = t; t; t = t->Tnext) { type_debug(t); if (t->Tflags & TFdependent) goto Lisdependent; if (tyfunc(t->Tty) #if TARGET_SEGMENTED || tybasic(t->Tty) == TYtemplate #endif ) { for (param_t *p = t->Tparamtypes; p; p = p->Pnext) { if (p->Ptype && type_isdependent(p->Ptype)) goto Lisdependent; if (p->Pelem && el_isdependent(p->Pelem)) goto Lisdependent; } } else if (type_struct(t) && (stempl = t->Ttag->Sstruct->Stempsym) != NULL) { for (param_t *p = t->Ttag->Sstruct->Sarglist; p; p = p->Pnext) { if (p->Ptype && type_isdependent(p->Ptype)) goto Lisdependent; if (p->Pelem && el_isdependent(p->Pelem)) goto Lisdependent; } } } //printf("\tis not dependent\n"); return 0; Lisdependent: //printf("\tis dependent\n"); // Dependence on a dependent type makes this type dependent as well tstart->Tflags |= TFdependent; return 1; }
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); }