Location location = this->location();
Struct_type* st = type->struct_type();
if (this->vals_ == NULL || !this->has_keys_)
- return new Struct_construction_expression(type, this->vals_, location);
+ {
+ if (this->vals_ != NULL && !this->vals_->empty())
+ {
+ std::string reason;
+ if (type->has_hidden_fields(NULL, &reason))
+ {
+ if (reason.empty())
+ error_at(this->location(),
+ "implicit assignment of hidden field");
+ else
+ error_at(this->location(), "%s", reason.c_str());
+ }
+ }
+
+ return new Struct_construction_expression(type, this->vals_, location);
+ }
size_t field_count = st->field_count();
std::vector<Expression*> vals(field_count);
return Expression::make_error(location);
}
+ if (type->named_type() != NULL
+ && type->named_type()->named_object()->package() != NULL
+ && Gogo::is_hidden_name(sf->field_name()))
+ error_at(name_expr->location(),
+ "assignment of unexported field %qs in %qs literal",
+ Gogo::message_name(sf->field_name()).c_str(),
+ type->named_type()->message_name().c_str());
+
vals[index] = val;
}
tree
Receive_expression::do_get_tree(Translate_context* context)
{
+ Location loc = this->location();
+
Channel_type* channel_type = this->channel_->type()->channel_type();
if (channel_type == NULL)
{
go_assert(this->channel_->type()->is_error());
return error_mark_node;
}
+
+ Expression* td = Expression::make_type_descriptor(channel_type, loc);
+ tree td_tree = td->get_tree(context);
+
Type* element_type = channel_type->element_type();
Btype* element_type_btype = element_type->get_backend(context->gogo());
tree element_type_tree = type_to_tree(element_type_btype);
if (element_type_tree == error_mark_node || channel == error_mark_node)
return error_mark_node;
- return Gogo::receive_from_channel(element_type_tree, channel,
- this->for_select_, this->location());
+ return Gogo::receive_from_channel(element_type_tree, td_tree, channel, loc);
}
// Dump ast representation for a receive expression.