diff mbox

Go patch committed: Fix recover thunks which return multiple values

Message ID mcrwrmkpma5.fsf@google.com
State New
Headers show

Commit Message

Ian Lance Taylor Jan. 4, 2011, 6:16 p.m. UTC
This patch to the Go frontend fixes building recover thunks which return
multiple values.  We aren't going to explicitly lower the newly built
function, so we need to explicitly return the multiple call results.
Bootstrapped and tested on x86_64-unknown-linux-gnu.

Ian
diff mbox

Patch

diff -r 887b04e764e2 go/gogo.cc
--- a/go/gogo.cc	Tue Jan 04 07:35:37 2011 -0800
+++ b/go/gogo.cc	Tue Jan 04 10:10:54 2011 -0800
@@ -2062,7 +2062,7 @@ 
       for (Typed_identifier_list::const_iterator p = orig_results->begin();
 	   p != orig_results->end();
 	   ++p)
-	new_results->push_back(*p);
+	new_results->push_back(Typed_identifier("", p->type(), p->location()));
     }
 
   Function_type *new_fntype = Type::make_function_type(NULL, new_params,
@@ -2120,7 +2120,7 @@ 
     }
   args->push_back(this->can_recover_arg(location));
 
-  Expression* call = Expression::make_call(fn, args, false, location);
+  Call_expression* call = Expression::make_call(fn, args, false, location);
 
   Statement* s;
   if (orig_fntype->results() == NULL || orig_fntype->results()->empty())
@@ -2128,7 +2128,14 @@ 
   else
     {
       Expression_list* vals = new Expression_list();
-      vals->push_back(call);
+      size_t rc = orig_fntype->results()->size();
+      if (rc == 1)
+	vals->push_back(call);
+      else
+	{
+	  for (size_t i = 0; i < rc; ++i)
+	    vals->push_back(Expression::make_call_result(call, i));
+	}
       s = Statement::make_return_statement(new_func->type()->results(),
 					   vals, location);
     }