From cf93b21734e179144dac34751860b0aa9d2aedaa Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Sat, 7 Sep 2024 03:00:46 -0700 Subject: [PATCH] Add tests to ensure unmarked instance variables are considered protected --- clang/test/SemaObjC/ivar-access-tests.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/clang/test/SemaObjC/ivar-access-tests.m b/clang/test/SemaObjC/ivar-access-tests.m index cd7e09d406adaa5..6060dea5ab0f0e9 100644 --- a/clang/test/SemaObjC/ivar-access-tests.m +++ b/clang/test/SemaObjC/ivar-access-tests.m @@ -2,6 +2,8 @@ @interface MySuperClass { + int unmarked; + @private int private; @@ -17,6 +19,7 @@ @implementation MySuperClass - (void) test { int access; MySuperClass *s = 0; + access = s->unmarked; access = s->private; access = s->protected; } @@ -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; } @@ -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; } @@ -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}} } @@ -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;