aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-02-10 18:21:58 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-02-10 18:21:58 +0000
commit7b8ec21790fa899f8729b8901380129565405dcd (patch)
tree23afb9500e147fde2f5e284cb7dda07627d8feca /gcc/go
parenta3fa23e44b9bb4bbcd68bd8c960c00d53afb7c23 (diff)
downloadgcc-7b8ec21790fa899f8729b8901380129565405dcd.zip
gcc-7b8ec21790fa899f8729b8901380129565405dcd.tar.gz
gcc-7b8ec21790fa899f8729b8901380129565405dcd.tar.bz2
Don't crash checking for unexported self-referential pointer field.
From-SVN: r170017
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/types.cc20
1 files changed, 14 insertions, 6 deletions
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index aa331c2..86efc3b 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -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)