diff mbox

Go patch committed: Don't crash on defer of type conversion

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

Commit Message

Ian Lance Taylor Feb. 15, 2011, 7:52 p.m. UTC
Code like "defer T(v)" where T is a type and v is a value is invalid.
However, since this is a type conversion which looks like a function
call, it may not be detected as invalid at parse time.  This patch
avoids a crash where such a type conversion is used with defer.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian
diff mbox

Patch

diff -r 31a6b335fc55 go/types.cc
--- a/go/types.cc	Tue Feb 15 11:41:00 2011 -0800
+++ b/go/types.cc	Tue Feb 15 11:48:40 2011 -0800
@@ -5659,7 +5659,7 @@ 
 	{
 	  if (q->name().empty())
 	    {
-	      if (q->type() == p->type())
+	      if (q->type()->forwarded() == p->type()->forwarded())
 		error_at(p->location(), "interface inheritance loop");
 	      else
 		{
@@ -5667,7 +5667,8 @@ 
 		  for (i = from + 1; i < this->methods_->size(); ++i)
 		    {
 		      const Typed_identifier* r = &this->methods_->at(i);
-		      if (r->name().empty() && r->type() == q->type())
+		      if (r->name().empty()
+			  && r->type()->forwarded() == q->type()->forwarded())
 			{
 			  error_at(p->location(),
 				   "inherited interface listed twice");