This patch to the Go frontend changes it to not try to get the backend
version of a redefinition.  A redefinition is an error anyhow, and
getting the backend version can cause the compiler to crash as it
walks over a list of statements for the second time.  No test case
added as I don't think it's worth adding a test case for a
crash-on-invalid.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Index: gcc/go/gofrontend/MERGE
--- gcc/go/gofrontend/MERGE     (revision 241124)
+++ gcc/go/gofrontend/MERGE     (working copy)
@@ -1,4 +1,4 @@
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/
--- gcc/go/gofrontend/   (revision 240942)
+++ gcc/go/gofrontend/   (working copy)
@@ -7214,6 +7214,14 @@ Named_object::get_backend(Gogo* gogo, st
                           std::vector<Btype*>& type_decls,
                           std::vector<Bfunction*>& func_decls)
+  // If this is a definition, avoid trying to get the backend
+  // representation, as that can crash.
+  if (this->is_redefinition_)
+    {
+      go_assert(saw_errors());
+      return;
+    }
   switch (this->classification_)

Reply via email to