some fixes:
- always remove imports from definition modules - minor improvement in error messages
This commit is contained in:
		
							parent
							
								
									8fc22f0db7
								
							
						
					
					
						commit
						6217293e23
					
				
					 3 changed files with 23 additions and 23 deletions
				
			
		| 
						 | 
					@ -53,6 +53,15 @@ df_error(nd, mess, edf)
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					STATIC int
 | 
				
			||||||
 | 
					ex_error(nd, mess)
 | 
				
			||||||
 | 
						t_node	*nd;
 | 
				
			||||||
 | 
						char	*mess;
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						node_error(nd, "\"%s\": %s", symbol2str(nd->nd_symb), mess);
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MkCoercion(pnd, tp)
 | 
					MkCoercion(pnd, tp)
 | 
				
			||||||
	t_node		**pnd;
 | 
						t_node		**pnd;
 | 
				
			||||||
	register t_type	*tp;
 | 
						register t_type	*tp;
 | 
				
			||||||
| 
						 | 
					@ -160,8 +169,7 @@ ChkArrow(expp)
 | 
				
			||||||
	tp = expp->nd_right->nd_type;
 | 
						tp = expp->nd_right->nd_type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (tp->tp_fund != T_POINTER) {
 | 
						if (tp->tp_fund != T_POINTER) {
 | 
				
			||||||
		node_error(expp, "\"^\": illegal operand");
 | 
							return ex_error(expp, "illegal operand type");
 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	expp->nd_type = RemoveEqual(PointedtoType(tp));
 | 
						expp->nd_type = RemoveEqual(PointedtoType(tp));
 | 
				
			||||||
| 
						 | 
					@ -837,8 +845,7 @@ ChkBinOper(expp)
 | 
				
			||||||
	*/
 | 
						*/
 | 
				
			||||||
	if (expp->nd_symb == IN) {
 | 
						if (expp->nd_symb == IN) {
 | 
				
			||||||
		if (tpr->tp_fund != T_SET) {
 | 
							if (tpr->tp_fund != T_SET) {
 | 
				
			||||||
			node_error(expp, "\"IN\": right operand must be a set");
 | 
								return ex_error(expp, "right operand must be a set");
 | 
				
			||||||
			return 0;
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (!TstAssCompat(ElementType(tpr), tpl)) {
 | 
							if (!TstAssCompat(ElementType(tpr), tpl)) {
 | 
				
			||||||
			/* Assignment compatible ???
 | 
								/* Assignment compatible ???
 | 
				
			||||||
| 
						 | 
					@ -863,9 +870,7 @@ ChkBinOper(expp)
 | 
				
			||||||
	if (!(tpr->tp_fund & allowed) || !(tpl->tp_fund & allowed)) {
 | 
						if (!(tpr->tp_fund & allowed) || !(tpl->tp_fund & allowed)) {
 | 
				
			||||||
	    	if (!((T_CARDINAL & allowed) &&
 | 
						    	if (!((T_CARDINAL & allowed) &&
 | 
				
			||||||
	             ChkAddress(tpl, tpr))) {
 | 
						             ChkAddress(tpl, tpr))) {
 | 
				
			||||||
			node_error(expp, "\"%s\": illegal operand type(s)", 
 | 
								return ex_error(expp, "illegal operand type(s)");
 | 
				
			||||||
				     symbol2str(expp->nd_symb));
 | 
					 | 
				
			||||||
			return 0;
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (expp->nd_type->tp_fund & T_CARDINAL) {
 | 
							if (expp->nd_type->tp_fund & T_CARDINAL) {
 | 
				
			||||||
			expp->nd_type = address_type;
 | 
								expp->nd_type = address_type;
 | 
				
			||||||
| 
						 | 
					@ -873,17 +878,13 @@ ChkBinOper(expp)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (Boolean(expp->nd_symb) && tpl != bool_type) {
 | 
						if (Boolean(expp->nd_symb) && tpl != bool_type) {
 | 
				
			||||||
		node_error(expp, "\"%s\": illegal operand type(s)",
 | 
							return ex_error(expp, "illegal operand type(s)");
 | 
				
			||||||
			     symbol2str(expp->nd_symb));
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Operands must be compatible (distilled from Def 8.2)
 | 
						/* Operands must be compatible (distilled from Def 8.2)
 | 
				
			||||||
	*/
 | 
						*/
 | 
				
			||||||
	if (!TstCompat(tpr, tpl)) {
 | 
						if (!TstCompat(tpr, tpl)) {
 | 
				
			||||||
		node_error(expp,"\"%s\": incompatible types",
 | 
							return ex_error(expp, "incompatible operand types");
 | 
				
			||||||
			   symbol2str(expp->nd_symb));
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	MkCoercion(&(expp->nd_left), tpl);
 | 
						MkCoercion(&(expp->nd_left), tpl);
 | 
				
			||||||
| 
						 | 
					@ -968,8 +969,7 @@ ChkUnOper(expp)
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		crash("ChkUnOper");
 | 
							crash("ChkUnOper");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	node_error(expp, "\"%s\": illegal operand", symbol2str(expp->nd_symb));
 | 
						return ex_error(expp, "illegal operand type");
 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
STATIC t_node *
 | 
					STATIC t_node *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,6 +25,7 @@
 | 
				
			||||||
#include	"scope.h"
 | 
					#include	"scope.h"
 | 
				
			||||||
#include	"node.h"
 | 
					#include	"node.h"
 | 
				
			||||||
#include	"Lpars.h"
 | 
					#include	"Lpars.h"
 | 
				
			||||||
 | 
					#include	"warning.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
STATIC
 | 
					STATIC
 | 
				
			||||||
DefInFront(df)
 | 
					DefInFront(df)
 | 
				
			||||||
| 
						 | 
					@ -185,22 +186,27 @@ define(id, scope, kind)
 | 
				
			||||||
	return MkDef(id, scope, kind);
 | 
						return MkDef(id, scope, kind);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RemoveImports(pdf)
 | 
					end_definition_list(pdf)
 | 
				
			||||||
	register t_def **pdf;
 | 
						register t_def **pdf;
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	/*	Remove all imports from a definition module. This is
 | 
						/*	Remove all imports from a definition module. This is
 | 
				
			||||||
		neccesary because the implementation module might import
 | 
							neccesary because the implementation module might import
 | 
				
			||||||
		them again.
 | 
							them again.
 | 
				
			||||||
 | 
							Also, mark all other definitions "QUALIFIED EXPORT".
 | 
				
			||||||
	*/
 | 
						*/
 | 
				
			||||||
	register t_def *df = *pdf;
 | 
						register t_def *df = *pdf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while (df) {
 | 
						while (df) {
 | 
				
			||||||
		if (df->df_kind & D_IMPORTED) {
 | 
							if (df->df_kind & D_IMPORTED) {
 | 
				
			||||||
 | 
								if (! (df->df_flags & D_USED)) {
 | 
				
			||||||
 | 
									warning(W_ORDINARY, "identifier \"%s\" imported but not used", df->df_idf->id_text);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			RemoveFromIdList(df);
 | 
								RemoveFromIdList(df);
 | 
				
			||||||
			*pdf = df->df_nextinscope;
 | 
								*pdf = df->df_nextinscope;
 | 
				
			||||||
			free_def(df);
 | 
								free_def(df);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else {
 | 
							else {
 | 
				
			||||||
 | 
								df->df_flags |= D_QEXPORTED;
 | 
				
			||||||
			pdf = &(df->df_nextinscope);
 | 
								pdf = &(df->df_nextinscope);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		df = *pdf;
 | 
							df = *pdf;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -167,12 +167,7 @@ node_warning(exportlist, W_OLDFASHIONED, "export list in definition module ignor
 | 
				
			||||||
		/* empty */
 | 
							/* empty */
 | 
				
			||||||
	]
 | 
						]
 | 
				
			||||||
	definition* END IDENT
 | 
						definition* END IDENT
 | 
				
			||||||
			{ register t_def *df1 = CurrentScope->sc_def;
 | 
								{ end_definition_list(&(CurrentScope->sc_def));
 | 
				
			||||||
			  while (df1) {
 | 
					 | 
				
			||||||
				/* Make all definitions "QUALIFIED EXPORT" */
 | 
					 | 
				
			||||||
				df1->df_flags |= D_QEXPORTED;
 | 
					 | 
				
			||||||
				df1 = df1->df_nextinscope;
 | 
					 | 
				
			||||||
			  }
 | 
					 | 
				
			||||||
			  DefinitionModule--;
 | 
								  DefinitionModule--;
 | 
				
			||||||
			  match_id(df->df_idf, dot.TOK_IDF);
 | 
								  match_id(df->df_idf, dot.TOK_IDF);
 | 
				
			||||||
			  df->df_flags &= ~D_BUSY;
 | 
								  df->df_flags &= ~D_BUSY;
 | 
				
			||||||
| 
						 | 
					@ -219,7 +214,6 @@ ProgramModule
 | 
				
			||||||
	IDENT	{ if (state == IMPLEMENTATION) {
 | 
						IDENT	{ if (state == IMPLEMENTATION) {
 | 
				
			||||||
			df = GetDefinitionModule(dot.TOK_IDF, 0);
 | 
								df = GetDefinitionModule(dot.TOK_IDF, 0);
 | 
				
			||||||
			CurrVis = df->mod_vis;
 | 
								CurrVis = df->mod_vis;
 | 
				
			||||||
			RemoveImports(&(CurrentScope->sc_def));
 | 
					 | 
				
			||||||
		  }
 | 
							  }
 | 
				
			||||||
		  else {
 | 
							  else {
 | 
				
			||||||
			Defined = df = define(dot.TOK_IDF, GlobalScope, D_MODULE);
 | 
								Defined = df = define(dot.TOK_IDF, GlobalScope, D_MODULE);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue