[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / test / SemaObjC / illegal-nonarc-bridged-cast.m
blob8284a2a92413f6040f41e417fe63570be3146105
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;
5 @class NSString;
7 @interface NSString
8 @end
10 CFTypeRef CFCreateSomething(void);
11 CFStringRef CFCreateString(void);
12 CFTypeRef CFGetSomething(void);
13 CFStringRef CFGetString(void);
15 id CreateSomething(void);
16 NSString *CreateNSString(void);
18 void from_cf(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();
26 void to_cf(id obj) {
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();
33 void fixits(void) {
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
46 // types.
47 void test_wcast_qual(void) {
48   CFStringRef c;
49   NSString *n0 = (NSString *)c;
50   NSString **n1 = (NSString **)&c;
51   const NSString *n2;
52   const NSString **n3;
53   void *p0 = (void *)n2;
54   void **p1 = (void **)n3;