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