1 // RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -verify %s
2 // RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only -verify -DNOARC %s
4 // expected-no-diagnostics
7 int testObjCComparisonRules(void *v, id x, id y) {
10 // expected-error@-2 {{implicit conversion of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}}
11 // expected-note@-3 {{use __bridge to convert directly (no change in ownership)}}
12 // expected-note@-4 {{use __bridge_retained to make an ARC object available as a +1 'void *'}}
16 // expected-error@-2 {{implicit conversion of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}}
17 // expected-note@-3 {{use __bridge to convert directly (no change in ownership)}}
18 // expected-note@-4 {{use __bridge_retained to make an ARC object available as a +1 'void *'}}
20 return v == (id)(void *)0; // OK
21 return v == nullptr; // OK
22 return v == (void *)0;
28 int testMixedQualComparisonRules(void *v, const void *cv, A *a, const A *ca) {
31 // expected-error@-2 {{implicit conversion of Objective-C pointer type 'const A *' to C pointer type 'const void *' requires a bridged cast}}
32 // expected-note@-3 {{use __bridge to convert directly (no change in ownership)}}
33 // expected-note@-4 {{use __bridge_retained to make an ARC object available as a +1 'const void *'}}
35 // FIXME: The "to" type in this diagnostic is wrong; we should convert to "const void *".
38 // expected-error@-2 {{implicit conversion of Objective-C pointer type 'const A *' to C pointer type 'void *' requires a bridged cast}}
39 // expected-note@-3 {{use __bridge to convert directly (no change in ownership)}}
40 // expected-note@-4 {{use __bridge_retained to make an ARC object available as a +1 'void *'}}
44 // expected-error@-2 {{implicit conversion of Objective-C pointer type 'A *' to C pointer type 'const void *' requires a bridged cast}}
45 // expected-note@-3 {{use __bridge to convert directly (no change in ownership)}}
46 // expected-note@-4 {{use __bridge_retained to make an ARC object available as a +1 'const void *'}}
49 // FIXME: Shouldn't these be rejected in ARC mode too?
56 int testDoublePtr(void *pv, void **ppv, A *__strong* pspa, A *__weak* pwpa, A *__strong** ppspa) {
61 return pspa == pwpa; // expected-error {{comparison of distinct pointer types}}
62 return ppv == pspa; // expected-error {{comparison of distinct pointer types}}
63 return pspa == ppv; // expected-error {{comparison of distinct pointer types}}
65 return ppv == ppspa; // expected-error{{comparison of distinct pointer types}}