references


git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@1091 59561ff5-6e30-0410-9f3c-9617f08c8826
diff --git a/libasn1fix/asn1fix.c b/libasn1fix/asn1fix.c
index 21a5621..d8cc863 100644
--- a/libasn1fix/asn1fix.c
+++ b/libasn1fix/asn1fix.c
@@ -477,7 +477,8 @@
 			"ASN.1 expression \"%s\" at line %d of module %s\n"
 			"clashes with expression \"%s\" at line %d of module %s"
 			"%s%s%s.\n"
-			"Please rename either instance to resolve the conflict",
+			"Rename or remove either instance "
+				"to resolve the conflict",
 				arg->expr->Identifier,
 				arg->expr->_lineno,
 				arg->mod->ModuleName,
diff --git a/libasn1fix/asn1fix_cws.c b/libasn1fix/asn1fix_cws.c
index 4925794..0279c96 100644
--- a/libasn1fix/asn1fix_cws.c
+++ b/libasn1fix/asn1fix_cws.c
@@ -188,7 +188,7 @@
 		if(isdigit(*p)) {
 			asn1c_integer_t value;
 			if(asn1p_atoi(p, &value)) {
-				FATAL("Value %s at line %d is too large for this compiler! Please contact the asn1c author.\n", p, arg->expr->_lineno);
+				FATAL("Value %s at line %d is too large for this compiler! Contact the asn1c author.\n", p, arg->expr->_lineno);
 				return -1;
 			}
 			expr = asn1p_expr_new(arg->expr->_lineno);
@@ -197,7 +197,7 @@
 			expr->expr_type = ASN_BASIC_INTEGER;
 			expr->value = asn1p_value_fromint(value);
 		} else {
-			WARNING("asn1c is not yet able to parse arbitrary direct values; please convert %s at line %d to a reference.", p, arg->expr->_lineno);
+			WARNING("asn1c is not yet able to parse arbitrary direct values; try converting %s at line %d to a reference.", p, arg->expr->_lineno);
 			free(p);
 			return 1;
 		}
diff --git a/libasn1fix/asn1fix_dereft.c b/libasn1fix/asn1fix_dereft.c
index 19af0e8..769abed 100644
--- a/libasn1fix/asn1fix_dereft.c
+++ b/libasn1fix/asn1fix_dereft.c
@@ -29,6 +29,7 @@
 	type_expr = asn1f_find_terminal_type(arg, expr);
 	if(type_expr == NULL) {
 		const char *type_name;
+		asn1p_expr_t *idexpr;
 
 		if(errno == EEXIST) {
 			/* Ignore missing type
@@ -39,8 +40,11 @@
 		}
 
 		type_name = asn1f_printable_reference(expr->reference);
+		/* Avoid NULL in case of unnamed T ::= SEQUENCE OF ... */
+		for(idexpr = expr; !idexpr->Identifier && idexpr->parent_expr;
+			idexpr = idexpr->parent_expr);
 		FATAL("Unknown type \"%s\" referenced by \"%s\" at line %d",
-			type_name, expr->Identifier, expr->_lineno);
+			type_name, idexpr->Identifier, expr->_lineno);
 		return -1;
 	}
 
diff --git a/libasn1fix/asn1fix_retrieve.c b/libasn1fix/asn1fix_retrieve.c
index 731c269..2c004be 100644
--- a/libasn1fix/asn1fix_retrieve.c
+++ b/libasn1fix/asn1fix_retrieve.c
@@ -58,7 +58,8 @@
 			arg->expr->_mark |= TM_BROKEN;
 			FATAL("Cannot find external module \"%s\" "
 				"mentioned for "
-				"\"%s\" at line %d",
+				"\"%s\" at line %d. "
+				"Obtain this module and instruct compiler to process it too.",
 				xp->fromModuleName, name, arg->expr->_lineno);
 		}
 		/* ENOENT/ETOOMANYREFS */
@@ -144,10 +145,8 @@
 	return NULL;
 }
 
-
-
-asn1p_expr_t *
-asn1f_lookup_symbol(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref) {
+static asn1p_expr_t *
+asn1f_lookup_symbol_impl(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref, int recursion_depth) {
 	asn1p_expr_t *ref_tc;			/* Referenced tc */
 	asn1p_module_t *imports_from;
 	char *modulename;
@@ -170,6 +169,15 @@
 		mod->ModuleName,
 		ref->_lineno);
 
+	if(recursion_depth++ > 30 /* Arbitrary constant */) {
+		FATAL("Excessive circular referencing detected in module %s for %s at line %d",
+			mod->ModuleName,
+			asn1f_printable_reference(ref),
+			ref->_lineno);
+		errno = ETOOMANYREFS;
+		return NULL;
+	}
+
 	if(ref->comp_count == 1) {
 		modulename = NULL;
 		identifier = ref->components[0].name;
@@ -247,7 +255,7 @@
 			assert(tmpref.comp_count > 0);
 		}
 
-		expr = asn1f_lookup_symbol(arg, imports_from, &tmpref);
+		expr = asn1f_lookup_symbol_impl(arg, imports_from, &tmpref, recursion_depth);
 		if(!expr && !(arg->expr->_mark & TM_BROKEN)
 		&& !(imports_from->_tags & MT_STANDARD_MODULE)) {
 			arg->expr->_mark |= TM_BROKEN;
@@ -327,6 +335,11 @@
 
 
 asn1p_expr_t *
+asn1f_lookup_symbol(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref) {
+	return asn1f_lookup_symbol_impl(arg, mod, ref, 0);
+}
+
+asn1p_expr_t *
 asn1f_find_terminal_type(arg_t *arg, asn1p_expr_t *expr) {
 	return asn1f_find_terminal_thing(arg, expr, FTT_TYPE);
 }