diff mbox

Go patch committed: Don't crash on type switch of untyped value

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

Commit Message

Ian Lance Taylor Feb. 24, 2011, 4:02 a.m. UTC
This patch to the Go frontend avoids crashing on a type switch of an
untyped value.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r 50b98fea9d3b go/statements.cc
--- a/go/statements.cc	Wed Feb 23 19:52:03 2011 -0800
+++ b/go/statements.cc	Wed Feb 23 19:58:43 2011 -0800
@@ -3911,7 +3911,11 @@ 
       if (val_type->is_nil_type())
 	rhs = Expression::make_nil(loc);
       else
-	rhs = Expression::make_type_descriptor(val_type, loc);
+	{
+	  if (val_type->is_abstract())
+	    val_type = val_type->make_non_abstract_type();
+	  rhs = Expression::make_type_descriptor(val_type, loc);
+	}
       Statement* s = Statement::make_assignment(lhs, rhs, loc);
       b->add_statement(s);
     }