compiler: avoid crash on erroneous type

If there is an error constructing the backend type, the GCC backend
will report that the size is 1.  That will then cause construction of
the ptrmask to crash.  Avoid that case by just generating an empty
ptrmask.

Noticed while compiling a broken package.  The policy I've been
following is to not commit a test case for a compiler crash on invalid
code, so no test case.

Change-Id: Ied85154d9d49012be9d693c4488a077c214efb7e
Reviewed-on: https://go-review.googlesource.com/45775
Reviewed-by: Than McIntosh <thanm@google.com>
diff --git a/go/types.cc b/go/types.cc
index 61a3363..912a23e 100644
--- a/go/types.cc
+++ b/go/types.cc
@@ -2570,16 +2570,16 @@
 bool
 Type::needs_gcprog(Gogo* gogo, int64_t* ptrsize, int64_t* ptrdata)
 {
+  Type* voidptr = Type::make_pointer_type(Type::make_void_type());
+  if (!voidptr->backend_type_size(gogo, ptrsize))
+    go_unreachable();
+
   if (!this->backend_type_ptrdata(gogo, ptrdata))
     {
       go_assert(saw_errors());
       return false;
     }
 
-  Type* voidptr = Type::make_pointer_type(Type::make_void_type());
-  if (!voidptr->backend_type_size(gogo, ptrsize))
-    go_unreachable();
-
   return *ptrdata / *ptrsize > max_ptrmask_bytes;
 }
 
@@ -2795,7 +2795,13 @@
 Type::gc_ptrmask_var(Gogo* gogo, int64_t ptrsize, int64_t ptrdata)
 {
   Ptrmask ptrmask(ptrdata / ptrsize);
-  ptrmask.set_from(gogo, this, ptrsize, 0);
+  if (ptrdata >= ptrsize)
+    ptrmask.set_from(gogo, this, ptrsize, 0);
+  else
+    {
+      // This can happen in error cases.  Just build an empty gcbits.
+      go_assert(saw_errors());
+    }
   std::string sym_name = "runtime.gcbits." + ptrmask.symname();
   Bvariable* bvnull = NULL;
   std::pair<GC_gcbits_vars::iterator, bool> ins =