Patchwork Go patch committed: Better error message for invalid shifts

login
register
mail settings
Submitter Ian Taylor
Date Dec. 14, 2012, 3:02 p.m.
Message ID <mcrpq2cd6dq.fsf@google.com>
Download mbox | patch
Permalink /patch/206514/
State New
Headers show

Comments

Ian Taylor - Dec. 14, 2012, 3:02 p.m.
My understanding of shifts of constants in Go has improved.  This patch
more accurately reflects the language spec when it comes to reporting
errors for invalid shifts.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

diff -r 9be532343312 go/expressions.cc
--- a/go/expressions.cc	Thu Dec 13 14:14:53 2012 -0800
+++ b/go/expressions.cc	Fri Dec 14 06:45:18 2012 -0800
@@ -5463,13 +5463,10 @@ 
       // Give a useful error if that happened.
       if (tleft->is_abstract()
 	  && subcontext.type != NULL
-	  && (this->left_->type()->integer_type() == NULL
-	      || (subcontext.type->integer_type() == NULL
-		  && subcontext.type->float_type() == NULL
-		  && subcontext.type->complex_type() == NULL
-		  && subcontext.type->interface_type() == NULL)))
+	  && !subcontext.may_be_abstract
+	  && subcontext.type->integer_type() == NULL)
 	this->report_error(("invalid context-determined non-integer type "
-			    "for shift operand"));
+			    "for left operand of shift"));
 
       // The context for the right hand operand is the same as for the
       // left hand operand, except for a shift operator.