diff options
author | Alan Donovan <adonovan@google.com> | 2014-09-30 16:08:04 -0400 |
---|---|---|
committer | Alan Donovan <adonovan@google.com> | 2014-09-30 16:08:04 -0400 |
commit | 74a642c5aad99f6d9f5c041eb2b14fac96eb1732 (patch) | |
tree | f4e98fca8f41d9aef1418c70b9bcba3441a923fe | |
parent | 9f22c8913d2ca1806b3ddcd6b64a81f21a577bc9 (diff) | |
download | go-74a642c5aad99f6d9f5c041eb2b14fac96eb1732.tar.gz |
cmd/cgo: add missing ast.SliceExpr.Max case to AST traversal.
+ static test
NB: there's a preexisting (dynamic) failure of test issue7978.go.
LGTM=iant
R=rsc, iant
CC=golang-codereviews
https://codereview.appspot.com/144650045
-rw-r--r-- | misc/cgo/test/basic.go | 5 | ||||
-rw-r--r-- | src/cmd/cgo/ast.go | 3 |
2 files changed, 8 insertions, 0 deletions
diff --git a/misc/cgo/test/basic.go b/misc/cgo/test/basic.go index 79cbf2b9c..019139d01 100644 --- a/misc/cgo/test/basic.go +++ b/misc/cgo/test/basic.go @@ -157,3 +157,8 @@ func testUnsignedInt(t *testing.T) { t.Errorf("Incorrect unsigned int - got %x, want %x", a, b) } } + +// Static (build-time) test that syntax traversal visits all operands of s[i:j:k]. +func sliceOperands(array [2000]int) { + _ = array[C.KILO:C.KILO:C.KILO] // no type error +} diff --git a/src/cmd/cgo/ast.go b/src/cmd/cgo/ast.go index 6c5a16086..10e2278a1 100644 --- a/src/cmd/cgo/ast.go +++ b/src/cmd/cgo/ast.go @@ -308,6 +308,9 @@ func (f *File) walk(x interface{}, context string, visit func(*File, interface{} if n.High != nil { f.walk(&n.High, "expr", visit) } + if n.Max != nil { + f.walk(&n.Max, "expr", visit) + } case *ast.TypeAssertExpr: f.walk(&n.X, "expr", visit) f.walk(&n.Type, "type", visit) |