Don't crash when returning something from a function named '_'.
authorIan Lance Taylor <ian@gcc.gnu.org>
Tue, 21 Dec 2010 23:13:18 +0000 (23:13 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Tue, 21 Dec 2010 23:13:18 +0000 (23:13 +0000)
From-SVN: r168143

gcc/go/gofrontend/gogo.cc

index 2e453844500b586aa1cb7f1204aa971174634c7b..bf197e5632e9e0592e9f480ecc1a35b3b08bab60 100644 (file)
@@ -659,7 +659,13 @@ Gogo::start_function(const std::string& name, Function_type* type,
 
   Named_object* ret;
   if (Gogo::is_sink_name(*pname))
-    ret = Named_object::make_sink();
+    {
+      static int sink_count;
+      char buf[30];
+      snprintf(buf, sizeof buf, ".$sink%d", sink_count);
+      ++sink_count;
+      ret = Named_object::make_function(buf, NULL, function);
+    }
   else if (!type->is_method())
     {
       ret = this->package_->bindings()->add_function(*pname, NULL, function);