OSDN Git Service

compiler: Fix unsafe.Sizeof for named structs with named struct fields.
[pf3gnuchains/gcc-fork.git] / gcc / go / gofrontend / types.cc
index 3f6e97a..c2e5ed8 100644 (file)
@@ -7863,6 +7863,10 @@ Find_type_use::type(Type* type)
 bool
 Named_type::do_verify()
 {
+  if (this->is_verified_)
+    return true;
+  this->is_verified_ = true;
+
   Find_type_use find(this);
   Type::traverse(this->type_, &find);
   if (find.found())
@@ -7973,6 +7977,11 @@ Named_type::convert(Gogo* gogo)
 
   this->create_placeholder(gogo);
 
+  // If we are called to turn unsafe.Sizeof into a constant, we may
+  // not have verified the type yet.  We have to make sure it is
+  // verified, since that sets the list of dependencies.
+  this->verify();
+
   // Convert all the dependencies.  If they refer indirectly back to
   // this type, they will pick up the intermediate tree we just
   // created.