Skip to content

Commit

Permalink
compiler: Report errors for non-integral shift counts.
Browse files Browse the repository at this point in the history
Fixes golang/go#12618.

Change-Id: Ifb069bddad43f11ff2437a186b050d80a21e1c28
Reviewed-on: https://go-review.googlesource.com/14647
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
Chris Manghane authored and ianlancetaylor committed Oct 20, 2015
1 parent a4bcd31 commit 302d8ab
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion go/expressions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5601,7 +5601,9 @@ Binary_expression::do_check_types(Gogo*)
if (left_type->integer_type() == NULL)
this->report_error(_("shift of non-integer operand"));

if (!right_type->is_abstract()
if (right_type->is_string_type())
this->report_error(_("shift count not unsigned integer"));
else if (!right_type->is_abstract()
&& (right_type->integer_type() == NULL
|| !right_type->integer_type()->is_unsigned()))
this->report_error(_("shift count not unsigned integer"));
Expand Down

0 comments on commit 302d8ab

Please sign in to comment.