John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-nonfragile-abi -verify %s |
| 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 | |
| 24 | struct S { |
Argyrios Kyrtzidis | cff00d9 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 25 | id __attribute__((objc_ownership(none))) i; |
John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 26 | void * vp; |
| 27 | int i1; |
| 28 | }; |
| 29 | |
| 30 | // rdar://9046528 |
| 31 | |
| 32 | @class NSError; |
| 33 | |
Argyrios Kyrtzidis | cff00d9 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 34 | __autoreleasing id X; // expected-error {{global variables cannot have __autoreleasing ownership}} |
| 35 | __autoreleasing NSError *E; // expected-error {{global variables cannot have __autoreleasing ownership}} |
John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 36 | |
| 37 | |
Argyrios Kyrtzidis | cff00d9 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 38 | extern id __autoreleasing X1; // expected-error {{global variables cannot have __autoreleasing ownership}} |
John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 39 | |
| 40 | void func() |
| 41 | { |
| 42 | id X; |
Argyrios Kyrtzidis | cff00d9 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 43 | static id __autoreleasing X1; // expected-error {{global variables cannot have __autoreleasing ownership}} |
| 44 | extern id __autoreleasing E; // expected-error {{global variables cannot have __autoreleasing ownership}} |
John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 45 | |
| 46 | } |
| 47 | |
| 48 | // rdar://9157348 |
| 49 | |
| 50 | @interface J |
| 51 | @property (retain) id newFoo; // expected-note {{property declared here}} |
| 52 | @property (strong) id copyBar; // expected-note {{property declared here}} |
| 53 | @property (copy) id allocBaz; // expected-note {{property declared here}} |
| 54 | @property (copy, nonatomic) id new; |
| 55 | @end |
| 56 | |
| 57 | @implementation J |
| 58 | @synthesize newFoo; // expected-error {{property's synthesized getter follows Cocoa naming convention for returning}} |
| 59 | @synthesize copyBar; // expected-error {{property's synthesized getter follows Cocoa naming convention for returning}} |
| 60 | @synthesize allocBaz; // expected-error {{property's synthesized getter follows Cocoa naming convention for returning}} |
| 61 | @synthesize new; |
| 62 | - new {return 0; }; |
| 63 | @end |
| 64 | |
Fariborz Jahanian | ac8dbf0 | 2011-09-27 22:35:36 +0000 | [diff] [blame^] | 65 | |
| 66 | // rdar://10187884 |
| 67 | @interface Super |
| 68 | - (void)bar:(id)b; // expected-note {{parameter declared here}} |
| 69 | - (void)bar1:(id) __attribute((ns_consumed)) b; |
| 70 | - (void)ok:(id) __attribute((ns_consumed)) b; |
| 71 | - (id)ns_non; // expected-note {{method declared here}} |
| 72 | - (id)not_ret:(id) b __attribute((ns_returns_not_retained)); // expected-note {{method declared here}} |
| 73 | - (id)both__returns_not_retained:(id) b __attribute((ns_returns_not_retained)); |
| 74 | @end |
| 75 | |
| 76 | @interface Sub : Super |
| 77 | - (void)bar:(id) __attribute((ns_consumed)) b; // expected-error {{overriding method has mismatched ns_consumed attribute on its parameter}} |
| 78 | - (void)bar1:(id)b; |
| 79 | - (void)ok:(id) __attribute((ns_consumed)) b; |
| 80 | - (id)ns_non __attribute((ns_returns_not_retained)); // expected-error {{overriding method has mismatched ns_returns_not_retained attributes}} |
| 81 | - (id)not_ret:(id) b __attribute((ns_returns_retained)); // expected-error {{overriding method has mismatched ns_returns_retained attributes}} |
| 82 | - (id)both__returns_not_retained:(id) b __attribute((ns_returns_not_retained)); |
| 83 | @end |