You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutableRawPointer?'}}
308
+
309
+
char_ptr_func(x${Size})
310
+
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<CChar>' (aka 'UnsafeMutablePointer<Int8>')}}
311
+
opt_char_ptr_func(x${Size})
312
+
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<CChar>?' (aka 'Optional<UnsafeMutablePointer<Int8>>')}}
313
+
314
+
const_char_ptr_func(x${Size}) // Ok
315
+
const_opt_char_ptr_func(x${Size}) // Ok
316
+
317
+
int_${Size}_ptr_func(x${Size})
318
+
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<Int${Size}>'}}
319
+
uint_${Size}_ptr_func(x${Size})
320
+
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<UInt${Size}>'}}
321
+
322
+
opt_int_${Size}_ptr_func(x${Size})
323
+
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<Int${Size}>?'}}
324
+
opt_uint_${Size}_ptr_func(x${Size})
325
+
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<UInt${Size}>?'}}
// They currently raise a "cannot convert value" error because of
47
-
// the `UInt8` vs. `Int8` mismatch.
48
-
//
49
-
// If we decide to support these as bug-fixes for SE-0324, then the
50
-
// implicit inout-to-raw conversion should also accept them.
51
-
func test_se0324_accept(){
43
+
// Array<T> to C pointer conversion is supported under SE-0324
44
+
func test_array_to_c_pointer_concrete(){
52
45
letconstIntArray:[Int8]=[0]
53
-
read_uchar(constIntArray) // expected-error {{cannot convert value of type 'UnsafePointer<Int8>' to expected argument type 'UnsafePointer<UInt8>'}}
54
-
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('Int8' and 'UInt8') are expected to be equal}}
46
+
read_uchar(constIntArray)
55
47
56
48
letconstUIntArray:[UInt8]=[0]
57
-
read_char(constUIntArray) // expected-error {{cannot convert value of type 'UnsafePointer<UInt8>' to expected argument type 'UnsafePointer<CChar>' (aka 'UnsafePointer<Int8>')}}
58
-
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('UInt8' and 'CChar' (aka 'Int8')) are expected to be equal}}
49
+
read_char(constUIntArray)
59
50
60
-
varintArray:[Int8]=[0]
61
-
read_uchar(intArray) // expected-error {{cannot convert value of type 'UnsafePointer<Int8>' to expected argument type 'UnsafePointer<UInt8>'}}
62
-
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('Int8' and 'UInt8') are expected to be equal}}
51
+
varintArray:[Int8]=[0] // expected-warning {{variable 'intArray' was never mutated; consider changing to 'let' constant}}
52
+
read_uchar(intArray)
63
53
64
-
varuintArray:[UInt8]=[0]
65
-
read_char(uintArray) // expected-error {{cannot convert value of type 'UnsafePointer<UInt8>' to expected argument type 'UnsafePointer<CChar>' (aka 'UnsafePointer<Int8>')}}
66
-
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('UInt8' and 'CChar' (aka 'Int8')) are expected to be equal}}
54
+
varuintArray:[UInt8]=[0] // expected-warning {{variable 'uintArray' was never mutated; consider changing to 'let' constant}}
55
+
read_char(uintArray)
67
56
68
57
}
69
58
70
-
// These implicit casts should work according to
71
-
// SE-0324: Relax diagnostics for pointer arguments to C functions]
72
-
// They currently raise a "cannot convert value" error because of
73
-
// the `UInt8` vs. `Int8` mismatch.
74
-
//
75
-
// If we decide to support these as bug-fixes for SE-0324, then the
76
-
// implicit inout-to-raw conversion should issue a warning instead.
77
-
func test_se0324_error<T>(arg:T){
59
+
// Array<T> to C pointer conversion is supported under SE-0324
60
+
func test_array_to_c_pointer_generic<T>(arg:T){
78
61
letconstArray:[T]=[arg]
79
-
read_char(constArray) // expected-error {{cannot convert value of type 'UnsafePointer<T>' to expected argument type 'UnsafePointer<CChar>' (aka 'UnsafePointer<Int8>')}}
80
-
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('T' and 'CChar' (aka 'Int8')) are expected to be equal}}
81
-
read_uchar(constArray) // expected-error {{cannot convert value of type 'UnsafePointer<T>' to expected argument type 'UnsafePointer<UInt8>'}}
82
-
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('T' and 'UInt8') are expected to be equal}}
0 commit comments