|
| 1 | +// RUN: %target-swift-ide-test -Xcc -fexperimental-bounds-safety-attributes -print-module -module-to-print=BoundsAttributedFunction -I %S/Inputs -source-filename=x | %FileCheck %s --check-prefixes=CHECK,C-ONLY |
| 2 | +// RUN: %target-swift-ide-test -Xcc -fexperimental-bounds-safety-attributes -print-module -module-to-print=BoundsAttributedFunction -I %S/Inputs -source-filename=x -cxx-interoperability-mode=default | %FileCheck %s |
| 3 | +// RUN: %target-swift-ide-test -Xcc -fbounds-safety -disable-objc-interop -print-module -module-to-print=BoundsAttributedFunction -I %S/Inputs -source-filename=x | %FileCheck %s --check-prefixes=CHECK,BOUNDS-SAFETY,C-ONLY |
| 4 | + |
| 5 | +// This test case checks that ClangImporter can import declarations using various bounds attributes, |
| 6 | +// rather than being marked unavailable because of an unknown type. |
| 7 | + |
| 8 | +// CHECK: func a(_ p: UnsafeMutablePointer<Int{{[0-9]+}}>!, _ len: Int{{[0-9]+}}) -> UnsafeMutablePointer<Int{{[0-9]+}}>! |
| 9 | +// CHECK-NEXT: func b(_ p: UnsafeMutablePointer<CChar>!, _ len: Int{{[0-9]+}}) -> UnsafeMutablePointer<CChar>! |
| 10 | +// CHECK-NEXT: func c(_ p: UnsafeMutablePointer<CChar>!, _ len: Int{{[0-9]+}}) -> UnsafeMutablePointer<CChar>! |
| 11 | +// CHECK-NEXT: func d(_ p: UnsafeMutableRawPointer!, _ len: Int{{[0-9]+}}) -> UnsafeMutableRawPointer! |
| 12 | +// CHECK-NEXT: func e(_ p: UnsafeMutablePointer<Int{{[0-9]+}}>!, _ len: Int{{[0-9]+}}) -> UnsafeMutablePointer<Int{{[0-9]+}}>! |
| 13 | +// CHECK-NEXT: func f(_ p: UnsafeMutablePointer<Int{{[0-9]+}}>!, _ end: UnsafeMutablePointer<Int{{[0-9]+}}>!) -> UnsafeMutablePointer<Int{{[0-9]+}}>! |
| 14 | +// CHECK-NEXT: func g(_ p: UnsafeMutableRawPointer!, _ end: UnsafeMutableRawPointer!) -> UnsafeMutableRawPointer! |
| 15 | +// CHECK-NEXT: func h(_ p: UnsafeMutablePointer<CChar>!) -> UnsafeMutablePointer<CChar>! |
| 16 | +// CHECK-NEXT: func i(_ p: UnsafePointer<CChar>!) -> UnsafePointer<CChar>! |
| 17 | +// CHECK-NEXT: func j(_ p: UnsafeMutablePointer<CChar>!) -> UnsafeMutablePointer<CChar>! |
| 18 | +// CHECK-NEXT: func k(_ p: UnsafeMutableRawPointer!) -> UnsafeMutableRawPointer! |
| 19 | + |
| 20 | +// BOUNDS-SAFETY-NEXT: func l(_ p: UnsafeMutablePointer<CChar>!) -> UnsafeMutablePointer<CChar>! |
| 21 | +// BOUNDS-SAFETY-NEXT: func m(_ p: UnsafeMutableRawPointer!) -> UnsafeMutableRawPointer! |
| 22 | +// BOUNDS-SAFETY-NEXT: func n(_ p: UnsafeMutablePointer<CChar>!) -> UnsafeMutablePointer<CChar>! |
| 23 | +// BOUNDS-SAFETY-NEXT: func o(_ p: UnsafeMutableRawPointer!) -> UnsafeMutableRawPointer! |
| 24 | + |
| 25 | +// C-ONLY-NEXT: func p(_ len: Int{{[0-9]+}}, _ p: UnsafeMutablePointer<Int{{[0-9]+}}>!) |
| 26 | + |
| 27 | +// CHECK-NEXT: func q(_ p: UnsafeMutablePointer<Int{{[0-9]+}}>!, _ len: Int{{[0-9]+}}) |
| 28 | +// CHECK-NEXT: func r(_ p: UnsafeMutablePointer<UnsafeMutablePointer<Int{{[0-9]+}}>?>!, _ len: UnsafeMutablePointer<Int{{[0-9]+}}>!) |
| 29 | +// CHECK-NEXT: func s(_ p: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>!) -> UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>! |
| 30 | +// CHECK-NEXT: func t(_ p: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>!) -> UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>! |
| 31 | +// CHECK-NEXT: let len1: Int{{[0-9]+}} |
| 32 | +// CHECK-NEXT: func u(_ p: UnsafeMutablePointer<Int{{[0-9]+}}>!) -> UnsafeMutablePointer<Int{{[0-9]+}}>! |
| 33 | +// CHECK-NEXT: var len2: Int{{[0-9]+}} |
| 34 | +// CHECK-NEXT: func v(_ p: UnsafeMutablePointer<Int{{[0-9]+}}>!) -> UnsafeMutablePointer<Int{{[0-9]+}}>! |
| 35 | + |
| 36 | + |
| 37 | +// RUN: %target-swift-frontend -Xcc -fexperimental-bounds-safety-attributes -emit-module -plugin-path %swift-plugin-dir -I %S/Inputs %s -D C_ONLY |
| 38 | +// RUN: %target-swift-frontend -Xcc -fexperimental-bounds-safety-attributes -emit-module -plugin-path %swift-plugin-dir -I %S/Inputs %s -cxx-interoperability-mode=default |
| 39 | +// RUN: %target-swift-frontend -Xcc -fbounds-safety -disable-objc-interop -emit-module -plugin-path %swift-plugin-dir -I %S/Inputs %s -D C_ONLY -D BOUNDS_SAFETY |
| 40 | + |
| 41 | +import BoundsAttributedFunction |
| 42 | + |
| 43 | +func call(_ mutIntPtr: UnsafeMutablePointer<CInt>, |
| 44 | + _ mutCharPtr: UnsafeMutablePointer<CChar>, |
| 45 | + _ mutRawPtr: UnsafeMutableRawPointer, |
| 46 | + _ constCharPtr: UnsafePointer<CChar>, |
| 47 | + _ mutMutIntPtrPtr: UnsafeMutablePointer<UnsafeMutablePointer<CInt>?>!, |
| 48 | + _ mutMutCharPtrPtr: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>!, |
| 49 | + _ int: CInt, |
| 50 | + _ args: CVaListPointer) { |
| 51 | + let _ = a(mutIntPtr, int) |
| 52 | + let _ = b(mutCharPtr, int) |
| 53 | + let _ = c(mutCharPtr, int) |
| 54 | + let _ = d(mutRawPtr, int) |
| 55 | + let _ = e(mutIntPtr, int) |
| 56 | + let _ = f(mutIntPtr, mutIntPtr) |
| 57 | + let _ = g(mutRawPtr, mutRawPtr) |
| 58 | + let _ = h(mutCharPtr) |
| 59 | + let _ = i(constCharPtr) |
| 60 | + let _ = j(mutCharPtr) |
| 61 | + let _ = k(mutRawPtr) |
| 62 | + |
| 63 | +#if BOUNDS_SAFETY |
| 64 | + let _ = l(mutIntPtr) |
| 65 | + let _ = m(mutRawPtr) |
| 66 | + let _ = n(mutIntPtr) |
| 67 | + let _ = o(mutRawPtr) |
| 68 | +#endif |
| 69 | + |
| 70 | +#if C_ONLY |
| 71 | + let _ = p(int, mutIntPtr) |
| 72 | +#endif |
| 73 | + |
| 74 | + let _ = q(mutIntPtr, int) |
| 75 | + let _ = r(mutMutIntPtrPtr, mutIntPtr) |
| 76 | + let _ = s(mutMutCharPtrPtr) |
| 77 | + let _ = t(mutMutCharPtrPtr) |
| 78 | + let _ = len1 |
| 79 | + let _ = u(mutIntPtr) |
| 80 | + let _ = len2 |
| 81 | + len2 = 37 |
| 82 | + let _ = v(mutIntPtr) |
| 83 | + |
| 84 | + let _ = w(args) |
| 85 | +} |
0 commit comments