Skip to content

Commit

Permalink
Add tests to ensure unmarked instance variables are considered protected
Browse files Browse the repository at this point in the history
  • Loading branch information
qmfrederik committed Sep 7, 2024
1 parent 6407339 commit cf93b21
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions clang/test/SemaObjC/ivar-access-tests.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

@interface MySuperClass
{
int unmarked;

@private
int private;

Expand All @@ -17,6 +19,7 @@ @implementation MySuperClass
- (void) test {
int access;
MySuperClass *s = 0;
access = s->unmarked;
access = s->private;
access = s->protected;
}
Expand All @@ -30,9 +33,11 @@ @implementation MyClass
- (void) test {
int access;
MySuperClass *s = 0;
access = s->unmarked;
access = s->private; // expected-error {{instance variable 'private' is private}}
access = s->protected;
MyClass *m=0;
access = m->unmarked;
access = m->private; // expected-error {{instance variable 'private' is private}}
access = m->protected;
}
Expand All @@ -46,9 +51,11 @@ @implementation Deeper
- (void) test {
int access;
MySuperClass *s = 0;
access = s->unmarked;
access = s->private; // expected-error {{instance variable 'private' is private}}
access = s->protected;
MyClass *m=0;
access = m->unmarked;
access = m->private; // expected-error {{instance variable 'private' is private}}
access = m->protected;
}
Expand All @@ -61,9 +68,11 @@ @implementation Unrelated
- (void) test {
int access;
MySuperClass *s = 0;
access = s->unmarked; // expected-error {{instance variable 'unmarked' is protected}}
access = s->private; // expected-error {{instance variable 'private' is private}}
access = s->protected; // expected-error {{instance variable 'protected' is protected}}
MyClass *m=0;
access = m->unmarked; // expected-error {{instance variable 'unmarked' is protected}}
access = m->private; // expected-error {{instance variable 'private' is private}}
access = m->protected; // expected-error {{instance variable 'protected' is protected}}
}
Expand All @@ -73,6 +82,7 @@ int main (void)
{
MySuperClass *s = 0;
int access;
access = s->unmarked; // expected-error {{instance variable 'unmarked' is protected}}
access = s->private; // expected-error {{instance variable 'private' is private}}
access = s->protected; // expected-error {{instance variable 'protected' is protected}}
return 0;
Expand Down

0 comments on commit cf93b21

Please sign in to comment.