[InstCombine] Preserve NSW flags for `lshr (mul nuw X, C1), C2 -> mul nuw nsw X,...
[llvm-project.git] / clang / test / SemaObjC / objcbridgemutable-attribute.m
blob1826f3b9690e199544ee4619c2b07d73bfecf5ff
1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
3 typedef struct __attribute__((objc_bridge_mutable(NSMutableDictionary))) __CFDictionary * CFMutableDictionaryRef; // expected-note {{declared here}}
5 typedef struct __attribute__((objc_bridge_mutable(12))) __CFDictionaryB1 * CFMutableDictionaryB1Ref; // expected-error {{parameter of 'objc_bridge_mutable' attribute must be a single name of an Objective-C class}}
7 typedef struct __attribute__((objc_bridge_mutable(P))) __CFDictionaryB2 * CFMutableDictionaryB2Ref; // expected-note {{declared here}}
9 typedef struct __attribute__((objc_bridge_mutable(NSMutableDictionary, Unknown))) __CFDictionaryB3 * CFMutableDictionaryB3Ref;  // expected-error {{use of undeclared identifier 'Unknown'}}
11 typedef struct __attribute__((objc_bridge_mutable)) __CFDictionaryB4 * CFMutableDictionaryB4Ref;  // expected-error {{'objc_bridge_mutable' attribute takes one argument}}
13 @interface NSDictionary
14 @end
16 @interface NSMutableDictionary : NSDictionary
17 @end
19 @protocol P @end
21 void Test(NSMutableDictionary *md, NSDictionary *nd, CFMutableDictionaryRef mcf, CFMutableDictionaryB2Ref bmcf) {
23   (void) (CFMutableDictionaryRef)md;
24   (void) (CFMutableDictionaryRef)nd; // expected-warning {{'NSDictionary' cannot bridge to 'CFMutableDictionaryRef' (aka 'struct __CFDictionary *')}}
25   (void) (NSDictionary *)mcf; // ok, bridgt_type NSMutableDictionary can be type-cast to its super class.
26   NSDictionary *nsdobj = (NSMutableDictionary*)0;
27   (void) (NSMutableDictionary *)mcf; // ok;
28   (void) (NSMutableDictionary *)bmcf; // expected-error {{CF object of type 'CFMutableDictionaryB2Ref' (aka 'struct __CFDictionaryB2 *') is bridged to 'P', which is not an Objective-C class}}
29