From fc481247a67956ceffcb58e11741adeff68c4113 Mon Sep 17 00:00:00 2001
From: BenceJanosSzabo <bence.janos.szabo@ericsson.com>
Date: Thu, 9 Feb 2017 15:08:25 +0100
Subject: [PATCH] xsd2ttcn: enumeration in union conversion fix (Bug 511912)

Change-Id: I83ec8fd50fe35e14b18dce643b4dc7b8a8e41656
Signed-off-by: BenceJanosSzabo <bence.janos.szabo@ericsson.com>
---
 ...example_org_enumeration_restriction_e.ttcn | 20 +++++++++++++++++++
 .../xsd/enumeration_restriction.xsd           | 19 ++++++++++++++++++
 xsdconvert/GeneralTypes.hh                    |  2 +-
 3 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_enumeration_restriction_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_enumeration_restriction_e.ttcn
index 7b4d41578..7b10e177f 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_enumeration_restriction_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_enumeration_restriction_e.ttcn
@@ -154,6 +154,26 @@ type Only_int Ints (
 );
 
 
+type union UnionWithEnumField
+{
+	enumerated {
+		x,
+		none_,
+		type_
+	} alt_,
+	XSD.PositiveInteger alt_1 (1 .. !1000000)
+}
+with {
+  variant "useUnion";
+  variant "element";
+  variant (alt_) "name as ''";
+  variant (alt_) "text 'none_' as 'none'";
+  variant (alt_) "text 'type_' as 'type'";
+  variant (alt_) "text 'x' as ''";
+  variant (alt_1) "name as ''";
+};
+
+
 }
 with {
   encode "XML";
diff --git a/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction.xsd b/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction.xsd
index ccb09e6ba..64720a207 100644
--- a/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction.xsd
+++ b/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction.xsd
@@ -125,4 +125,23 @@
 	</xs:restriction>
 </xs:simpleType>
 
+<xs:element name="UnionWithEnumField">
+	<xs:simpleType>
+		<xs:union>
+			<xs:simpleType>
+				<xs:restriction base="xs:normalizedString">
+					<xs:enumeration value=""/>
+					<xs:enumeration value="none"/>
+					<xs:enumeration value="type"/>
+				</xs:restriction>
+			</xs:simpleType>
+			<xs:simpleType>
+				<xs:restriction base="xs:positiveInteger">
+					<xs:maxExclusive value="1000000"/>
+				</xs:restriction>
+			</xs:simpleType>
+		</xs:union>
+	</xs:simpleType>
+</xs:element>
+
 </xs:schema>
diff --git a/xsdconvert/GeneralTypes.hh b/xsdconvert/GeneralTypes.hh
index 01adeac7d..d364accf9 100644
--- a/xsdconvert/GeneralTypes.hh
+++ b/xsdconvert/GeneralTypes.hh
@@ -148,7 +148,7 @@ public:
   }
 
   QualifiedName(const Mstring& ns, const Mstring nm)
-  : nsuri(ns), name(nm), dup(false) {
+  : nsuri(ns), name(nm), orig_name(nm), dup(false) {
   }
 
   QualifiedName(const Mstring& ns, const Mstring nm, const Mstring orig)
-- 
GitLab