blob: 701e945f69021a00d51907f44a3f4da4e5edf79b [file] [log] [blame]
Richard Trieu55733de2011-10-28 00:41:25 +00001// RUN: cp %s %t
2// RUN: %clang_cc1 -fsyntax-only -fixit %t
3// RUN: %clang_cc1 -E -o - %t | FileCheck %s
4
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. */
9
10int printf(char const *, ...);
11int scanf(char const *, ...);
12
13void pr9751() {
14 const char kFormat1[] = "%s";
15 printf(kFormat1, 5);
16 printf("%s", 5);
17
18 const char kFormat2[] = "%.3p";
19 void *p;
20 printf(kFormat2, p);
21 printf("%.3p", p);
22
23 const char kFormat3[] = "%0s";
24 printf(kFormat3, "a");
25 printf("%0s", "a");
26
27 const char kFormat4[] = "%hhs";
28 printf(kFormat4, "a");
29 printf("%hhs", "a");
30
31 const char kFormat5[] = "%-0d";
32 printf(kFormat5, 5);
33 printf("%-0d", 5);
34
35 const char kFormat6[] = "%00d";
36 int *i;
37 scanf(kFormat6, i);
38 scanf("%00d", i);
39}
40
41// CHECK: const char kFormat1[] = "%s";
42// CHECK: printf(kFormat1, 5);
43// CHECK: printf("%d", 5);
44
45// CHECK: const char kFormat2[] = "%.3p";
46// CHECK: void *p;
47// CHECK: printf(kFormat2, p);
48// CHECK: printf("%p", p);
49
50// CHECK: const char kFormat3[] = "%0s";
51// CHECK: printf(kFormat3, "a");
52// CHECK: printf("%s", "a");
53
54// CHECK: const char kFormat4[] = "%hhs";
55// CHECK: printf(kFormat4, "a");
56// CHECK: printf("%s", "a");
57
58// CHECK: const char kFormat5[] = "%-0d";
59// CHECK: printf(kFormat5, 5);
60// CHECK: printf("%-d", 5);
61
62// CHECK: const char kFormat6[] = "%00d";
63// CHECK: int *i;
64// CHECK: scanf(kFormat6, i);
65// CHECK: scanf("%d", i);