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 5 6#if !defined(PEDANTIC) 7// expected-no-diagnostics 8#endif 9 10#if __LP64__ 11typedef unsigned long NSUInteger; 12typedef long NSInteger; 13typedef long ptrdiff_t; 14#else 15typedef unsigned int NSUInteger; 16typedef int NSInteger; 17#if __is_target_os(watchos) 18 // Watch ABI uses long for ptrdiff_t. 19 typedef long ptrdiff_t; 20#else 21 typedef int ptrdiff_t; 22#endif 23#endif 24 25@class NSString; 26 27extern void NSLog(NSString *format, ...); 28 29void testSizeSpecifier() { 30 NSInteger i = 0; 31 NSUInteger j = 0; 32 NSLog(@"max NSInteger = %zi", i); 33 NSLog(@"max NSUinteger = %zu", j); 34 35#if defined(PEDANTIC) 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}} 38#endif 39} 40 41void testPtrdiffSpecifier(ptrdiff_t x) { 42 NSInteger i = 0; 43 NSUInteger j = 0; 44 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}} 51#endif 52} 53