]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: add missing ast.SliceExpr.Max case to AST traversal.
authorAlan Donovan <adonovan@google.com>
Tue, 30 Sep 2014 20:08:04 +0000 (16:08 -0400)
committerAlan Donovan <adonovan@google.com>
Tue, 30 Sep 2014 20:08:04 +0000 (16:08 -0400)
+ 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

misc/cgo/test/basic.go
src/cmd/cgo/ast.go

index 79cbf2b9cf15e95057d776f33b4d4227cba13238..019139d01046247fa71684e1d0f4f3eed15e54d9 100644 (file)
@@ -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
+}
index 6c5a1608668f88a7592ced4223628f3ea9ffa77c..10e2278a1d61e2f8f2b16e97e1756ca981c84724 100644 (file)
@@ -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)