aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/types.cc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2015-12-04 14:52:09 +0000
committerEric Botcazou <ebotcazou@adacore.com>2015-12-04 14:52:09 +0000
commit62dd1863abd65ada3d0929db1789c617ff34e1a6 (patch)
tree94204ba776de500b6dc0fc54682d443fd0755f6d /gcc/go/gofrontend/types.cc
parentc672cad4aff4f9923eab0995cc327a0cb7fc8e2a (diff)
Merge from trunk @231250.scalar-storage-order
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/scalar-storage-order@231274 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/go/gofrontend/types.cc')
-rw-r--r--gcc/go/gofrontend/types.cc46
1 files changed, 22 insertions, 24 deletions
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index 64b560b45d6..802a17dc0e3 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');
}