mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +00:00
cmd/compile: don't crash on (unsafe.Sizeof)(0)
Fixes #17270. Change-Id: I4affa57e10baf1a758bc0977265d160f220b2945 Reviewed-on: https://go-review.googlesource.com/29960 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
4d07d3e29c
commit
03a1dc3522
@ -1185,11 +1185,12 @@ OpSwitch:
|
|||||||
|
|
||||||
// call and call like
|
// call and call like
|
||||||
case OCALL:
|
case OCALL:
|
||||||
|
n.Left = typecheck(n.Left, Erv|Etype|Ecall)
|
||||||
|
n.Diag |= n.Left.Diag
|
||||||
l := n.Left
|
l := n.Left
|
||||||
|
|
||||||
if l.Op == ONAME {
|
if l.Op == ONAME {
|
||||||
r := unsafenmagic(n)
|
if r := unsafenmagic(n); r != nil {
|
||||||
if r != nil {
|
|
||||||
if n.Isddd {
|
if n.Isddd {
|
||||||
yyerror("invalid use of ... with builtin %v", l)
|
yyerror("invalid use of ... with builtin %v", l)
|
||||||
}
|
}
|
||||||
@ -1197,12 +1198,8 @@ OpSwitch:
|
|||||||
n = typecheck1(n, top)
|
n = typecheck1(n, top)
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
n.Left = typecheck(n.Left, Erv|Etype|Ecall)
|
if l.Etype != 0 {
|
||||||
n.Diag |= n.Left.Diag
|
|
||||||
l = n.Left
|
|
||||||
if l.Op == ONAME && l.Etype != 0 {
|
|
||||||
// TODO(marvin): Fix Node.EType type union.
|
// TODO(marvin): Fix Node.EType type union.
|
||||||
if n.Isddd && Op(l.Etype) != OAPPEND {
|
if n.Isddd && Op(l.Etype) != OAPPEND {
|
||||||
yyerror("invalid use of ... with builtin %v", l)
|
yyerror("invalid use of ... with builtin %v", l)
|
||||||
@ -1217,6 +1214,7 @@ OpSwitch:
|
|||||||
n = typecheck1(n, top)
|
n = typecheck1(n, top)
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
n.Left = defaultlit(n.Left, nil)
|
n.Left = defaultlit(n.Left, nil)
|
||||||
l = n.Left
|
l = n.Left
|
||||||
|
11
test/fixedbugs/issue17270.go
Normal file
11
test/fixedbugs/issue17270.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// compile
|
||||||
|
|
||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package p
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
const _ = (unsafe.Sizeof)(0)
|
Loading…
x
Reference in New Issue
Block a user