Skip to content

Commit 93abb9b

Browse files
qmfrederikdavidchisnall
authored andcommitted
Add tests to ensure unmarked instance variables are considered protected
1 parent 5fa137c commit 93abb9b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

clang/test/SemaObjC/ivar-access-tests.m

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
@interface MySuperClass
44
{
5+
int unmarked;
6+
57
@private
68
int private;
79

@@ -17,6 +19,7 @@ @implementation MySuperClass
1719
- (void) test {
1820
int access;
1921
MySuperClass *s = 0;
22+
access = s->unmarked;
2023
access = s->private;
2124
access = s->protected;
2225
}
@@ -30,9 +33,11 @@ @implementation MyClass
3033
- (void) test {
3134
int access;
3235
MySuperClass *s = 0;
36+
access = s->unmarked;
3337
access = s->private; // expected-error {{instance variable 'private' is private}}
3438
access = s->protected;
3539
MyClass *m=0;
40+
access = m->unmarked;
3641
access = m->private; // expected-error {{instance variable 'private' is private}}
3742
access = m->protected;
3843
}
@@ -46,9 +51,11 @@ @implementation Deeper
4651
- (void) test {
4752
int access;
4853
MySuperClass *s = 0;
54+
access = s->unmarked;
4955
access = s->private; // expected-error {{instance variable 'private' is private}}
5056
access = s->protected;
5157
MyClass *m=0;
58+
access = m->unmarked;
5259
access = m->private; // expected-error {{instance variable 'private' is private}}
5360
access = m->protected;
5461
}
@@ -61,9 +68,11 @@ @implementation Unrelated
6168
- (void) test {
6269
int access;
6370
MySuperClass *s = 0;
71+
access = s->unmarked; // expected-error {{instance variable 'unmarked' is protected}}
6472
access = s->private; // expected-error {{instance variable 'private' is private}}
6573
access = s->protected; // expected-error {{instance variable 'protected' is protected}}
6674
MyClass *m=0;
75+
access = m->unmarked; // expected-error {{instance variable 'unmarked' is protected}}
6776
access = m->private; // expected-error {{instance variable 'private' is private}}
6877
access = m->protected; // expected-error {{instance variable 'protected' is protected}}
6978
}
@@ -73,6 +82,7 @@ int main (void)
7382
{
7483
MySuperClass *s = 0;
7584
int access;
85+
access = s->unmarked; // expected-error {{instance variable 'unmarked' is protected}}
7686
access = s->private; // expected-error {{instance variable 'private' is private}}
7787
access = s->protected; // expected-error {{instance variable 'protected' is protected}}
7888
return 0;

0 commit comments

Comments
 (0)