Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/ORBit2/ChangeLog,v
retrieving revision 1.426
diff -u -p -r1.426 ChangeLog
--- ChangeLog	16 Oct 2002 09:27:54 -0000	1.426
+++ ChangeLog	16 Oct 2002 12:04:02 -0000
@@ -1,3 +1,14 @@
+2002-10-16  James Henstridge  <james@daa.com.au>
+
+	* test/everything/client.c (testIInterface): add a test to check
+	that the subnames array of the FixedLengthUnion typecode is
+	correct.
+
+	* src/idl-compiler/orbit-idl-c-typecode.c
+	(orbit_output_tcstruct_anon_subnames_array): when generating the
+	subnames array for unions, repeat the name once for each label
+	associated with the case statement.
+
 2002-10-16  Michael Meeks  <michael@ximian.com>
 
 	* test/everything/client.c (testIInterface):
Index: src/idl-compiler/orbit-idl-c-typecode.c
===================================================================
RCS file: /cvs/gnome/ORBit2/src/idl-compiler/orbit-idl-c-typecode.c,v
retrieving revision 1.22
diff -u -p -r1.22 orbit-idl-c-typecode.c
--- src/idl-compiler/orbit-idl-c-typecode.c	2 Oct 2002 07:35:29 -0000	1.22
+++ src/idl-compiler/orbit-idl-c-typecode.c	16 Oct 2002 12:04:03 -0000
@@ -151,7 +151,8 @@ orbit_output_tcstruct_anon_subnames_arra
 		fprintf (fh, "static const char * anon_subnames_array%d[] = {", subnames_id);
 
 		for (l = IDL_TYPE_UNION (node).switch_body; l; l = IDL_LIST (l).next) {
-			IDL_tree dcl;
+			IDL_tree dcl, label;
+			const char *subname;
 
 			g_assert (IDL_NODE_TYPE (IDL_LIST (l).data) == IDLN_CASE_STMT);
 
@@ -162,10 +163,17 @@ orbit_output_tcstruct_anon_subnames_arra
 				  IDL_NODE_TYPE (dcl) == IDLN_TYPE_ARRAY);
 
 			if (IDL_NODE_TYPE (dcl) == IDLN_IDENT)
-				fprintf (fh, "\"%s\"", IDL_IDENT (dcl).str);
-
+				subname = IDL_IDENT (dcl).str;
 			else /* IDLN_TYPE_ARRAY */
-				fprintf (fh, "\"%s\"", IDL_IDENT (IDL_TYPE_ARRAY (dcl).ident).str);
+				subname = IDL_IDENT (IDL_TYPE_ARRAY (dcl).ident).str;
+
+			/* output the name once for each label */
+			for (label = IDL_CASE_STMT (IDL_LIST (l).data).labels;
+			     label != NULL; label = IDL_LIST (label).next) {
+				fprintf (fh, "\"%s\"", subname);
+				if (IDL_LIST (label).next)
+					fprintf (fh, ", ");
+			}
 
 			if (IDL_LIST (l).next)
 				fprintf (fh, ", ");
Index: test/everything/client.c
===================================================================
RCS file: /cvs/gnome/ORBit2/test/everything/client.c,v
retrieving revision 1.84
diff -u -p -r1.84 client.c
--- test/everything/client.c	16 Oct 2002 09:27:55 -0000	1.84
+++ test/everything/client.c	16 Oct 2002 12:04:13 -0000
@@ -397,6 +397,16 @@ testIInterface (test_TestFactory   facto
 	g_assert (tc->subtypes[0]->kind);
 
 	CORBA_free (tcs);
+
+	/* test subnames for unions correctly handle multiple case
+	 * labels pointing at the same sub type. */
+	tc = TC_test_FixedLengthUnion;
+	g_assert(tc->sub_parts == 5);
+	g_assert(!strcmp(tc->subnames[0], "x"));
+	g_assert(!strcmp(tc->subnames[1], "y"));
+	g_assert(!strcmp(tc->subnames[2], "z"));
+	g_assert(!strcmp(tc->subnames[3], "z"));
+	g_assert(!strcmp(tc->subnames[4], "v"));
 }
 
 static void
@@ -678,7 +688,6 @@ testFixedLengthUnion (test_TestFactory  
   g_assert (outArg._u.x == constants_LONG_OUT);
   g_assert (retn._d == 'd');
   g_assert (retn._u.z == FALSE);
-
 
   CORBA_Object_release (objref, ev);
   g_assert (ev->_major == CORBA_NO_EXCEPTION);
