diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2017-07-18 23:29:15 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2017-07-18 23:29:15 +0000 |
commit | 6033b55bd90c3e0e857b4a1b54ab1d243377e56e (patch) | |
tree | 228b66f528ce1d6fcee3fca02761bac5620702fb /gcc | |
parent | 9e45ca5f83954a340cc78c2f86b7b3294188047f (diff) | |
download | gcc-6033b55bd90c3e0e857b4a1b54ab1d243377e56e.zip gcc-6033b55bd90c3e0e857b4a1b54ab1d243377e56e.tar.gz gcc-6033b55bd90c3e0e857b4a1b54ab1d243377e56e.tar.bz2 |
compiler: insert backend type conversion for closure func ptr
In Func_expression::do_get_backend when creating the backend
representation for a closure, create a backend type conversion to
account for potential differences between the closure struct type
(where the number of fields is dependent on the number of values
referenced in the closure) and the generic function descriptor type
(struct with single function pointer field).
Reviewed-on: https://go-review.googlesource.com/49255
From-SVN: r250327
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/go/gofrontend/MERGE | 2 | ||||
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 0b110e0..f6d7a00 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -c49ddc84f3ce89310585aad23ab6e51ef5523748 +3d9ff9bc339942922f1be3bef07c6fe2978ad81a 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/expressions.cc b/gcc/go/gofrontend/expressions.cc index 12505b2..597f0a0 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -1204,7 +1204,14 @@ Func_expression::do_get_backend(Translate_context* context) // expression. It is a pointer to a struct whose first field points // to the function code and whose remaining fields are the addresses // of the closed-over variables. - return this->closure_->get_backend(context); + Bexpression *bexpr = this->closure_->get_backend(context); + + // Introduce a backend type conversion, to account for any differences + // between the argument type (function descriptor, struct with a + // single field) and the closure (struct with multiple fields). + Gogo* gogo = context->gogo(); + Btype *btype = this->type()->get_backend(gogo); + return gogo->backend()->convert_expression(btype, bexpr, this->location()); } // Ast dump for function. |