brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 842d2a1 Raw
59 lines · plain
1// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -verify %s -fobjc-arc2//3// These tests exist as a means to help ensure that diagnostics aren't printed4// in overload resolution in ObjC.5 6struct Type1 { int a; };7typedef const __attribute__((objc_bridge(id))) void * CFTypeRef;8@interface Iface1 @end9 10@interface NeverCalled11- (void) test:(struct Type1 *)arg;12- (void) test2:(CFTypeRef)arg;13@end14 15@interface TakesIface116- (void) test:(Iface1 *)arg;17- (void) test2:(Iface1 *)arg;18@end19 20// PR2608521void 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 NeverCalledv229- (void) testStr:(NSString *)arg;30@end31 32@interface TakesVanillaConstChar33- (void) testStr:(const void *)a;34@end35 36// Not called out explicitly by PR26085, but related.37void testTakesNSString(id x) {38  // Overload resolution should not emit a diagnostic about needing to add an39  // '@' before "someStringLiteral".40  [x testStr:"someStringLiteral"];41}42 43id CreateSomething(void);44 45@interface TakesCFTypeRef46- (void) testCFTypeRef:(CFTypeRef)arg;47@end48 49@interface NeverCalledv350- (void) testCFTypeRef:(struct Type1 *)arg;51@end52 53// Not called out explicitly by PR26085, but related.54void 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