From 8561b0408e1a5e3a2d48d28592e01a53f2e1de0f Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 13 Oct 2013 04:15:20 +0000 Subject: compiler: Fix handling of imported struct with embedded builtin type. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203496 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/go/gofrontend/import.h | 5 +++++ gcc/go/gofrontend/types.cc | 13 +++++++++++++ 2 files changed, 18 insertions(+) (limited to 'gcc/go') diff --git a/gcc/go/gofrontend/import.h b/gcc/go/gofrontend/import.h index c6844cda8a5..9917937e4d3 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 69e3e99c1ff..40b62f41bc0 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() == ' ') -- cgit v1.2.1