compiler: generalize cleanup of unresolved placeholder pointer types
authorIan Lance Taylor <ian@gcc.gnu.org>
Mon, 26 Aug 2019 19:55:41 +0000 (19:55 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 26 Aug 2019 19:55:41 +0000 (19:55 +0000)
    This change extends the work in https://golang.org/cl/51131 to include
    placeholder pointer types created for Go function types, which can
    also be left dangling/unresolved in some instances. This fixes an
    assert in Llvm_backend::materializeComposite.

    Test case can be found in https://golang.org/cl/191743.

    Updates golang/go#33020.

    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/191744

From-SVN: r274935

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

index 73c7534..4f08f23 100644 (file)
@@ -1,4 +1,4 @@
-c9ca1c6bf887c752cc75cf1ddaec8ddd1ec962d4
+58c0fc64d91edc53ef9828b85cf3dc86aeb94e12
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index b46525d..20f8f27 100644 (file)
@@ -1138,6 +1138,7 @@ Type::get_backend_placeholder(Gogo* gogo)
        // A Go function type is a pointer to a struct type.
        Location loc = this->function_type()->location();
        bt = gogo->backend()->placeholder_pointer_type("", loc, false);
+       Type::placeholder_pointers.push_back(this);
       }
       break;
 
@@ -1145,8 +1146,7 @@ Type::get_backend_placeholder(Gogo* gogo)
       {
        Location loc = Linemap::unknown_location();
        bt = gogo->backend()->placeholder_pointer_type("", loc, false);
-       Pointer_type* pt = this->convert<Pointer_type, TYPE_POINTER>();
-       Type::placeholder_pointers.push_back(pt);
+       Type::placeholder_pointers.push_back(this);
       }
       break;
 
@@ -5474,10 +5474,11 @@ Pointer_type::do_import(Import* imp)
 
 Type::Pointer_type_table Type::pointer_types;
 
-// A list of placeholder pointer types.  We keep this so we can ensure
-// they are finalized.
+// A list of placeholder pointer types; items on this list will be either be
+// Pointer_type or Function_type. We keep this so we can ensure they are
+// finalized.
 
-std::vector<Pointer_type*> Type::placeholder_pointers;
+std::vector<Type*> Type::placeholder_pointers;
 
 // Make a pointer type.
 
@@ -5513,11 +5514,11 @@ Type::finish_pointer_types(Gogo* gogo)
   // placeholder pointer types as we finalized existing ones.
   for (size_t i = 0; i < Type::placeholder_pointers.size(); i++)
     {
-      Pointer_type* pt = Type::placeholder_pointers[i];
-      Type_btypes::iterator tbti = Type::type_btypes.find(pt);
+      Type* typ = Type::placeholder_pointers[i];
+      Type_btypes::iterator tbti = Type::type_btypes.find(typ);
       if (tbti != Type::type_btypes.end() && tbti->second.is_placeholder)
         {
-          pt->finish_backend(gogo, tbti->second.btype);
+          typ->finish_backend(gogo, tbti->second.btype);
           tbti->second.is_placeholder = false;
         }
     }
index 2b51df5..0978701 100644 (file)
@@ -1409,7 +1409,7 @@ class Type
   static Pointer_type_table pointer_types;
 
   // List of placeholder pointer types.
-  static std::vector<Pointer_type*> placeholder_pointers;
+  static std::vector<Type*> placeholder_pointers;
 
   // The type classification.
   Type_classification classification_;