compiler: build a single backend type for type alias
authorIan Lance Taylor <ian@gcc.gnu.org>
Thu, 12 Jul 2018 04:18:48 +0000 (04:18 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Thu, 12 Jul 2018 04:18:48 +0000 (04:18 +0000)
    A type alias and its underlying type are identical. Build 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.

    Reviewed-on: https://go-review.googlesource.com/123362

From-SVN: r262572

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/gogo.cc
gcc/go/gofrontend/types.cc

index 7d5c0aa7e0d0b8e1a4d9a3f3286823116c3528e3..a18e3f3b9f94cfccb7041e747b413b55eb76b58e 100644 (file)
@@ -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 eb31aa20f51a25211cdfe5eddc40c7d34a848cba..c89785c22374ca8cff508d8ca6e9769449bd5648 100644 (file)
@@ -7604,7 +7604,7 @@ Named_object::get_backend(Gogo* gogo, std::vector<Bexpression*>& const_decls,
     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 e5f84c51549c0ebd960fd6dd6aa0aa7a853abb4c..07819e23c8d0b4fbf49aebafafa814d3fe9569b0 100644 (file)
@@ -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);