1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -verify -Wformat %s 2 // RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -fdiagnostics-parseable-fixits -Wformat %s 2>&1 | FileCheck %s 3 4 extern "C" int printf(const char * restrict, ...); 5 6 #if __LP64__ 7 typedef long CFIndex; 8 typedef long NSInteger; 9 typedef unsigned long NSUInteger; 10 #else 11 typedef int CFIndex; 12 typedef int NSInteger; 13 typedef unsigned int NSUInteger; 14 #endif 15 16 enum class CFIndexEnum : CFIndex { One }; 17 enum class NSIntegerEnum : NSInteger { Two }; 18 enum class NSUIntegerEnum : NSUInteger { Three }; 19 20 void f() { 21 printf("%d", CFIndexEnum::One); // expected-warning{{format specifies type 'int' but the argument has type 'CFIndexEnum'}} 22 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%ld" 23 // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"static_cast<long>(" 24 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:32-[[@LINE-3]]:32}:")" 25 26 printf("%d", NSIntegerEnum::Two); // expected-warning{{format specifies type 'int' but the argument has type 'NSIntegerEnum'}} 27 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%ld" 28 // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"static_cast<long>(" 29 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:34-[[@LINE-3]]:34}:")" 30 31 printf("%d", NSUIntegerEnum::Three); // expected-warning{{format specifies type 'int' but the argument has type 'NSUIntegerEnum'}} 32 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%lu" 33 // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"static_cast<unsigned long>(" 34 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:37-[[@LINE-3]]:37}:")" 35 } 36