removed -N command-line argument


git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@36 59561ff5-6e30-0410-9f3c-9617f08c8826
diff --git a/tests/07-int-OK.asn1.-EF b/tests/07-int-OK.asn1.-EF
new file mode 100644
index 0000000..b3d6a0c
--- /dev/null
+++ b/tests/07-int-OK.asn1.-EF
@@ -0,0 +1,20 @@
+
+ModuleTestInt1 {iso(-1) org(3) dod(6) internet(1) private(4)
+	enterprise(1) spelio(9363) software(1) asn1c(5) test(1)
+	7 }
+DEFINITIONS ::=
+BEGIN
+
+int123456 INTEGER ::= 123456
+
+Interval ::= INTEGER (1..123456)
+
+SameInterval ::= INTEGER
+
+Reason ::= INTEGER {
+    no-reason(0),
+    negative-reason(-10),
+    some-large-value(1324324)
+}
+
+END
diff --git a/tests/16-constraint-OK.asn1.-EF b/tests/16-constraint-OK.asn1.-EF
new file mode 100644
index 0000000..e039e09
--- /dev/null
+++ b/tests/16-constraint-OK.asn1.-EF
@@ -0,0 +1,20 @@
+
+ModuleTestConstraint {iso(-1) org(3) dod(6) internet(1) private(4)
+	enterprise(1) spelio(9363) software(1) asn1c(5) test(1)
+	16 }
+DEFINITIONS ::=
+BEGIN
+
+Type1 ::= IA5String (SIZE (1..10,...))(FROM ("a".."z"|"#"))
+
+Type2 ::= IA5String (SIZE (MIN..4)|FROM ("abc"))
+
+Type3 ::= BMPString (SIZE (1))
+
+Type4 ::= INTEGER (1..MAX)
+
+Type5 ::= BOOLEAN (TRUE|FALSE)
+
+v1 Type1 ::= "#value with ""double quotes"""
+
+END
diff --git a/tests/20-constr-OK.asn1.-EF b/tests/20-constr-OK.asn1.-EF
new file mode 100644
index 0000000..bf4e396
--- /dev/null
+++ b/tests/20-constr-OK.asn1.-EF
@@ -0,0 +1,24 @@
+
+ModuleTestConstr {iso(-1) org(3) dod(6) internet(1) private(4)
+	enterprise(1) spelio(9363) software(1) asn1c(5) test(1)
+	20 }
+DEFINITIONS IMPLICIT TAGS EXTENSIBILITY IMPLIED ::=
+BEGIN
+
+ConstructedType1 ::= SEQUENCE {
+    a	 [1] IMPLICIT INTEGER,
+    b	 [2] IMPLICIT INTEGER,
+    d	 UTF8String,
+    ...!ex1,
+    c	 IA5String
+}
+
+ConstructedType2 ::= SET {
+    a	 [1] IMPLICIT INTEGER,
+    b	 [2] IMPLICIT INTEGER,
+    ...
+}
+
+ex1 INTEGER ::= 1
+
+END
diff --git a/tests/21-tags-OK.asn1.-EF b/tests/21-tags-OK.asn1.-EF
new file mode 100644
index 0000000..bf468d4
--- /dev/null
+++ b/tests/21-tags-OK.asn1.-EF
@@ -0,0 +1,26 @@
+
+ModuleTestTags1 {iso(-1) org(3) dod(6) internet(1) private(4)
+	enterprise(1) spelio(9363) software(1) asn1c(5) test(1)
+	21 1 }
+DEFINITIONS EXPLICIT TAGS ::=
+BEGIN
+
+T1 ::= CHOICE {
+    first	 [0] EXPLICIT INTEGER,
+    second	 [1] EXPLICIT INTEGER
+}
+
+END
+
+ModuleTestTags2 {iso(-1) org(3) dod(6) internet(1) private(4)
+	enterprise(1) spelio(9363) software(1) asn1c(5) test(1)
+	21 2 }
+DEFINITIONS IMPLICIT TAGS ::=
+BEGIN
+
+T2 ::= SEQUENCE {
+    one	 [0] EXPLICIT T1,
+    two	 [1] IMPLICIT IA5String
+}
+
+END
diff --git a/tests/22-tags-OK.asn1.-EF b/tests/22-tags-OK.asn1.-EF
new file mode 100644
index 0000000..3edad65
--- /dev/null
+++ b/tests/22-tags-OK.asn1.-EF
@@ -0,0 +1,17 @@
+
+ModuleTestTags3 {iso(-1) org(3) dod(6) internet(1) private(4)
+	enterprise(1) spelio(9363) software(1) asn1c(5) test(1)
+	22 }
+DEFINITIONS AUTOMATIC TAGS ::=
+BEGIN
+
+T1 ::= SEQUENCE {
+    a	 [0] IMPLICIT INTEGER,
+    b	 [1] EXPLICIT CHOICE {
+        i	 [0] IMPLICIT INTEGER,    
+        n	 [1] IMPLICIT IA5String
+    },
+    c	 [2] IMPLICIT UTF8String
+}
+
+END
diff --git a/tests/23-bits-OK.asn1.-EF b/tests/23-bits-OK.asn1.-EF
new file mode 100644
index 0000000..a3e15a5
--- /dev/null
+++ b/tests/23-bits-OK.asn1.-EF
@@ -0,0 +1,20 @@
+
+ModuleTestBitString {iso(-1) org(3) dod(6) internet(1) private(4)
+	enterprise(1) spelio(9363) software(1) asn1c(5) test(1)
+	23 }
+DEFINITIONS AUTOMATIC TAGS ::=
+BEGIN
+
+v28 INTEGER ::= 28
+
+BS1 ::= BIT STRING {
+    first(0),
+    third(2),
+    twenty-eight(28)
+}
+
+one-zero-one BS1 ::= '101'B
+
+one0one BS1 ::= '101'B
+
+END
diff --git a/tests/24-sequence-OK.asn1.-EF b/tests/24-sequence-OK.asn1.-EF
new file mode 100644
index 0000000..d1380d2
--- /dev/null
+++ b/tests/24-sequence-OK.asn1.-EF
@@ -0,0 +1,15 @@
+
+ModuleTestSequence {iso(-1) org(3) dod(6) internet(1) private(4)
+	enterprise(1) spelio(9363) software(1) asn1c(5) test(1)
+	24 }
+DEFINITIONS IMPLICIT TAGS ::=
+BEGIN
+
+T ::= [5] EXPLICIT SEQUENCE {
+    a	 INTEGER,
+    b	 [0] IMPLICIT INTEGER OPTIONAL,
+    c	 [1] IMPLICIT INTEGER DEFAULT <?>,
+    d	 [5] EXPLICIT INTEGER
+}
+
+END
diff --git a/tests/34-class-OK.asn1.-EF b/tests/34-class-OK.asn1.-EF
new file mode 100644
index 0000000..e9f76b5
--- /dev/null
+++ b/tests/34-class-OK.asn1.-EF
@@ -0,0 +1,36 @@
+
+ModuleTestClassSimple {iso(-1) org(3) dod(6) internet(1) private(4)
+	enterprise(1) spelio(9363) software(1) asn1c(5) test(1)
+	34 }
+DEFINITIONS IMPLICIT TAGS ::=
+BEGIN
+
+EXTENSION ::= CLASS {
+    &id	 OBJECT IDENTIFIER UNIQUE,
+    &ExtnType	
+} WITH SYNTAX {
+		SYNTAX		&ExtnType
+		IDENTIFIED BY	&id
+	}
+
+
+Ext1 ::= SEQUENCE {
+    extnId	 EXTENSION.&id
+}
+
+EXTENSION-ATTRIBUTE ::= CLASS {
+    &id	 INTEGER (0..256) UNIQUE,
+    &Type	
+} WITH SYNTAX {&Type IDENTIFIED BY &id}
+
+
+terminal-type EXTENSION-ATTRIBUTE ::= { TerminalType IDENTIFIED BY 23}
+
+ExtensionAttribute ::= SEQUENCE {
+    extension-attribute-type	 [0] IMPLICIT EXTENSION-ATTRIBUTE.&id ({ExtensionAttributeTable}),
+    extension-attribute-value	 [1] IMPLICIT EXTENSION-ATTRIBUTE.&Type ({ExtensionAttributeTable}{@extension-attribute-type})
+}
+
+ub-extension-attributes INTEGER ::= 256
+
+END
diff --git a/tests/39-sequence-of-OK.asn1.-P b/tests/39-sequence-of-OK.asn1.-P
index d073e49..7536fca 100644
--- a/tests/39-sequence-of-OK.asn1.-P
+++ b/tests/39-sequence-of-OK.asn1.-P
@@ -54,7 +54,7 @@
 		asn1_DEF_collection_tags,
 		sizeof(asn1_DEF_collection_tags)
 			/sizeof(asn1_DEF_collection_tags[0]),
-		0,	/* Tags to skip */
+		1,	/* Tags to skip */
 		1,	/* Whether CONSTRUCTED */
 		&asn1_DEF_collection_specs	/* Additional specs */
 	};
@@ -103,7 +103,7 @@
 	asn1_DEF_T_tags,
 	sizeof(asn1_DEF_T_tags)
 		/sizeof(asn1_DEF_T_tags[0]),
-	0,	/* Tags to skip */
+	1,	/* Tags to skip */
 	1,	/* Whether CONSTRUCTED */
 	&asn1_DEF_T_specs	/* Additional specs */
 };
@@ -176,7 +176,7 @@
 	asn1_DEF_T2_tags,
 	sizeof(asn1_DEF_T2_tags)
 		/sizeof(asn1_DEF_T2_tags[0]),
-	0,	/* Tags to skip */
+	1,	/* Tags to skip */
 	1,	/* Whether CONSTRUCTED */
 	&asn1_DEF_T2_specs	/* Additional specs */
 };
diff --git a/tests/42-real-life-OK.asn1.-EF b/tests/42-real-life-OK.asn1.-EF
new file mode 100644
index 0000000..7b3a89d
--- /dev/null
+++ b/tests/42-real-life-OK.asn1.-EF
@@ -0,0 +1,45 @@
+
+ModuleLAPStorage {iso(-1) org(3) dod(6) internet(1) private(4)
+	enterprise(1) spelio(9363) software(1) asn1c(5) test(1)
+	42 }
+DEFINITIONS EXTENSIBILITY IMPLIED ::=
+BEGIN
+
+LogLine ::= SEQUENCE {
+    line-digest	 IA5String,
+    varsets	 SEQUENCE OF VariablePartSet,
+    ...
+}
+
+VariablePartSet ::= SEQUENCE {
+    vparts	 SEQUENCE OF VariablePart,
+    resolution	 ActionItem,
+    ...
+}
+
+VariablePart ::= CHOICE {
+    vset	 SET OF VisibleString,
+    vrange	 SEQUENCE {
+        from	 VisibleString,    
+        to	 VisibleString,    
+        ...
+    },
+    ...
+}
+
+ActionItem ::= SEQUENCE {
+    accept-as	 ENUMERATED {
+        unknown(0),    
+        safe(1),    
+        unsafe(2),    
+        ...
+    },
+    notify	 SEQUENCE {
+        critical	 BOOLEAN,    
+        email	 SET OF VisibleString,    
+        ...
+    } OPTIONAL,
+    ...
+}
+
+END
diff --git a/tests/42-real-life-OK.asn1.-PR b/tests/42-real-life-OK.asn1.-PR
index 0cf1be9..990e2c2 100644
--- a/tests/42-real-life-OK.asn1.-PR
+++ b/tests/42-real-life-OK.asn1.-PR
@@ -58,7 +58,7 @@
 		asn1_DEF_varsets_tags,
 		sizeof(asn1_DEF_varsets_tags)
 			/sizeof(asn1_DEF_varsets_tags[0]),
-		0,	/* Tags to skip */
+		1,	/* Tags to skip */
 		1,	/* Whether CONSTRUCTED */
 		&asn1_DEF_varsets_specs	/* Additional specs */
 	};
@@ -107,7 +107,7 @@
 	asn1_DEF_LogLine_tags,
 	sizeof(asn1_DEF_LogLine_tags)
 		/sizeof(asn1_DEF_LogLine_tags[0]),
-	0,	/* Tags to skip */
+	1,	/* Tags to skip */
 	1,	/* Whether CONSTRUCTED */
 	&asn1_DEF_LogLine_specs	/* Additional specs */
 };
@@ -172,7 +172,7 @@
 		asn1_DEF_vparts_tags,
 		sizeof(asn1_DEF_vparts_tags)
 			/sizeof(asn1_DEF_vparts_tags[0]),
-		0,	/* Tags to skip */
+		1,	/* Tags to skip */
 		1,	/* Whether CONSTRUCTED */
 		&asn1_DEF_vparts_specs	/* Additional specs */
 	};
@@ -221,7 +221,7 @@
 	asn1_DEF_VariablePartSet_tags,
 	sizeof(asn1_DEF_VariablePartSet_tags)
 		/sizeof(asn1_DEF_VariablePartSet_tags[0]),
-	0,	/* Tags to skip */
+	1,	/* Tags to skip */
 	1,	/* Whether CONSTRUCTED */
 	&asn1_DEF_VariablePartSet_specs	/* Additional specs */
 };
@@ -306,7 +306,7 @@
 			asn1_DEF_vset_tags,
 			sizeof(asn1_DEF_vset_tags)
 				/sizeof(asn1_DEF_vset_tags[0]),
-			0,	/* Tags to skip */
+			1,	/* Tags to skip */
 			1,	/* Whether CONSTRUCTED */
 			&asn1_DEF_vset_specs	/* Additional specs */
 		};
@@ -355,7 +355,7 @@
 			asn1_DEF_vrange_tags,
 			sizeof(asn1_DEF_vrange_tags)
 				/sizeof(asn1_DEF_vrange_tags[0]),
-			0,	/* Tags to skip */
+			1,	/* Tags to skip */
 			1,	/* Whether CONSTRUCTED */
 			&asn1_DEF_vrange_specs	/* Additional specs */
 		};
@@ -494,7 +494,7 @@
 			asn1_DEF_email_tags,
 			sizeof(asn1_DEF_email_tags)
 				/sizeof(asn1_DEF_email_tags[0]),
-			0,	/* Tags to skip */
+			1,	/* Tags to skip */
 			1,	/* Whether CONSTRUCTED */
 			&asn1_DEF_email_specs	/* Additional specs */
 		};
@@ -543,7 +543,7 @@
 		asn1_DEF_notify_tags,
 		sizeof(asn1_DEF_notify_tags)
 			/sizeof(asn1_DEF_notify_tags[0]),
-		0,	/* Tags to skip */
+		1,	/* Tags to skip */
 		1,	/* Whether CONSTRUCTED */
 		&asn1_DEF_notify_specs	/* Additional specs */
 	};
@@ -592,7 +592,7 @@
 	asn1_DEF_ActionItem_tags,
 	sizeof(asn1_DEF_ActionItem_tags)
 		/sizeof(asn1_DEF_ActionItem_tags[0]),
-	0,	/* Tags to skip */
+	1,	/* Tags to skip */
 	1,	/* Whether CONSTRUCTED */
 	&asn1_DEF_ActionItem_specs	/* Additional specs */
 };
diff --git a/tests/44-choice-in-sequence-OK.asn1.-P b/tests/44-choice-in-sequence-OK.asn1.-P
new file mode 100644
index 0000000..6cab701
--- /dev/null
+++ b/tests/44-choice-in-sequence-OK.asn1.-P
@@ -0,0 +1,293 @@
+
+/*** <<< DEPS [T] >>> ***/
+
+/* Dependencies for T */
+#include <NULL.h>
+
+/* Dependencies for b */
+#include <NULL.h>
+#include <NULL.h>
+
+/* Dependencies for e */
+#include <NULL.h>
+#include <NULL.h>
+
+/* Dependencies for h */
+#include <NULL.h>
+#include <NULL.h>
+
+#include <constr_SEQUENCE.h>
+
+extern asn1_TYPE_descriptor_t asn1_DEF_T;
+
+/*** <<< TYPE-DECLS [T] >>> ***/
+
+
+typedef struct T {
+	NULL_t	 a;
+	struct b {
+		enum {
+			b_PR_NOTHING,	/* No components present */
+			b_PR_c,
+			b_PR_d,
+			b_PR_e,
+			b_PR_h,
+		} present;
+		union {
+			NULL_t	 c;
+			NULL_t	 d;
+			struct e {
+				enum {
+					e_PR_NOTHING,	/* No components present */
+					e_PR_f,
+					e_PR_g,
+				} present;
+				union {
+					NULL_t	 f;
+					NULL_t	 g;
+				} choice;
+				
+				/* Context for parsing across buffer boundaries */
+				ber_dec_ctx_t _ber_dec_ctx;
+			} e;
+			struct h {
+				enum {
+					h_PR_NOTHING,	/* No components present */
+					h_PR_i,
+					h_PR_j,
+				} present;
+				union {
+					NULL_t	 i;
+					NULL_t	 j;
+				} choice;
+				
+				/* Context for parsing across buffer boundaries */
+				ber_dec_ctx_t _ber_dec_ctx;
+			} h;
+		} choice;
+		
+		/* Context for parsing across buffer boundaries */
+		ber_dec_ctx_t _ber_dec_ctx;
+	} b;
+	
+	/* Context for parsing across buffer boundaries */
+	ber_dec_ctx_t _ber_dec_ctx;
+} T_t;
+
+/*** <<< STAT-DEFS [T] >>> ***/
+
+			#include <constr_CHOICE.h>
+			
+			static asn1_CHOICE_element_t asn1_DEF_e_elements[] = {
+				{ offsetof(struct e, choice.f), 0,
+					(ASN_TAG_CLASS_PRIVATE | (7 << 2)),
+					-1,	/* IMPLICIT tag at current level */
+					(void *)&asn1_DEF_NULL,
+					"f"
+					},
+				{ offsetof(struct e, choice.g), 0,
+					(ASN_TAG_CLASS_PRIVATE | (8 << 2)),
+					-1,	/* IMPLICIT tag at current level */
+					(void *)&asn1_DEF_NULL,
+					"g"
+					},
+			};
+			static ber_tlv_tag_t asn1_DEF_e_tags[] = {
+			};
+			static asn1_TYPE_tag2member_t asn1_DEF_e_tag2el[] = {
+			    { (ASN_TAG_CLASS_PRIVATE | (7 << 2)), 0, 0, 0 }, /* f at 20 */
+			    { (ASN_TAG_CLASS_PRIVATE | (8 << 2)), 1, 0, 0 }, /* g at 21 */
+			};
+			static asn1_CHOICE_specifics_t asn1_DEF_e_specs = {
+				sizeof(struct e),
+				offsetof(struct e, _ber_dec_ctx),
+				offsetof(struct e, present),
+				sizeof(((struct e *)0)->present),
+				asn1_DEF_e_elements,
+				2,	/* Elements count */
+				asn1_DEF_e_tag2el,
+				2,	/* Count of tags in the map */
+				0	/* Whether extensible */
+			};
+			asn1_TYPE_descriptor_t asn1_DEF_e = {
+				"e",
+				CHOICE_constraint,
+				CHOICE_decode_ber,
+				CHOICE_encode_der,
+				CHOICE_print,
+				CHOICE_free,
+				CHOICE_outmost_tag,
+				asn1_DEF_e_tags,
+				sizeof(asn1_DEF_e_tags)
+					/sizeof(asn1_DEF_e_tags[0]),
+				0,	/* Tags to skip */
+				1,	/* Whether CONSTRUCTED */
+				&asn1_DEF_e_specs	/* Additional specs */
+			};
+			
+			#include <constr_CHOICE.h>
+			
+			static asn1_CHOICE_element_t asn1_DEF_h_elements[] = {
+				{ offsetof(struct h, choice.i), 0,
+					(ASN_TAG_CLASS_PRIVATE | (1 << 2)),
+					-1,	/* IMPLICIT tag at current level */
+					(void *)&asn1_DEF_NULL,
+					"i"
+					},
+				{ offsetof(struct h, choice.j), 0,
+					(ASN_TAG_CLASS_PRIVATE | (2 << 2)),
+					-1,	/* IMPLICIT tag at current level */
+					(void *)&asn1_DEF_NULL,
+					"j"
+					},
+			};
+			static ber_tlv_tag_t asn1_DEF_h_tags[] = {
+			};
+			static asn1_TYPE_tag2member_t asn1_DEF_h_tag2el[] = {
+			    { (ASN_TAG_CLASS_PRIVATE | (1 << 2)), 0, 0, 0 }, /* i at 24 */
+			    { (ASN_TAG_CLASS_PRIVATE | (2 << 2)), 1, 0, 0 }, /* j at 25 */
+			};
+			static asn1_CHOICE_specifics_t asn1_DEF_h_specs = {
+				sizeof(struct h),
+				offsetof(struct h, _ber_dec_ctx),
+				offsetof(struct h, present),
+				sizeof(((struct h *)0)->present),
+				asn1_DEF_h_elements,
+				2,	/* Elements count */
+				asn1_DEF_h_tag2el,
+				2,	/* Count of tags in the map */
+				0	/* Whether extensible */
+			};
+			asn1_TYPE_descriptor_t asn1_DEF_h = {
+				"h",
+				CHOICE_constraint,
+				CHOICE_decode_ber,
+				CHOICE_encode_der,
+				CHOICE_print,
+				CHOICE_free,
+				CHOICE_outmost_tag,
+				asn1_DEF_h_tags,
+				sizeof(asn1_DEF_h_tags)
+					/sizeof(asn1_DEF_h_tags[0]),
+				0,	/* Tags to skip */
+				1,	/* Whether CONSTRUCTED */
+				&asn1_DEF_h_specs	/* Additional specs */
+			};
+			
+	#include <constr_CHOICE.h>
+	
+	static asn1_CHOICE_element_t asn1_DEF_b_elements[] = {
+		{ offsetof(struct b, choice.c), 0,
+			(ASN_TAG_CLASS_PRIVATE | (5 << 2)),
+			-1,	/* IMPLICIT tag at current level */
+			(void *)&asn1_DEF_NULL,
+			"c"
+			},
+		{ offsetof(struct b, choice.d), 0,
+			(ASN_TAG_CLASS_PRIVATE | (6 << 2)),
+			-1,	/* IMPLICIT tag at current level */
+			(void *)&asn1_DEF_NULL,
+			"d"
+			},
+		{ offsetof(struct b, choice.e), 0,
+			-1 /* Ambiguous tag (CHOICE?) */,
+			0,
+			(void *)&asn1_DEF_e,
+			"e"
+			},
+		{ offsetof(struct b, choice.h), 0,
+			(ASN_TAG_CLASS_PRIVATE | (9 << 2)),
+			+1,	/* EXPLICIT tag at current level */
+			(void *)&asn1_DEF_h,
+			"h"
+			},
+	};
+	static ber_tlv_tag_t asn1_DEF_b_tags[] = {
+	};
+	static asn1_TYPE_tag2member_t asn1_DEF_b_tag2el[] = {
+	    { (ASN_TAG_CLASS_PRIVATE | (5 << 2)), 0, 0, 0 }, /* c at 17 */
+	    { (ASN_TAG_CLASS_PRIVATE | (6 << 2)), 1, 0, 0 }, /* d at 18 */
+	    { (ASN_TAG_CLASS_PRIVATE | (7 << 2)), 2, 0, 0 }, /* f at 20 */
+	    { (ASN_TAG_CLASS_PRIVATE | (8 << 2)), 2, 0, 0 }, /* g at 21 */
+	    { (ASN_TAG_CLASS_PRIVATE | (9 << 2)), 3, 0, 0 }, /* h at 24 */
+	};
+	static asn1_CHOICE_specifics_t asn1_DEF_b_specs = {
+		sizeof(struct b),
+		offsetof(struct b, _ber_dec_ctx),
+		offsetof(struct b, present),
+		sizeof(((struct b *)0)->present),
+		asn1_DEF_b_elements,
+		4,	/* Elements count */
+		asn1_DEF_b_tag2el,
+		5,	/* Count of tags in the map */
+		0	/* Whether extensible */
+	};
+	asn1_TYPE_descriptor_t asn1_DEF_b = {
+		"b",
+		CHOICE_constraint,
+		CHOICE_decode_ber,
+		CHOICE_encode_der,
+		CHOICE_print,
+		CHOICE_free,
+		CHOICE_outmost_tag,
+		asn1_DEF_b_tags,
+		sizeof(asn1_DEF_b_tags)
+			/sizeof(asn1_DEF_b_tags[0]),
+		0,	/* Tags to skip */
+		1,	/* Whether CONSTRUCTED */
+		&asn1_DEF_b_specs	/* Additional specs */
+	};
+	
+#include <constr_SEQUENCE.h>
+
+static asn1_SEQUENCE_element_t asn1_DEF_T_elements[] = {
+	{ offsetof(struct T, a), 0,
+		(ASN_TAG_CLASS_PRIVATE | (2 << 2)),
+		-1,	/* IMPLICIT tag at current level */
+		(void *)&asn1_DEF_NULL,
+		"a"
+		},
+	{ offsetof(struct T, b), 0,
+		-1 /* Ambiguous tag (CHOICE?) */,
+		0,
+		(void *)&asn1_DEF_b,
+		"b"
+		},
+};
+static ber_tlv_tag_t asn1_DEF_T_tags[] = {
+	(ASN_TAG_CLASS_PRIVATE | (1 << 2))
+};
+static asn1_TYPE_tag2member_t asn1_DEF_T_tag2el[] = {
+    { (ASN_TAG_CLASS_PRIVATE | (2 << 2)), 0, 0, 0 }, /* a at 15 */
+    { (ASN_TAG_CLASS_PRIVATE | (5 << 2)), 1, 0, 0 }, /* c at 17 */
+    { (ASN_TAG_CLASS_PRIVATE | (6 << 2)), 1, 0, 0 }, /* d at 18 */
+    { (ASN_TAG_CLASS_PRIVATE | (7 << 2)), 1, 0, 0 }, /* f at 20 */
+    { (ASN_TAG_CLASS_PRIVATE | (8 << 2)), 1, 0, 0 }, /* g at 21 */
+    { (ASN_TAG_CLASS_PRIVATE | (9 << 2)), 1, 0, 0 }, /* h at 24 */
+};
+static asn1_SEQUENCE_specifics_t asn1_DEF_T_specs = {
+	sizeof(struct T),
+	offsetof(struct T, _ber_dec_ctx),
+	asn1_DEF_T_elements,
+	2,	/* Elements count */
+	asn1_DEF_T_tag2el,
+	6,	/* Count of tags in the map */
+	-1,	/* Start extensions */
+	-1	/* Stop extensions */
+};
+asn1_TYPE_descriptor_t asn1_DEF_T = {
+	"T",
+	SEQUENCE_constraint,
+	SEQUENCE_decode_ber,
+	SEQUENCE_encode_der,
+	SEQUENCE_print,
+	SEQUENCE_free,
+	0,	/* Use generic outmost tag fetcher */
+	asn1_DEF_T_tags,
+	sizeof(asn1_DEF_T_tags)
+		/sizeof(asn1_DEF_T_tags[0]),
+	1,	/* Tags to skip */
+	1,	/* Whether CONSTRUCTED */
+	&asn1_DEF_T_specs	/* Additional specs */
+};
+
diff --git a/tests/45-undefined-type-SE.asn1 b/tests/45-undefined-type-SE.asn1
new file mode 100644
index 0000000..0450e87
--- /dev/null
+++ b/tests/45-undefined-type-SE.asn1
@@ -0,0 +1,16 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .45
+
+ModuleKnownExternType
+	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 45 }
+	DEFINITIONS ::=
+BEGIN
+
+	Type ::= KnownExt -- KnownExt is known to be external.
+
+END
diff --git a/tests/45-undefined-type-SE.asn1.-EFfknown-extern-type=KnownExt b/tests/45-undefined-type-SE.asn1.-EFfknown-extern-type=KnownExt
new file mode 100644
index 0000000..423b32b
--- /dev/null
+++ b/tests/45-undefined-type-SE.asn1.-EFfknown-extern-type=KnownExt
@@ -0,0 +1,10 @@
+
+ModuleKnownExternType {iso(-1) org(3) dod(6) internet(1) private(4)
+	enterprise(1) spelio(9363) software(1) asn1c(5) test(1)
+	45 }
+DEFINITIONS ::=
+BEGIN
+
+Type ::= KnownExt
+
+END
diff --git a/tests/46-redefine-OK.asn1 b/tests/46-redefine-OK.asn1
new file mode 100644
index 0000000..7890363
--- /dev/null
+++ b/tests/46-redefine-OK.asn1
@@ -0,0 +1,22 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .46
+
+ModuleChoiceInSequence
+	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 46 }
+	DEFINITIONS IMPLICIT TAGS ::=
+BEGIN
+
+	PrimitiveType ::= OCTET STRING
+
+	ConstructedType ::= SEQUENCE {
+		field	[5] PrimitiveType
+	}
+
+	T ::= [3] ConstructedType
+
+END
diff --git a/tests/46-redefine-OK.asn1.-PR b/tests/46-redefine-OK.asn1.-PR
new file mode 100644
index 0000000..2fc1e4d
--- /dev/null
+++ b/tests/46-redefine-OK.asn1.-PR
@@ -0,0 +1,254 @@
+
+/*** <<< DEPS [PrimitiveType] >>> ***/
+
+#include <OCTET_STRING.h>
+
+/*** <<< TYPE-DECLS [PrimitiveType] >>> ***/
+
+
+typedef OCTET_STRING_t	 PrimitiveType_t;
+
+
+/*** <<< FUNC-DECLS [PrimitiveType] >>> ***/
+
+extern asn1_TYPE_descriptor_t asn1_DEF_PrimitiveType;
+asn_constr_check_f PrimitiveType_constraint;
+ber_type_decoder_f PrimitiveType_decode_ber;
+der_type_encoder_f PrimitiveType_encode_der;
+asn_struct_print_f PrimitiveType_print;
+asn_struct_free_f PrimitiveType_free;
+
+/*** <<< STAT-DEFS [PrimitiveType] >>> ***/
+
+static ber_tlv_tag_t asn1_DEF_PrimitiveType_tags[] = {
+	(ASN_TAG_CLASS_UNIVERSAL | (4 << 2))
+};
+asn1_TYPE_descriptor_t asn1_DEF_PrimitiveType = {
+	"PrimitiveType",
+	PrimitiveType_constraint,
+	PrimitiveType_decode_ber,
+	PrimitiveType_encode_der,
+	PrimitiveType_print,
+	PrimitiveType_free,
+	0,	/* Use generic outmost tag fetcher */
+	asn1_DEF_PrimitiveType_tags,
+	sizeof(asn1_DEF_PrimitiveType_tags)
+		/sizeof(asn1_DEF_PrimitiveType_tags[0]),
+	1,	/* Tags to skip */
+	-0,	/* Unknown yet */
+	0	/* No specifics */
+};
+
+int
+PrimitiveType_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
+			asn_app_consume_bytes_f *app_errlog, void *app_key) {
+	
+	/* Make the underlying type checker permanent */
+	td->check_constraints = asn1_DEF_OCTET_STRING.check_constraints;
+	return td->check_constraints
+		(td, sptr, app_errlog, app_key);
+}
+
+/*
+ * This type is implemented using OCTET_STRING,
+ * so adjust the DEF appropriately.
+ */
+static void
+inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
+	td->ber_decoder = asn1_DEF_OCTET_STRING.ber_decoder;
+	td->der_encoder = asn1_DEF_OCTET_STRING.der_encoder;
+	td->free_struct = asn1_DEF_OCTET_STRING.free_struct;
+	td->print_struct = asn1_DEF_OCTET_STRING.print_struct;
+	td->last_tag_form = asn1_DEF_OCTET_STRING.last_tag_form;
+	td->specifics = asn1_DEF_OCTET_STRING.specifics;
+}
+
+ber_dec_rval_t
+PrimitiveType_decode_ber(asn1_TYPE_descriptor_t *td,
+		void **structure, void *bufptr, size_t size, int tag_mode) {
+	inherit_TYPE_descriptor(td);
+	return td->ber_decoder(td, structure,
+		bufptr, size, tag_mode);
+}
+
+der_enc_rval_t
+PrimitiveType_encode_der(asn1_TYPE_descriptor_t *td,
+		void *structure, int tag_mode, ber_tlv_tag_t tag,
+		asn_app_consume_bytes_f *cb, void *app_key) {
+	inherit_TYPE_descriptor(td);
+	return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
+}
+
+int
+PrimitiveType_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
+		int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
+	inherit_TYPE_descriptor(td);
+	return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
+}
+
+void
+PrimitiveType_free(asn1_TYPE_descriptor_t *td,
+		void *struct_ptr, int contents_only) {
+	inherit_TYPE_descriptor(td);
+	td->free_struct(td, struct_ptr, contents_only);
+}
+
+
+/*** <<< DEPS [ConstructedType] >>> ***/
+
+/* Dependencies for ConstructedType */
+#include <PrimitiveType.h>
+
+#include <constr_SEQUENCE.h>
+
+extern asn1_TYPE_descriptor_t asn1_DEF_ConstructedType;
+
+/*** <<< TYPE-DECLS [ConstructedType] >>> ***/
+
+
+typedef struct ConstructedType {
+	PrimitiveType_t	 field;
+	
+	/* Context for parsing across buffer boundaries */
+	ber_dec_ctx_t _ber_dec_ctx;
+} ConstructedType_t;
+
+/*** <<< STAT-DEFS [ConstructedType] >>> ***/
+
+#include <constr_SEQUENCE.h>
+
+static asn1_SEQUENCE_element_t asn1_DEF_ConstructedType_elements[] = {
+	{ offsetof(struct ConstructedType, field), 0,
+		(ASN_TAG_CLASS_CONTEXT | (5 << 2)),
+		-1,	/* IMPLICIT tag at current level */
+		(void *)&asn1_DEF_PrimitiveType,
+		"field"
+		},
+};
+static ber_tlv_tag_t asn1_DEF_ConstructedType_tags[] = {
+	(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
+};
+static asn1_TYPE_tag2member_t asn1_DEF_ConstructedType_tag2el[] = {
+    { (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 0, 0, 0 }, /* field at 18 */
+};
+static asn1_SEQUENCE_specifics_t asn1_DEF_ConstructedType_specs = {
+	sizeof(struct ConstructedType),
+	offsetof(struct ConstructedType, _ber_dec_ctx),
+	asn1_DEF_ConstructedType_elements,
+	1,	/* Elements count */
+	asn1_DEF_ConstructedType_tag2el,
+	1,	/* Count of tags in the map */
+	-1,	/* Start extensions */
+	-1	/* Stop extensions */
+};
+asn1_TYPE_descriptor_t asn1_DEF_ConstructedType = {
+	"ConstructedType",
+	SEQUENCE_constraint,
+	SEQUENCE_decode_ber,
+	SEQUENCE_encode_der,
+	SEQUENCE_print,
+	SEQUENCE_free,
+	0,	/* Use generic outmost tag fetcher */
+	asn1_DEF_ConstructedType_tags,
+	sizeof(asn1_DEF_ConstructedType_tags)
+		/sizeof(asn1_DEF_ConstructedType_tags[0]),
+	1,	/* Tags to skip */
+	1,	/* Whether CONSTRUCTED */
+	&asn1_DEF_ConstructedType_specs	/* Additional specs */
+};
+
+
+/*** <<< DEPS [T] >>> ***/
+
+#include <ConstructedType.h>
+
+/*** <<< TYPE-DECLS [T] >>> ***/
+
+
+typedef ConstructedType_t	 T_t;
+
+
+/*** <<< FUNC-DECLS [T] >>> ***/
+
+extern asn1_TYPE_descriptor_t asn1_DEF_T;
+asn_constr_check_f T_constraint;
+ber_type_decoder_f T_decode_ber;
+der_type_encoder_f T_encode_der;
+asn_struct_print_f T_print;
+asn_struct_free_f T_free;
+
+/*** <<< STAT-DEFS [T] >>> ***/
+
+static ber_tlv_tag_t asn1_DEF_T_tags[] = {
+	(ASN_TAG_CLASS_CONTEXT | (3 << 2))
+};
+asn1_TYPE_descriptor_t asn1_DEF_T = {
+	"T",
+	T_constraint,
+	T_decode_ber,
+	T_encode_der,
+	T_print,
+	T_free,
+	0,	/* Use generic outmost tag fetcher */
+	asn1_DEF_T_tags,
+	sizeof(asn1_DEF_T_tags)
+		/sizeof(asn1_DEF_T_tags[0]),
+	1,	/* Tags to skip */
+	-0,	/* Unknown yet */
+	0	/* No specifics */
+};
+
+int
+T_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
+			asn_app_consume_bytes_f *app_errlog, void *app_key) {
+	
+	/* Make the underlying type checker permanent */
+	td->check_constraints = asn1_DEF_ConstructedType.check_constraints;
+	return td->check_constraints
+		(td, sptr, app_errlog, app_key);
+}
+
+/*
+ * This type is implemented using ConstructedType,
+ * so adjust the DEF appropriately.
+ */
+static void
+inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
+	td->ber_decoder = asn1_DEF_ConstructedType.ber_decoder;
+	td->der_encoder = asn1_DEF_ConstructedType.der_encoder;
+	td->free_struct = asn1_DEF_ConstructedType.free_struct;
+	td->print_struct = asn1_DEF_ConstructedType.print_struct;
+	td->last_tag_form = asn1_DEF_ConstructedType.last_tag_form;
+	td->specifics = asn1_DEF_ConstructedType.specifics;
+}
+
+ber_dec_rval_t
+T_decode_ber(asn1_TYPE_descriptor_t *td,
+		void **structure, void *bufptr, size_t size, int tag_mode) {
+	inherit_TYPE_descriptor(td);
+	return td->ber_decoder(td, structure,
+		bufptr, size, tag_mode);
+}
+
+der_enc_rval_t
+T_encode_der(asn1_TYPE_descriptor_t *td,
+		void *structure, int tag_mode, ber_tlv_tag_t tag,
+		asn_app_consume_bytes_f *cb, void *app_key) {
+	inherit_TYPE_descriptor(td);
+	return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
+}
+
+int
+T_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
+		int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
+	inherit_TYPE_descriptor(td);
+	return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
+}
+
+void
+T_free(asn1_TYPE_descriptor_t *td,
+		void *struct_ptr, int contents_only) {
+	inherit_TYPE_descriptor(td);
+	td->free_struct(td, struct_ptr, contents_only);
+}
+