brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.1 KiB · 0982c81 Raw
105 lines · plain
1// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s2 3@interface NSArray @end4 5@interface NSMutableArray : NSArray @end6 7@interface MyClass8{9  NSMutableArray * _array;10}11 12@property (readonly) NSMutableArray * array;13 14@end15 16@interface MyClass ()17 18@property (readwrite, retain) NSMutableArray * array;19 20@end21 22@implementation MyClass23 24@synthesize array=_array;25 26@end27 28int main(void)29{30  return 0;31}32 33class TCPPObject34{35public:36 TCPPObject(const TCPPObject& inObj);37 TCPPObject();38 ~TCPPObject();39 TCPPObject& operator=(const TCPPObject& inObj); // expected-note {{'operator=' declared here}}40private:41 void* fData;42};43 44class Trivial45{46public:47 Trivial(const Trivial& inObj);48 Trivial();49 ~Trivial();50private:51 void* fData;52};53 54@interface MyDocument55{56@private57 TCPPObject _cppObject;58 TCPPObject _ncppObject;59 Trivial _tcppObject;60}61@property (assign, readwrite) const TCPPObject& cppObject;62@property (assign, readwrite, nonatomic) const TCPPObject& ncppObject;63@property (assign, readwrite) const Trivial& tcppObject;64@end65 66@implementation MyDocument67 68@synthesize cppObject = _cppObject; // expected-error {{atomic property of reference type 'const TCPPObject &' cannot have non-trivial assignment operator}}69@synthesize ncppObject = _ncppObject;70 71@synthesize tcppObject = _tcppObject;72@end73 74struct IncompleteStruct; // expected-note 2 {{forward declaration of 'IncompleteStruct'}}75struct ConvertToIncomplete { operator IncompleteStruct&(); };76@interface SynthIncompleteRef77@property (readonly, nonatomic) IncompleteStruct& x; // expected-note {{property declared here}}78@property (readonly, nonatomic) IncompleteStruct& y; // expected-note {{property declared here}}79@end80 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'}}83@end 84 85 86// Check error handling for instantiation during property synthesis.87template<typename T> class TemplateClass1 {88  T *x; // expected-error {{'x' declared as a pointer to a reference of type 'int &'}}89};90template<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}}95};96__attribute__((objc_root_class)) @interface InterfaceWithTemplateProperties 97@property TemplateClass2<int&> intprop;98@property TemplateClass2<int&> &floatprop;99@end100@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}}104@end  105