diff mbox series

Go patch committed: Propagate array length error marker

Message ID CAOyqgcVA0W22UuUkX9-HQvLXxZyfvPU78sqZqk9twDwMF2Oy6A@mail.gmail.com
State New
Headers show
Series Go patch committed: Propagate array length error marker | expand

Commit Message

Ian Lance Taylor July 6, 2022, 12:11 a.m. UTC
This patch to the Go frontend propagates the array length error marker
farther, to avoid a compiler crash on invalid code.  This fixes
https://go.dev/issue/53639.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
c70a48a8f8f6a43b35f783b5672c9a3c0a363c31
diff mbox series

Patch

diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 461e2fdf271..7c5c45672d7 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@ 
-a209dca9ec918535977dcab99fd9bb60986ffacd
+d295a0a2c96c0f7c3abd94fea3aa4e2303bf2af2
 
 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/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 00d35a965a9..2492d9fe735 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -8486,6 +8486,11 @@  Builtin_call_expression::do_flatten(Gogo* gogo, Named_object* function,
 	     pa != this->args()->end();
 	     ++pa)
 	  {
+	    if ((*pa)->is_error_expression())
+	      {
+		go_assert(saw_errors());
+		return Expression::make_error(loc);
+	      }
 	    if ((*pa)->is_nil_expression())
 	      {
 		Expression* nil = Expression::make_nil(loc);
@@ -13391,6 +13396,7 @@  Array_index_expression::do_check_types(Gogo*)
   if (array_type == NULL)
     {
       go_assert(this->array_->type()->is_error());
+      this->set_is_error();
       return;
     }
 
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index 4995283bb60..9f34801f695 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -7429,7 +7429,10 @@  bool
 Array_type::do_verify()
 {
   if (this->element_type()->is_error_type())
-    return false;
+    {
+      this->set_is_error();
+      return false;
+    }
   if (!this->verify_length())
     {
       this->length_ = Expression::make_error(this->length_->location());