]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
compiler: don't crash on a, b := int(0)
authorIan Lance Taylor <iant@golang.org>
Tue, 10 Aug 2021 23:13:01 +0000 (16:13 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 11 Aug 2021 02:36:15 +0000 (19:36 -0700)
Fixes PR go/101851

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

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

index b983fdab35c0793621a98430b8e67a0c20b5acdf..be092de568b18c53ba492ca77ebb8f1801b54d9b 100644 (file)
@@ -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.
index f462b0e2a34f86f57ad28ab5d3889b1475e17726..67917dac95d8e95495283fae50d8b64570715cde 100644 (file)
@@ -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