Type* ptype = this->expr_->type()->points_to();
if (!ptype->is_void_type())
{
- Btype* pbtype = ptype->get_backend(gogo);
- int64_t s = gogo->backend()->type_size(pbtype);
+ int64_t s;
+ bool ok = ptype->backend_type_size(gogo, &s);
+ if (!ok)
+ {
+ go_assert(saw_errors());
+ return Expression::make_error(this->location());
+ }
if (s >= 4096 || this->issue_nil_check_)
{
Temporary_statement* temp =
Btype* pbtype = ptype->get_backend(gogo);
if (!ptype->is_void_type())
{
- int64_t s = gogo->backend()->type_size(pbtype);
+ int64_t s;
+ bool ok = ptype->backend_type_size(gogo, &s);
+ if (!ok)
+ {
+ go_assert(saw_errors());
+ return gogo->backend()->error_expression();
+ }
if (s >= 4096 || this->issue_nil_check_)
{
go_assert(this->expr_->is_variable());
Expression::make_conditional(cond, arg1_len, arg2_len, location);
Type* element_type = at->element_type();
- Btype* element_btype = element_type->get_backend(gogo);
- int64_t element_size = gogo->backend()->type_size(element_btype);
+ int64_t element_size;
+ bool ok = element_type->backend_type_size(gogo, &element_size);
+ if (!ok)
+ {
+ go_assert(saw_errors());
+ return gogo->backend()->error_expression();
+ }
+
Expression* size_expr = Expression::make_integer_int64(element_size,
length->type(),
location);
{
arg2_val = at->get_value_pointer(gogo, arg2);
arg2_len = at->get_length(gogo, arg2);
- Btype* element_btype = element_type->get_backend(gogo);
- size = gogo->backend()->type_size(element_btype);
+ bool ok = element_type->backend_type_size(gogo, &size);
+ if (!ok)
+ {
+ go_assert(saw_errors());
+ return gogo->backend()->error_expression();
+ }
}
Expression* element_size =
Expression::make_integer_int64(size, NULL, location);
Gogo* gogo = context->gogo();
Location loc = this->location();
- Btype* btype = this->type_->get_backend(gogo);
if (this->allocate_on_stack_)
{
- int64_t size = gogo->backend()->type_size(btype);
+ int64_t size;
+ bool ok = this->type_->backend_type_size(gogo, &size);
+ if (!ok)
+ {
+ go_assert(saw_errors());
+ return gogo->backend()->error_expression();
+ }
return gogo->backend()->stack_allocation_expression(size, loc);
}
- Bexpression* space =
+ Btype* btype = this->type_->get_backend(gogo);
+ Bexpression* space =
gogo->allocate_memory(this->type_, loc)->get_backend(context);
Btype* pbtype = gogo->backend()->pointer_type(btype);
return gogo->backend()->convert_expression(pbtype, space, loc);
Bexpression*
Type_info_expression::do_get_backend(Translate_context* context)
{
- Btype* btype = this->type_->get_backend(context->gogo());
Gogo* gogo = context->gogo();
+ bool ok = true;
int64_t val;
switch (this->type_info_)
{
case TYPE_INFO_SIZE:
- val = gogo->backend()->type_size(btype);
+ ok = this->type_->backend_type_size(gogo, &val);
break;
case TYPE_INFO_ALIGNMENT:
- val = gogo->backend()->type_alignment(btype);
+ ok = this->type_->backend_type_align(gogo, &val);
break;
case TYPE_INFO_FIELD_ALIGNMENT:
- val = gogo->backend()->type_field_alignment(btype);
+ ok = this->type_->backend_type_field_align(gogo, &val);
break;
default:
go_unreachable();
}
+ if (!ok)
+ {
+ go_assert(saw_errors());
+ return gogo->backend()->error_expression();
+ }
Expression* e = Expression::make_integer_int64(val, this->type(),
this->location());
return e->get_backend(context);
return false;
Btype* bt = this->get_backend_placeholder(gogo);
*psize = gogo->backend()->type_size(bt);
+ if (*psize == -1)
+ {
+ if (this->named_type() != NULL)
+ error_at(this->named_type()->location(),
+ "type %s larger than address space",
+ Gogo::message_name(this->named_type()->name()).c_str());
+ else
+ error("type %s larger than address space",
+ this->reflection(gogo).c_str());
+
+ // Make this an error type to avoid knock-on errors.
+ this->classification_ = TYPE_ERROR;
+ return false;
+ }
return true;
}
// Differentiate between slices with zero-length and non-zero-length values.
Type* element_type = this->element_type();
- Btype* ebtype = element_type->get_backend(gogo);
- int64_t element_size = gogo->backend()->type_size(ebtype);
+ int64_t element_size;
+ bool ok = element_type->backend_type_size(gogo, &element_size);
+ if (!ok) {
+ go_assert(saw_errors());
+ element_size = 4;
+ }
Type* uintptr_type = Type::lookup_integer_type("uintptr");
unsigned long opval = element_size == 0 ? GC_APTR : GC_SLICE;
Btype* pbtype = gogo->backend()->pointer_type(gogo->backend()->void_type());
int64_t pwidth = gogo->backend()->type_size(pbtype);
- int64_t iwidth = gogo->backend()->type_size(this->get_backend(gogo));
+ int64_t iwidth;
+ bool ok = this->backend_type_size(gogo, &iwidth);
+ if (!ok)
+ {
+ go_assert(saw_errors());
+ iwidth = 4;
+ }
Type* element_type = this->element_type();
if (bound < 1 || !element_type->has_pointer())