xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/class-property-access.m (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify %s
2f4a2713aSLionel Sambuc// expected-no-diagnostics
3f4a2713aSLionel Sambuc
4f4a2713aSLionel Sambuc@interface Test {}
5f4a2713aSLionel Sambuc+ (Test*)one;
6f4a2713aSLionel Sambuc- (int)two;
7f4a2713aSLionel Sambuc@end
8f4a2713aSLionel Sambuc
9f4a2713aSLionel Sambucint main ()
10f4a2713aSLionel Sambuc{
11f4a2713aSLionel Sambuc  return Test.one.two;
12f4a2713aSLionel Sambuc}
13f4a2713aSLionel Sambuc
14*0a6a1f1dSLionel Sambuc// rdar://16650575
15*0a6a1f1dSLionel Sambuc__attribute__((objc_root_class))
16*0a6a1f1dSLionel Sambuc@interface RootClass {
17*0a6a1f1dSLionel Sambuc  Class isa;
18*0a6a1f1dSLionel Sambuc}
19*0a6a1f1dSLionel Sambuc
20*0a6a1f1dSLionel Sambuc@property int property;
21*0a6a1f1dSLionel Sambuc-(int)method;
22*0a6a1f1dSLionel Sambuc- (void) setMethod : (int)arg;
23*0a6a1f1dSLionel Sambuc+(int)classMethod;
24*0a6a1f1dSLionel Sambuc@end
25*0a6a1f1dSLionel Sambuc
26*0a6a1f1dSLionel Sambuc@interface Subclass : RootClass @end
27*0a6a1f1dSLionel Sambucvoid Test1() {
28*0a6a1f1dSLionel Sambuc    // now okay
29*0a6a1f1dSLionel Sambuc    (void)RootClass.property;
30*0a6a1f1dSLionel Sambuc    (void)Subclass.property;
31*0a6a1f1dSLionel Sambuc    (void)RootClass.method;
32*0a6a1f1dSLionel Sambuc    (void)Subclass.method;
33*0a6a1f1dSLionel Sambuc
34*0a6a1f1dSLionel Sambuc    RootClass.property = 1;
35*0a6a1f1dSLionel Sambuc    Subclass.property = 2;
36*0a6a1f1dSLionel Sambuc    RootClass.method = 3;
37*0a6a1f1dSLionel Sambuc    Subclass.method = 4;
38*0a6a1f1dSLionel Sambuc
39*0a6a1f1dSLionel Sambuc    // okay
40*0a6a1f1dSLionel Sambuc    (void)RootClass.classMethod;
41*0a6a1f1dSLionel Sambuc    (void)Subclass.classMethod;
42*0a6a1f1dSLionel Sambuc
43*0a6a1f1dSLionel Sambuc    // also okay
44*0a6a1f1dSLionel Sambuc    (void)[RootClass property];
45*0a6a1f1dSLionel Sambuc    (void)[Subclass property];
46*0a6a1f1dSLionel Sambuc    [RootClass method];
47*0a6a1f1dSLionel Sambuc    [Subclass method];
48*0a6a1f1dSLionel Sambuc    [RootClass classMethod];
49*0a6a1f1dSLionel Sambuc    [Subclass classMethod];
50*0a6a1f1dSLionel Sambuc
51*0a6a1f1dSLionel Sambuc    // also okay
52*0a6a1f1dSLionel Sambuc    [RootClass setProperty : 1];
53*0a6a1f1dSLionel Sambuc    [Subclass setProperty : 2];
54*0a6a1f1dSLionel Sambuc    [RootClass setMethod : 3];
55*0a6a1f1dSLionel Sambuc    [Subclass setMethod : 4];
56*0a6a1f1dSLionel Sambuc}
57