aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-12-13 18:09:56 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-12-13 18:09:56 +0000
commit863ea6cf55e6f8d7469e257d22eb2c69a0cb181c (patch)
tree17857b9c308b4cc1737d65129e8c2e3aefabe495 /gcc/go
parent80fd8eba8ed7cc70a89e4f31931a5da28464357a (diff)
downloadgcc-863ea6cf55e6f8d7469e257d22eb2c69a0cb181c.zip
gcc-863ea6cf55e6f8d7469e257d22eb2c69a0cb181c.tar.gz
gcc-863ea6cf55e6f8d7469e257d22eb2c69a0cb181c.tar.bz2
compiler: Permit converting between string and named []byte/[]rune.
From-SVN: r182291
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/expressions.cc15
-rw-r--r--gcc/go/gofrontend/types.cc6
2 files changed, 5 insertions, 16 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 18858d5..ab6f4fe 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -3322,7 +3322,7 @@ Type_conversion_expression::do_lower(Gogo*, Named_object*,
mpfr_clear(imag);
}
- if (type->is_slice_type() && type->named_type() == NULL)
+ if (type->is_slice_type())
{
Type* element_type = type->array_type()->element_type()->forwarded();
bool is_byte = element_type == Type::lookup_integer_type("uint8");
@@ -3621,20 +3621,11 @@ Type_conversion_expression::do_get_tree(Translate_context* context)
integer_type_node,
fold_convert(integer_type_node, expr_tree));
}
- else if (type->is_string_type()
- && (expr_type->array_type() != NULL
- || (expr_type->points_to() != NULL
- && expr_type->points_to()->array_type() != NULL)))
+ else if (type->is_string_type() && expr_type->is_slice_type())
{
- Type* t = expr_type;
- if (t->points_to() != NULL)
- {
- t = t->points_to();
- expr_tree = build_fold_indirect_ref(expr_tree);
- }
if (!DECL_P(expr_tree))
expr_tree = save_expr(expr_tree);
- Array_type* a = t->array_type();
+ Array_type* a = expr_type->array_type();
Type* e = a->element_type()->forwarded();
go_assert(e->integer_type() != NULL);
tree valptr = fold_convert(const_ptr_type_node,
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index fed83b3..432a647 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -662,7 +662,7 @@ Type::are_convertible(const Type* lhs, const Type* rhs, std::string* reason)
{
if (rhs->integer_type() != NULL)
return true;
- if (rhs->is_slice_type() && rhs->named_type() == NULL)
+ if (rhs->is_slice_type())
{
const Type* e = rhs->array_type()->element_type()->forwarded();
if (e->integer_type() != NULL
@@ -673,9 +673,7 @@ Type::are_convertible(const Type* lhs, const Type* rhs, std::string* reason)
}
// A string may be converted to []byte or []int.
- if (rhs->is_string_type()
- && lhs->is_slice_type()
- && lhs->named_type() == NULL)
+ if (rhs->is_string_type() && lhs->is_slice_type())
{
const Type* e = lhs->array_type()->element_type()->forwarded();
if (e->integer_type() != NULL