1// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-unreachable-code
2// expected-no-diagnostics
3
4@interface NSObject
5+ alloc;
6- init;
7@end
8
9@protocol Test
10  @property int required;
11
12@optional
13  @property int optional;
14  @property int optional1;
15  @property int optional_preexisting_setter_getter;
16  @property (setter = setOptional_preexisting_setter_getter: ,
17	     getter = optional_preexisting_setter_getter) int optional_with_setter_getter_attr;
18@required
19  @property int required1;
20@optional
21  @property int optional_to_be_defined;
22  @property (readonly, getter = optional_preexisting_setter_getter) int optional_getter_attr;
23@end
24
25@interface Test : NSObject <Test> {
26  int ivar;
27  int ivar1;
28  int ivar2;
29}
30@property int required;
31@property int optional_to_be_defined;
32- (int) optional_preexisting_setter_getter;
33- (void) setOptional_preexisting_setter_getter:(int)value;
34@end
35
36@implementation Test
37@synthesize required = ivar;
38@synthesize required1 = ivar1;
39@synthesize optional_to_be_defined = ivar2;
40- (int) optional_preexisting_setter_getter { return ivar; }
41- (void) setOptional_preexisting_setter_getter:(int)value
42	   {
43		ivar = value;
44	   }
45- (void) setOptional_getter_attr:(int)value { ivar = value; }
46@end
47
48void abort(void);
49int main ()
50{
51	Test *x = [[Test alloc] init];
52	/* 1. Test of a required property */
53	x.required1 = 100;
54  	if (x.required1 != 100)
55	  abort ();
56
57	/* 2. Test of a synthesize optional property */
58  	x.optional_to_be_defined = 123;
59	if (x.optional_to_be_defined != 123)
60	  abort ();
61
62	/* 3. Test of optional property with pre-sxisting defined setter/getter */
63	x.optional_preexisting_setter_getter = 200;
64	if (x.optional_preexisting_setter_getter != 200)
65	  abort ();
66
67	/* 4. Test of optional property with setter/getter attribute */
68	if (x.optional_with_setter_getter_attr != 200)
69	  abort ();
70	return 0;
71
72	/* 5. Test of optional property with getter attribute and default setter method. */
73	x.optional_getter_attr = 1000;
74        if (x.optional_getter_attr != 1000)
75	  abort ();
76
77	return 0;
78}
79
80