Go patch committed: Build a single backend type for a type alias

Message ID CAOyqgcVOv-Ha0meXGMJqBJp=2tf0E_YEfTGfWcu89ez+cvFn+Q@mail.gmail.com
State New
Headers show
Series
  • Go patch committed: Build a single backend type for a type alias
Related show

Commit Message

Ian Lance Taylor July 12, 2018, 4:18 a.m.
A type alias and its underlying type are identical.  This patch to the
Go frontend by Cherry Zhang builds a single backend type for them.
Previously we build two backend types, which sometimes confuse the
backend's type system.

Also don't include type aliases into the list of named type
declarations, since they are not named types.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian

Patch

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 262554)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@ 
-ea7ac7784791dca517b6681a02c39c11bf136755
+267686fd1dffbc03e610e9f17dadb4e72c75f18d
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/gogo.cc
===================================================================
--- gcc/go/gofrontend/gogo.cc	(revision 262540)
+++ gcc/go/gofrontend/gogo.cc	(working copy)
@@ -7604,7 +7604,7 @@  Named_object::get_backend(Gogo* gogo, st
     case NAMED_OBJECT_TYPE:
       {
         Named_type* named_type = this->u_.type_value;
-	if (!Gogo::is_erroneous_name(this->name_))
+	if (!Gogo::is_erroneous_name(this->name_) && !named_type->is_alias())
 	  type_decls.push_back(named_type->get_backend(gogo));
 
         // We need to produce a type descriptor for every named
Index: gcc/go/gofrontend/types.cc
===================================================================
--- gcc/go/gofrontend/types.cc	(revision 262540)
+++ gcc/go/gofrontend/types.cc	(working copy)
@@ -991,6 +991,11 @@  Type::get_backend(Gogo* gogo)
   if (this->btype_ != NULL)
     return this->btype_;
 
+  if (this->named_type() != NULL && this->named_type()->is_alias()) {
+    this->btype_ = this->unalias()->get_backend(gogo);
+    return this->btype_;
+  }
+
   if (this->forward_declaration_type() != NULL
       || this->named_type() != NULL)
     return this->get_btype_without_hash(gogo);