aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2019-03-06 20:40:32 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-03-06 20:40:32 +0000
commit1c98301f2b8b5f1bd7a411b1bbb66cc5694688bf (patch)
tree1881b8081cd0813196d30ec6ed6b1ec429981903 /gcc
parent2de5d0ea90d2e64ff3d345b17228043e08a5d1ac (diff)
downloadgcc-1c98301f2b8b5f1bd7a411b1bbb66cc5694688bf.zip
gcc-1c98301f2b8b5f1bd7a411b1bbb66cc5694688bf.tar.gz
gcc-1c98301f2b8b5f1bd7a411b1bbb66cc5694688bf.tar.bz2
compiler: emit underlying constant in array_type length export
In Array_type::do_export, when emitting a concrete array length, evaluate the length expression to an integer constant and emit that constant, instead of calling the more general method for emitting expressions. This is to avoid the possibility that we will need to emit a conversion, which could confuse the gccgoimporter. Fixes golang/go#30628. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/165741 From-SVN: r269443
Diffstat (limited to 'gcc')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/types.cc15
2 files changed, 12 insertions, 5 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index a93dedb..f1bbc37 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-13c98c3477647888fc7a186e9055793b0961e806
+959260238817af3205fb9907dd92319291e6a893
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 82f9fb0..2d34a28 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -7581,10 +7581,17 @@ Array_type::do_export(Export* exp) const
exp->write_c_string("[");
if (this->length_ != NULL)
{
- Export_function_body efb(exp, 0);
- efb.set_type_context(this->length_->type());
- this->length_->export_expression(&efb);
- exp->write_string(efb.body());
+ Numeric_constant nc;
+ mpz_t val;
+ if (!this->length_->numeric_constant_value(&nc) || !nc.to_int(&val))
+ {
+ go_assert(saw_errors());
+ return;
+ }
+ char* s = mpz_get_str(NULL, 10, val);
+ exp->write_string(s);
+ exp->write_string(" ");
+ mpz_clear(val);
}
exp->write_c_string("] ");
exp->write_type(this->element_type_);