]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
compiler: Fix handling of imported struct with embedded builtin type.
authorIan Lance Taylor <ian@gcc.gnu.org>
Sun, 13 Oct 2013 04:15:20 +0000 (04:15 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Sun, 13 Oct 2013 04:15:20 +0000 (04:15 +0000)
From-SVN: r203496

gcc/go/gofrontend/import.h
gcc/go/gofrontend/types.cc

index c6844cda8a54d6f5ed7b302278ead69bf65c7921..9917937e4d3ba3abaa3f85642be2a0c93d61aecb 100644 (file)
@@ -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()
index 69e3e99c1ff03e31bcdaf8f235ef950443104869..40b62f41bc0fbbfa7587434c6f21d6b3f251fdf5 100644 (file)
@@ -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() == ' ')