fix #965
This commit is contained in:
@@ -60,11 +60,14 @@ func findLoop(states []*blockState, path []int, from, iblk int) []int {
|
||||
path = append(path, iblk)
|
||||
self := states[iblk]
|
||||
for _, succ := range self.succs {
|
||||
if states[succ].fdel {
|
||||
if s := states[succ]; s.fdel || s.loop {
|
||||
continue
|
||||
}
|
||||
if pos := find(path, succ); pos >= 0 {
|
||||
if pos > 0 {
|
||||
for _, i := range path[pos:] { // mark inner loop
|
||||
states[i].loop = true
|
||||
}
|
||||
continue
|
||||
}
|
||||
for _, i := range path {
|
||||
@@ -72,6 +75,11 @@ func findLoop(states []*blockState, path []int, from, iblk int) []int {
|
||||
s.loop = true
|
||||
s.fdel = true
|
||||
}
|
||||
for _, s := range states { // clear inner loop mark
|
||||
if !s.fdel {
|
||||
s.loop = false
|
||||
}
|
||||
}
|
||||
return path
|
||||
}
|
||||
if ret := findLoop(states, path, from, succ); len(ret) > 0 {
|
||||
|
||||
@@ -44,6 +44,9 @@ func TestTestdefer(t *testing.T) {
|
||||
if strings.HasPrefix(name, "firstloop") {
|
||||
return "Loop"
|
||||
}
|
||||
if strings.HasPrefix(name, "gobuild") {
|
||||
return "Import"
|
||||
}
|
||||
return "main"
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user