OSDN Git Service

Don't crash on type switch of nil.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 24 Feb 2011 03:53:10 +0000 (03:53 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 24 Feb 2011 03:53:10 +0000 (03:53 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170455 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/statements.cc

index 45e45a3..629fdd8 100644 (file)
@@ -3905,10 +3905,13 @@ Type_switch_statement::do_lower(Gogo*, Block* enclosing)
     {
       // Doing a type switch on a non-interface type.  Should we issue
       // a warning for this case?
-      // descriptor_temp = DESCRIPTOR
       Expression* lhs = Expression::make_temporary_reference(descriptor_temp,
                                                             loc);
-      Expression* rhs = Expression::make_type_descriptor(val_type, loc);
+      Expression* rhs;
+      if (val_type->is_nil_type())
+       rhs = Expression::make_nil(loc);
+      else
+       rhs = Expression::make_type_descriptor(val_type, loc);
       Statement* s = Statement::make_assignment(lhs, rhs, loc);
       b->add_statement(s);
     }