compiler: look up composite literal keys in the global namespace

A composite literal key may not have a global definition, so
Gogo::define_global_names may not see it.  In order to correctly
handle the case in which a predeclared identifier is used as a
composite literal key, do an explicit check of the global namespace.

Test case is https://golang.org/cl/227783.

Change-Id: I07ca5217993b13ee2344204d2e93ec7d624f85fd
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/227784
Reviewed-by: Than McIntosh <thanm@google.com>
diff --git a/go/expressions.cc b/go/expressions.cc
index 42ad93b..deac874 100644
--- a/go/expressions.cc
+++ b/go/expressions.cc
@@ -16032,9 +16032,17 @@
   Named_object* no = gogo->lookup(this->name_, NULL);
   if (no == NULL)
     {
-      go_error_at(this->location(), "reference to undefined name %qs",
-		  Gogo::message_name(this->name_).c_str());
-      return Expression::make_error(this->location());
+      // Gogo::lookup doesn't look in the global namespace, and names
+      // used in composite literal keys aren't seen by
+      // Gogo::define_global_names, so we have to look in the global
+      // namespace ourselves.
+      no = gogo->lookup_global(Gogo::unpack_hidden_name(this->name_).c_str());
+      if (no == NULL)
+	{
+	  go_error_at(this->location(), "reference to undefined name %qs",
+		      Gogo::message_name(this->name_).c_str());
+	  return Expression::make_error(this->location());
+	}
     }
   return Expression::make_unknown_reference(no, this->location());
 }