diff mbox series

Go patch committed: Copy has_padding field if struct backend type exists

Message ID CAOyqgcVtrj_KcszuU_yZNZnDAmwgCc=BTguyErY12i4HHaFw0Q@mail.gmail.com
State New
Headers show
Series Go patch committed: Copy has_padding field if struct backend type exists | expand

Commit Message

Ian Lance Taylor Feb. 14, 2019, 9:07 p.m. UTC
This patch fixes the Go frontend to copy the has_padding field if a
struct backend type already exists.  The has_padding field is set when
creating the struct backend type, and checked when creating a
composite literal of that struct type.  When two structs shared the
same backend type, because they were identical, the has_padding field
was not set correctly for the second struct.  This fixes that problem.
The test case is https://golang.org/cl/162617.  This fixes GCC PR
89321.  Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.
Committed to mainline.

Ian
diff mbox series

Patch

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 268891)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@ 
-a487c86418488f6a17dab4f9945e2a5d495e3ddb
+c2fc3b83d832725accd4fa5874a5b5ca02dd90dc
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/types.cc
===================================================================
--- gcc/go/gofrontend/types.cc	(revision 268891)
+++ gcc/go/gofrontend/types.cc	(working copy)
@@ -1003,6 +1003,16 @@  Type::get_backend(Gogo* gogo)
 	  ins.first->second.is_placeholder = false;
 	}
 
+      // We set the has_padding field of a Struct_type when we convert
+      // to the backend type, so if we have multiple Struct_type's
+      // mapping to the same backend type we need to copy the
+      // has_padding field.  FIXME: This is awkward.  We shouldn't
+      // really change the type when setting the backend type, but
+      // there isn't any other good time to add the padding field.
+      if (ins.first->first->struct_type() != NULL
+	  && ins.first->first->struct_type()->has_padding())
+	this->struct_type()->set_has_padding();
+
       return ins.first->second.btype;
     }