diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-15 09:35:56 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-15 09:35:56 +0000 |
commit | e8844fc36936140eb1c9f659a16b401980733b49 (patch) | |
tree | 604287ecd222a7298e95b6799dafc8e1b6467250 /gcc/go/gofrontend | |
parent | 5ce2a6ec8443c9fcf3c4f96383246efa8f5b3d6a (diff) | |
download | gcc-e8844fc36936140eb1c9f659a16b401980733b49.tar.gz |
2012-03-15 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 185416 using svnmerge
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@185423 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/go/gofrontend')
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 15 | ||||
-rw-r--r-- | gcc/go/gofrontend/gogo-tree.cc | 4 | ||||
-rw-r--r-- | gcc/go/gofrontend/gogo.cc | 5 |
3 files changed, 14 insertions, 10 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 134b5ae2aae..90cf6f32dab 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -205,9 +205,6 @@ Expression::convert_for_assignment(Translate_context* context, Type* lhs_type, Type* rhs_type, tree rhs_tree, Location location) { - if (lhs_type == rhs_type) - return rhs_tree; - if (lhs_type->is_error() || rhs_type->is_error()) return error_mark_node; @@ -220,7 +217,7 @@ Expression::convert_for_assignment(Translate_context* context, Type* lhs_type, if (lhs_type_tree == error_mark_node) return error_mark_node; - if (lhs_type->interface_type() != NULL) + if (lhs_type != rhs_type && lhs_type->interface_type() != NULL) { if (rhs_type->interface_type() == NULL) return Expression::convert_type_to_interface(context, lhs_type, @@ -231,7 +228,7 @@ Expression::convert_for_assignment(Translate_context* context, Type* lhs_type, rhs_type, rhs_tree, false, location); } - else if (rhs_type->interface_type() != NULL) + else if (lhs_type != rhs_type && rhs_type->interface_type() != NULL) return Expression::convert_interface_to_type(context, lhs_type, rhs_type, rhs_tree, location); else if (lhs_type->is_slice_type() && rhs_type->is_nil_type()) @@ -289,10 +286,16 @@ Expression::convert_for_assignment(Translate_context* context, Type* lhs_type, || (TREE_CODE(lhs_type_tree) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(rhs_tree)) == ARRAY_TYPE)) { + // Avoid confusion from zero sized variables which may be + // represented as non-zero-sized. + if (int_size_in_bytes(lhs_type_tree) == 0 + || int_size_in_bytes(TREE_TYPE(rhs_tree)) == 0) + return rhs_tree; + // This conversion must be permitted by Go, or we wouldn't have // gotten here. go_assert(int_size_in_bytes(lhs_type_tree) - == int_size_in_bytes(TREE_TYPE(rhs_tree))); + == int_size_in_bytes(TREE_TYPE(rhs_tree))); return fold_build1_loc(location.gcc_location(), VIEW_CONVERT_EXPR, lhs_type_tree, rhs_tree); } diff --git a/gcc/go/gofrontend/gogo-tree.cc b/gcc/go/gofrontend/gogo-tree.cc index 603b97ec0c1..fa229320c96 100644 --- a/gcc/go/gofrontend/gogo-tree.cc +++ b/gcc/go/gofrontend/gogo-tree.cc @@ -843,7 +843,9 @@ Gogo::write_globals() this->backend()->global_variable_set_init(var, tree_to_expr(init)); } - else if (is_sink) + else if (is_sink + || int_size_in_bytes(TREE_TYPE(init)) == 0 + || int_size_in_bytes(TREE_TYPE(vec[i])) == 0) var_init_tree = init; else var_init_tree = fold_build2_loc(no->location().gcc_location(), diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc index ca57aea26ee..5fe5aead9c0 100644 --- a/gcc/go/gofrontend/gogo.cc +++ b/gcc/go/gofrontend/gogo.cc @@ -628,7 +628,7 @@ Gogo::start_function(const std::string& name, Function_type* type, Variable* this_param = new Variable(receiver->type(), NULL, false, true, true, location); std::string rname = receiver->name(); - if (rname.empty()) + if (rname.empty() || Gogo::is_sink_name(rname)) { // We need to give receivers a name since they wind up in // DECL_ARGUMENTS. FIXME. @@ -638,8 +638,7 @@ Gogo::start_function(const std::string& name, Function_type* type, ++count; rname = buf; } - if (!Gogo::is_sink_name(rname)) - block->bindings()->add_variable(rname, NULL, this_param); + block->bindings()->add_variable(rname, NULL, this_param); } const Typed_identifier_list* parameters = type->parameters(); |