diff mbox

[gccgo] Support anonymous struct fields with -ggo

Message ID mcriq4jognb.fsf@google.com
State New
Headers show

Commit Message

Ian Lance Taylor July 13, 2010, 9:49 a.m. UTC
This patch to goout.c supports anonymous struct fields when using -ggo,
which can arise when using the gcc anonymous union extension.  Committed
to gccgo branch.

Ian
diff mbox

Patch

Index: goout.c
===================================================================
--- goout.c	(revision 161752)
+++ goout.c	(working copy)
@@ -429,13 +429,20 @@  go_output_type (struct goout_container *
     case RECORD_TYPE:
       {
 	tree field;
+	int i;
 
 	fprintf (asm_out_file, "struct { ");
+	i = 0;
 	for (field = TYPE_FIELDS (type);
 	     field != NULL_TREE;
 	     field = TREE_CHAIN (field))
 	  {
-	    if (DECL_NAME (field) != NULL)
+	    if (DECL_NAME (field) == NULL)
+	      {
+		fprintf (asm_out_file, "_f%d ", i);
+		i++;
+	      }
+	    else
               {
 		const char *var_name;
 		void **slot;
@@ -449,8 +456,6 @@  go_output_type (struct goout_container *
 		else
 		  fprintf (asm_out_file, "_%s ", var_name);
 	      }
-	    else
-	      fprintf (asm_out_file, "INVALID-unnamed ");
 	    if (DECL_BIT_FIELD (field))
 	      fprintf (asm_out_file, "INVALID-bit-field");
 	    else