1// RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s
2
3void abort(void);
4
5@interface Subclass
6+ (int)magicNumber;
7+ (void)setMagicNumber:(int)value;
8+ (void)setFakeSetterNumber:(int)value;
9@end
10
11@implementation Subclass
12int _magicNumber = 0;
13+ (int)magicNumber {
14  return _magicNumber;
15}
16
17+ (void)setMagicNumber:(int)value {
18  _magicNumber = value;
19}
20
21+ (void)setFakeSetterNumber:(int)value {
22  _magicNumber = value;
23}
24
25+ (void) classMeth
26{
27	self.magicNumber = 10;
28	if (self.magicNumber != 10)
29	  abort ();
30}
31@end
32
33int main (void) {
34
35  int a;
36  Subclass.magicNumber = 2 /*[Subclass setMagicNumber:2]*/;
37  if (Subclass.magicNumber != 0)
38    abort ();
39  if (Subclass.magicNumber != 2)
40    abort ();
41  Subclass.magicNumber += 3;
42  if (Subclass.magicNumber != 5)
43    abort ();
44  Subclass.magicNumber -= 5;
45  if (Subclass.magicNumber != 0)
46    abort ();
47  /* We only have a setter in the following case. */
48  Subclass.fakeSetterNumber = 123;
49
50  /* We read it using the other getter. */
51  if (Subclass.magicNumber != 123)
52   abort ();
53  Subclass.fakeSetterNumber = Subclass.magicNumber;
54  if (Subclass.magicNumber != 123)
55   abort ();
56
57  Subclass.fakeSetterNumberX = 123; // expected-error{{property 'fakeSetterNumberX' not found on object of type 'Subclass'}}
58
59  /* Test class methods using the new syntax. */
60  [Subclass classMeth];
61  return 0;
62}
63