Go patch committed: Build type descriptor for alias in other package

Message ID CAOyqgcU=njZZnbxGonaGv54C67FtuoXUbseG7HvxGHPDWZEJnQ@mail.gmail.com
State New
Headers show
  • Go patch committed: Build type descriptor for alias in other package
Related show

Commit Message

Ian Lance Taylor Dec. 11, 2019, 12:16 a.m.
This patch to the Go frontend by Cherry Zhang generates type
descriptors for pointers to aliases defined in other packages.  When a
type descriptor is needed (for e.g. interface conversion), if the type
is a pointer to a named type defined in another package, we don't
generate the definition of the type descriptor because it is generated
in the package where the type is defined.  However, if the named type
is an alias to an unnamed type, its descriptor is not generated in the
other package, and we need to generate it.  Bootstrapped and ran Go
testsuite on x86_64-pc-linux-gnu.  Committed to mainline.



Index: gcc/go/gofrontend/MERGE
--- gcc/go/gofrontend/MERGE	(revision 279136)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@ 
 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 278984)
+++ gcc/go/gofrontend/types.cc	(working copy)
@@ -1453,13 +1453,13 @@  Type::type_descriptor_defined_elsewhere(
       if (this->points_to() != NULL
-	  && this->points_to()->named_type() != NULL
-	  && this->points_to()->named_type()->named_object()->package() != NULL)
+	  && this->points_to()->unalias()->named_type() != NULL
+	  && this->points_to()->unalias()->named_type()->named_object()->package() != NULL)
 	  // This is an unnamed pointer to a named type defined in a
 	  // different package.  The descriptor should be defined in
 	  // that package.
-	  *package = this->points_to()->named_type()->named_object()->package();
+	  *package = this->points_to()->unalias()->named_type()->named_object()->package();
 	  return true;