Minix again

This commit is contained in:
eck 1989-10-20 13:06:10 +00:00
parent 01f77a03af
commit b6a7d4fa0f
6 changed files with 37 additions and 59 deletions

View file

@ -21,7 +21,7 @@
!File: nparams.h !File: nparams.h
#define NPARAMS 32 /* maximum number of parameters of macros */ #define NPARAMS 32 /* maximum number of parameters */
#define STDC_NPARAMS 31 /* ANSI limit on number of parameters */ #define STDC_NPARAMS 31 /* ANSI limit on number of parameters */

View file

@ -21,7 +21,7 @@
!File: nparams.h !File: nparams.h
#define NPARAMS 32 /* maximum number of parameters of macros */ #define NPARAMS 32 /* maximum number of parameters */
#define STDC_NPARAMS 31 /* ANSI limit on number of parameters */ #define STDC_NPARAMS 31 /* ANSI limit on number of parameters */

View file

@ -348,7 +348,7 @@ equal_type(tp, otp, check_qual)
|| (tp->tp_unsigned != otp->tp_unsigned) || (tp->tp_unsigned != otp->tp_unsigned)
|| (tp->tp_align != otp->tp_align)) || (tp->tp_align != otp->tp_align))
return 0; return 0;
if (tp->tp_fund != ARRAY /* && tp->tp_fund != STRUCT */ ) { /* UNION ??? */ if (tp->tp_fund != ARRAY) {
if (tp->tp_size != otp->tp_size) if (tp->tp_size != otp->tp_size)
return 0; return 0;
} }
@ -516,6 +516,7 @@ struct type *tp;
register struct sdef *sdf; register struct sdef *sdf;
ASSERT(tp); ASSERT(tp);
if (tp->tp_typequal & TQ_CONST) return 1; if (tp->tp_typequal & TQ_CONST) return 1;
sdf = tp->tp_sdef; sdf = tp->tp_sdef;
while (sdf) { while (sdf) {

View file

@ -206,7 +206,7 @@ ch3bin(expp, oper, expr)
*expp = intexpr((arith)((oper == AND) ? 0 : 1), *expp = intexpr((arith)((oper == AND) ? 0 : 1),
INT); INT);
} }
(*expp)->ex_flags |= ex->ex_flags; (*expp)->ex_flags |= ex->ex_flags | EX_ILVALUE;
free_expression(ex); free_expression(ex);
} }
else else
@ -217,7 +217,7 @@ ch3bin(expp, oper, expr)
and ((oper == AND) || (oper == OR)) and ((oper == AND) || (oper == OR))
*/ */
if ((oper == AND) == (expr->VL_VALUE != (arith)0)) { if ((oper == AND) == (expr->VL_VALUE != (arith)0)) {
(*expp)->ex_flags |= expr->ex_flags; (*expp)->ex_flags |= expr->ex_flags | EX_ILVALUE;
free_expression(expr); free_expression(expr);
} }
else { else {
@ -297,7 +297,8 @@ pntminuspnt(expp, oper, expr)
ch3cast(expp, CAST, pa_type); /* ptr-ptr: result has pa_type */ ch3cast(expp, CAST, pa_type); /* ptr-ptr: result has pa_type */
ch3bin(expp, '/', ch3bin(expp, '/',
intexpr(size_of_type(up_type, "object"), pa_type->tp_fund)); intexpr(size_of_type(up_type, "object"), pa_type->tp_fund));
ch3cast(expp, CAST, int_type); /* result will be an integer expr */ ch3cast(expp, CAST, pa_type); /* result will be an integgral expr */
/* cast necessary ??? */
} }
mk_binop(expp, oper, expr, commutative) mk_binop(expp, oper, expr, commutative)

View file

@ -29,7 +29,7 @@ struct pkey {
char *pk_name; char *pk_name;
int pk_key; int pk_key;
} pragmas[] = { } pragmas[] = {
{"flags", P_FLAGS}, {"cemflags", P_FLAGS},
{0, P_UNKNOWN} {0, P_UNKNOWN}
}; };

View file

@ -319,23 +319,26 @@ free_proto_list(pl)
remove_proto_tag(tp) remove_proto_tag(tp)
struct type *tp; struct type *tp;
{ {
struct idf *ident; register struct idf *ident;
struct tag *tg, *otg = 0; register struct tag *tgp, **tgpp;
while(tp->tp_up) tp = tp->tp_up; while(tp->tp_up) tp = tp->tp_up;
ident = tp->tp_idf; ident = tp->tp_idf;
switch(tp->tp_fund) { switch (tp->tp_fund) {
case ENUM: tg = ident->id_enum; break; case ENUM: tgpp = &(ident->id_enum); break;
case UNION: case STRUCT:
case STRUCT: tg = ident->id_struct; break; case UNION: tgpp = &(ident->id_struct); break;
default: return; default: return;
} }
while (tg && tg->tg_type != tp) {
otg = tg; while((*tgpp) && (*tgpp)->tg_type != tp) {
tg = tg->next; tgpp = &((*tgpp)->next);
} }
if (tg ->tg_level > L_PROTO) return; ASSERT(*tgpp);
tgp = *tgpp;
if (tgp->tg_level > L_PROTO) return;
#ifdef DEBUG #ifdef DEBUG
if (options['t']) if (options['t'])
@ -343,26 +346,15 @@ struct type *tp;
ident->id_text); ident->id_text);
#endif #endif
if (!otg) { (*tgpp) = tgp->next;
switch(tp->tp_fund) { free_tag(tgp);
case ENUM: ident->id_enum = tg->next; break;
case UNION:
case STRUCT: ident->id_struct = tg->next; break;
}
free_tag(tg);
}
else {
otg->next = tg->next;
free_tag(tg);
}
} }
remove_proto_idfs(pl) remove_proto_idfs(pl)
register struct proto *pl; register struct proto *pl;
{ {
/* Remove all the identifier definitions from the /* Remove all the identifier definitions from the
prototype list. Keep in account the recursive prototype list.
function definitions.
*/ */
register struct def *def; register struct def *def;
@ -372,21 +364,6 @@ remove_proto_idfs(pl)
if (options['t']) if (options['t'])
print("Removing idf %s from list\n", print("Removing idf %s from list\n",
pl->pl_idf->id_text); pl->pl_idf->id_text);
#endif
/* Remove all the definitions made within
a prototype.
??? is this really necessary (Hans)
wasn't this done before in the declaration
*/
#if 0
if (pl->pl_flag & PL_FORMAL) {
register struct type *tp = pl->pl_type;
while (tp && tp->tp_fund != FUNCTION)
tp = tp->tp_up;
if (tp)
debug("remove_proto_idfs(tp->tp_proto)");
}
#endif #endif
def = pl->pl_idf->id_def; def = pl->pl_idf->id_def;
if (def && def->df_level <= L_PROTO){ if (def && def->df_level <= L_PROTO){
@ -417,34 +394,34 @@ call_proto(expp)
register struct proto *pl = NO_PROTO; register struct proto *pl = NO_PROTO;
static struct proto ellipsis = { 0, 0, 0, PL_ELLIPSIS }; static struct proto ellipsis = { 0, 0, 0, PL_ELLIPSIS };
if (left != NILEXPR) { /* in case of an error */ if (left != NILEXPR) { /* in case of an error */
register struct type *tp = left->ex_type; register struct type *tp = left->ex_type;
while (tp && tp->tp_fund != FUNCTION) while (tp && tp->tp_fund != FUNCTION)
tp = tp->tp_up; tp = tp->tp_up;
pl = (tp && tp->tp_proto) ? tp->tp_proto : NO_PROTO; if (tp && tp->tp_proto)
pl = tp->tp_proto;
} }
if (right != NILEXPR) { /* function call with parameters */ if (right != NILEXPR) { /* function call with parameters */
register struct expr *ex = right;
register struct expr **ep = &((*expp)->OP_RIGHT); register struct expr **ep = &((*expp)->OP_RIGHT);
register int ecnt = 0, pcnt = 0; register int ecnt = 0, pcnt = 0;
struct expr **estack[NPARAMS]; struct expr **estack[NPARAMS];
struct proto *pstack[NPARAMS]; struct proto *pstack[NPARAMS];
/* stack up the parameter expressions */ /* stack up the parameter expressions */
while (ex->ex_class == Oper && ex->OP_OPER == PARCOMMA) { while (right->ex_class == Oper && right->OP_OPER == PARCOMMA) {
if (ecnt == STDC_NPARAMS) if (ecnt == STDC_NPARAMS)
strict("number of parameters exceeds ANSI limit"); strict("number of parameters exceeds ANSI limit");
if (ecnt >= NPARAMS-1) { if (ecnt >= NPARAMS-1) {
error("too many parameters"); error("too many parameters");
return; return;
} }
estack[ecnt++] = &(ex->OP_RIGHT); estack[ecnt++] = &(right->OP_RIGHT);
ep = &(ex->OP_LEFT); ep = &(right->OP_LEFT);
ex = ex->OP_LEFT; right = right->OP_LEFT;
} }
estack[ecnt++] = ep; estack[ecnt] = ep;
/* Declarations like int f(void) do not expect any /* Declarations like int f(void) do not expect any
parameters. parameters.
@ -456,19 +433,18 @@ call_proto(expp)
/* stack up the prototypes */ /* stack up the prototypes */
if (pl) { if (pl) {
pcnt--;
do { do {
/* stack prototypes */ /* stack prototypes */
pstack[pcnt++] = pl; pstack[++pcnt] = pl;
pl = pl->next; pl = pl->next;
} while (pl); } while (pl);
pcnt--;
} }
else { else {
pcnt = 0;
pstack[0] = &ellipsis; pstack[0] = &ellipsis;
} }
for (--ecnt; ecnt >= 0; ecnt--) { for (ecnt; ecnt >= 0; ecnt--) {
/* Only the parameters specified in the prototype /* Only the parameters specified in the prototype
are checked and converted. The parameters that are checked and converted. The parameters that
fall under the ellipsis clause are neither fall under the ellipsis clause are neither