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
// However, trying to convert between @convention(c) functions
9
+
// with differing cTypes doesn't work.
10
+
11
+
let _ :@convention(c)(Int)->Int= f1!
12
+
// expected-error@-1{{cannot convert value of type '@convention(c, cType: "size_t (*)(size_t)") (Int) -> Int' to specified type '@convention(c) (Int) -> Int'}}
13
+
14
+
let _ :(@convention(c)(Int)->Int)?= f1
15
+
// expected-error@-1{{cannot convert value of type '(@convention(c, cType: "size_t (*)(size_t)") (Int) -> Int)?' to specified type '(@convention(c) (Int) -> Int)?'}}
16
+
17
+
let _ :(@convention(c, cType:"void *(*)(void *)")(Int)->Int)?= f1
18
+
// expected-error@-1{{cannot convert value of type '(@convention(c, cType: "size_t (*)(size_t)") (Int) -> Int)?' to specified type '(@convention(c, cType: "void *(*)(void *)") (Int) -> Int)?'}}
19
+
20
+
21
+
// Converting from @convention(c) -> @convention(swift) works
22
+
23
+
let _ :(Int)->Int=({ x in x }as@convention(c)(Int)->Int)
24
+
let _ :(Int)->Int=({ x in x }as@convention(c, cType:"size_t (*)(size_t)")(Int)->Int)
25
+
26
+
27
+
// Converting from @convention(swift) -> @convention(c) doesn't work.
28
+
29
+
letfs:(Int)->Int={ x in x }
30
+
31
+
let _ :@convention(c)(Int)->Int= fs
32
+
// expected-error@-1{{a C function pointer can only be formed from a reference to a 'func' or a literal closure}}
33
+
34
+
let _ :@convention(c, cType:"size_t (*)(size_t)")(Int)->Int= fs
35
+
// expected-error@-1{{a C function pointer can only be formed from a reference to a 'func' or a literal closure}}
0 commit comments