Skip to content

Commit 302d8ab

Browse files
Chris Manghaneianlancetaylor
authored andcommitted
compiler: Report errors for non-integral shift counts.
Fixes golang/go#12618. Change-Id: Ifb069bddad43f11ff2437a186b050d80a21e1c28 Reviewed-on: https://go-review.googlesource.com/14647 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent a4bcd31 commit 302d8ab

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

go/expressions.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5601,7 +5601,9 @@ Binary_expression::do_check_types(Gogo*)
56015601
if (left_type->integer_type() == NULL)
56025602
this->report_error(_("shift of non-integer operand"));
56035603

5604-
if (!right_type->is_abstract()
5604+
if (right_type->is_string_type())
5605+
this->report_error(_("shift count not unsigned integer"));
5606+
else if (!right_type->is_abstract()
56055607
&& (right_type->integer_type() == NULL
56065608
|| !right_type->integer_type()->is_unsigned()))
56075609
this->report_error(_("shift count not unsigned integer"));

0 commit comments

Comments
 (0)