]> Cypherpunks repositories - gostls13.git/commitdiff
half of bug193
authorRuss Cox <rsc@golang.org>
Mon, 24 Aug 2009 01:09:44 +0000 (18:09 -0700)
committerRuss Cox <rsc@golang.org>
Mon, 24 Aug 2009 01:09:44 +0000 (18:09 -0700)
R=ken
OCL=33730
CL=33730

src/cmd/gc/const.c
src/cmd/gc/typecheck.c
test/golden.out

index 6beacab6d1e8d902d06adc27b556ba2161bfea4f..d774773a4378473277fbf051cef772dddc5754f3 100644 (file)
@@ -100,7 +100,12 @@ convlit1(Node **np, Type *t, int explicit)
        case OLSH:
        case ORSH:
                convlit(&n->left, t);
-               n->type = n->left->type;
+               t = n->left->type;
+               if(t != T && !isint[t->etype]) {
+                       yyerror("invalid operation: %#N (shift of type %T)", n, t);
+                       t = T;
+               }
+               n->type = t;
                return;
        }
        // avoided repeated calculations, errors
@@ -728,7 +733,12 @@ defaultlit(Node **np, Type *t)
        case OLSH:
        case ORSH:
                defaultlit(&n->left, t);
-               n->type = n->left->type;
+               t = n->left->type;
+               if(t != T && !isint[t->etype]) {
+                       yyerror("invalid operation: %#N (shift of type %T)", n, t);
+                       t = T;
+               }
+               n->type = t;
                return;
        default:
                defaultlit(&n->left, t);
index fba107f8b3d4a5cfc1fa60e9c6efa9f736d873b8..8c76ebb8371aafb664a35761b880210b5f42d9d2 100644 (file)
@@ -335,6 +335,11 @@ reswitch:
                        yyerror("invalid operation: %#N (shift count type %T)", n, r->type);
                        goto error;
                }
+               t = l->type;
+               if(t != T && t->etype != TIDEAL && !isint[t->etype]) {
+                       yyerror("invalid operation: %#N (shift of type %T)", n, t);
+                       goto error;
+               }
                // no defaultlit for left
                // the outer context gives the type
                n->type = l->type;
index eedbcb2f114eb1623afdeb8b09cf27099c1bc1b1..c1a6092e678ee7febdd6f1ccc58ccd8371d655c7 100644 (file)
@@ -170,9 +170,7 @@ bugs/bug190.go:15: invalid recursive type func(S) (S)
 BUG: should compile
 
 =========== bugs/bug193.go
-BUG: errchk: bugs/bug193.go:13: error message does not match 'shift'
-bugs/bug193.go:13: fatal error: optoas: no entry LSH-float
-errchk: bugs/bug193.go:14: missing expected error: 'shift'
+BUG: errchk: bugs/bug193.go:14: missing expected error: 'shift'
 
 =========== bugs/bug194.go
 bugs/bug194.go:15: array index must be non-negative integer constant