brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 867f4a6 Raw
71 lines · plain
1// RUN: %clang_cc1 -x objective-c -Wno-objc-root-class -fms-extensions -rewrite-objc %s -o %t-rw.cpp2// RUN: FileCheck  --input-file=%t-rw.cpp %s3 4typedef struct MyWidget {5  int a;6} MyWidget;7 8MyWidget gWidget = { 17 };9 10@protocol MyProto11- (MyWidget *)widget;12@end13 14@interface Foo 15@end16 17@interface Bar: Foo <MyProto>18@end19 20@interface Container 21+ (MyWidget *)elementForView:(Foo *)view;22@end23 24@implementation Foo25@end26 27@implementation Bar28- (MyWidget *)widget {29  return &gWidget;30}31@end32 33@implementation Container34+ (MyWidget *)elementForView:(Foo *)view35{36  MyWidget *widget = (void*)0;37  if (@protocol(MyProto)) {38    widget = [(id <MyProto>)view widget];39  }40  return widget;41}42@end43 44int main(void) {45  id view;46  MyWidget *w = [Container elementForView: view];47 48  return 0;49}50 51@class NSObject;52 53@interface NSProtocolChecker54+ (id)protocolCheckerWithTarget:(NSObject *)anObject protocol:(Protocol *)aProtocol;55@end56 57@protocol NSConnectionVersionedProtocol58@end59 60 61@interface NSConnection @end62 63@implementation NSConnection64- (void) Meth {65  [NSProtocolChecker protocolCheckerWithTarget:0 protocol:@protocol(NSConnectionVersionedProtocol)];66}67@end68 69// CHECK: static struct _protocol_t *_OBJC_PROTOCOL_REFERENCE_$_NSConnectionVersionedProtocol = &_OBJC_PROTOCOL_NSConnectionVersionedProtocol70// CHECK: sel_registerName("protocolCheckerWithTarget:protocol:"), (NSObject *)0, (Protocol *)_OBJC_PROTOCOL_REFERENCE_$_NSConnectionVersionedProtocol71