blob: ec2e10fc067cdb9fc0e892e3b3d161409265ba2d [file] [log] [blame]
John McCall31168b02011-06-15 23:02:42 +00001// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-nonfragile-abi -verify %s
2
3// rdar://8843524
4
5struct A {
6 id x; // expected-error {{ARC forbids Objective-C objects in structs or unions}}
7};
8
9union 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
24struct S {
Argyrios Kyrtzidiscff00d92011-06-24 00:08:59 +000025 id __attribute__((objc_ownership(none))) i;
John McCall31168b02011-06-15 23:02:42 +000026 void * vp;
27 int i1;
28};
29
30// rdar://9046528
31
32@class NSError;
33
Argyrios Kyrtzidiscff00d92011-06-24 00:08:59 +000034__autoreleasing id X; // expected-error {{global variables cannot have __autoreleasing ownership}}
35__autoreleasing NSError *E; // expected-error {{global variables cannot have __autoreleasing ownership}}
John McCall31168b02011-06-15 23:02:42 +000036
37
Argyrios Kyrtzidiscff00d92011-06-24 00:08:59 +000038extern id __autoreleasing X1; // expected-error {{global variables cannot have __autoreleasing ownership}}
John McCall31168b02011-06-15 23:02:42 +000039
40void func()
41{
42 id X;
Argyrios Kyrtzidiscff00d92011-06-24 00:08:59 +000043 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 McCall31168b02011-06-15 23:02:42 +000045
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 Jahanianac8dbf02011-09-27 22:35:36 +000065
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