aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2015-12-02 01:28:26 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2015-12-02 01:28:26 +0000
commit1ac22e762e2a5f2c6d48afbe16393d204d9caf47 (patch)
tree2d6eaf29c9cfc6c82d9577f10c8009d3959b537f /gcc/go
parent867038d7d37e44283414d32c5c4707530342e434 (diff)
downloadgcc-1ac22e762e2a5f2c6d48afbe16393d204d9caf47.zip
gcc-1ac22e762e2a5f2c6d48afbe16393d204d9caf47.tar.gz
gcc-1ac22e762e2a5f2c6d48afbe16393d204d9caf47.tar.bz2
re PR go/65717 (64-bit runtime FAILs with 32-bit compiler)
PR go/65717 compiler: Fix array reflection when len doesn't fit in unsigned long. This comes up when using a 32-bit host and a 64-bit target. Fixes https://gcc.gnu.org/PR65717. Reviewed-on: https://go-review.googlesource.com/17330 From-SVN: r231142
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/types.cc46
2 files changed, 23 insertions, 25 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 80136ab..b4c90ef 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-81eb6a3f425b2158c67ee32c0cc973a72ce9d6be
+c375f3bf470f94220149b486c947bb3eb57cde7d
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index 64b560b..802a17d 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -6398,22 +6398,21 @@ Array_type::do_reflection(Gogo* gogo, std::string* ret) const
if (this->length_ != NULL)
{
Numeric_constant nc;
- unsigned long val;
- if (!this->length_->numeric_constant_value(&nc)
- || nc.to_unsigned_long(&val) != Numeric_constant::NC_UL_VALID)
+ if (!this->length_->numeric_constant_value(&nc))
{
- if (!this->issued_length_error_)
- {
- error_at(this->length_->location(), "invalid array length");
- this->issued_length_error_ = true;
- }
+ go_assert(saw_errors());
+ return;
}
- else
+ mpz_t val;
+ if (!nc.to_int(&val))
{
- char buf[50];
- snprintf(buf, sizeof buf, "%lu", val);
- ret->append(buf);
+ go_assert(saw_errors());
+ return;
}
+ char* s = mpz_get_str(NULL, 10, val);
+ ret->append(s);
+ free(s);
+ mpz_clear(val);
}
ret->push_back(']');
@@ -6544,22 +6543,21 @@ Array_type::do_mangled_name(Gogo* gogo, std::string* ret) const
if (this->length_ != NULL)
{
Numeric_constant nc;
- unsigned long val;
- if (!this->length_->numeric_constant_value(&nc)
- || nc.to_unsigned_long(&val) != Numeric_constant::NC_UL_VALID)
+ if (!this->length_->numeric_constant_value(&nc))
{
- if (!this->issued_length_error_)
- {
- error_at(this->length_->location(), "invalid array length");
- this->issued_length_error_ = true;
- }
+ go_assert(saw_errors());
+ return;
}
- else
+ mpz_t val;
+ if (!nc.to_int(&val))
{
- char buf[50];
- snprintf(buf, sizeof buf, "%lu", val);
- ret->append(buf);
+ go_assert(saw_errors());
+ return;
}
+ char *s = mpz_get_str(NULL, 10, val);
+ ret->append(s);
+ free(s);
+ mpz_clear(val);
}
ret->push_back('e');
}