forked from OSchip/llvm-project
fix format specifier fixit for printf("%ld", "foo");
It should reset the length modifier (unless it's a wchar_t string). llvm-svn: 146252
This commit is contained in:
parent
222c66db38
commit
2027de3be9
|
@ -366,6 +366,8 @@ bool PrintfSpecifier::fixType(QualType QT, const LangOptions &LangOpt) {
|
||||||
// Set the long length modifier for wide characters
|
// Set the long length modifier for wide characters
|
||||||
if (QT->getPointeeType()->isWideCharType())
|
if (QT->getPointeeType()->isWideCharType())
|
||||||
LM.setKind(LengthModifier::AsWideChar);
|
LM.setKind(LengthModifier::AsWideChar);
|
||||||
|
else
|
||||||
|
LM.setKind(LengthModifier::None);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,9 @@ void test() {
|
||||||
printf("%f", (intmax_t) 42);
|
printf("%f", (intmax_t) 42);
|
||||||
printf("%f", (uintmax_t) 42);
|
printf("%f", (uintmax_t) 42);
|
||||||
printf("%f", (ptrdiff_t) 42);
|
printf("%f", (ptrdiff_t) 42);
|
||||||
|
|
||||||
|
// string
|
||||||
|
printf("%ld", "foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the fixes...
|
// Validate the fixes...
|
||||||
|
@ -83,3 +86,4 @@ void test() {
|
||||||
// CHECK: printf("%jd", (intmax_t) 42);
|
// CHECK: printf("%jd", (intmax_t) 42);
|
||||||
// CHECK: printf("%ju", (uintmax_t) 42);
|
// CHECK: printf("%ju", (uintmax_t) 42);
|
||||||
// CHECK: printf("%td", (ptrdiff_t) 42);
|
// CHECK: printf("%td", (ptrdiff_t) 42);
|
||||||
|
// CHECK: printf("%s", "foo");
|
||||||
|
|
Loading…
Reference in New Issue