From 0e5badd93b1c6c67bf29b7808f16b15b8d94549d Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Wed, 5 Dec 2012 18:44:49 +0000 Subject: Format strings: offer a cast to 'unichar' for %C in Objective-C contexts. For most cases where a conversion specifier doesn't match an argument, we usually guess that the conversion specifier is wrong. However, if the argument is an integer type and the specifier is %C, it's likely the user really did mean to print the integer as a character. (This is more common than %c because there is no way to specify a unichar literal -- you have to write an integer literal, such as '0x2603', and then cast it to unichar.) This does not change the behavior of %S, since there are fewer cases where printing a literal Unicode *string* is necessary, but this could easily be changed in the future. llvm-svn: 169400 --- clang/test/SemaObjC/format-strings-objc.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'clang/test/SemaObjC/format-strings-objc.m') diff --git a/clang/test/SemaObjC/format-strings-objc.m b/clang/test/SemaObjC/format-strings-objc.m index 7faa995002d..bd33ad41a56 100644 --- a/clang/test/SemaObjC/format-strings-objc.m +++ b/clang/test/SemaObjC/format-strings-objc.m @@ -145,7 +145,7 @@ void test_percent_S() { NSLog(@"%S", ptr); // no-warning const wchar_t* wchar_ptr = L"ab"; - NSLog(@"%S", wchar_ptr); // expected-warning{{format specifies type 'const unsigned short *' but the argument has type 'const wchar_t *'}} + NSLog(@"%S", wchar_ptr); // expected-warning{{format specifies type 'const unichar *' (aka 'const unsigned short *') but the argument has type 'const wchar_t *'}} } void test_percent_ls() { @@ -154,7 +154,7 @@ void test_percent_ls() { NSLog(@"%ls", ptr); // no-warning const wchar_t* wchar_ptr = L"ab"; - NSLog(@"%ls", wchar_ptr); // expected-warning{{format specifies type 'const unsigned short *' but the argument has type 'const wchar_t *'}} + NSLog(@"%ls", wchar_ptr); // expected-warning{{format specifies type 'const unichar *' (aka 'const unsigned short *') but the argument has type 'const wchar_t *'}} } void test_percent_C() { @@ -162,7 +162,7 @@ void test_percent_C() { NSLog(@"%C", data); // no-warning const wchar_t wchar_data = L'a'; - NSLog(@"%C", wchar_data); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'wchar_t'}} + NSLog(@"%C", wchar_data); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'wchar_t'}} } // Test that %@ works with toll-free bridging (). -- cgit v1.2.3