{
named_type->
type_descriptor_pointer(gogo, Linemap::predeclared_location());
- named_type->gc_symbol_pointer(gogo);
Type* pn = Type::make_pointer_type(named_type);
pn->type_descriptor_pointer(gogo, Linemap::predeclared_location());
- pn->gc_symbol_pointer(gogo);
+ if (named_type->in_heap())
+ {
+ named_type->gc_symbol_pointer(gogo);
+ pn->gc_symbol_pointer(gogo);
+ }
}
}
break;
Expression_list* vals = new Expression_list();
vals->reserve(12);
- if (!this->has_pointer())
+ bool has_pointer;
+ if (name != NULL)
+ has_pointer = name->has_pointer();
+ else
+ has_pointer = this->has_pointer();
+ if (!has_pointer)
runtime_type_kind |= RUNTIME_TYPE_KIND_NO_POINTERS;
if (this->is_direct_iface_type())
runtime_type_kind |= RUNTIME_TYPE_KIND_DIRECT_IFACE;
int64_t ptrsize;
int64_t ptrdata;
- if (this->needs_gcprog(gogo, &ptrsize, &ptrdata))
+ if (has_pointer && this->needs_gcprog(gogo, &ptrsize, &ptrdata))
runtime_type_kind |= RUNTIME_TYPE_KIND_GC_PROG;
Struct_field_list::const_iterator p = fields->begin();
++p;
go_assert(p->is_field_name("ptrdata"));
type_info = Expression::TYPE_INFO_DESCRIPTOR_PTRDATA;
- vals->push_back(Expression::make_type_info(this, type_info));
+ if (has_pointer)
+ vals->push_back(Expression::make_type_info(this, type_info));
+ else
+ vals->push_back(Expression::make_integer_ul(0, p->type(), bloc));
++p;
go_assert(p->is_field_name("hash"));
++p;
go_assert(p->is_field_name("gcdata"));
- vals->push_back(Expression::make_gc_symbol(this));
+ if (has_pointer)
+ vals->push_back(Expression::make_gc_symbol(this));
+ else
+ vals->push_back(Expression::make_cast(p->type(),
+ Expression::make_nil(bloc),
+ bloc));
++p;
go_assert(p->is_field_name("string"));
bool
Named_type::do_has_pointer() const
{
+ // A type that is not in the heap has no pointers that we care about.
+ if (!this->in_heap_)
+ return false;
+
if (this->seen_)
return false;
this->seen_ = true;
do_verify()
{ return this->to_type_->verify(); }
+ // If this is a pointer to a type that can't be in the heap, then
+ // the garbage collector does not have to look at this, so pretend
+ // that this is not a pointer at all.
bool
do_has_pointer() const
- { return true; }
+ { return this->to_type_->in_heap(); }
bool
do_compare_is_identity(Gogo*)