1 // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fblocks -Wcast-qual -verify %s
3 typedef const void *CFTypeRef;
4 typedef const struct __CFString *CFStringRef;
10 CFTypeRef CFCreateSomething(void);
11 CFStringRef CFCreateString(void);
12 CFTypeRef CFGetSomething(void);
13 CFStringRef CFGetString(void);
15 id CreateSomething(void);
16 NSString *CreateNSString(void);
19 id obj1 = (__bridge_transfer id)CFCreateSomething(); // expected-warning {{'__bridge_transfer' casts have no effect when not using ARC}}
20 id obj2 = (__bridge_transfer NSString*)CFCreateString(); // expected-warning {{'__bridge_transfer' casts have no effect when not using ARC}}
21 (__bridge int*)CFCreateSomething(); // expected-warning {{expression result unused}} expected-warning {{cast from 'const void *' to 'int *' drops const qualifier}}
22 id obj3 = (__bridge id)CFGetSomething();
23 id obj4 = (__bridge NSString*)CFGetString();
27 CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); // expected-warning {{'__bridge_retained' casts have no effect when not using ARC}}
28 CFStringRef cf2 = (__bridge_retained CFStringRef)CreateNSString(); // expected-warning {{'__bridge_retained' casts have no effect when not using ARC}}
29 CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething();
30 CFStringRef cf4 = (__bridge CFStringRef)CreateNSString();
34 id obj1 = (id)CFCreateSomething();
35 CFTypeRef cf1 = (CFTypeRef)CreateSomething();
38 #pragma clang diagnostic ignored "-Warc-bridge-casts-disallowed-in-nonarc"
40 void to_cf_ignored(id obj) {
41 CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); // no-warning
42 CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething(); // no-warning
45 // Check that clang doesn't warn about dropping const from Objective-C object
47 void test_wcast_qual(void) {
49 NSString *n0 = (NSString *)c;
50 NSString **n1 = (NSString **)&c;
53 void *p0 = (void *)n2;
54 void **p1 = (void **)n3;