[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Sema / format-strings-no-fixit.c
blobdd323bf5c5de7b6f7935720cffc19f0f585a37e6
1 // RUN: cp %s %t
2 // RUN: %clang_cc1 -fsyntax-only -fixit %t
3 // RUN: %clang_cc1 -E -o - %t | FileCheck %s
5 /* This is a test of the various code modification hints that are
6 provided as part of warning or extension diagnostics. Only
7 warnings for format strings within the function call will be
8 fixed by -fixit. Other format strings will be left alone. */
10 int printf(char const *, ...);
11 int scanf(char const *, ...);
13 void pr9751(void) {
14 const char kFormat1[] = "%s";
15 printf(kFormat1, 5);
16 printf("%s", 5);
18 const char kFormat2[] = "%.3p";
19 void *p;
20 printf(kFormat2, p);
21 printf("%.3p", p);
23 const char kFormat3[] = "%0s";
24 printf(kFormat3, "a");
25 printf("%0s", "a");
27 const char kFormat4[] = "%hhs";
28 printf(kFormat4, "a");
29 printf("%hhs", "a");
31 const char kFormat5[] = "%-0d";
32 printf(kFormat5, 5);
33 printf("%-0d", 5);
35 const char kFormat6[] = "%00d";
36 int *i;
37 scanf(kFormat6, i);
38 scanf("%00d", i);
41 // CHECK: const char kFormat1[] = "%s";
42 // CHECK: printf(kFormat1, 5);
43 // CHECK: printf("%d", 5);
45 // CHECK: const char kFormat2[] = "%.3p";
46 // CHECK: void *p;
47 // CHECK: printf(kFormat2, p);
48 // CHECK: printf("%p", p);
50 // CHECK: const char kFormat3[] = "%0s";
51 // CHECK: printf(kFormat3, "a");
52 // CHECK: printf("%s", "a");
54 // CHECK: const char kFormat4[] = "%hhs";
55 // CHECK: printf(kFormat4, "a");
56 // CHECK: printf("%s", "a");
58 // CHECK: const char kFormat5[] = "%-0d";
59 // CHECK: printf(kFormat5, 5);
60 // CHECK: printf("%-d", 5);
62 // CHECK: const char kFormat6[] = "%00d";
63 // CHECK: int *i;
64 // CHECK: scanf(kFormat6, i);
65 // CHECK: scanf("%d", i);