2012-09-13 10:11:15 +08:00
|
|
|
// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -fblocks -Wformat-non-iso -verify %s
|
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -fblocks -Wformat-non-iso -verify %s
|
2012-09-06 06:56:26 +08:00
|
|
|
|
2014-05-31 12:12:14 +08:00
|
|
|
// RUN: %clang_cc1 -triple i386-apple-darwin9 -fdiagnostics-parseable-fixits -fblocks -Wformat-non-iso %s 2>&1 | FileCheck -check-prefix=CHECK -check-prefix=CHECK-32 %s
|
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fdiagnostics-parseable-fixits -fblocks -Wformat-non-iso %s 2>&1 | FileCheck -check-prefix=CHECK -check-prefix=CHECK-64 %s
|
2012-09-06 06:56:26 +08:00
|
|
|
|
|
|
|
int printf(const char * restrict, ...);
|
|
|
|
|
|
|
|
#if __LP64__
|
2017-06-27 07:02:27 +08:00
|
|
|
typedef long CFIndex;
|
2012-09-06 06:56:26 +08:00
|
|
|
typedef long NSInteger;
|
|
|
|
typedef unsigned long NSUInteger;
|
|
|
|
typedef int SInt32;
|
|
|
|
typedef unsigned int UInt32;
|
|
|
|
|
|
|
|
#else
|
2017-06-27 07:02:27 +08:00
|
|
|
typedef int CFIndex;
|
2012-09-06 06:56:26 +08:00
|
|
|
typedef int NSInteger;
|
|
|
|
typedef unsigned int NSUInteger;
|
|
|
|
typedef long SInt32;
|
|
|
|
typedef unsigned long UInt32;
|
|
|
|
#endif
|
|
|
|
|
2013-03-26 06:28:37 +08:00
|
|
|
typedef SInt32 OSStatus;
|
|
|
|
|
2014-05-31 12:12:14 +08:00
|
|
|
typedef enum NSIntegerEnum : NSInteger {
|
|
|
|
EnumValueA,
|
|
|
|
EnumValueB
|
|
|
|
} NSIntegerEnum;
|
|
|
|
|
2017-06-27 07:02:27 +08:00
|
|
|
CFIndex getCFIndex();
|
2012-09-06 06:56:26 +08:00
|
|
|
NSInteger getNSInteger();
|
|
|
|
NSUInteger getNSUInteger();
|
|
|
|
SInt32 getSInt32();
|
|
|
|
UInt32 getUInt32();
|
2014-05-31 12:12:14 +08:00
|
|
|
NSIntegerEnum getNSIntegerEnum();
|
2012-09-06 06:56:26 +08:00
|
|
|
|
|
|
|
void testCorrectionInAllCases() {
|
|
|
|
printf("%s", getNSInteger()); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
printf("%s", getNSUInteger()); // expected-warning{{values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead}}
|
|
|
|
printf("%s", getSInt32()); // expected-warning{{values of type 'SInt32' should not be used as format arguments; add an explicit cast to 'int' instead}}
|
|
|
|
printf("%s", getUInt32()); // expected-warning{{values of type 'UInt32' should not be used as format arguments; add an explicit cast to 'unsigned int' instead}}
|
|
|
|
|
2013-01-18 02:47:12 +08:00
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:11-[[@LINE-5]]:13}:"%ld"
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:16-[[@LINE-6]]:16}:"(long)"
|
2012-09-06 06:56:26 +08:00
|
|
|
|
2013-01-18 02:47:12 +08:00
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-7]]:11-[[@LINE-7]]:13}:"%lu"
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-8]]:16-[[@LINE-8]]:16}:"(unsigned long)"
|
2012-09-06 06:56:26 +08:00
|
|
|
|
2013-01-18 02:47:12 +08:00
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-9]]:11-[[@LINE-9]]:13}:"%d"
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-10]]:16-[[@LINE-10]]:16}:"(int)"
|
2012-09-06 06:56:26 +08:00
|
|
|
|
2013-01-18 02:47:12 +08:00
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-11]]:11-[[@LINE-11]]:13}:"%u"
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-12]]:16-[[@LINE-12]]:16}:"(unsigned int)"
|
2014-05-31 12:12:14 +08:00
|
|
|
|
|
|
|
printf("%s", getNSIntegerEnum()); // expected-warning{{enum values with underlying type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"%ld"
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:16-[[@LINE-3]]:16}:"(long)"
|
2017-06-27 07:02:27 +08:00
|
|
|
|
|
|
|
printf("%s", getCFIndex()); // expected-warning{{values of type 'CFIndex' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"%ld"
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:16-[[@LINE-3]]:16}:"(long)"
|
2012-09-06 06:56:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@interface Foo {
|
|
|
|
@public
|
|
|
|
NSInteger _value;
|
|
|
|
}
|
|
|
|
- (NSInteger)getInteger;
|
|
|
|
|
|
|
|
@property NSInteger value;
|
|
|
|
@end
|
|
|
|
|
|
|
|
struct Bar {
|
|
|
|
NSInteger value;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void testParens(Foo *obj, struct Bar *record) {
|
|
|
|
NSInteger arr[4] = {0};
|
|
|
|
NSInteger i = 0;
|
|
|
|
|
2012-12-06 02:44:44 +08:00
|
|
|
// These cases match the relevant cases in CheckPrintfHandler::checkFormatExpr.
|
2012-09-06 06:56:26 +08:00
|
|
|
printf("%s", arr[0]); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
printf("%s", getNSInteger()); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
printf("%s", i); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
printf("%s", obj->_value); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
printf("%s", [obj getInteger]); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
printf("%s", obj.value); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
printf("%s", record->value); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
2014-11-13 07:15:38 +08:00
|
|
|
printf("%s", (i ? i : i)); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
2012-09-06 06:56:26 +08:00
|
|
|
printf("%s", *arr); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
|
|
|
|
// CHECK-NOT: fix-it:{{.*}}:")"
|
|
|
|
|
2014-11-13 07:15:38 +08:00
|
|
|
printf("%s", i ? i : i); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
2012-09-06 06:56:26 +08:00
|
|
|
|
2013-01-18 02:47:12 +08:00
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"%ld"
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:16-[[@LINE-3]]:16}:"(long)("
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:25-[[@LINE-4]]:25}:")"
|
2012-09-06 06:56:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if __LP64__
|
|
|
|
|
|
|
|
void testWarn() {
|
|
|
|
printf("%d", getNSInteger()); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
printf("%u", getNSUInteger()); // expected-warning{{values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead}}
|
|
|
|
printf("%ld", getSInt32()); // expected-warning{{values of type 'SInt32' should not be used as format arguments; add an explicit cast to 'int' instead}}
|
|
|
|
printf("%lu", getUInt32()); // expected-warning{{values of type 'UInt32' should not be used as format arguments; add an explicit cast to 'unsigned int' instead}}
|
|
|
|
|
2013-01-18 02:47:12 +08:00
|
|
|
// CHECK-64: fix-it:"{{.*}}":{[[@LINE-5]]:11-[[@LINE-5]]:13}:"%ld"
|
|
|
|
// CHECK-64: fix-it:"{{.*}}":{[[@LINE-6]]:16-[[@LINE-6]]:16}:"(long)"
|
2012-09-06 06:56:26 +08:00
|
|
|
|
2013-01-18 02:47:12 +08:00
|
|
|
// CHECK-64: fix-it:"{{.*}}":{[[@LINE-7]]:11-[[@LINE-7]]:13}:"%lu"
|
|
|
|
// CHECK-64: fix-it:"{{.*}}":{[[@LINE-8]]:16-[[@LINE-8]]:16}:"(unsigned long)"
|
2012-09-06 06:56:26 +08:00
|
|
|
|
2013-01-18 02:47:12 +08:00
|
|
|
// CHECK-64: fix-it:"{{.*}}":{[[@LINE-9]]:11-[[@LINE-9]]:14}:"%d"
|
|
|
|
// CHECK-64: fix-it:"{{.*}}":{[[@LINE-10]]:17-[[@LINE-10]]:17}:"(int)"
|
2012-09-06 06:56:26 +08:00
|
|
|
|
2013-01-18 02:47:12 +08:00
|
|
|
// CHECK-64: fix-it:"{{.*}}":{[[@LINE-11]]:11-[[@LINE-11]]:14}:"%u"
|
|
|
|
// CHECK-64: fix-it:"{{.*}}":{[[@LINE-12]]:17-[[@LINE-12]]:17}:"(unsigned int)"
|
2014-05-31 12:12:14 +08:00
|
|
|
|
|
|
|
printf("%d", getNSIntegerEnum()); // expected-warning{{enum values with underlying type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
|
|
|
|
// CHECK-64: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"%ld"
|
|
|
|
// CHECK-64: fix-it:"{{.*}}":{[[@LINE-3]]:16-[[@LINE-3]]:16}:"(long)"
|
2017-06-27 07:02:27 +08:00
|
|
|
|
|
|
|
printf("%d", getCFIndex()); // expected-warning{{values of type 'CFIndex' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
|
|
|
|
// CHECK-64: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"%ld"
|
|
|
|
// CHECK-64: fix-it:"{{.*}}":{[[@LINE-3]]:16-[[@LINE-3]]:16}:"(long)"
|
2012-09-06 06:56:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void testPreserveHex() {
|
|
|
|
printf("%x", getNSInteger()); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
printf("%x", getNSUInteger()); // expected-warning{{values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead}}
|
|
|
|
|
2013-01-18 02:47:12 +08:00
|
|
|
// CHECK-64: fix-it:"{{.*}}":{[[@LINE-3]]:11-[[@LINE-3]]:13}:"%lx"
|
|
|
|
// CHECK-64: fix-it:"{{.*}}":{[[@LINE-4]]:16-[[@LINE-4]]:16}:"(long)"
|
2012-09-06 06:56:26 +08:00
|
|
|
|
2013-01-18 02:47:12 +08:00
|
|
|
// CHECK-64: fix-it:"{{.*}}":{[[@LINE-5]]:11-[[@LINE-5]]:13}:"%lx"
|
|
|
|
// CHECK-64: fix-it:"{{.*}}":{[[@LINE-6]]:16-[[@LINE-6]]:16}:"(unsigned long)"
|
2012-09-06 06:56:26 +08:00
|
|
|
}
|
|
|
|
|
2013-01-18 02:47:16 +08:00
|
|
|
void testSignedness(NSInteger i, NSUInteger u) {
|
|
|
|
printf("%d", u); // expected-warning{{values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead}}
|
|
|
|
printf("%i", u); // expected-warning{{values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead}}
|
|
|
|
printf("%u", i); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
|
|
|
|
// CHECK-64: fix-it:"{{.*}}":{[[@LINE-4]]:11-[[@LINE-4]]:13}:"%lu"
|
|
|
|
// CHECK-64: fix-it:"{{.*}}":{[[@LINE-4]]:11-[[@LINE-4]]:13}:"%lu"
|
|
|
|
// CHECK-64: fix-it:"{{.*}}":{[[@LINE-4]]:11-[[@LINE-4]]:13}:"%ld"
|
|
|
|
}
|
|
|
|
|
2012-09-06 06:56:26 +08:00
|
|
|
void testNoWarn() {
|
|
|
|
printf("%ld", getNSInteger()); // no-warning
|
|
|
|
printf("%lu", getNSUInteger()); // no-warning
|
|
|
|
printf("%d", getSInt32()); // no-warning
|
|
|
|
printf("%u", getUInt32()); // no-warning
|
2014-05-31 12:12:14 +08:00
|
|
|
printf("%ld", getNSIntegerEnum()); // no-warning
|
2012-09-06 06:56:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
void testWarn() {
|
|
|
|
printf("%ld", getNSInteger()); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
printf("%lu", getNSUInteger()); // expected-warning{{values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead}}
|
|
|
|
printf("%d", getSInt32()); // expected-warning{{values of type 'SInt32' should not be used as format arguments; add an explicit cast to 'int' instead}}
|
|
|
|
printf("%u", getUInt32()); // expected-warning{{values of type 'UInt32' should not be used as format arguments; add an explicit cast to 'unsigned int' instead}}
|
|
|
|
|
2013-01-18 02:47:12 +08:00
|
|
|
// CHECK-32: fix-it:"{{.*}}":{[[@LINE-5]]:17-[[@LINE-5]]:17}:"(long)"
|
|
|
|
// CHECK-32: fix-it:"{{.*}}":{[[@LINE-5]]:17-[[@LINE-5]]:17}:"(unsigned long)"
|
|
|
|
// CHECK-32: fix-it:"{{.*}}":{[[@LINE-5]]:16-[[@LINE-5]]:16}:"(int)"
|
|
|
|
// CHECK-32: fix-it:"{{.*}}":{[[@LINE-5]]:16-[[@LINE-5]]:16}:"(unsigned int)"
|
2014-05-31 12:12:14 +08:00
|
|
|
|
|
|
|
printf("%ld", getNSIntegerEnum()); // expected-warning{{enum values with underlying type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
|
|
|
|
// CHECK-32: fix-it:"{{.*}}":{[[@LINE-2]]:17-[[@LINE-2]]:17}:"(long)"
|
2017-06-27 07:02:27 +08:00
|
|
|
|
|
|
|
printf("%ld", getCFIndex()); // expected-warning{{values of type 'CFIndex' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
|
|
|
|
// CHECK-32: fix-it:"{{.*}}":{[[@LINE-2]]:17-[[@LINE-2]]:17}:"(long)"
|
2012-09-06 06:56:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void testPreserveHex() {
|
|
|
|
printf("%lx", getNSInteger()); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
printf("%lx", getNSUInteger()); // expected-warning{{values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead}}
|
|
|
|
|
2013-01-18 02:47:12 +08:00
|
|
|
// CHECK-32: fix-it:"{{.*}}":{[[@LINE-3]]:17-[[@LINE-3]]:17}:"(long)"
|
|
|
|
// CHECK-32: fix-it:"{{.*}}":{[[@LINE-3]]:17-[[@LINE-3]]:17}:"(unsigned long)"
|
2012-09-06 06:56:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void testNoWarn() {
|
|
|
|
printf("%d", getNSInteger()); // no-warning
|
|
|
|
printf("%u", getNSUInteger()); // no-warning
|
|
|
|
printf("%ld", getSInt32()); // no-warning
|
|
|
|
printf("%lu", getUInt32()); // no-warning
|
2014-05-31 12:12:14 +08:00
|
|
|
printf("%d", getNSIntegerEnum()); // no-warning
|
2012-09-06 06:56:26 +08:00
|
|
|
}
|
|
|
|
|
2013-01-18 02:47:16 +08:00
|
|
|
void testSignedness(NSInteger i, NSUInteger u) {
|
|
|
|
// It is valid to use a specifier with the opposite signedness as long as
|
|
|
|
// the type is correct.
|
|
|
|
printf("%d", u); // no-warning
|
|
|
|
printf("%i", u); // no-warning
|
|
|
|
printf("%u", i); // no-warning
|
|
|
|
}
|
|
|
|
|
2012-09-06 06:56:26 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
void testCasts() {
|
|
|
|
printf("%s", (NSInteger)0); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
printf("%s", (NSUInteger)0); // expected-warning{{values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead}}
|
|
|
|
printf("%s", (SInt32)0); // expected-warning{{values of type 'SInt32' should not be used as format arguments; add an explicit cast to 'int' instead}}
|
|
|
|
printf("%s", (UInt32)0); // expected-warning{{values of type 'UInt32' should not be used as format arguments; add an explicit cast to 'unsigned int' instead}}
|
|
|
|
|
2013-01-18 02:47:12 +08:00
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:11-[[@LINE-5]]:13}:"%ld"
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:16-[[@LINE-6]]:27}:"(long)"
|
2012-09-06 06:56:26 +08:00
|
|
|
|
2013-01-18 02:47:12 +08:00
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-7]]:11-[[@LINE-7]]:13}:"%lu"
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-8]]:16-[[@LINE-8]]:28}:"(unsigned long)"
|
2012-09-06 06:56:26 +08:00
|
|
|
|
2013-01-18 02:47:12 +08:00
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-9]]:11-[[@LINE-9]]:13}:"%d"
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-10]]:16-[[@LINE-10]]:24}:"(int)"
|
2012-09-06 06:56:26 +08:00
|
|
|
|
2013-01-18 02:47:12 +08:00
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-11]]:11-[[@LINE-11]]:13}:"%u"
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-12]]:16-[[@LINE-12]]:24}:"(unsigned int)"
|
2014-05-31 12:12:14 +08:00
|
|
|
|
|
|
|
printf("%s", (NSIntegerEnum)0); // expected-warning{{enum values with underlying type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"%ld"
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:16-[[@LINE-3]]:31}:"(long)"
|
2017-06-27 07:02:27 +08:00
|
|
|
|
|
|
|
printf("%s", (CFIndex)0); // expected-warning{{values of type 'CFIndex' should not be used as format arguments; add an explicit cast to 'long' instead}}
|
|
|
|
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"%ld"
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:16-[[@LINE-3]]:25}:"(long)"
|
2012-09-06 06:56:26 +08:00
|
|
|
}
|
2012-09-13 10:11:03 +08:00
|
|
|
|
|
|
|
void testCapitals() {
|
2012-09-13 10:11:15 +08:00
|
|
|
printf("%D", 1); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}}
|
|
|
|
printf("%U", 1); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'u'?}}
|
|
|
|
printf("%O", 1); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'o'?}}
|
2012-09-13 10:11:03 +08:00
|
|
|
|
2013-01-18 02:47:12 +08:00
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:12-[[@LINE-4]]:13}:"d"
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:12-[[@LINE-4]]:13}:"u"
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:12-[[@LINE-4]]:13}:"o"
|
2012-09-13 10:11:03 +08:00
|
|
|
|
2012-09-13 10:11:15 +08:00
|
|
|
|
|
|
|
printf("%lD", 1); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}} expected-warning{{format specifies type 'long' but the argument has type 'int'}}
|
|
|
|
|
|
|
|
// FIXME: offering two somewhat-conflicting fixits is less than ideal.
|
2013-01-18 02:47:12 +08:00
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:13-[[@LINE-3]]:14}:"d"
|
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:11-[[@LINE-4]]:14}:"%D"
|
2012-09-13 10:11:03 +08:00
|
|
|
}
|
2013-03-26 06:28:37 +08:00
|
|
|
|
|
|
|
void testLayeredTypedefs(OSStatus i) {
|
|
|
|
printf("%s", i); // expected-warning {{values of type 'OSStatus' should not be used as format arguments}}
|
2013-03-26 07:05:40 +08:00
|
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%d"
|
2013-03-26 06:28:37 +08:00
|
|
|
}
|
|
|
|
|