+ this->named_tree_ = t;
+}
+
+// Get a tree for a named type.
+
+tree
+Named_type::do_get_tree(Gogo* gogo)
+{
+ if (this->is_error_)
+ return error_mark_node;
+
+ tree t = this->named_tree_;
+
+ // FIXME: GOGO can be NULL when called from go_type_for_size, which
+ // is only used for basic types.
+ if (gogo == NULL || !gogo->named_types_are_converted())
+ {
+ // We have not completed converting named types. NAMED_TREE_ is
+ // a placeholder and we shouldn't do anything further.
+ if (t != NULL_TREE)
+ return t;
+
+ // We don't build dependencies for types whose sizes do not
+ // change or are not relevant, so we may see them here while
+ // converting types.
+ this->create_placeholder(gogo);
+ t = this->named_tree_;
+ gcc_assert(t != NULL_TREE);
+ return t;
+ }
+
+ // We are not converting types. This should only be called if the
+ // type has already been converted.
+ gcc_assert(this->is_converted_);
+ gcc_assert(t != NULL_TREE && TYPE_SIZE(t) != NULL_TREE);
+
+ // Complete the tree.
+ Type* base = this->type_->base();
+ tree t1;
+ switch (base->classification())
+ {
+ case TYPE_ERROR:
+ return error_mark_node;
+
+ case TYPE_VOID:
+ case TYPE_BOOLEAN:
+ case TYPE_INTEGER:
+ case TYPE_FLOAT:
+ case TYPE_COMPLEX:
+ case TYPE_STRING:
+ case TYPE_NIL:
+ case TYPE_MAP:
+ case TYPE_CHANNEL:
+ case TYPE_STRUCT:
+ case TYPE_INTERFACE:
+ return t;
+
+ case TYPE_FUNCTION:
+ // Don't build a circular data structure. GENERIC can't handle
+ // it.
+ if (this->seen_ > 0)
+ {
+ this->is_circular_ = true;
+ return ptr_type_node;
+ }
+ ++this->seen_;
+ t1 = Type::get_named_type_tree(gogo, base);
+ --this->seen_;
+ if (t1 == error_mark_node)
+ return error_mark_node;
+ if (this->is_circular_)
+ t1 = ptr_type_node;
+ gcc_assert(t != NULL_TREE && TREE_CODE(t) == POINTER_TYPE);
+ gcc_assert(TREE_CODE(t1) == POINTER_TYPE);
+ TREE_TYPE(t) = TREE_TYPE(t1);
+ return t;
+
+ case TYPE_POINTER:
+ // Don't build a circular data structure. GENERIC can't handle
+ // it.
+ if (this->seen_ > 0)
+ {
+ this->is_circular_ = true;
+ return ptr_type_node;
+ }
+ ++this->seen_;
+ t1 = Type::get_named_type_tree(gogo, base);
+ --this->seen_;
+ if (t1 == error_mark_node)
+ return error_mark_node;
+ if (this->is_circular_)
+ t1 = ptr_type_node;
+ gcc_assert(t != NULL_TREE && TREE_CODE(t) == POINTER_TYPE);
+ gcc_assert(TREE_CODE(t1) == POINTER_TYPE);
+ TREE_TYPE(t) = TREE_TYPE(t1);
+ return t;
+
+ case TYPE_ARRAY:
+ if (base->is_open_array_type())
+ {
+ if (this->seen_ > 0)
+ return t;
+ else
+ {
+ ++this->seen_;
+ t = base->array_type()->fill_in_slice_tree(gogo, t);
+ --this->seen_;
+ }
+ }
+ return t;
+
+ default:
+ case TYPE_SINK:
+ case TYPE_CALL_MULTIPLE_RESULT:
+ case TYPE_NAMED:
+ case TYPE_FORWARD:
+ gcc_unreachable();
+ }
+
+ gcc_unreachable();