1 // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -verify %s -fobjc-arc 2 // 3 // These tests exist as a means to help ensure that diagnostics aren't printed 4 // in overload resolution in ObjC. 5 6 struct Type1 { int a; }; 7 typedef const __attribute__((objc_bridge(id))) void * CFTypeRef; 8 @interface Iface1 @end 9 10 @interface NeverCalled 11 - (void) test:(struct Type1 *)arg; 12 - (void) test2:(CFTypeRef)arg; 13 @end 14 15 @interface TakesIface1 16 - (void) test:(Iface1 *)arg; 17 - (void) test2:(Iface1 *)arg; 18 @end 19 20 // PR26085, rdar://problem/24111333 21 void testTakesIface1(id x, Iface1 *arg) { 22 // This should resolve silently to `TakesIface1`. 23 [x test:arg]; 24 [x test2:arg]; 25 } 26 27 @class NSString; 28 @interface NeverCalledv2 29 - (void) testStr:(NSString *)arg; 30 @end 31 32 @interface TakesVanillaConstChar 33 - (void) testStr:(const void *)a; 34 @end 35 36 // Not called out explicitly by PR26085, but related. 37 void testTakesNSString(id x) { 38 // Overload resolution should not emit a diagnostic about needing to add an 39 // '@' before "someStringLiteral". 40 [x testStr:"someStringLiteral"]; 41 } 42 43 id CreateSomething(); 44 45 @interface TakesCFTypeRef 46 - (void) testCFTypeRef:(CFTypeRef)arg; 47 @end 48 49 @interface NeverCalledv3 50 - (void) testCFTypeRef:(struct Type1 *)arg; 51 @end 52 53 // Not called out explicitly by PR26085, but related. 54 void testTakesCFTypeRef(id x) { 55 // Overload resolution should occur silently, select the CFTypeRef overload, 56 // and produce a single complaint. (with notes) 57 [x testCFTypeRef:CreateSomething()]; // expected-error{{implicit conversion of Objective-C pointer type 'id' to C pointer type 'CFTypeRef'}} expected-note{{use __bridge}} expected-note{{use __bridge_retained}} 58 } 59