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
					
				
					 5 changed files with 22 additions and 15 deletions
				
			
		| 
						 | 
				
			
			@ -85,8 +85,7 @@ ch3bin(expp, oper, expr)
 | 
			
		|||
					*expp, '(', (struct expr *)0);
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
			*expp = new_oper(expp_tp->tp_up,
 | 
			
		||||
					*expp, '(', expr);
 | 
			
		||||
			*expp = new_oper(expp_tp->tp_up, *expp, '(', expr);
 | 
			
		||||
		(*expp)->ex_flags |= EX_SIDEEFFECTS;
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -325,7 +325,7 @@ dump_type(tp)
 | 
			
		|||
			ops = 0;
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
		tp = tp->tp_up;
 | 
			
		||||
		if (!ops) tp = tp->tp_up;
 | 
			
		||||
	}
 | 
			
		||||
	dumplevel--;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -379,7 +379,7 @@ type2str(tp)
 | 
			
		|||
			ops = 0;
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
		tp = tp->tp_up;
 | 
			
		||||
		if (!ops) tp = tp->tp_up;
 | 
			
		||||
	}
 | 
			
		||||
	return buf;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -184,7 +184,7 @@ compile(argc, argv)
 | 
			
		|||
		FileName = source = argv[0];
 | 
			
		||||
	else {
 | 
			
		||||
		source = 0;
 | 
			
		||||
		FileName = "standard input";
 | 
			
		||||
		FileName = Salloc("standard input", 16);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (!InsertFile(source, (char **) 0, &result)) /* read the source file	*/
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -160,8 +160,13 @@ struct type *tp;
 | 
			
		|||
struct idf **idpp;
 | 
			
		||||
{
 | 
			
		||||
	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;
 | 
			
		||||
	switch(tp->tp_fund) {
 | 
			
		||||
	case ENUM: tg = tp->tp_idf->id_enum; break;
 | 
			
		||||
| 
						 | 
				
			
			@ -271,12 +276,8 @@ update_proto(tp, otp)
 | 
			
		|||
	*/
 | 
			
		||||
	register struct proto *pl, *opl;
 | 
			
		||||
 | 
			
		||||
	if (tp == otp) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	if (!tp || !otp) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	if (tp == otp) return;
 | 
			
		||||
	if (!tp || !otp) return;
 | 
			
		||||
 | 
			
		||||
	while (tp->tp_fund != FUNCTION) {
 | 
			
		||||
		tp = tp->tp_up;
 | 
			
		||||
| 
						 | 
				
			
			@ -298,7 +299,6 @@ update_proto(tp, otp)
 | 
			
		|||
	} else if (opl) {
 | 
			
		||||
		/* old decl has type */
 | 
			
		||||
	} else if (pl) {
 | 
			
		||||
		/* new decl has type */
 | 
			
		||||
		otp->tp_proto = pl;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -309,7 +309,7 @@ free_proto_list(pl)
 | 
			
		|||
	register struct proto *pl;
 | 
			
		||||
{
 | 
			
		||||
	while (pl) {
 | 
			
		||||
		struct proto *tmp = pl->next;
 | 
			
		||||
		register struct proto *tmp = pl->next;
 | 
			
		||||
		free_proto(pl);
 | 
			
		||||
		pl = tmp;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -323,8 +323,13 @@ struct type *tp;
 | 
			
		|||
{
 | 
			
		||||
	register struct idf *ident;
 | 
			
		||||
	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;
 | 
			
		||||
	switch (tp->tp_fund) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -212,6 +212,9 @@ declare_struct(fund, idf, tpp)
 | 
			
		|||
	else	{
 | 
			
		||||
		/* The struct is new. */
 | 
			
		||||
		/* Hook in a new struct tag */
 | 
			
		||||
		if (level <= L_PROTO)
 | 
			
		||||
			warning("declaration of %s-tag inside parameter list",
 | 
			
		||||
				    symbol2str(fund));
 | 
			
		||||
		tg = new_tag();
 | 
			
		||||
		tg->next = *tgp;
 | 
			
		||||
		*tgp = tg;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue