OSDN Git Service

Don't crash checking for unexported self-referential pointer field.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 Feb 2011 18:21:58 +0000 (18:21 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 Feb 2011 18:21:58 +0000 (18:21 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170017 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/types.cc

index aa331c2..86efc3b 100644 (file)
@@ -8052,9 +8052,9 @@ Type::is_unexported_field_or_method(Gogo* gogo, const Type* type,
                                    const std::string& name,
                                    std::vector<const Named_type*>* seen)
 {
-  type = type->deref();
-
   const Named_type* nt = type->named_type();
+  if (nt == NULL)
+    nt = type->deref()->named_type();
   if (nt != NULL)
     {
       if (nt->is_unexported_local_method(gogo, name))
@@ -8072,6 +8072,8 @@ Type::is_unexported_field_or_method(Gogo* gogo, const Type* type,
        }
     }
 
+  type = type->deref();
+
   const Interface_type* it = type->interface_type();
   if (it != NULL && it->is_unexported_method(gogo, name))
     return true;
@@ -8095,11 +8097,17 @@ Type::is_unexported_field_or_method(Gogo* gogo, const Type* type,
        ++pf)
     {
       if (pf->is_anonymous()
-         && (!pf->type()->deref()->is_error_type()
-             && !pf->type()->deref()->is_undefined()))
+         && !pf->type()->deref()->is_error_type()
+         && !pf->type()->deref()->is_undefined())
        {
-         Named_type* subtype = pf->type()->deref()->named_type();
-         gcc_assert(subtype != NULL);
+         Named_type* subtype = pf->type()->named_type();
+         if (subtype == NULL)
+           subtype = pf->type()->deref()->named_type();
+         if (subtype == NULL)
+           {
+             // This is an error, but it will be diagnosed elsewhere.
+             continue;
+           }
          if (Type::is_unexported_field_or_method(gogo, subtype, name, seen))
            {
              if (nt != NULL)