Go patch committed: Fix shift type determination

Submitted by Ian Lance Taylor on Aug. 9, 2017, 9:24 p.m.

Details

Message ID CAOyqgcVa5UrphXyRTXqSSeH99LdoreiotjhUg0wN8mqpFbEQYg@mail.gmail.com
State New
Headers show

Commit Message

Ian Lance Taylor Aug. 9, 2017, 9:24 p.m.
In Go it's possible to construct an lshift expression using
unsafe.Sizeof that is technically a compile-time constant but can't be
evaluated without going through backend methods.  This patch by Than
McIntosh ensures that in this case Type::make_non_abstract_type is
called on the numeric operand of the shift (as opposed to leaving as
abstract), to avoid an assert later on in the compiler flow.  This
fixes https://golang.org/issue/21372.  Bootstrapped and ran Go
testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian

Patch hide | download patch | download mbox

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 250992)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@ 
-5fd112e5c2968e94761c41519c451d789e23a92b
+480fdfa9dd416bd17115a94fa6021c4dd805fc39
 
 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 250873)
+++ gcc/go/gofrontend/expressions.cc	(working copy)
@@ -5655,7 +5655,7 @@  Binary_expression::do_determine_type(con
 
   Type_context subcontext(*context);
 
-  if (is_constant_expr)
+  if (is_constant_expr && !is_shift_op)
     {
       subcontext.type = NULL;
       subcontext.may_be_abstract = true;