compiler: connect the concrete type and the placeholder for circular types
authorIan Lance Taylor <ian@gcc.gnu.org>
Tue, 17 Jul 2018 17:21:10 +0000 (17:21 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Tue, 17 Jul 2018 17:21:10 +0000 (17:21 +0000)
    Previously, when creating the backend representation of a
    circular type, we resolve the placeholder to a
    circular_pointer_type. The backend doesn't know what the
    concrete type is.

    This CL changes it to resolve the placeholder to the concrete
    type instead, so the backend may have better knowledge of the
    concrete type.

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

From-SVN: r262830

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

index 3e0b65593cd0177bebaa2feca0537e489f048f97..f9d37e728e777677083fc42f8960ff849103fde6 100644 (file)
@@ -1,4 +1,4 @@
-db991403fc97854201b3f40492f4f6b9d471cabc
+d6338c94e5574b63469c740159d064e89c6718bf
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 07819e23c8d0b4fbf49aebafafa814d3fe9569b0..fa8c0ad1901af651806e67d0d1a6c70f52b64702 100644 (file)
@@ -10786,15 +10786,10 @@ Named_type::do_get_backend(Gogo* gogo)
       // Don't build a circular data structure.  GENERIC can't handle
       // it.
       if (this->seen_in_get_backend_)
-       {
-         this->is_circular_ = true;
-         return gogo->backend()->circular_pointer_type(bt, true);
-       }
+        return gogo->backend()->circular_pointer_type(bt, true);
       this->seen_in_get_backend_ = true;
       bt1 = Type::get_named_base_btype(gogo, base);
       this->seen_in_get_backend_ = false;
-      if (this->is_circular_)
-       bt1 = gogo->backend()->circular_pointer_type(bt, true);
       if (!gogo->backend()->set_placeholder_pointer_type(bt, bt1))
        bt = gogo->backend()->error_type();
       return bt;
@@ -10803,15 +10798,10 @@ Named_type::do_get_backend(Gogo* gogo)
       // Don't build a circular data structure. GENERIC can't handle
       // it.
       if (this->seen_in_get_backend_)
-       {
-         this->is_circular_ = true;
-         return gogo->backend()->circular_pointer_type(bt, false);
-       }
+        return gogo->backend()->circular_pointer_type(bt, false);
       this->seen_in_get_backend_ = true;
       bt1 = Type::get_named_base_btype(gogo, base);
       this->seen_in_get_backend_ = false;
-      if (this->is_circular_)
-       bt1 = gogo->backend()->circular_pointer_type(bt, false);
       if (!gogo->backend()->set_placeholder_pointer_type(bt, bt1))
        bt = gogo->backend()->error_type();
       return bt;
index 234e0a6abbda0389f1d571f42bbb8e4d58c2ae48..0f85c3a2b9b72c0d43f6f4008a05f1cbc27139a2 100644 (file)
@@ -3243,8 +3243,8 @@ class Named_type : public Type
       interface_method_tables_(NULL), pointer_interface_method_tables_(NULL),
       location_(location), named_btype_(NULL), dependencies_(),
       is_alias_(false), is_visible_(true), is_error_(false), in_heap_(true),
-      is_placeholder_(false), is_converted_(false), is_circular_(false),
-      is_verified_(false), seen_(false), seen_in_compare_is_identity_(false),
+      is_placeholder_(false), is_converted_(false), is_verified_(false),
+      seen_(false), seen_in_compare_is_identity_(false),
       seen_in_get_backend_(false), seen_alias_(false)
   { }
 
@@ -3345,12 +3345,6 @@ class Named_type : public Type
   is_valid() const
   { return !this->is_error_; }
 
-  // Whether this is a circular type: a pointer or function type that
-  // refers to itself, which is not possible in C.
-  bool
-  is_circular() const
-  { return this->is_circular_; }
-
   // Return the base type for this type.
   Type*
   named_base();
@@ -3557,9 +3551,6 @@ class Named_type : public Type
   // Whether this type has been converted to the backend
   // representation.  Implies that is_placeholder_ is false.
   bool is_converted_;
-  // Whether this is a pointer or function type which refers to the
-  // type itself.
-  bool is_circular_;
   // Whether this type has been verified.
   bool is_verified_;
   // In a recursive operation such as has_pointer, this flag is used