Skip to content

Commit

Permalink
cmd/cgo: add missing ast.SliceExpr.Max case to AST traversal.
Browse files Browse the repository at this point in the history
+ static test

NB: there's a preexisting (dynamic) failure of test issue7978.go.

LGTM=iant
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/144650045
  • Loading branch information
adonovan committed Sep 30, 2014
1 parent 146713b commit 74b8693
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions misc/cgo/test/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 3 additions & 0 deletions src/cmd/cgo/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 74b8693

Please sign in to comment.