Fix: sometimes crashed on initializers for unknown types

This commit is contained in:
ceriel 1991-09-30 15:00:46 +00:00
parent 3e17bc4188
commit 8d25f69e77
3 changed files with 22 additions and 1 deletions

View file

@ -140,6 +140,9 @@ gen_tpcheck(tpp)
if (! valid_type(tp, "union")) if (! valid_type(tp, "union"))
gen_error = pack_level; gen_error = pack_level;
break; break;
case ERRONEOUS:
if (! gen_error) gen_error = pack_level;
break;
} }
} }
@ -252,6 +255,9 @@ gen_tphead(tpp, nest)
return gen_tphead(&(sd->sd_type), 1); return gen_tphead(&(sd->sd_type), 1);
} }
return &(sd->sd_type); return &(sd->sd_type);
case ERRONEOUS:
if (! gen_error) gen_error = pack_level;
/* fall through */
default: default:
p->nelem = 1; p->nelem = 1;
p->elem_count = 1; p->elem_count = 1;
@ -273,6 +279,9 @@ gen_tpmiddle()
again: again:
tp = *(p->s_tpp); tp = *(p->s_tpp);
switch(tp->tp_fund) { switch(tp->tp_fund) {
case ERRONEOUS:
if (! gen_error) gen_error = pack_level;
return p->s_tpp;
default: default:
if (p->elem_count == p->nelem && p->s_nested) { if (p->elem_count == p->nelem && p->s_nested) {
p = p->next; p = p->next;
@ -556,6 +565,8 @@ and also to prevent runtime coercions for compile-time constants.
#endif NOBITFIELD #endif NOBITFIELD
case ERRONEOUS: case ERRONEOUS:
if (! gen_error) gen_error = pack_level;
/* fall through */
case VOID: case VOID:
break; break;
default: default:

View file

@ -134,6 +134,9 @@ gen_tpcheck(tpp, union_allowed)
if (! valid_type(tp, "union")) if (! valid_type(tp, "union"))
gen_error = pack_level; gen_error = pack_level;
break; break;
case ERRONEOUS:
if (! gen_error) gen_error = pack_level;
break;
} }
} }
@ -243,6 +246,9 @@ gen_tphead(tpp, nest)
return gen_tphead(&(sd->sd_type), 1); return gen_tphead(&(sd->sd_type), 1);
} }
return &(sd->sd_type); return &(sd->sd_type);
case ERRONEOUS:
if (! gen_error) gen_error = pack_level;
/* fall through */
default: default:
p->nelem = 1; p->nelem = 1;
p->elem_count = 1; p->elem_count = 1;
@ -264,6 +270,9 @@ gen_tpmiddle()
again: again:
tp = *(p->s_tpp); tp = *(p->s_tpp);
switch(tp->tp_fund) { switch(tp->tp_fund) {
case ERRONEOUS:
if (! gen_error) gen_error = pack_level;
return p->s_tpp;
default: default:
if (p->elem_count == p->nelem && p->s_nested) { if (p->elem_count == p->nelem && p->s_nested) {
p = p->next; p = p->next;
@ -544,6 +553,7 @@ and also to prevent runtime coercions for compile-time constants.
#endif NOBITFIELD #endif NOBITFIELD
case ERRONEOUS: case ERRONEOUS:
if (! gen_error) gen_error = pack_level;
break; break;
default: default:
crash("check_ival"); crash("check_ival");

View file

@ -96,7 +96,7 @@ GEN_H = botch_free.h dataflow.h debug.h density.h errout.h \
regcount.h \ regcount.h \
code.h declar.h decspecs.h def.h expr.h field.h estack.h util.h \ code.h declar.h decspecs.h def.h expr.h field.h estack.h util.h \
idf.h macro.h stmt.h struct.h switch.h type.h l_brace.h l_state.h \ idf.h macro.h stmt.h struct.h switch.h type.h l_brace.h l_state.h \
l_outdef.h stack.h l_outdef.h stack.h lapbuf.h noRoption.h nofloat.h
HFILES= $(GEN_H) $(SRC_H) HFILES= $(GEN_H) $(SRC_H)