xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/property-9.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuctypedef signed char BOOL;
4*f4a2713aSLionel Sambuc@protocol NSObject  - (BOOL)isEqual:(id)object; @end
5*f4a2713aSLionel Sambuc
6*f4a2713aSLionel Sambuc@interface NSObject <NSObject> {} @end
7*f4a2713aSLionel Sambuc
8*f4a2713aSLionel Sambuc@interface _NSServicesInContextMenu : NSObject {
9*f4a2713aSLionel Sambuc    id _requestor;
10*f4a2713aSLionel Sambuc    NSObject *_appleEventDescriptor;
11*f4a2713aSLionel Sambuc}
12*f4a2713aSLionel Sambuc
13*f4a2713aSLionel Sambuc@property (retain, nonatomic) id requestor;
14*f4a2713aSLionel Sambuc@property (retain, nonatomic) id appleEventDescriptor;
15*f4a2713aSLionel Sambuc
16*f4a2713aSLionel Sambuc@end
17*f4a2713aSLionel Sambuc
18*f4a2713aSLionel Sambuc@implementation _NSServicesInContextMenu
19*f4a2713aSLionel Sambuc
20*f4a2713aSLionel Sambuc@synthesize requestor = _requestor, appleEventDescriptor = _appleEventDescriptor;
21*f4a2713aSLionel Sambuc
22*f4a2713aSLionel Sambuc@end
23*f4a2713aSLionel Sambuc
24*f4a2713aSLionel Sambuc@class NSString;
25*f4a2713aSLionel Sambuc
26*f4a2713aSLionel Sambuc@protocol MyProtocol
27*f4a2713aSLionel Sambuc- (NSString *)stringValue;
28*f4a2713aSLionel Sambuc@end
29*f4a2713aSLionel Sambuc
30*f4a2713aSLionel Sambuc@interface MyClass : NSObject {
31*f4a2713aSLionel Sambuc  id  _myIvar;
32*f4a2713aSLionel Sambuc}
33*f4a2713aSLionel Sambuc@property (readwrite, retain) id<MyProtocol> myIvar;
34*f4a2713aSLionel Sambuc@end
35*f4a2713aSLionel Sambuc
36*f4a2713aSLionel Sambuc@implementation MyClass
37*f4a2713aSLionel Sambuc@synthesize myIvar = _myIvar;
38*f4a2713aSLionel Sambuc@end
39*f4a2713aSLionel Sambuc
40*f4a2713aSLionel Sambuc
41*f4a2713aSLionel Sambuc@interface BadPropClass
42*f4a2713aSLionel Sambuc{
43*f4a2713aSLionel Sambuc int _awesome;
44*f4a2713aSLionel Sambuc}
45*f4a2713aSLionel Sambuc
46*f4a2713aSLionel Sambuc@property (readonly) int; // expected-warning {{declaration does not declare anything}}
47*f4a2713aSLionel Sambuc@property (readonly) ; // expected-error {{type name requires a specifier or qualifier}}
48*f4a2713aSLionel Sambuc@property (readonly) int : 4; // expected-error {{property requires fields to be named}}
49*f4a2713aSLionel Sambuc
50*f4a2713aSLionel Sambuc
51*f4a2713aSLionel Sambuc// test parser recovery: rdar://6254579
52*f4a2713aSLionel Sambuc@property (                           // expected-note {{to match this '('}}
53*f4a2713aSLionel Sambuc           readonly getter=isAwesome) // expected-error {{expected ')'}}
54*f4a2713aSLionel Sambuc
55*f4a2713aSLionel Sambuc  int _awesome;
56*f4a2713aSLionel Sambuc@property (readonlyx) // expected-error {{unknown property attribute 'readonlyx'}}
57*f4a2713aSLionel Sambuc  int _awesome2;
58*f4a2713aSLionel Sambuc
59*f4a2713aSLionel Sambuc@property (    // expected-note {{to match this '('}}
60*f4a2713aSLionel Sambuc           +)  // expected-error {{expected ')'}}
61*f4a2713aSLionel Sambuc
62*f4a2713aSLionel Sambuc  int _awesome3;
63*f4a2713aSLionel Sambuc
64*f4a2713aSLionel Sambuc@end
65*f4a2713aSLionel Sambuc
66*f4a2713aSLionel Sambuc@protocol PVImageViewProtocol
67*f4a2713aSLionel Sambuc@property int inEyeDropperMode;
68*f4a2713aSLionel Sambuc@end
69*f4a2713aSLionel Sambuc
70*f4a2713aSLionel Sambuc@interface Cls
71*f4a2713aSLionel Sambuc@property int inEyeDropperMode;
72*f4a2713aSLionel Sambuc@end
73*f4a2713aSLionel Sambuc
74*f4a2713aSLionel Sambuc@interface PVAdjustColor @end
75*f4a2713aSLionel Sambuc
76*f4a2713aSLionel Sambuc@implementation PVAdjustColor
77*f4a2713aSLionel Sambuc
78*f4a2713aSLionel Sambuc- xx {
79*f4a2713aSLionel Sambuc  id <PVImageViewProtocol> view;
80*f4a2713aSLionel Sambuc  Cls *c;
81*f4a2713aSLionel Sambuc
82*f4a2713aSLionel Sambuc  c.inEyeDropperMode = 1;
83*f4a2713aSLionel Sambuc  view.inEyeDropperMode = 1;
84*f4a2713aSLionel Sambuc}
85*f4a2713aSLionel Sambuc@end
86*f4a2713aSLionel Sambuc
87*f4a2713aSLionel Sambuc// radar 7427072
88*f4a2713aSLionel Sambuc@interface MyStyleIntf
89*f4a2713aSLionel Sambuc{
90*f4a2713aSLionel Sambuc    int _myStyle;
91*f4a2713aSLionel Sambuc}
92*f4a2713aSLionel Sambuc
93*f4a2713aSLionel Sambuc@property(readonly) int myStyle;
94*f4a2713aSLionel Sambuc
95*f4a2713aSLionel Sambuc- (float)setMyStyle:(int)style;
96*f4a2713aSLionel Sambuc@end
97*f4a2713aSLionel Sambuc
98*f4a2713aSLionel Sambuc// rdar://8774513
99*f4a2713aSLionel Sambuc@class MDAInstance; // expected-note {{forward declaration of class here}}
100*f4a2713aSLionel Sambuc
101*f4a2713aSLionel Sambuc@interface MDATestDocument
102*f4a2713aSLionel Sambuc@property(retain) MDAInstance *instance;
103*f4a2713aSLionel Sambuc@end
104*f4a2713aSLionel Sambuc
105*f4a2713aSLionel Sambucid f0(MDATestDocument *d) {
106*f4a2713aSLionel Sambuc  return d.instance.path; // expected-error {{property 'path' cannot be found in forward class object 'MDAInstance'}}
107*f4a2713aSLionel Sambuc}
108*f4a2713aSLionel Sambuc
109