aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2013-10-13 04:15:20 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2013-10-13 04:15:20 +0000
commit6137391a4810dd1274acb8fb5bbd7ca081bd0e2b (patch)
tree4934ec8e54c3f970c6dd299252e3f5e056246c46 /gcc
parent713b26d0565da191fce4962c9b63a247eacfab9a (diff)
downloadgcc-6137391a4810dd1274acb8fb5bbd7ca081bd0e2b.zip
gcc-6137391a4810dd1274acb8fb5bbd7ca081bd0e2b.tar.gz
gcc-6137391a4810dd1274acb8fb5bbd7ca081bd0e2b.tar.bz2
compiler: Fix handling of imported struct with embedded builtin type.
From-SVN: r203496
Diffstat (limited to 'gcc')
-rw-r--r--gcc/go/gofrontend/import.h5
-rw-r--r--gcc/go/gofrontend/types.cc13
2 files changed, 18 insertions, 0 deletions
diff --git a/gcc/go/gofrontend/import.h b/gcc/go/gofrontend/import.h
index c6844cd..9917937 100644
--- a/gcc/go/gofrontend/import.h
+++ b/gcc/go/gofrontend/import.h
@@ -149,6 +149,11 @@ class Import
location() const
{ return this->location_; }
+ // Return the package we are importing.
+ Package*
+ package() const
+ { return this->package_; }
+
// Return the next character.
int
peek_char()
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index 69e3e99..40b62f4 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -5258,6 +5258,19 @@ Struct_type::do_import(Import* imp)
}
Type* ftype = imp->read_type();
+ // We don't pack the names of builtin types. In
+ // Struct_field::is_field_name we cope with a hack. Now we
+ // need another hack so that we don't accidentally think
+ // that an embedded builtin type is accessible from another
+ // package (we know that all the builtin types are not
+ // exported).
+ if (name.empty() && ftype->deref()->named_type() != NULL)
+ {
+ const std::string fn(ftype->deref()->named_type()->name());
+ if (fn[0] >= 'a' && fn[0] <= 'z')
+ name = '.' + imp->package()->pkgpath() + '.' + fn;
+ }
+
Struct_field sf(Typed_identifier(name, ftype, imp->location()));
if (imp->peek_char() == ' ')