brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.8 KiB · f89c6be Raw
124 lines · plain
1// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fobjc-runtime=macosx-10.13.0 -fblocks -fobjc-arc -Wno-strict-prototypes %s -verify2// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fobjc-runtime=macosx-10.13.0 -fblocks -fobjc-arc -xobjective-c++ %s -verify3 4#define EXT_RET __attribute__((objc_externally_retained))5 6@interface ObjCTy7@end8 9void test1(void) {10  EXT_RET int a; // expected-warning{{'objc_externally_retained' can only be applied to}}11  EXT_RET __weak ObjCTy *b; // expected-warning{{'objc_externally_retained' can only be applied to}}12  EXT_RET __weak int (^c)(void); // expected-warning{{'objc_externally_retained' can only be applied to}}13 14  EXT_RET int (^d)(void) = ^{return 0;};15  EXT_RET ObjCTy *e = 0;16  EXT_RET __strong ObjCTy *f = 0;17 18  e = 0; // expected-error{{variable declared with 'objc_externally_retained' cannot be modified in ARC}}19  f = 0; // expected-error{{variable declared with 'objc_externally_retained' cannot be modified in ARC}}20  d = ^{ return 0; }; // expected-error{{variable declared with 'objc_externally_retained' cannot be modified in ARC}}21}22 23void test2(ObjCTy *a);24 25void test2(ObjCTy *a) EXT_RET {26  a = 0; // expected-error{{variable declared with 'objc_externally_retained' cannot be modified in ARC}}27}28 29EXT_RET ObjCTy *test3; // expected-warning{{'objc_externally_retained' can only be applied to}}30 31@interface X // expected-warning{{defined without specifying a base class}} expected-note{{add a super class}}32-(void)m: (ObjCTy *) p;33@end34@implementation X35-(void)m: (ObjCTy *) p EXT_RET {36  p = 0; // expected-error{{variable declared with 'objc_externally_retained' cannot be modified in ARC}}37}38@end39 40void test4(void) {41  __attribute__((objc_externally_retained(0))) ObjCTy *a; // expected-error{{'objc_externally_retained' attribute takes no arguments}}42}43 44void test5(ObjCTy *first, __strong ObjCTy *second) EXT_RET {45  first = 0; // expected-error{{variable declared with 'objc_externally_retained' cannot be modified in ARC}}46  second = 0; // fine47}48 49void test6(ObjCTy *first,50           __strong ObjCTy *second) EXT_RET {51  first = 0; // expected-error{{variable declared with 'objc_externally_retained' cannot be modified in ARC}}52  second = 0;53}54 55__attribute__((objc_root_class)) @interface Y @end56 57@implementation Y58- (void)test7:(__strong ObjCTy *)first59    withThird:(ObjCTy *)second EXT_RET {60  first = 0;61  second = 0; // expected-error{{variable declared with 'objc_externally_retained' cannot be modified in ARC}}62}63@end64 65void (^blk)(ObjCTy *, ObjCTy *) =66    ^(__strong ObjCTy *first, ObjCTy *second) EXT_RET {67  first = 0;68  second = 0; // expected-error{{variable declared with 'objc_externally_retained' cannot be modified in ARC}}69};70 71void (^blk2)(ObjCTy *, ObjCTy *) =72    ^(__strong ObjCTy *first, ObjCTy *second) __attribute__((objc_externally_retained)) {73  first = 0;74  second = 0; // expected-error{{variable declared with 'objc_externally_retained' cannot be modified in ARC}}75};76 77void test8(EXT_RET ObjCTy *x) {} // expected-warning{{'objc_externally_retained' attribute only applies to variables}}78 79#pragma clang attribute ext_ret.push(__attribute__((objc_externally_retained)), apply_to=any(function, block, objc_method))80void test9(ObjCTy *first, __strong ObjCTy *second) {81  first = 0; // expected-error{{variable declared with 'objc_externally_retained' cannot be modified in ARC}}82  second = 0;83}84void (^test10)(ObjCTy *first, ObjCTy *second) = ^(ObjCTy *first, __strong ObjCTy *second) {85  first = 0; // expected-error{{variable declared with 'objc_externally_retained' cannot be modified in ARC}}86  second = 0;87};88__attribute__((objc_root_class)) @interface Test11 @end89@implementation Test1190-(void)meth: (ObjCTy *)first withSecond:(__strong ObjCTy *)second {91  first = 0; // expected-error{{variable declared with 'objc_externally_retained' cannot be modified in ARC}}92  second = 0;93}94+(void)othermeth: (ObjCTy *)first withSecond:(__strong ObjCTy *)second {95  first = 0; // expected-error{{variable declared with 'objc_externally_retained' cannot be modified in ARC}}96  second = 0;97}98@end99 100#if __cplusplus101class Test12 {102  void inline_member(ObjCTy *first, __strong ObjCTy *second) {103    first = 0; // expected-error{{variable declared with 'objc_externally_retained' cannot be modified in ARC}}104    second = 0;105  }106  static void static_inline_member(ObjCTy *first, __strong ObjCTy *second) {107    first = 0; // expected-error{{variable declared with 'objc_externally_retained' cannot be modified in ARC}}108    second = 0;109  }110};111#endif112 113void test13(ObjCTy *first, __weak ObjCTy *second, __unsafe_unretained ObjCTy *third, __strong ObjCTy *fourth) {114  first = 0; // expected-error{{variable declared with 'objc_externally_retained' cannot be modified in ARC}}115  second = 0;116  third = 0;117  fourth = 0;118}119 120#pragma clang attribute ext_ret.pop121 122__attribute__((objc_externally_retained))123void unprototyped();124