|
| 1 | +// RUN: not %target-swift-frontend -swift-version 3 -typecheck %s 2>&1 | %FileCheck -check-prefix=CHECK-3 -check-prefix=CHECK-%target-runtime-3 %s |
| 2 | +// RUN: not %target-swift-frontend -swift-version 4 -typecheck %s 2>&1 | %FileCheck -check-prefix=CHECK-4 -check-prefix=CHECK-%target-runtime-4 %s |
| 3 | + |
| 4 | +#if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) |
| 5 | + import Darwin |
| 6 | +#else |
| 7 | + import Glibc |
| 8 | +#endif |
| 9 | + |
| 10 | +func test() { |
| 11 | + let _: Int = strxfrm |
| 12 | + // CHECK-3: [[@LINE-1]]:16: error: cannot convert value of type '({{.+}}) -> UInt'{{( [(]aka .+[)])?}} to specified type 'Int' |
| 13 | + // CHECK-4: [[@LINE-2]]:16: error: cannot convert value of type '({{.+}}) -> Int'{{( [(]aka .+[)])?}} to specified type 'Int' |
| 14 | + |
| 15 | + let _: Int = strcspn |
| 16 | + // CHECK-3: [[@LINE-1]]:16: error: cannot convert value of type '({{.+}}) -> UInt'{{( [(]aka .+[)])?}} to specified type 'Int' |
| 17 | + // CHECK-4: [[@LINE-2]]:16: error: cannot convert value of type '({{.+}}) -> Int'{{( [(]aka .+[)])?}} to specified type 'Int' |
| 18 | + |
| 19 | + let _: Int = strspn |
| 20 | + // CHECK-3: [[@LINE-1]]:16: error: cannot convert value of type '({{.+}}) -> UInt'{{( [(]aka .+[)])?}} to specified type 'Int' |
| 21 | + // CHECK-4: [[@LINE-2]]:16: error: cannot convert value of type '({{.+}}) -> Int'{{( [(]aka .+[)])?}} to specified type 'Int' |
| 22 | + |
| 23 | + let _: Int = strlen |
| 24 | + // CHECK-3: [[@LINE-1]]:16: error: cannot convert value of type '({{.+}}) -> UInt'{{( [(]aka .+[)])?}} to specified type 'Int' |
| 25 | + // CHECK-4: [[@LINE-2]]:16: error: cannot convert value of type '({{.+}}) -> Int'{{( [(]aka .+[)])?}} to specified type 'Int' |
| 26 | +} |
| 27 | + |
| 28 | +// These functions aren't consistently available across platforms, so only |
| 29 | +// test for them on Apple platforms. |
| 30 | +func testApple() { |
| 31 | + let _: Int = strlcpy |
| 32 | + // CHECK-objc-3: [[@LINE-1]]:16: error: cannot convert value of type '({{.+}}) -> UInt'{{( [(]aka .+[)])?}} to specified type 'Int' |
| 33 | + // CHECK-objc-4: [[@LINE-2]]:16: error: cannot convert value of type '({{.+}}) -> Int'{{( [(]aka .+[)])?}} to specified type 'Int' |
| 34 | + |
| 35 | + let _: Int = strlcat |
| 36 | + // CHECK-objc-3: [[@LINE-1]]:16: error: cannot convert value of type '({{.+}}) -> UInt'{{( [(]aka .+[)])?}} to specified type 'Int' |
| 37 | + // CHECK-objc-4: [[@LINE-2]]:16: error: cannot convert value of type '({{.+}}) -> Int'{{( [(]aka .+[)])?}} to specified type 'Int' |
| 38 | + |
| 39 | + // wcslen is different: it wasn't a builtin until Swift 4, and so its return |
| 40 | + // type has always been 'Int'. |
| 41 | + let _: Int = wcslen |
| 42 | + // CHECK-objc-3: [[@LINE-1]]:16: error: cannot convert value of type '({{.+}}) -> Int'{{( [(]aka .+[)])?}} to specified type 'Int' |
| 43 | + // CHECK-objc-4: [[@LINE-2]]:16: error: cannot convert value of type '({{.+}}) -> Int'{{( [(]aka .+[)])?}} to specified type 'Int' |
| 44 | +} |
0 commit comments