Go patch committed: Don't generate type descriptors for aliases

Message ID CAOyqgcUy0vJ1SX-iW2i-eg-+zkuj6xYWNCaX9KRk_4CBqzJz=A@mail.gmail.com
State New
Headers show
  • Go patch committed: Don't generate type descriptors for aliases
Related show

Commit Message

Ian Lance Taylor Sept. 11, 2019, 2:26 p.m.
This Go frontend patch by Than McIntosh suppresses type descriptor
generation for aliases.

This changes Named_object::get_backend to ignore aliases when creating
type descriptors for types, to be consistent with
Type::needs_specific_type_functions and the Specific_type_functions
traversal class.  For example, when compiling a package that creates
an alias to an an externally defined type, e.g.,

   import "foo"
   type MyFoo = foo.Foo

it makes sense to skip the alias (not try to generate type specific
functions for it) and let the normal mechanisms take care of the alias
target, depending on whether the target is defined locally or defined

A testcase for this problen can be found in https://golang.org/cl/193261.

This fixes https://golang.org/issue/33866.

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



Index: gcc/go/gofrontend/MERGE
--- gcc/go/gofrontend/MERGE	(revision 275650)
+++ 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/gogo.cc
--- gcc/go/gofrontend/gogo.cc	(revision 275594)
+++ gcc/go/gofrontend/gogo.cc	(working copy)
@@ -8718,7 +8718,13 @@  Named_object::get_backend(Gogo* gogo, st
         Named_type* named_type = this->u_.type_value;
-	if (!Gogo::is_erroneous_name(this->name_) && !named_type->is_alias())
+        // No need to do anything for aliases-- whatever has to be done
+        // can be done for the alias target.
+        if (named_type->is_alias())
+          break;
+	if (!Gogo::is_erroneous_name(this->name_))
         // We need to produce a type descriptor for every named