From 4d67cae5e6671aaa433b6d6a96c9da47cfd71b45 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 26 Aug 2019 19:55:41 +0000 Subject: [PATCH] compiler: generalize cleanup of unresolved placeholder pointer types 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 | 2 +- gcc/go/gofrontend/types.cc | 17 +++++++++-------- gcc/go/gofrontend/types.h | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 73c7534..4f08f23 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -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. diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index b46525d..20f8f27 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -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(); - 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 Type::placeholder_pointers; +std::vector 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; } } diff --git a/gcc/go/gofrontend/types.h b/gcc/go/gofrontend/types.h index 2b51df5..0978701 100644 --- a/gcc/go/gofrontend/types.h +++ b/gcc/go/gofrontend/types.h @@ -1409,7 +1409,7 @@ class Type static Pointer_type_table pointer_types; // List of placeholder pointer types. - static std::vector placeholder_pointers; + static std::vector placeholder_pointers; // The type classification. Type_classification classification_; -- 2.7.4