#endif /* DBSYMTAB */
if (df->df_type->tp_size <= 0) {
if (df->df_sc != STATIC &&
- df->df_type->tp_fund == ARRAY && df->df_type->tp_up) {
+ df->df_type->tp_fund == ARRAY &&
+ df->df_type->tp_up &&
+ df->df_type->tp_up->tp_size >= 0) {
C_df_dnam(idf->id_text);
C_bss_cst(ATW(df->df_type->tp_up->tp_size), (arith)0, 1);
}
'{'
struct_declaration(stp, &sdefp, &size)+
'}'
- {stp->tp_size = align(size, stp->tp_align);}
+ {stp->tp_size = align(size, stp->tp_align);
+ completed(stp);
+ }
;
struct_declaration(struct type *stp; struct sdef ***sdefpp; arith *szp;)
if (tp->tp_fund == VOID) {
error("cannot construct array of void");
count = (arith) -1;
- } else if (count >= 0 && tp->tp_size < 0) {
- error("cannot construct array of unknown type");
- count = (arith)-1;
}
- if (count > (arith)0)
- count *= tp->tp_size;
dtp = array_of(tp, count, qual);
break;
default:
register struct type *dtp = tp->tp_array;
/* look for a type with the right size */
- while (dtp && (dtp->tp_size != count || dtp->tp_typequal != qual))
+ while (dtp && (dtp->tp_nel != count || dtp->tp_typequal != qual))
dtp = dtp->next;
if (!dtp) {
dtp = create_type(ARRAY);
dtp->tp_up = tp;
- dtp->tp_size = count;
+ dtp->tp_nel = count;
dtp->tp_align = tp->tp_align;
dtp->tp_typequal = qual;
dtp->next = tp->tp_array;
tp->tp_array = dtp;
+ if (tp->tp_size >= 0 && count >= 0) {
+ dtp->tp_size = count * tp->tp_size;
+ }
+ else dtp->tp_size = -1;
}
return dtp;
}
return tp;
}
+
+completed(tp)
+ struct type *tp;
+{
+ register struct type *atp = tp->tp_array;
+
+ while (atp) {
+ if (atp->tp_nel >= 0) {
+ atp->tp_size = atp->tp_nel * tp->tp_size;
+ }
+ atp = atp->next;
+ }
+}
/* tp__up: from FIELD, POINTER, ARRAY or FUNCTION to fund. */
struct type *tp__up;
union {
+ arith tp__nel; /* # of elements for array */
/* tp__field: field descriptor if fund == FIELD */
struct field *tp__field;
struct {
#define tp_sdef tp_union.tp_istagged.tp__sdef
#define tp_up tp_union.tp_nottagged.tp__up
#define tp_field tp_union.tp_nottagged.tp_f.tp__field
+#define tp_nel tp_union.tp_nottagged.tp_f.tp__nel
#define tp_proto tp_union.tp_nottagged.tp_f.tp_isfunc.tp__proto
#define tp_pseudoproto tp_union.tp_nottagged.tp_f.tp_isfunc.tp__pseudoproto