| Jordan Rose | 76831c6 | 2012-10-11 16:10:19 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks -Wno-objc-root-class -std=c++11 -Warc-repeated-use-of-weak -verify %s | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 2 |  | 
|  | 3 | @interface Test { | 
|  | 4 | @public | 
|  | 5 | Test *ivar; | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 6 | __weak id weakIvar; | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 7 | } | 
|  | 8 | @property(weak) Test *weakProp; | 
|  | 9 | @property(strong) Test *strongProp; | 
|  | 10 |  | 
|  | 11 | - (__weak id)implicitProp; | 
|  | 12 |  | 
|  | 13 | + (__weak id)weakProp; | 
|  | 14 | @end | 
|  | 15 |  | 
|  | 16 | extern void use(id); | 
|  | 17 | extern id get(); | 
|  | 18 | extern bool condition(); | 
|  | 19 | #define nil ((id)0) | 
|  | 20 |  | 
|  | 21 | void sanity(Test *a) { | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 22 | use(a.weakProp); // expected-warning{{weak property 'weakProp' is accessed multiple times in this function but may be unpredictably set to nil; assign to a strong variable to keep the object alive}} | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 23 | use(a.weakProp); // expected-note{{also accessed here}} | 
|  | 24 |  | 
|  | 25 | use(a.strongProp); | 
|  | 26 | use(a.strongProp); // no-warning | 
|  | 27 |  | 
|  | 28 | use(a.weakProp); // expected-note{{also accessed here}} | 
|  | 29 | } | 
|  | 30 |  | 
|  | 31 | void singleUse(Test *a) { | 
|  | 32 | use(a.weakProp); // no-warning | 
|  | 33 | use(a.strongProp); // no-warning | 
|  | 34 | } | 
|  | 35 |  | 
|  | 36 | void assignsOnly(Test *a) { | 
|  | 37 | a.weakProp = get(); // no-warning | 
|  | 38 |  | 
|  | 39 | id next = get(); | 
|  | 40 | if (next) | 
|  | 41 | a.weakProp = next; // no-warning | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 42 |  | 
|  | 43 | a->weakIvar = get(); // no-warning | 
|  | 44 | next = get(); | 
|  | 45 | if (next) | 
|  | 46 | a->weakIvar = next; // no-warning | 
|  | 47 |  | 
|  | 48 | extern __weak id x; | 
|  | 49 | x = get(); // no-warning | 
|  | 50 | next = get(); | 
|  | 51 | if (next) | 
|  | 52 | x = next; // no-warning | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 53 | } | 
|  | 54 |  | 
|  | 55 | void assignThenRead(Test *a) { | 
|  | 56 | a.weakProp = get(); // expected-note{{also accessed here}} | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 57 | use(a.weakProp); // expected-warning{{weak property 'weakProp' is accessed multiple times}} | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 58 | } | 
|  | 59 |  | 
|  | 60 | void twoVariables(Test *a, Test *b) { | 
|  | 61 | use(a.weakProp); // no-warning | 
|  | 62 | use(b.weakProp); // no-warning | 
|  | 63 | } | 
|  | 64 |  | 
|  | 65 | void doubleLevelAccess(Test *a) { | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 66 | use(a.strongProp.weakProp); // expected-warning{{weak property 'weakProp' may be accessed multiple times in this function and may be unpredictably set to nil; assign to a strong variable to keep the object alive}} | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 67 | use(a.strongProp.weakProp); // expected-note{{also accessed here}} | 
|  | 68 | } | 
|  | 69 |  | 
|  | 70 | void doubleLevelAccessIvar(Test *a) { | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 71 | use(a.strongProp.weakProp); // expected-warning{{weak property 'weakProp' may be accessed multiple times}} | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 72 | use(a.strongProp.weakProp); // expected-note{{also accessed here}} | 
|  | 73 | } | 
|  | 74 |  | 
|  | 75 | void implicitProperties(Test *a) { | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 76 | use(a.implicitProp); // expected-warning{{weak implicit property 'implicitProp' is accessed multiple times}} | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 77 | use(a.implicitProp); // expected-note{{also accessed here}} | 
|  | 78 | } | 
|  | 79 |  | 
|  | 80 | void classProperties() { | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 81 | use(Test.weakProp); // expected-warning{{weak implicit property 'weakProp' is accessed multiple times}} | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 82 | use(Test.weakProp); // expected-note{{also accessed here}} | 
|  | 83 | } | 
|  | 84 |  | 
|  | 85 | void classPropertiesAreDifferent(Test *a) { | 
|  | 86 | use(Test.weakProp); // no-warning | 
|  | 87 | use(a.weakProp); // no-warning | 
|  | 88 | use(a.strongProp.weakProp); // no-warning | 
|  | 89 | } | 
|  | 90 |  | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 91 | void ivars(Test *a) { | 
|  | 92 | use(a->weakIvar); // expected-warning{{weak instance variable 'weakIvar' is accessed multiple times}} | 
|  | 93 | use(a->weakIvar); // expected-note{{also accessed here}} | 
|  | 94 | } | 
|  | 95 |  | 
|  | 96 | void globals() { | 
|  | 97 | extern __weak id a; | 
|  | 98 | use(a); // expected-warning{{weak variable 'a' is accessed multiple times}} | 
|  | 99 | use(a); // expected-note{{also accessed here}} | 
|  | 100 | } | 
|  | 101 |  | 
| Jordan Rose | 2248765 | 2012-10-11 16:06:21 +0000 | [diff] [blame] | 102 | void messageGetter(Test *a) { | 
|  | 103 | use([a weakProp]); // expected-warning{{weak property 'weakProp' is accessed multiple times}} | 
|  | 104 | use([a weakProp]); // expected-note{{also accessed here}} | 
|  | 105 | } | 
|  | 106 |  | 
|  | 107 | void messageSetter(Test *a) { | 
|  | 108 | [a setWeakProp:get()]; // no-warning | 
|  | 109 | [a setWeakProp:get()]; // no-warning | 
|  | 110 | } | 
|  | 111 |  | 
|  | 112 | void messageSetterAndGetter(Test *a) { | 
|  | 113 | [a setWeakProp:get()]; // expected-note{{also accessed here}} | 
|  | 114 | use([a weakProp]); // expected-warning{{weak property 'weakProp' is accessed multiple times}} | 
|  | 115 | } | 
|  | 116 |  | 
|  | 117 | void mixDotAndMessageSend(Test *a, Test *b) { | 
|  | 118 | use(a.weakProp); // expected-warning{{weak property 'weakProp' is accessed multiple times}} | 
|  | 119 | use([a weakProp]); // expected-note{{also accessed here}} | 
|  | 120 |  | 
|  | 121 | use([b weakProp]); // expected-warning{{weak property 'weakProp' is accessed multiple times}} | 
|  | 122 | use(b.weakProp); // expected-note{{also accessed here}} | 
|  | 123 | } | 
|  | 124 |  | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 125 |  | 
|  | 126 | void assignToStrongWrongInit(Test *a) { | 
|  | 127 | id val = a.weakProp; // expected-note{{also accessed here}} | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 128 | use(a.weakProp); // expected-warning{{weak property 'weakProp' is accessed multiple times}} | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 129 | } | 
|  | 130 |  | 
|  | 131 | void assignToStrongWrong(Test *a) { | 
|  | 132 | id val; | 
|  | 133 | val = a.weakProp; // expected-note{{also accessed here}} | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 134 | use(a.weakProp); // expected-warning{{weak property 'weakProp' is accessed multiple times}} | 
|  | 135 | } | 
|  | 136 |  | 
|  | 137 | void assignToIvarWrong(Test *a) { | 
|  | 138 | a->weakIvar = get(); // expected-note{{also accessed here}} | 
|  | 139 | use(a->weakIvar); // expected-warning{{weak instance variable 'weakIvar' is accessed multiple times}} | 
|  | 140 | } | 
|  | 141 |  | 
|  | 142 | void assignToGlobalWrong() { | 
|  | 143 | extern __weak id a; | 
|  | 144 | a = get(); // expected-note{{also accessed here}} | 
|  | 145 | use(a); // expected-warning{{weak variable 'a' is accessed multiple times}} | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 146 | } | 
|  | 147 |  | 
|  | 148 | void assignToStrongOK(Test *a) { | 
|  | 149 | if (condition()) { | 
|  | 150 | id val = a.weakProp; // no-warning | 
|  | 151 | (void)val; | 
|  | 152 | } else { | 
|  | 153 | id val; | 
|  | 154 | val = a.weakProp; // no-warning | 
|  | 155 | (void)val; | 
|  | 156 | } | 
|  | 157 | } | 
|  | 158 |  | 
|  | 159 | void assignToStrongConditional(Test *a) { | 
|  | 160 | id val = (condition() ? a.weakProp : a.weakProp); // no-warning | 
|  | 161 | id val2 = a.implicitProp ?: a.implicitProp; // no-warning | 
|  | 162 | } | 
|  | 163 |  | 
|  | 164 | void testBlock(Test *a) { | 
|  | 165 | use(a.weakProp); // no-warning | 
|  | 166 |  | 
|  | 167 | use(^{ | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 168 | use(a.weakProp); // expected-warning{{weak property 'weakProp' is accessed multiple times in this block}} | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 169 | use(a.weakProp); // expected-note{{also accessed here}} | 
|  | 170 | }); | 
|  | 171 | } | 
|  | 172 |  | 
| Jordan Rose | e723a27 | 2012-10-10 16:43:06 +0000 | [diff] [blame] | 173 | void assignToStrongWithCasts(Test *a) { | 
|  | 174 | if (condition()) { | 
|  | 175 | Test *val = (Test *)a.weakProp; // no-warning | 
|  | 176 | (void)val; | 
|  | 177 | } else { | 
|  | 178 | id val; | 
|  | 179 | val = (Test *)a.weakProp; // no-warning | 
|  | 180 | (void)val; | 
|  | 181 | } | 
|  | 182 | } | 
|  | 183 |  | 
| Jordan Rose | b1e3e5f | 2012-10-11 17:02:00 +0000 | [diff] [blame] | 184 | void assignToStrongWithMessages(Test *a) { | 
|  | 185 | if (condition()) { | 
|  | 186 | id val = [a weakProp]; // no-warning | 
|  | 187 | (void)val; | 
|  | 188 | } else { | 
|  | 189 | id val; | 
|  | 190 | val = [a weakProp]; // no-warning | 
|  | 191 | (void)val; | 
|  | 192 | } | 
|  | 193 | } | 
|  | 194 |  | 
|  | 195 |  | 
| Jordan Rose | 76831c6 | 2012-10-11 16:10:19 +0000 | [diff] [blame] | 196 | void assignAfterRead(Test *a) { | 
|  | 197 | // Special exception for a single read before any writes. | 
|  | 198 | if (!a.weakProp) // no-warning | 
|  | 199 | a.weakProp = get(); // no-warning | 
|  | 200 | } | 
|  | 201 |  | 
|  | 202 | void readOnceWriteMany(Test *a) { | 
|  | 203 | if (!a.weakProp) { // no-warning | 
|  | 204 | a.weakProp = get(); // no-warning | 
|  | 205 | a.weakProp = get(); // no-warning | 
|  | 206 | } | 
|  | 207 | } | 
|  | 208 |  | 
|  | 209 | void readOnceAfterWrite(Test *a) { | 
|  | 210 | a.weakProp = get(); // expected-note{{also accessed here}} | 
|  | 211 | if (!a.weakProp) { // expected-warning{{weak property 'weakProp' is accessed multiple times in this function}} | 
|  | 212 | a.weakProp = get(); // expected-note{{also accessed here}} | 
|  | 213 | } | 
|  | 214 | } | 
|  | 215 |  | 
|  | 216 | void readOnceWriteManyLoops(Test *a, Test *b, Test *c, Test *d, Test *e) { | 
|  | 217 | while (condition()) { | 
|  | 218 | if (!a.weakProp) { // expected-warning{{weak property 'weakProp' is accessed multiple times in this function}} | 
|  | 219 | a.weakProp = get(); // expected-note{{also accessed here}} | 
|  | 220 | a.weakProp = get(); // expected-note{{also accessed here}} | 
|  | 221 | } | 
|  | 222 | } | 
|  | 223 |  | 
|  | 224 | do { | 
|  | 225 | if (!b.weakProp) { // expected-warning{{weak property 'weakProp' is accessed multiple times in this function}} | 
|  | 226 | b.weakProp = get(); // expected-note{{also accessed here}} | 
|  | 227 | b.weakProp = get(); // expected-note{{also accessed here}} | 
|  | 228 | } | 
|  | 229 | } while (condition()); | 
|  | 230 |  | 
|  | 231 | for (id x = get(); x; x = get()) { | 
|  | 232 | if (!c.weakProp) { // expected-warning{{weak property 'weakProp' is accessed multiple times in this function}} | 
|  | 233 | c.weakProp = get(); // expected-note{{also accessed here}} | 
|  | 234 | c.weakProp = get(); // expected-note{{also accessed here}} | 
|  | 235 | } | 
|  | 236 | } | 
|  | 237 |  | 
|  | 238 | for (id x in get()) { | 
|  | 239 | if (!d.weakProp) { // expected-warning{{weak property 'weakProp' is accessed multiple times in this function}} | 
|  | 240 | d.weakProp = get(); // expected-note{{also accessed here}} | 
|  | 241 | d.weakProp = get(); // expected-note{{also accessed here}} | 
|  | 242 | } | 
|  | 243 | } | 
|  | 244 |  | 
|  | 245 | int array[] = { 1, 2, 3 }; | 
|  | 246 | for (int i : array) { | 
|  | 247 | if (!e.weakProp) { // expected-warning{{weak property 'weakProp' is accessed multiple times in this function}} | 
|  | 248 | e.weakProp = get(); // expected-note{{also accessed here}} | 
|  | 249 | e.weakProp = get(); // expected-note{{also accessed here}} | 
|  | 250 | } | 
|  | 251 | } | 
|  | 252 | } | 
|  | 253 |  | 
|  | 254 | void readOnlyLoop(Test *a) { | 
|  | 255 | while (condition()) { | 
|  | 256 | use(a.weakProp); // expected-warning{{weak property 'weakProp' is accessed multiple times in this function}} | 
|  | 257 | } | 
|  | 258 | } | 
|  | 259 |  | 
| Jordan Rose | 25c0ea8 | 2012-10-29 17:46:47 +0000 | [diff] [blame] | 260 | void readInIterationLoop() { | 
|  | 261 | for (Test *a in get()) | 
|  | 262 | use(a.weakProp); // no-warning | 
|  | 263 | } | 
|  | 264 |  | 
|  | 265 | void readDoubleLevelAccessInLoop() { | 
|  | 266 | for (Test *a in get()) { | 
|  | 267 | use(a.strongProp.weakProp); // no-warning | 
|  | 268 | } | 
|  | 269 | } | 
|  | 270 |  | 
|  | 271 | void readParameterInLoop(Test *a) { | 
|  | 272 | for (id unused in get()) { | 
|  | 273 | use(a.weakProp); // expected-warning{{weak property 'weakProp' is accessed multiple times in this function}} | 
|  | 274 | (void)unused; | 
|  | 275 | } | 
|  | 276 | } | 
|  | 277 |  | 
|  | 278 | void readGlobalInLoop() { | 
|  | 279 | static __weak id a; | 
|  | 280 | for (id unused in get()) { | 
|  | 281 | use(a); // expected-warning{{weak variable 'a' is accessed multiple times in this function}} | 
|  | 282 | (void)unused; | 
|  | 283 | } | 
|  | 284 | } | 
|  | 285 |  | 
|  | 286 | void doWhileLoop(Test *a) { | 
|  | 287 | do { | 
|  | 288 | use(a.weakProp); // no-warning | 
|  | 289 | } while(0); | 
|  | 290 | } | 
|  | 291 |  | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 292 |  | 
|  | 293 | @interface Test (Methods) | 
|  | 294 | @end | 
|  | 295 |  | 
|  | 296 | @implementation Test (Methods) | 
|  | 297 | - (void)sanity { | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 298 | use(self.weakProp); // expected-warning{{weak property 'weakProp' is accessed multiple times in this method but may be unpredictably set to nil; assign to a strong variable to keep the object alive}} | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 299 | use(self.weakProp); // expected-note{{also accessed here}} | 
|  | 300 | } | 
|  | 301 |  | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 302 | - (void)ivars { | 
|  | 303 | use(weakIvar); // expected-warning{{weak instance variable 'weakIvar' is accessed multiple times in this method but may be unpredictably set to nil; assign to a strong variable to keep the object alive}} | 
|  | 304 | use(weakIvar); // expected-note{{also accessed here}} | 
|  | 305 | } | 
|  | 306 |  | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 307 | - (void)doubleLevelAccessForSelf { | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 308 | use(self.strongProp.weakProp); // expected-warning{{weak property 'weakProp' is accessed multiple times}} | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 309 | use(self.strongProp.weakProp); // expected-note{{also accessed here}} | 
|  | 310 |  | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 311 | use(self->ivar.weakProp); // expected-warning{{weak property 'weakProp' is accessed multiple times}} | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 312 | use(self->ivar.weakProp); // expected-note{{also accessed here}} | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 313 |  | 
|  | 314 | use(self->ivar->weakIvar); // expected-warning{{weak instance variable 'weakIvar' is accessed multiple times}} | 
|  | 315 | use(self->ivar->weakIvar); // expected-note{{also accessed here}} | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 316 | } | 
|  | 317 |  | 
|  | 318 | - (void)distinctFromOther:(Test *)other { | 
|  | 319 | use(self.strongProp.weakProp); // no-warning | 
|  | 320 | use(other.strongProp.weakProp); // no-warning | 
|  | 321 |  | 
|  | 322 | use(self->ivar.weakProp); // no-warning | 
|  | 323 | use(other->ivar.weakProp); // no-warning | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 324 |  | 
|  | 325 | use(self.strongProp->weakIvar); // no-warning | 
|  | 326 | use(other.strongProp->weakIvar); // no-warning | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 327 | } | 
|  | 328 | @end | 
|  | 329 |  | 
|  | 330 |  | 
|  | 331 | class Wrapper { | 
|  | 332 | Test *a; | 
|  | 333 |  | 
|  | 334 | public: | 
|  | 335 | void fields() { | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 336 | use(a.weakProp); // expected-warning{{weak property 'weakProp' is accessed multiple times in this function but may be unpredictably set to nil; assign to a strong variable to keep the object alive}} | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 337 | use(a.weakProp); // expected-note{{also accessed here}} | 
|  | 338 | } | 
|  | 339 |  | 
|  | 340 | void distinctFromOther(Test *b, const Wrapper &w) { | 
|  | 341 | use(a.weakProp); // no-warning | 
|  | 342 | use(b.weakProp); // no-warning | 
|  | 343 | use(w.a.weakProp); // no-warning | 
|  | 344 | } | 
|  | 345 |  | 
|  | 346 | static void doubleLevelAccessField(const Wrapper &x, const Wrapper &y) { | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 347 | use(x.a.weakProp); // expected-warning{{weak property 'weakProp' may be accessed multiple times}} | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 348 | use(y.a.weakProp); // expected-note{{also accessed here}} | 
|  | 349 | } | 
|  | 350 | }; | 
|  | 351 |  | 
|  | 352 |  | 
|  | 353 | // ----------------------- | 
|  | 354 | // False positives | 
|  | 355 | // ----------------------- | 
|  | 356 |  | 
|  | 357 | // Most of these would require flow-sensitive analysis to silence correctly. | 
|  | 358 |  | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 359 | void assignNil(Test *a) { | 
|  | 360 | if (condition()) | 
|  | 361 | a.weakProp = nil; // expected-note{{also accessed here}} | 
|  | 362 |  | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 363 | use(a.weakProp); // expected-warning{{weak property 'weakProp' is accessed multiple times}} | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 364 | } | 
|  | 365 |  | 
|  | 366 | void branch(Test *a) { | 
|  | 367 | if (condition()) | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 368 | use(a.weakProp); // expected-warning{{weak property 'weakProp' is accessed multiple times}} | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 369 | else | 
|  | 370 | use(a.weakProp); // expected-note{{also accessed here}} | 
|  | 371 | } | 
|  | 372 |  | 
|  | 373 | void doubleLevelAccess(Test *a, Test *b) { | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 374 | use(a.strongProp.weakProp); // expected-warning{{weak property 'weakProp' may be accessed multiple times}} | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 375 | use(b.strongProp.weakProp); // expected-note{{also accessed here}} | 
|  | 376 |  | 
|  | 377 | use(a.weakProp.weakProp); // no-warning | 
|  | 378 | } | 
|  | 379 |  | 
|  | 380 | void doubleLevelAccessIvar(Test *a, Test *b) { | 
| Jordan Rose | 657b5f4 | 2012-09-28 22:21:35 +0000 | [diff] [blame] | 381 | use(a->ivar.weakProp); // expected-warning{{weak property 'weakProp' may be accessed multiple times}} | 
| Jordan Rose | d393458 | 2012-09-28 22:21:30 +0000 | [diff] [blame] | 382 | use(b->ivar.weakProp); // expected-note{{also accessed here}} | 
|  | 383 |  | 
|  | 384 | use(a.strongProp.weakProp); // no-warning | 
|  | 385 | } | 
| Jordan Rose | 25c0ea8 | 2012-10-29 17:46:47 +0000 | [diff] [blame] | 386 |  |