aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/format-strings-fixit.c
diff options
context:
space:
mode:
authorTom Care <tcare@apple.com>2010-06-11 04:22:02 +0000
committerTom Care <tcare@apple.com>2010-06-11 04:22:02 +0000
commit876e994957472eda4b40136d4e1d6e08e2be338f (patch)
treee11b0094f73ab59b6f69a7df8ab80cbcf588830c /test/Sema/format-strings-fixit.c
parente60cea829b3bc45fcfedbfdb08cffb61f5bde79f (diff)
Small fixes regarding printf fix suggestions.
- Added some handling of flags that become invalid when changing the conversion specifier. - Changed fixit behavior to remove unnecessary length modifiers. - Separated some tests out and added some comments. modified: lib/Analysis/PrintfFormatString.cpp test/Sema/format-strings-fixit.c git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105807 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/format-strings-fixit.c')
-rw-r--r--test/Sema/format-strings-fixit.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/test/Sema/format-strings-fixit.c b/test/Sema/format-strings-fixit.c
index ba38973049..9a1fef0401 100644
--- a/test/Sema/format-strings-fixit.c
+++ b/test/Sema/format-strings-fixit.c
@@ -10,11 +10,19 @@
int printf(char const *, ...);
void test() {
- printf("%0s", (int) 123);
- printf("abc%f", "testing testing 123");
+ // Basic types
+ printf("%s", (int) 123);
+ printf("abc%0f", "testing testing 123");
printf("%u", (long) -12);
+
+ // Larger types
printf("%+.2d", (unsigned long long) 123456);
printf("%1d", (long double) 1.23);
- printf("%Ld", (long double) -4.56);
+
+ // Flag handling
+ printf("%0+s", (unsigned) 31337); // flags should stay
+ printf("%0f", "test"); // flag should be removed
+
+ // Positional arguments
printf("%1$f:%2$.*3$f:%4$.*3$f\n", 1, 2, 3, 4);
}