diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/go/gofrontend/MERGE | 2 | ||||
-rw-r--r-- | gcc/go/gofrontend/parse.cc | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 08a86e9..0a116a8 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -6c9070324d5b7c8483bc7c17b0a8faaa1fb1ae30 +681580a3afc687ba3ff9ef240c67e8630e4306e6 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/parse.cc b/gcc/go/gofrontend/parse.cc index 81525a7..b7411d1 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -3026,6 +3026,21 @@ Parse::create_closure(Named_object* function, Enclosing_vars* enclosing_vars, Struct_type* st = closure_var->var_value()->type()->deref()->struct_type(); Expression* cv = Expression::make_struct_composite_literal(st, initializer, location); + + // When compiling the runtime, closures do not escape. When escape + // analysis becomes the default, and applies to closures, this + // should be changed to make it an error if a closure escapes. + if (this->gogo_->compiling_runtime() + && this->gogo_->package_name() == "runtime") + { + Temporary_statement* ctemp = Statement::make_temporary(st, cv, location); + this->gogo_->add_statement(ctemp); + Expression* ref = Expression::make_temporary_reference(ctemp, location); + Expression* addr = Expression::make_unary(OPERATOR_AND, ref, location); + addr->unary_expression()->set_does_not_escape(); + return addr; + } + return Expression::make_heap_expression(cv, location); } |