From: Ian Lance Taylor <iant@golang.org>
To: gcc-patches <gcc-patches@gcc.gnu.org>,
"gofrontend-dev@googlegroups.com"
<gofrontend-dev@googlegroups.com>
Subject: Go patch committed: avoid orphaning Bexpressions when processing conversions
Date: Mon, 12 Jun 2017 17:52:00 -0000 [thread overview]
Message-ID: <CAOyqgcWwUxFNdqkW4A-1aiJB-1t9JRsH66fFCguE3Zju9C3==g@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 451 bytes --]
The Go frontend method Type_conversion_expression::do_get_backend was
(in some circumstances) creating a Bexpression for the source
expression of the conversion and then throwing it away before using
it. This patch by Than McIntosh fixes up this method to insure that
the call to get_backend() on the source expression is only made when
the result will be used. Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu. Committed to mainline.
Ian
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2064 bytes --]
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE (revision 249125)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-d4875b19266d5f726e0e32843b903075f5c50b4c
+61222d34c1b33a369bd86008a0541455dd17727e
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
Index: gcc/go/gofrontend/expressions.cc
===================================================================
--- gcc/go/gofrontend/expressions.cc (revision 249125)
+++ gcc/go/gofrontend/expressions.cc (working copy)
@@ -3410,11 +3410,13 @@ Type_conversion_expression::do_get_backe
Gogo* gogo = context->gogo();
Btype* btype = type->get_backend(gogo);
- Bexpression* bexpr = this->expr_->get_backend(context);
Location loc = this->location();
if (Type::are_identical(type, expr_type, false, NULL))
- return gogo->backend()->convert_expression(btype, bexpr, loc);
+ {
+ Bexpression* bexpr = this->expr_->get_backend(context);
+ return gogo->backend()->convert_expression(btype, bexpr, loc);
+ }
else if (type->interface_type() != NULL
|| expr_type->interface_type() != NULL)
{
@@ -3483,6 +3485,7 @@ Type_conversion_expression::do_get_backe
else if (type->is_numeric_type())
{
go_assert(Type::are_convertible(type, expr_type, NULL));
+ Bexpression* bexpr = this->expr_->get_backend(context);
return gogo->backend()->convert_expression(btype, bexpr, loc);
}
else if ((type->is_unsafe_pointer_type()
@@ -3493,7 +3496,10 @@ Type_conversion_expression::do_get_backe
|| (this->may_convert_function_types_
&& type->function_type() != NULL
&& expr_type->function_type() != NULL))
- return gogo->backend()->convert_expression(btype, bexpr, loc);
+ {
+ Bexpression* bexpr = this->expr_->get_backend(context);
+ return gogo->backend()->convert_expression(btype, bexpr, loc);
+ }
else
{
Expression* conversion =
reply other threads:[~2017-06-12 17:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAOyqgcWwUxFNdqkW4A-1aiJB-1t9JRsH66fFCguE3Zju9C3==g@mail.gmail.com' \
--to=iant@golang.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=gofrontend-dev@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).