1 // RUN: %clang_cc1 -fblocks -fobjc-arc -Wnullable-to-nonnull-conversion -fsyntax-only -verify -Wno-objc-root-class %s
2 // RUN: %clang_cc1 -fblocks -fobjc-arc -Wnullable-to-nonnull-conversion -fsyntax-only -verify -Wno-objc-root-class -DNOWARN %s
12 ) stringWithUTF8String:(const char*)x;
16 void takesNonNull(NSString * _Nonnull ptr);
18 void testBoxedString(void) {
19 // No diagnostic emitted as this doesn't need a stringWithUTF8String message
21 takesNonNull(@("hey"));
22 takesNonNull(@(u8"hey"));
24 // If the string isn't a valid UTF-8 string, a diagnostic is emitted since the
25 // boxed expression turns into a message send.
26 takesNonNull(@(u8"\xFF")); // expected-warning {{string is ill-formed as UTF-8}}
27 takesNonNull(@(u8"\xC0\x80")); // expected-warning {{string is ill-formed as UTF-8}}
29 const char *str = "hey";
30 takesNonNull([NSString stringWithUTF8String:str]);
33 // expected-warning@-7 {{implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull'}}
34 // expected-warning@-7 {{implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull'}}
35 // expected-warning@-5 {{implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull'}}
36 // expected-warning@-5 {{implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull'}}