Go patch committed: No error for interface type of shift

Submitted by Ian Taylor on Sept. 22, 2012, 6:33 a.m.

Details

Message ID mcrmx0io9bx.fsf@google.com
State New
Headers show

Commit Message

Ian Taylor Sept. 22, 2012, 6:33 a.m.
In Go if the type of the left operand a shift operand must be determined
from context, it gets the type of the overall expression, ignoring the
type of the right operand.  It is then an error if it does not get a
integral type.  However, it is also OK if it gets an interface type.
The compiler was incorrectly giving an error in that case.  This patch
fixes the problem.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline and 4.7 branch.

Ian

Patch hide | download patch | download mbox

diff -r c972277cb9d2 go/expressions.cc
--- a/go/expressions.cc	Fri Sep 21 23:03:46 2012 -0700
+++ b/go/expressions.cc	Fri Sep 21 23:21:06 2012 -0700
@@ -5453,7 +5453,8 @@ 
 	  && (this->left_->type()->integer_type() == NULL
 	      || (subcontext.type->integer_type() == NULL
 		  && subcontext.type->float_type() == NULL
-		  && subcontext.type->complex_type() == NULL)))
+		  && subcontext.type->complex_type() == NULL
+		  && subcontext.type->interface_type() == NULL)))
 	this->report_error(("invalid context-determined non-integer type "
 			    "for shift operand"));