format-strings-fixit.c revision 01cb1aa458516b9061a65ea4b8a2ca55f71cb34f
1// RUN: cp %s %t 2// RUN: %clang_cc1 -pedantic -Wall -fixit %t || true 3// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror %t 4 5/* This is a test of the various code modification hints that are 6 provided as part of warning or extension diagnostics. All of the 7 warnings will be fixed by -fixit, and the resulting file should 8 compile cleanly with -Werror -pedantic. */ 9 10int printf(char const *, ...); 11 12void test() { 13 // Basic types 14 printf("%s", (int) 123); 15 printf("abc%0f", "testing testing 123"); 16 printf("%u", (long) -12); 17 printf("%p", 123); 18 printf("%c\n", "x"); 19 printf("%c\n", 1.23); 20 21 // Larger types 22 printf("%+.2d", (unsigned long long) 123456); 23 printf("%1d", (long double) 1.23); 24 25 // Flag handling 26 printf("%0+s", (unsigned) 31337); // flags should stay 27 printf("%0f", "test"); // flag should be removed 28 29 // Positional arguments 30 printf("%1$f:%2$.*3$f:%4$.*3$f\n", 1, 2, 3, 4); 31} 32