This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Go patch committed: Fix import of struct with embedded builtin type


This patch to the Go frontend fixes the handling of an imported struct
with an embedded builtin type.  We used to permit the importing package
to refer to the field, which is wrong because builtin types are not
exported.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.  Will commit to 4.8
branch when it opens.

Ian

diff -r f6abee26f176 go/import.h
--- a/go/import.h	Fri Oct 11 15:51:49 2013 -0700
+++ b/go/import.h	Sat Oct 12 20:57:20 2013 -0700
@@ -149,6 +149,11 @@
   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 -r f6abee26f176 go/types.cc
--- a/go/types.cc	Fri Oct 11 15:51:49 2013 -0700
+++ b/go/types.cc	Sat Oct 12 20:57:20 2013 -0700
@@ -5258,6 +5258,17 @@
 	    }
 	  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 (ftype->named_type() != NULL
+	      && ftype->named_type()->is_builtin())
+	    name = ('.' + imp->package()->pkgpath() + '.'
+		    + ftype->named_type()->name());
+
 	  Struct_field sf(Typed_identifier(name, ftype, imp->location()));
 
 	  if (imp->peek_char() == ' ')

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]