diff mbox

Go patch committed: Don't allow constant shifts of non-integers

Message ID CAOyqgcXCw0jzQnG5VHHeG9Te=ZnPoG+2KZ_Dn+k4RLgRxcy9_A@mail.gmail.com
State New
Headers show

Commit Message

Ian Lance Taylor Sept. 10, 2015, 3:46 a.m. UTC
This patch by Chris Manghane fixes the Go frontend to not try to do a
constant shift of non-integer values.  This fixes
https://golang.org/issue/11616 .  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 227427)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@ 
-672ac2abc52d8bd70cb9fb03dd4a32fdde9c438f
+913b47c957ea91db2f724491d88cb20e8f9be8c7
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/expressions.cc
===================================================================
--- gcc/go/gofrontend/expressions.cc	(revision 227420)
+++ gcc/go/gofrontend/expressions.cc	(working copy)
@@ -4523,6 +4523,12 @@  Binary_expression::eval_constant(Operato
     return false;
   if (!is_shift && !right_nc->set_type(type, true, location))
     return false;
+  if (is_shift
+      && ((left_type->integer_type() == NULL
+           && !left_type->is_abstract())
+          || (right_type->integer_type() == NULL
+              && !right_type->is_abstract())))
+    return false;
 
   bool r;
   if (type->complex_type() != NULL)