From patchwork Fri Mar 25 19:23:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 88410 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 10FF01007D2 for ; Sat, 26 Mar 2011 06:23:39 +1100 (EST) Received: (qmail 7099 invoked by alias); 25 Mar 2011 19:23:38 -0000 Received: (qmail 7088 invoked by uid 22791); 25 Mar 2011 19:23:37 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 25 Mar 2011 19:23:32 +0000 Received: from hpaq6.eem.corp.google.com (hpaq6.eem.corp.google.com [172.25.149.6]) by smtp-out.google.com with ESMTP id p2PJNUdg032607 for ; Fri, 25 Mar 2011 12:23:31 -0700 Received: from iwr19 (iwr19.prod.google.com [10.241.69.83]) by hpaq6.eem.corp.google.com with ESMTP id p2PJNSPF023078 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Fri, 25 Mar 2011 12:23:29 -0700 Received: by iwr19 with SMTP id 19so1870961iwr.21 for ; Fri, 25 Mar 2011 12:23:28 -0700 (PDT) Received: by 10.231.23.129 with SMTP id r1mr1197563ibb.30.1301081008439; Fri, 25 Mar 2011 12:23:28 -0700 (PDT) Received: from coign.google.com (dhcp-172-22-127-165.mtv.corp.google.com [172.22.127.165]) by mx.google.com with ESMTPS id g17sm836906ibb.6.2011.03.25.12.23.27 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 25 Mar 2011 12:23:27 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: go patch committed: Avoid double error on negative shift count Date: Fri, 25 Mar 2011 12:23:26 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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); }