3 // Copyright 2019 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Make sure that in code involving indexing, the bounds
8 // check always fails at the line number of the '[' token.
18 type T struct{ a, b, c, d, e int } // unSSAable
23 sink = a /*line :999999:1*/ [ /*line :100:1*/ i]
27 sink = a /*line :999999:1*/ [ /*line :200:1*/ i]
31 sink = a /*line :999999:1*/ [ /*line :300:1*/ i]
35 a /*line :999999:1*/ [ /*line :400:1*/ i] = 1
39 a /*line :999999:1*/ [ /*line :500:1*/ i] = 1
43 a /*line :999999:1*/ [ /*line :600:1*/ i] = 1
48 sinkT = a /*line :999999:1*/ [ /*line :700:1*/ i]
52 sinkT = a /*line :999999:1*/ [ /*line :800:1*/ i]
56 a /*line :999999:1*/ [ /*line :900:1*/ i] = T{}
60 a /*line :999999:1*/ [ /*line :1000:1*/ i] = T{}
65 sinkS = a /*line :999999:1*/ [ /*line :1100:1*/ i:]
69 sinkS = a /*line :999999:1*/ [ /*line :1200:1*/ i:]
73 sinkS = a /*line :999999:1*/ [: /*line :1300:1*/ i]
77 sinkS = a /*line :999999:1*/ [: /*line :1400:1*/ i]
82 sinkST = a /*line :999999:1*/ [ /*line :1500:1*/ i:]
86 sinkST = a /*line :999999:1*/ [ /*line :1600:1*/ i:]
90 sinkST = a /*line :999999:1*/ [: /*line :1700:1*/ i]
94 sinkST = a /*line :999999:1*/ [: /*line :1800:1*/ i]
99 sinkB = s /*line :999999:1*/ [ /*line :1900:1*/ i]
103 sinkStr = s /*line :999999:1*/ [ /*line :2000:1*/ i:]
107 sinkStr = s /*line :999999:1*/ [: /*line :2100:1*/ i]
125 func shouldPanic(f func()) {
127 if recover() == nil {
128 panic("did not panic")
131 n := runtime.Callers(1, pcs[:])
132 iter := runtime.CallersFrames(pcs[:n])
135 frame, more := iter.Next()
136 buf += fmt.Sprintf("%s:%d %s\n", frame.File, frame.Line, frame.Function)
141 if !strings.Contains(buf, "999999") {
142 fmt.Printf("could not find marker line in traceback:\n%s\n", buf)