fixed bug: tp_up is field in union; be more careful
give warning for struct/union declarations in prototypes
This commit is contained in:
parent
01535f998d
commit
b8d6eae391
|
@ -85,8 +85,7 @@ ch3bin(expp, oper, expr)
|
||||||
*expp, '(', (struct expr *)0);
|
*expp, '(', (struct expr *)0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*expp = new_oper(expp_tp->tp_up,
|
*expp = new_oper(expp_tp->tp_up, *expp, '(', expr);
|
||||||
*expp, '(', expr);
|
|
||||||
(*expp)->ex_flags |= EX_SIDEEFFECTS;
|
(*expp)->ex_flags |= EX_SIDEEFFECTS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -325,7 +325,7 @@ dump_type(tp)
|
||||||
ops = 0;
|
ops = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tp = tp->tp_up;
|
if (!ops) tp = tp->tp_up;
|
||||||
}
|
}
|
||||||
dumplevel--;
|
dumplevel--;
|
||||||
}
|
}
|
||||||
|
@ -379,7 +379,7 @@ type2str(tp)
|
||||||
ops = 0;
|
ops = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tp = tp->tp_up;
|
if (!ops) tp = tp->tp_up;
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,7 +184,7 @@ compile(argc, argv)
|
||||||
FileName = source = argv[0];
|
FileName = source = argv[0];
|
||||||
else {
|
else {
|
||||||
source = 0;
|
source = 0;
|
||||||
FileName = "standard input";
|
FileName = Salloc("standard input", 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!InsertFile(source, (char **) 0, &result)) /* read the source file */
|
if (!InsertFile(source, (char **) 0, &result)) /* read the source file */
|
||||||
|
|
|
@ -160,8 +160,13 @@ struct type *tp;
|
||||||
struct idf **idpp;
|
struct idf **idpp;
|
||||||
{
|
{
|
||||||
struct tag *tg = (struct tag *)0;
|
struct tag *tg = (struct tag *)0;
|
||||||
|
register int fund = tp->tp_fund;
|
||||||
|
|
||||||
while (tp->tp_up) tp = tp->tp_up;
|
while (fund == FIELD || fund == POINTER
|
||||||
|
|| fund == ARRAY || fund == FUNCTION) {
|
||||||
|
tp = tp->tp_up;
|
||||||
|
fund = tp->tp_fund;
|
||||||
|
}
|
||||||
*idpp = tp->tp_idf;
|
*idpp = tp->tp_idf;
|
||||||
switch(tp->tp_fund) {
|
switch(tp->tp_fund) {
|
||||||
case ENUM: tg = tp->tp_idf->id_enum; break;
|
case ENUM: tg = tp->tp_idf->id_enum; break;
|
||||||
|
@ -271,12 +276,8 @@ update_proto(tp, otp)
|
||||||
*/
|
*/
|
||||||
register struct proto *pl, *opl;
|
register struct proto *pl, *opl;
|
||||||
|
|
||||||
if (tp == otp) {
|
if (tp == otp) return;
|
||||||
return;
|
if (!tp || !otp) return;
|
||||||
}
|
|
||||||
if (!tp || !otp) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (tp->tp_fund != FUNCTION) {
|
while (tp->tp_fund != FUNCTION) {
|
||||||
tp = tp->tp_up;
|
tp = tp->tp_up;
|
||||||
|
@ -298,7 +299,6 @@ update_proto(tp, otp)
|
||||||
} else if (opl) {
|
} else if (opl) {
|
||||||
/* old decl has type */
|
/* old decl has type */
|
||||||
} else if (pl) {
|
} else if (pl) {
|
||||||
/* new decl has type */
|
|
||||||
otp->tp_proto = pl;
|
otp->tp_proto = pl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ free_proto_list(pl)
|
||||||
register struct proto *pl;
|
register struct proto *pl;
|
||||||
{
|
{
|
||||||
while (pl) {
|
while (pl) {
|
||||||
struct proto *tmp = pl->next;
|
register struct proto *tmp = pl->next;
|
||||||
free_proto(pl);
|
free_proto(pl);
|
||||||
pl = tmp;
|
pl = tmp;
|
||||||
}
|
}
|
||||||
|
@ -323,8 +323,13 @@ struct type *tp;
|
||||||
{
|
{
|
||||||
register struct idf *ident;
|
register struct idf *ident;
|
||||||
register struct tag *tgp, **tgpp;
|
register struct tag *tgp, **tgpp;
|
||||||
|
register int fund = tp->tp_fund;
|
||||||
|
|
||||||
while(tp->tp_up) tp = tp->tp_up;
|
while (fund == FIELD || fund == POINTER
|
||||||
|
|| fund == ARRAY || fund == FUNCTION) {
|
||||||
|
tp = tp->tp_up;
|
||||||
|
fund = tp->tp_fund;
|
||||||
|
}
|
||||||
|
|
||||||
ident = tp->tp_idf;
|
ident = tp->tp_idf;
|
||||||
switch (tp->tp_fund) {
|
switch (tp->tp_fund) {
|
||||||
|
|
|
@ -212,6 +212,9 @@ declare_struct(fund, idf, tpp)
|
||||||
else {
|
else {
|
||||||
/* The struct is new. */
|
/* The struct is new. */
|
||||||
/* Hook in a new struct tag */
|
/* Hook in a new struct tag */
|
||||||
|
if (level <= L_PROTO)
|
||||||
|
warning("declaration of %s-tag inside parameter list",
|
||||||
|
symbol2str(fund));
|
||||||
tg = new_tag();
|
tg = new_tag();
|
||||||
tg->next = *tgp;
|
tg->next = *tgp;
|
||||||
*tgp = tg;
|
*tgp = tg;
|
||||||
|
|
Loading…
Reference in a new issue