]> Cypherpunks.ru repositories - gostls13.git/blob - test/fixedbugs/issue34123.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / fixedbugs / issue34123.go
1 // run
2
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.
6
7 // Make sure that the line number is reported correctly
8 // for faulting instructions.
9
10 package main
11
12 import (
13         "fmt"
14         "runtime"
15 )
16
17 var x byte
18 var p *byte
19
20 //go:noinline
21 func f() {
22         q := p
23         x = 11  // line 23
24         *q = 12 // line 24
25 }
26 func main() {
27         defer func() {
28                 recover()
29                 var pcs [10]uintptr
30                 n := runtime.Callers(1, pcs[:])
31                 frames := runtime.CallersFrames(pcs[:n])
32                 for {
33                         f, more := frames.Next()
34                         if f.Function == "main.f" && f.Line != 24 {
35                                 panic(fmt.Errorf("expected line 24, got line %d", f.Line))
36                         }
37                         if !more {
38                                 break
39                         }
40                 }
41         }()
42         f()
43 }