This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
go patch committed: Avoid double error on negative shift count
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org, gofrontend-dev at googlegroups dot com
- Date: Fri, 25 Mar 2011 12:23:26 -0700
- Subject: go patch committed: Avoid double error on negative shift count
This patch to the Go frontend avoids a double error when there is a
negative shift count. We used to give a negative shift count error
followed by an overflow error. This just gives the former.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.
Ian
diff -r 31aaf6e2aa75 go/expressions.cc
--- a/go/expressions.cc Fri Mar 25 10:32:02 2011 -0700
+++ b/go/expressions.cc Fri Mar 25 12:20:47 2011 -0700
@@ -5747,7 +5747,13 @@
if (this->right_->integer_constant_value(true, val, &type))
{
if (mpz_sgn(val) < 0)
- this->report_error(_("negative shift count"));
+ {
+ this->report_error(_("negative shift count"));
+ mpz_set_ui(val, 0);
+ source_location rloc = this->right_->location();
+ this->right_ = Expression::make_integer(&val, right_type,
+ rloc);
+ }
}
mpz_clear(val);
}