Don't crash on attempt to index array type expression.
authorIan Lance Taylor <ian@gcc.gnu.org>
Tue, 22 Feb 2011 03:16:38 +0000 (03:16 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Tue, 22 Feb 2011 03:16:38 +0000 (03:16 +0000)
From-SVN: r170387

gcc/go/gofrontend/expressions.cc

index 8b064e617f56d6773e1e47b46d92db6c621044e8..b58792c20650e011a690496f076687d748d874ff 100644 (file)
@@ -9034,6 +9034,11 @@ Index_expression::do_lower(Gogo*, Named_object*, int)
   Type* type = left->type();
   if (type->is_error_type())
     return Expression::make_error(location);
+  else if (left->is_type_expression())
+    {
+      error_at(location, "attempt to index type expression");
+      return Expression::make_error(location);
+    }
   else if (type->array_type() != NULL)
     return Expression::make_array_index(left, start, end, location);
   else if (type->points_to() != NULL