public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-2845] compiler: don't crash on a, b := int(0)
@ 2021-08-11  2:36 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2021-08-11  2:36 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:fed7c1634e8e50600e20cb97dbfbd74ecbd5ba22

commit r12-2845-gfed7c1634e8e50600e20cb97dbfbd74ecbd5ba22
Author: Ian Lance Taylor <iant@golang.org>
Date:   Tue Aug 10 16:13:01 2021 -0700

    compiler: don't crash on a, b := int(0)
    
    Fixes PR go/101851
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/341330

Diff:
---
 gcc/go/gofrontend/MERGE          |  2 +-
 gcc/go/gofrontend/expressions.cc | 15 +++++++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index b983fdab35c..be092de568b 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-d5d51242efc432fa62d4e9b141b01c280af32d19
+7e092d2cc5af7648036496485b639f2c9db2f2d8
 
 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 f462b0e2a34..67917dac95d 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -11202,12 +11202,23 @@ Call_expression::do_lower(Gogo* gogo, Named_object* function,
 {
   Location loc = this->location();
 
+  if (this->is_error_expression())
+    return Expression::make_error(loc);
+
   // A type cast can look like a function call.
   if (this->fn_->is_type_expression()
       && this->args_ != NULL
       && this->args_->size() == 1)
-    return Expression::make_cast(this->fn_->type(), this->args_->front(),
-				 loc);
+    {
+      if (this->expected_result_count_ != 0
+	  && this->expected_result_count_ != 1)
+	{
+	  this->report_error(_("type conversion result count mismatch"));
+	  return Expression::make_error(loc);
+	}
+      return Expression::make_cast(this->fn_->type(), this->args_->front(),
+				   loc);
+    }
 
   // Because do_type will return an error type and thus prevent future
   // errors, check for that case now to ensure that the error gets


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-11  2:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-11  2:36 [gcc r12-2845] compiler: don't crash on a, b := int(0) 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).