diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-14 08:52:21 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-14 08:52:21 +0000 |
commit | d0b175bffc2f2cb91d1fb529b7c36d3e984d9594 (patch) | |
tree | eb438cb5c7cabed8d102b2c0c1bdd1b0aebb59eb /gcc/go/gofrontend | |
parent | 5e3123db0a9b4c8def9fee64446b130ce81ace45 (diff) | |
download | gcc-d0b175bffc2f2cb91d1fb529b7c36d3e984d9594.tar.gz |
2011-12-14 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 182322 using svnmerge
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@182325 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/go/gofrontend')
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 19 | ||||
-rw-r--r-- | gcc/go/gofrontend/import.cc | 46 | ||||
-rw-r--r-- | gcc/go/gofrontend/import.h | 4 | ||||
-rw-r--r-- | gcc/go/gofrontend/types.cc | 6 |
4 files changed, 21 insertions, 54 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 18858d519a0..365e99c5486 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, @@ -3678,7 +3669,7 @@ Type_conversion_expression::do_get_tree(Translate_context* context) if (e->integer_type()->is_unsigned() && e->integer_type()->bits() == 8) { - static tree string_to_byte_array_fndecl; + tree string_to_byte_array_fndecl = NULL_TREE; ret = Gogo::call_builtin(&string_to_byte_array_fndecl, this->location(), "__go_string_to_byte_array", @@ -3690,7 +3681,7 @@ Type_conversion_expression::do_get_tree(Translate_context* context) else { go_assert(e == Type::lookup_integer_type("int")); - static tree string_to_int_array_fndecl; + tree string_to_int_array_fndecl = NULL_TREE; ret = Gogo::call_builtin(&string_to_int_array_fndecl, this->location(), "__go_string_to_int_array", diff --git a/gcc/go/gofrontend/import.cc b/gcc/go/gofrontend/import.cc index 075109c0c04..a62069e8e23 100644 --- a/gcc/go/gofrontend/import.cc +++ b/gcc/go/gofrontend/import.cc @@ -215,46 +215,24 @@ Import::find_object_export_data(const std::string& filename, off_t offset, Location location) { - const char* errmsg; + char *buf; + size_t len; int err; - simple_object_read* sobj = simple_object_start_read(fd, offset, - "__GNU_GO", - &errmsg, &err); - if (sobj == NULL) - return NULL; - - off_t sec_offset; - off_t sec_length; - int found = simple_object_find_section(sobj, ".go_export", &sec_offset, - &sec_length, &errmsg, &err); - - simple_object_release_read(sobj); - - if (!found) - return NULL; - - if (lseek(fd, offset + sec_offset, SEEK_SET) < 0) + const char *errmsg = go_read_export_data(fd, offset, &buf, &len, &err); + if (errmsg != NULL) { - error_at(location, "lseek %s failed: %m", filename.c_str()); + if (err == 0) + error_at(location, "%s: %s", filename.c_str(), errmsg); + else + error_at(location, "%s: %s: %s", filename.c_str(), errmsg, + xstrerror(err)); return NULL; } - char* buf = new char[sec_length]; - ssize_t c = read(fd, buf, sec_length); - if (c < 0) - { - error_at(location, "read %s failed: %m", filename.c_str()); - delete[] buf; - return NULL; - } - if (c < sec_length) - { - error_at(location, "%s: short read", filename.c_str()); - delete[] buf; - return NULL; - } + if (buf == NULL) + return NULL; - return new Stream_from_buffer(buf, sec_length); + return new Stream_from_buffer(buf, len); } // Class Import. diff --git a/gcc/go/gofrontend/import.h b/gcc/go/gofrontend/import.h index f5b4b3d2be3..bdff0c2a9e1 100644 --- a/gcc/go/gofrontend/import.h +++ b/gcc/go/gofrontend/import.h @@ -287,7 +287,7 @@ class Stream_from_string : public Import::Stream size_t pos_; }; -// Read import data from an allocated buffer. +// Read import data from a buffer allocated using malloc. class Stream_from_buffer : public Import::Stream { @@ -297,7 +297,7 @@ class Stream_from_buffer : public Import::Stream { } ~Stream_from_buffer() - { delete[] this->buf_; } + { free(this->buf_); } protected: bool diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index fed83b31b9a..432a6472217 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 |