This patch to the Go frontend by Than McIntosh generalizes the cleanup
of unresolved placeholder pointer types. This patch extends the work
in https://golang.org/cl/51131
(https://gcc.gnu.org/ml/gcc-patches/2017-07/msg01934.html) 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 the LLVM backend. A test case can be found in
https://golang.org/cl/191743. Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu. Committed to mainline.
Ian
-------------- next part --------------
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE (revision 274890)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -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: gcc/go/gofrontend/types.cc
===================================================================
--- gcc/go/gofrontend/types.cc (revision 274169)
+++ gcc/go/gofrontend/types.cc (working copy)
@@ -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: gcc/go/gofrontend/types.h
===================================================================
--- gcc/go/gofrontend/types.h (revision 274169)
+++ gcc/go/gofrontend/types.h (working copy)
@@ -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_;