diff mbox

Go patch committed: Don't crash declaring function named "_"

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

Commit Message

Ian Lance Taylor March 3, 2011, 1:48 a.m. UTC
In Go the name "_" is special: it means that the object has no name at
all.  This patch to the Go frontend fixes the case of declaring a
function with the name "_".  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r 581b2502f121 go/parse.cc
--- a/go/parse.cc	Wed Mar 02 17:38:24 2011 -0800
+++ b/go/parse.cc	Wed Mar 02 17:43:26 2011 -0800
@@ -2063,9 +2063,12 @@ 
 	  return;
 	}
       this->advance_token();
-      named_object = this->gogo_->declare_function(name, fntype, location);
-      if (named_object->is_function_declaration())
-	named_object->func_declaration_value()->set_asm_name(asm_name);
+      if (!Gogo::is_sink_name(name))
+	{
+	  named_object = this->gogo_->declare_function(name, fntype, location);
+	  if (named_object->is_function_declaration())
+	    named_object->func_declaration_value()->set_asm_name(asm_name);
+	}
     }
 
   // Check for the easy error of a newline before the opening brace.
@@ -2082,8 +2085,8 @@ 
 
   if (!this->peek_token()->is_op(OPERATOR_LCURLY))
     {
-      if (named_object == NULL)
-	named_object = this->gogo_->declare_function(name, fntype, location);
+      if (named_object == NULL && !Gogo::is_sink_name(name))
+	this->gogo_->declare_function(name, fntype, location);
     }
   else
     {