Fixed problem with array's of incomplete types
This commit is contained in:
parent
0571a16bcb
commit
60c44af82b
|
@ -624,7 +624,9 @@ bss(idf)
|
||||||
#endif /* DBSYMTAB */
|
#endif /* DBSYMTAB */
|
||||||
if (df->df_type->tp_size <= 0) {
|
if (df->df_type->tp_size <= 0) {
|
||||||
if (df->df_sc != STATIC &&
|
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_df_dnam(idf->id_text);
|
||||||
C_bss_cst(ATW(df->df_type->tp_up->tp_size), (arith)0, 1);
|
C_bss_cst(ATW(df->df_type->tp_up->tp_size), (arith)0, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -490,7 +490,9 @@ struct_declaration_pack(register struct type *stp;)
|
||||||
'{'
|
'{'
|
||||||
struct_declaration(stp, &sdefp, &size)+
|
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;)
|
struct_declaration(struct type *stp; struct sdef ***sdefpp; arith *szp;)
|
||||||
|
|
|
@ -105,12 +105,7 @@ construct_type(fund, tp, qual, count, pl)
|
||||||
if (tp->tp_fund == VOID) {
|
if (tp->tp_fund == VOID) {
|
||||||
error("cannot construct array of void");
|
error("cannot construct array of void");
|
||||||
count = (arith) -1;
|
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);
|
dtp = array_of(tp, count, qual);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -199,17 +194,21 @@ array_of(tp, count, qual)
|
||||||
register struct type *dtp = tp->tp_array;
|
register struct type *dtp = tp->tp_array;
|
||||||
|
|
||||||
/* look for a type with the right size */
|
/* 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;
|
dtp = dtp->next;
|
||||||
|
|
||||||
if (!dtp) {
|
if (!dtp) {
|
||||||
dtp = create_type(ARRAY);
|
dtp = create_type(ARRAY);
|
||||||
dtp->tp_up = tp;
|
dtp->tp_up = tp;
|
||||||
dtp->tp_size = count;
|
dtp->tp_nel = count;
|
||||||
dtp->tp_align = tp->tp_align;
|
dtp->tp_align = tp->tp_align;
|
||||||
dtp->tp_typequal = qual;
|
dtp->tp_typequal = qual;
|
||||||
dtp->next = tp->tp_array;
|
dtp->next = tp->tp_array;
|
||||||
tp->tp_array = dtp;
|
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 dtp;
|
||||||
}
|
}
|
||||||
|
@ -286,3 +285,16 @@ standard_type(fund, sgn, algn, sz)
|
||||||
|
|
||||||
return tp;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ struct type {
|
||||||
/* tp__up: from FIELD, POINTER, ARRAY or FUNCTION to fund. */
|
/* tp__up: from FIELD, POINTER, ARRAY or FUNCTION to fund. */
|
||||||
struct type *tp__up;
|
struct type *tp__up;
|
||||||
union {
|
union {
|
||||||
|
arith tp__nel; /* # of elements for array */
|
||||||
/* tp__field: field descriptor if fund == FIELD */
|
/* tp__field: field descriptor if fund == FIELD */
|
||||||
struct field *tp__field;
|
struct field *tp__field;
|
||||||
struct {
|
struct {
|
||||||
|
@ -49,6 +50,7 @@ struct type {
|
||||||
#define tp_sdef tp_union.tp_istagged.tp__sdef
|
#define tp_sdef tp_union.tp_istagged.tp__sdef
|
||||||
#define tp_up tp_union.tp_nottagged.tp__up
|
#define tp_up tp_union.tp_nottagged.tp__up
|
||||||
#define tp_field tp_union.tp_nottagged.tp_f.tp__field
|
#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_proto tp_union.tp_nottagged.tp_f.tp_isfunc.tp__proto
|
||||||
#define tp_pseudoproto tp_union.tp_nottagged.tp_f.tp_isfunc.tp__pseudoproto
|
#define tp_pseudoproto tp_union.tp_nottagged.tp_f.tp_isfunc.tp__pseudoproto
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue