diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-26 21:06:06 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-26 21:06:06 +0000 |
commit | 13b61722048dfbfe6ba5ec6f52c728c37dd2cb4d (patch) | |
tree | 1dc815d906c2a6224fda22da5ff59aab9a3d6ba1 /gcc | |
parent | e02ed81e1bb3c1c8292448f6af7366a400ec3526 (diff) | |
download | gcc-13b61722048dfbfe6ba5ec6f52c728c37dd2cb4d.zip gcc-13b61722048dfbfe6ba5ec6f52c728c37dd2cb4d.tar.gz gcc-13b61722048dfbfe6ba5ec6f52c728c37dd2cb4d.tar.bz2 |
compiler: Don't make type fns for private fields in other packages.
From-SVN: r183579
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/go/gofrontend/gogo.cc | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc index af396dd..e94090b 100644 --- a/gcc/go/gofrontend/gogo.cc +++ b/gcc/go/gofrontend/gogo.cc @@ -1205,13 +1205,13 @@ Specific_type_functions::type(Type* t) { case Type::TYPE_NAMED: { + Named_type* nt = t->named_type(); if (!t->compare_is_identity(this->gogo_) && t->is_comparable()) - t->type_functions(this->gogo_, t->named_type(), NULL, NULL, &hash_fn, - &equal_fn); + t->type_functions(this->gogo_, nt, NULL, NULL, &hash_fn, &equal_fn); // If this is a struct type, we don't want to make functions // for the unnamed struct. - Type* rt = t->named_type()->real_type(); + Type* rt = nt->real_type(); if (rt->struct_type() == NULL) { if (Type::traverse(rt, this) == TRAVERSE_EXIT) @@ -1219,8 +1219,20 @@ Specific_type_functions::type(Type* t) } else { - if (rt->struct_type()->traverse_field_types(this) == TRAVERSE_EXIT) - return TRAVERSE_EXIT; + // If this type is defined in another package, then we don't + // need to worry about the unexported fields. + bool is_defined_elsewhere = nt->named_object()->package() != NULL; + const Struct_field_list* fields = rt->struct_type()->fields(); + for (Struct_field_list::const_iterator p = fields->begin(); + p != fields->end(); + ++p) + { + if (is_defined_elsewhere + && Gogo::is_hidden_name(p->field_name())) + continue; + if (Type::traverse(p->type(), this) == TRAVERSE_EXIT) + return TRAVERSE_EXIT; + } } return TRAVERSE_SKIP_COMPONENTS; |