blob: bbdd4d81059539e63496f98450d4443ca4ec286c [file] [log] [blame]
Tom Care3bfc5f42010-06-09 04:11:11 +00001// 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() {
Tom Care876e9942010-06-11 04:22:02 +000013 // Basic types
14 printf("%s", (int) 123);
15 printf("abc%0f", "testing testing 123");
Tom Care3bfc5f42010-06-09 04:11:11 +000016 printf("%u", (long) -12);
Ted Kremenek13927a42010-06-16 21:23:04 +000017 printf("%p", 123);
Tom Care876e9942010-06-11 04:22:02 +000018
19 // Larger types
Tom Care3bfc5f42010-06-09 04:11:11 +000020 printf("%+.2d", (unsigned long long) 123456);
21 printf("%1d", (long double) 1.23);
Tom Care876e9942010-06-11 04:22:02 +000022
23 // Flag handling
24 printf("%0+s", (unsigned) 31337); // flags should stay
25 printf("%0f", "test"); // flag should be removed
26
27 // Positional arguments
Tom Care3bfc5f42010-06-09 04:11:11 +000028 printf("%1$f:%2$.*3$f:%4$.*3$f\n", 1, 2, 3, 4);
29}