Fariborz Jahanian | ba96ffc | 2011-12-12 23:17:04 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -verify %s |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 2 | |
| 3 | // rdar://8843524 |
| 4 | |
| 5 | struct A { |
| 6 | id x; // expected-error {{ARC forbids Objective-C objects in structs or unions}} |
| 7 | }; |
| 8 | |
| 9 | union u { |
| 10 | id u; // expected-error {{ARC forbids Objective-C objects in structs or unions}} |
| 11 | }; |
| 12 | |
| 13 | @interface I { |
| 14 | struct A a; |
| 15 | struct B { |
| 16 | id y[10][20]; // expected-error {{ARC forbids Objective-C objects in structs or unions}} |
| 17 | id z; |
| 18 | } b; |
| 19 | |
| 20 | union u c; |
| 21 | }; |
| 22 | @end |
| 23 | |
Fariborz Jahanian | ba96ffc | 2011-12-12 23:17:04 +0000 | [diff] [blame^] | 24 | // rdar://10260525 |
| 25 | struct r10260525 { |
| 26 | id (^block) (); // expected-error {{ARC forbids blocks in structs or unions}} |
| 27 | }; |
| 28 | |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 29 | struct S { |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 30 | id __attribute__((objc_ownership(none))) i; |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 31 | void * vp; |
| 32 | int i1; |
| 33 | }; |
| 34 | |
| 35 | // rdar://9046528 |
| 36 | |
| 37 | @class NSError; |
| 38 | |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 39 | __autoreleasing id X; // expected-error {{global variables cannot have __autoreleasing ownership}} |
| 40 | __autoreleasing NSError *E; // expected-error {{global variables cannot have __autoreleasing ownership}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 41 | |
| 42 | |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 43 | extern id __autoreleasing X1; // expected-error {{global variables cannot have __autoreleasing ownership}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 44 | |
| 45 | void func() |
| 46 | { |
| 47 | id X; |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 48 | static id __autoreleasing X1; // expected-error {{global variables cannot have __autoreleasing ownership}} |
| 49 | extern id __autoreleasing E; // expected-error {{global variables cannot have __autoreleasing ownership}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 50 | |
| 51 | } |
| 52 | |
| 53 | // rdar://9157348 |
| 54 | |
| 55 | @interface J |
| 56 | @property (retain) id newFoo; // expected-note {{property declared here}} |
| 57 | @property (strong) id copyBar; // expected-note {{property declared here}} |
| 58 | @property (copy) id allocBaz; // expected-note {{property declared here}} |
| 59 | @property (copy, nonatomic) id new; |
| 60 | @end |
| 61 | |
| 62 | @implementation J |
| 63 | @synthesize newFoo; // expected-error {{property's synthesized getter follows Cocoa naming convention for returning}} |
| 64 | @synthesize copyBar; // expected-error {{property's synthesized getter follows Cocoa naming convention for returning}} |
| 65 | @synthesize allocBaz; // expected-error {{property's synthesized getter follows Cocoa naming convention for returning}} |
| 66 | @synthesize new; |
| 67 | - new {return 0; }; |
| 68 | @end |
| 69 | |
Fariborz Jahanian | 3240fe3 | 2011-09-27 22:35:36 +0000 | [diff] [blame] | 70 | |
| 71 | // rdar://10187884 |
| 72 | @interface Super |
| 73 | - (void)bar:(id)b; // expected-note {{parameter declared here}} |
| 74 | - (void)bar1:(id) __attribute((ns_consumed)) b; |
| 75 | - (void)ok:(id) __attribute((ns_consumed)) b; |
| 76 | - (id)ns_non; // expected-note {{method declared here}} |
| 77 | - (id)not_ret:(id) b __attribute((ns_returns_not_retained)); // expected-note {{method declared here}} |
| 78 | - (id)both__returns_not_retained:(id) b __attribute((ns_returns_not_retained)); |
| 79 | @end |
| 80 | |
| 81 | @interface Sub : Super |
| 82 | - (void)bar:(id) __attribute((ns_consumed)) b; // expected-error {{overriding method has mismatched ns_consumed attribute on its parameter}} |
| 83 | - (void)bar1:(id)b; |
| 84 | - (void)ok:(id) __attribute((ns_consumed)) b; |
| 85 | - (id)ns_non __attribute((ns_returns_not_retained)); // expected-error {{overriding method has mismatched ns_returns_not_retained attributes}} |
| 86 | - (id)not_ret:(id) b __attribute((ns_returns_retained)); // expected-error {{overriding method has mismatched ns_returns_retained attributes}} |
| 87 | - (id)both__returns_not_retained:(id) b __attribute((ns_returns_not_retained)); |
| 88 | @end |