aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2010-12-22 15:10:58 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2010-12-22 15:10:58 +0000
commit9ed91cebef42dd20ca7f9f665d3f7b2b248a3584 (patch)
tree15649d4f6cbdbc5d9d2219cbd8271f15ed0ef7f9 /gcc/go
parent46fc230528907c9adc42104c73819415de8d0a6c (diff)
downloadgcc-9ed91cebef42dd20ca7f9f665d3f7b2b248a3584.zip
gcc-9ed91cebef42dd20ca7f9f665d3f7b2b248a3584.tar.gz
gcc-9ed91cebef42dd20ca7f9f665d3f7b2b248a3584.tar.bz2
Fix handling of named results for functions which call recover.
From-SVN: r168170
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/gogo.cc19
-rw-r--r--gcc/go/gofrontend/gogo.h11
2 files changed, 30 insertions, 0 deletions
diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc
index 32d5589..be4de9c 100644
--- a/gcc/go/gofrontend/gogo.cc
+++ b/gcc/go/gofrontend/gogo.cc
@@ -2177,6 +2177,10 @@ Build_recover_thunks::function(Named_object* orig_no)
Convert_recover convert_recover(can_recover_no);
new_func->traverse(&convert_recover);
+ // Update the function pointers in any named results.
+ new_func->update_named_result_variables();
+ orig_func->update_named_result_variables();
+
return TRAVERSE_CONTINUE;
}
@@ -2505,6 +2509,21 @@ Function::create_named_result_variables(Gogo* gogo)
}
}
+// Update the named result variables when cloning a function which
+// calls recover.
+
+void
+Function::update_named_result_variables()
+{
+ if (this->named_results_ == NULL)
+ return;
+
+ for (Named_results::iterator p = this->named_results_->begin();
+ p != this->named_results_->end();
+ ++p)
+ (*p)->result_var_value()->set_function(this);
+}
+
// Return the closure variable, creating it if necessary.
Named_object*
diff --git a/gcc/go/gofrontend/gogo.h b/gcc/go/gofrontend/gogo.h
index 96729b2..dd7afc8 100644
--- a/gcc/go/gofrontend/gogo.h
+++ b/gcc/go/gofrontend/gogo.h
@@ -787,6 +787,11 @@ class Function
void
create_named_result_variables(Gogo*);
+ // Update the named result variables when cloning a function which
+ // calls recover.
+ void
+ update_named_result_variables();
+
// Add a new field to the closure variable.
void
add_closure_field(Named_object* var, source_location loc)
@@ -1318,6 +1323,12 @@ class Result_variable
is_in_heap() const
{ return this->is_address_taken_; }
+ // Set the function. This is used when cloning functions which call
+ // recover.
+ void
+ set_function(Function* function)
+ { this->function_ = function; }
+
private:
// Type of result variable.
Type* type_;