1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
3 @interface NSArray @end
5 @interface NSMutableArray : NSArray @end
9 NSMutableArray * _array;
12 @property (readonly) NSMutableArray * array;
18 @property (readwrite, retain) NSMutableArray * array;
22 @implementation MyClass
24 @synthesize array=_array;
36 TCPPObject(const TCPPObject& inObj);
39 TCPPObject& operator=(const TCPPObject& inObj); // expected-note {{'operator=' declared here}}
47 Trivial(const Trivial& inObj);
57 TCPPObject _cppObject;
58 TCPPObject _ncppObject;
61 @property (assign, readwrite) const TCPPObject& cppObject;
62 @property (assign, readwrite, nonatomic) const TCPPObject& ncppObject;
63 @property (assign, readwrite) const Trivial& tcppObject;
66 @implementation MyDocument
68 @synthesize cppObject = _cppObject; // expected-error {{atomic property of reference type 'const TCPPObject &' cannot have non-trivial assignment operator}}
69 @synthesize ncppObject = _ncppObject;
71 @synthesize tcppObject = _tcppObject;
74 struct IncompleteStruct; // expected-note 2 {{forward declaration of 'IncompleteStruct'}}
75 struct ConvertToIncomplete { operator IncompleteStruct&(); };
76 @interface SynthIncompleteRef
77 @property (readonly, nonatomic) IncompleteStruct& x; // expected-note {{property declared here}}
78 @property (readonly, nonatomic) IncompleteStruct& y; // expected-note {{property declared here}}
81 @implementation SynthIncompleteRef // expected-error {{cannot synthesize property 'x' with incomplete type 'IncompleteStruct'}}
82 @synthesize y; // expected-error {{cannot synthesize property 'y' with incomplete type 'IncompleteStruct'}}
86 // Check error handling for instantiation during property synthesis.
87 template<typename T> class TemplateClass1 {
88 T *x; // expected-error {{'x' declared as a pointer to a reference of type 'int &'}}
90 template<typename T> class TemplateClass2 {
91 TemplateClass2& operator=(TemplateClass1<T>);
92 TemplateClass2& operator=(TemplateClass2) { T(); } // expected-error {{reference to type 'int' requires an initializer}} \
93 // expected-note 2 {{implicitly declared private here}} \
94 // expected-note {{'operator=' declared here}}
96 __attribute__((objc_root_class)) @interface InterfaceWithTemplateProperties
97 @property TemplateClass2<int&> intprop;
98 @property TemplateClass2<int&> &floatprop;
100 @implementation InterfaceWithTemplateProperties // expected-error 2 {{'operator=' is a private member of 'TemplateClass2<int &>'}} \
101 // expected-error {{atomic property of reference type 'TemplateClass2<int &> &' cannot have non-trivial assignment operator}} \
102 // expected-note {{in instantiation of template class}} \
103 // expected-note {{in instantiation of member function}}