mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add a new warning that detects when a function will call itself recursively on all code paths. Attempts to invoke functions like this may cause unbounded stack growth at least or undefined behavior in the worst cases. The detection code is implemented as DFS for a reachable exit path in a given SILFunction.
21 lines
394 B
Swift
21 lines
394 B
Swift
// RUN: %target-swift-frontend -emit-sil -primary-file %s -o /dev/null -verify
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
// A negative test that the infinite recursion pass doesn't diagnose dynamic
|
|
// dispatch.
|
|
|
|
import Foundation
|
|
|
|
class MyRecursiveClass {
|
|
required init() {}
|
|
@objc dynamic func foo() {
|
|
return type(of: self).foo(self)()
|
|
}
|
|
|
|
@objc dynamic func foo2() {
|
|
return self.foo()
|
|
}
|
|
}
|
|
|