xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/ivar-in-implementations.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc@interface Super @end
4*f4a2713aSLionel Sambuc
5*f4a2713aSLionel Sambuc@interface INTFSTANDALONE : Super
6*f4a2713aSLionel Sambuc{
7*f4a2713aSLionel Sambuc  id IVAR;	// expected-note {{previous definition is here}}
8*f4a2713aSLionel Sambuc}
9*f4a2713aSLionel Sambuc
10*f4a2713aSLionel Sambuc@end
11*f4a2713aSLionel Sambuc
12*f4a2713aSLionel Sambuc@implementation INTFSTANDALONE : Super // expected-warning {{class implementation may not have super class}}
13*f4a2713aSLionel Sambuc{
14*f4a2713aSLionel Sambuc  id PRIV_IVAR;
15*f4a2713aSLionel Sambuc@protected
16*f4a2713aSLionel Sambuc  id PRTCTD;
17*f4a2713aSLionel Sambuc@private
18*f4a2713aSLionel Sambuc  id IVAR3;
19*f4a2713aSLionel Sambuc  int IVAR;	// expected-error {{instance variable is already declared}}
20*f4a2713aSLionel Sambuc@public
21*f4a2713aSLionel Sambuc  id IVAR4;
22*f4a2713aSLionel Sambuc}
23*f4a2713aSLionel Sambuc@end
24*f4a2713aSLionel Sambuc
25*f4a2713aSLionel Sambuc@interface Base @end
26*f4a2713aSLionel Sambuc
27*f4a2713aSLionel Sambuc@implementation Base {
28*f4a2713aSLionel Sambuc    int ivar1;
29*f4a2713aSLionel Sambuc@public
30*f4a2713aSLionel Sambuc    int ivar2;
31*f4a2713aSLionel Sambuc}
32*f4a2713aSLionel Sambuc@end
33*f4a2713aSLionel Sambuc
34*f4a2713aSLionel Sambucid fn1(INTFSTANDALONE *b) { return b->PRIV_IVAR; } // expected-error {{instance variable 'PRIV_IVAR' is private}}
35*f4a2713aSLionel Sambuc
36*f4a2713aSLionel Sambucid fn2(INTFSTANDALONE *b) { return b->PRTCTD; }  // expected-error {{instance variable 'PRTCTD' is protected}}
37*f4a2713aSLionel Sambuc
38*f4a2713aSLionel Sambucid fn4(INTFSTANDALONE *b) { return b->IVAR4; }
39*f4a2713aSLionel Sambuc
40