]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
compiler: don't use sink as parameter in method expression thunk
authorIan Lance Taylor <iant@golang.org>
Mon, 27 Jun 2022 04:52:35 +0000 (21:52 -0700)
committerIan Lance Taylor <iant@golang.org>
Mon, 27 Jun 2022 16:53:22 +0000 (09:53 -0700)
Also fix a couple of cases where the error led to a later compiler crash.

Test case is https://go.dev/cl/414336.

Fixes golang/go#52871

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

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

index f84347ea575892ef5c62bf6b6f4ef2fc72c4e0a9..16d274ce99d86fc2d0926f56550a095aae449df5 100644 (file)
@@ -1,4 +1,4 @@
-6edae0ef6521569e8f949aaaafa9dc1139825051
+927528cdc112fc51e0d07ee79e7a1254b586eabe
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 135dae02262d9c5980eae1d73015416e43b3c2ee..f59f61d19ad348a963867e35d5d92fe8ed33f3f7 100644 (file)
@@ -1426,7 +1426,12 @@ Sink_expression::do_get_backend(Translate_context* context)
   Gogo* gogo = context->gogo();
   if (this->bvar_ == NULL)
     {
-      go_assert(this->type_ != NULL && !this->type_->is_sink_type());
+      if (this->type_ == NULL || this->type_->is_sink_type())
+       {
+         go_assert(saw_errors());
+         return gogo->backend()->error_expression();
+       }
+
       Named_object* fn = context->function();
       go_assert(fn != NULL);
       Bfunction* fn_ctx = fn->func_value()->get_or_make_decl(gogo, fn);
@@ -15235,7 +15240,7 @@ Selector_expression::lower_method_expression(Gogo* gogo)
           p != method_parameters->end();
           ++p, ++i)
        {
-         if (!p->name().empty())
+         if (!p->name().empty() && !Gogo::is_sink_name(p->name()))
            parameters->push_back(*p);
          else
            {
index 39aea769eb28a129596179d2086227757f70e904..e82be6840aa0b4c149c8fa379f4d738e2e12d3cb 100644 (file)
@@ -4654,8 +4654,11 @@ class Sink_type : public Type
   { return false; }
 
   Btype*
-  do_get_backend(Gogo*)
-  { go_unreachable(); }
+  do_get_backend(Gogo* gogo)
+  {
+    go_assert(saw_errors());
+    return gogo->backend()->error_type();
+  }
 
   Expression*
   do_type_descriptor(Gogo*, Named_type*)