[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / clang / test / SemaObjC / ivar-lookup.m
blob57f432c717a191be63ded6531cfd797d3bc7ec4b
1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
3 @interface Test {
4    int x;
7 -(void) setX: (int) d;
8 @end
10 extern struct foo x;
12 @implementation Test
14 -(void) setX: (int) n {
15    x = n;
18 @end
20 @interface Ivar
21 - (float*)method;
22 @end
24 @interface A {
25   A *Ivar;
27 - (int*)method;
28 @end
30 @implementation A
31 - (int*)method {
32   int *ip = [Ivar method]; // expected-warning{{incompatible pointer types initializing 'int *' with an expression of type 'float *'}}
33                            // Note that there is no warning in Objective-C++
34   return 0;
36 @end
38 @interface TwoIvars {
39   int a;
40   int b;
42 @end
44 @implementation TwoIvars
45 + (int)classMethod {
46   return a + b; // expected-error{{instance variable 'a' accessed in class method}} \
47   // expected-error{{instance variable 'b' accessed in class method}}
49 @end
51 // rdar://10309454
52 @interface Radar10309454
54   int IVAR; // expected-note 4 {{previous definition is here}}
56 @end
58 @interface Radar10309454()
60   int IVAR; // expected-error {{instance variable is already declared}}
61   int PIVAR; // expected-note {{previous definition is here}}
63 @end
65 @interface Radar10309454()
67   int IVAR; // expected-error {{instance variable is already declared}}
69 @end
71 @interface Radar10309454()
73   int IVAR; // expected-error {{instance variable is already declared}}
74   int PIVAR; // expected-error {{instance variable is already declared}}
76 @end
78 @implementation Radar10309454
80   int IVAR; // expected-error {{instance variable is already declared}}
82 @end
84 // PR5984
85 // rdar://14037151
86 @interface Radar14037151 {
87   int myStatus;
89 - (int) test;
90 @end
92 @implementation Radar14037151
93 - (int) test
95   myStatus = 1;     // works
96    __typeof(myStatus) __in;  // works.
97   union U {
98     __typeof(myStatus) __in;  // fails.
99   };
100   struct S {
101     __typeof(myStatus) __in;  // fails.
102     struct S1 { // expected-warning {{declaration does not declare anything}}
103       __typeof(myStatus) __in;  // fails.
104       struct S { // expected-warning {{declaration does not declare anything}}
105         __typeof(myStatus) __in;  // fails.
106       };
107     };
108   };
110   return 0;
112 @end
114 // rdar://14278560
115 @class NSString, NSData, NSNumber;
117 @interface NSObject
119   Class isa;
121 @end
123 @interface Foo
125   int a;
126   NSString* b;
127   NSData* c;
129 @end
131 @interface Bar : Foo
132 @end
134 @interface Bar () {
135         NSString *q_strong;
136         NSNumber *r_strong;
137         int d; // expected-note {{previous definition is here}}
138         NSString *e_strong; // expected-note {{previous definition is here}}
139         NSData *f_weak; // expected-note {{previous definition is here}}
140         int g; // expected-note 2 {{previous definition is here}}
142 @end
144 @interface Bar () {
145         int g; // expected-note {{previous definition is here}} \
146                // expected-error {{instance variable is already declared}}
148 @end
150 @implementation Bar {
151         int d; // expected-error {{instance variable is already declared}}
152         NSString *e_strong; // expected-error {{instance variable is already declared}}
153         NSData *f_weak; // expected-error {{instance variable is already declared}}
154         NSData *g; // expected-error 2 {{instance variable is already declared}}
156 @end