diff options
-rw-r--r-- | lib/Analysis/PrintfFormatString.cpp | 2 | ||||
-rw-r--r-- | test/Sema/format-strings-fixit.c | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/Analysis/PrintfFormatString.cpp b/lib/Analysis/PrintfFormatString.cpp index e14c952292..097cc62a6c 100644 --- a/lib/Analysis/PrintfFormatString.cpp +++ b/lib/Analysis/PrintfFormatString.cpp @@ -366,6 +366,8 @@ bool PrintfSpecifier::fixType(QualType QT, const LangOptions &LangOpt) { // Set the long length modifier for wide characters if (QT->getPointeeType()->isWideCharType()) LM.setKind(LengthModifier::AsWideChar); + else + LM.setKind(LengthModifier::None); return true; } diff --git a/test/Sema/format-strings-fixit.c b/test/Sema/format-strings-fixit.c index e87d8acef5..bfb54327b7 100644 --- a/test/Sema/format-strings-fixit.c +++ b/test/Sema/format-strings-fixit.c @@ -42,7 +42,7 @@ void test() { // Bad length modifiers printf("%hhs", "foo"); printf("%1$zp", (void *)0); - + // Perserve the original formatting for unsigned integers. unsigned long val = 42; printf("%X", val); @@ -57,6 +57,9 @@ void test() { printf("%f", (intmax_t) 42); printf("%f", (uintmax_t) 42); printf("%f", (ptrdiff_t) 42); + + // string + printf("%ld", "foo"); } // Validate the fixes... @@ -83,3 +86,4 @@ void test() { // CHECK: printf("%jd", (intmax_t) 42); // CHECK: printf("%ju", (uintmax_t) 42); // CHECK: printf("%td", (ptrdiff_t) 42); +// CHECK: printf("%s", "foo"); |