Don't crash declaring a function named "_".
authorIan Lance Taylor <ian@gcc.gnu.org>
Thu, 3 Mar 2011 01:48:28 +0000 (01:48 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Thu, 3 Mar 2011 01:48:28 +0000 (01:48 +0000)
From-SVN: r170636

gcc/go/gofrontend/parse.cc

index ab6021d0b2c7d7ce42fe30360391c4f1c0ed0177..7c03870e82e3814336a719c34598e0b17945940c 100644 (file)
@@ -2063,9 +2063,12 @@ Parse::function_decl()
          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 @@ Parse::function_decl()
 
   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
     {