1 // RUN: %clang_cc1 -triple thumbv7-apple-ios -Wno-objc-root-class -fsyntax-only -verify -Wformat %s
2 // RUN: %clang_cc1 -triple thumbv7-apple-ios -Wno-objc-root-class -fsyntax-only -verify -Wformat-pedantic -DPEDANTIC %s
3 // RUN: %clang_cc1 -triple thumbv7k-apple-watchos2.0.0 -fsyntax-only -fblocks -verify %s
4 // RUN: %clang_cc1 -triple thumbv7k-apple-watchos2.0.0 -fsyntax-only -fblocks -verify -Wformat-pedantic -DPEDANTIC %s
7 // expected-no-diagnostics
11 typedef unsigned long NSUInteger;
12 typedef long NSInteger;
13 typedef long ptrdiff_t;
15 typedef unsigned int NSUInteger;
16 typedef int NSInteger;
17 #if __is_target_os(watchos)
18 // Watch ABI uses long for ptrdiff_t.
19 typedef long ptrdiff_t;
21 typedef int ptrdiff_t;
27 extern void NSLog(NSString *format, ...);
29 void testSizeSpecifier(void) {
32 NSLog(@"max NSInteger = %zi", i);
33 NSLog(@"max NSUinteger = %zu", j);
36 // expected-warning@-4 {{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
37 // expected-warning@-4 {{values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead}}
41 void testPtrdiffSpecifier(ptrdiff_t x) {
45 NSLog(@"ptrdiff_t NSUinteger: %tu", j);
46 NSLog(@"ptrdiff_t NSInteger: %td", i);
47 NSLog(@"ptrdiff_t %tu, %td", x, x);
48 #if __is_target_os(watchos) && defined(PEDANTIC)
49 // expected-warning@-4 {{values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead}}
50 // expected-warning@-4 {{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}