Don't crash on type switch of untyped value.
authorIan Lance Taylor <ian@gcc.gnu.org>
Thu, 24 Feb 2011 04:02:33 +0000 (04:02 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Thu, 24 Feb 2011 04:02:33 +0000 (04:02 +0000)
From-SVN: r170456

gcc/go/gofrontend/statements.cc

index 629fdd8161519f54cec55ae29f929ff20403a088..c87574dff1c940adbe146d2f8a5dda22ca1c9c20 100644 (file)
@@ -3911,7 +3911,11 @@ Type_switch_statement::do_lower(Gogo*, Block* enclosing)
       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);
     }