Patchwork [gccgo] Support anonymous struct fields with -ggo

login
register
mail settings
Submitter Ian Taylor
Date July 13, 2010, 9:49 a.m.
Message ID <mcriq4jognb.fsf@google.com>
Download mbox | patch
Permalink /patch/58729/
State New
Headers show

Comments

Ian Taylor - July 13, 2010, 9:49 a.m.
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

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