* Go patch committed: Don't use sink as method expression thunk parameter
@ 2022-06-27 16:53 Ian Lance Taylor
0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2022-06-27 16:53 UTC (permalink / raw)
To: gcc-patches, gofrontend-dev
[-- Attachment #1: Type: text/plain, Size: 372 bytes --]
This Go frontend patch avoids using a sink name (_) as a parameter
name when creating a method expression thunk. The patch also fixes a
couple of cases where the error led to a later compiler crash. The
test case is https://go.dev/cl/414336. This fixes
https://go.dev/issue/52871. Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu. Committed to mainline.
Ian
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1895 bytes --]
5f6b6494035fb984d745efa28d334f7893e7272b
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index f84347ea575..16d274ce99d 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -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.
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 135dae02262..f59f61d19ad 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -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
{
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index 39aea769eb2..e82be6840aa 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -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*)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-27 16:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-27 16:53 Go patch committed: Don't use sink as method expression thunk parameter Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).