Lines Matching defs:printf

11 int printf(const char *restrict, ...); // expected-note{{passing argument to parameter here}}
31 printf(s); // expected-warning {{format string is not a string literal}}
50 printf("abc"
52 printf("abc\
59 printf("%*d", (unsigned) 1, 1); // no-warning
71 printf(s); // expected-warning {{format string is not a string literal}}
85 printf(i == 1 ? "yes" : "no"); // no-warning
86 printf(i == 0 ? (i == 1 ? "yes" : "no") : "dont know"); // no-warning
87 printf(i == 0 ? (i == 1 ? s : "no") : "dont know"); // expected-warning{{format string is not a string literal}}
88 printf("yes" ?: "no %d", 1); // expected-warning{{data argument not used by format string}}
95 printf("%n", b); // expected-warning{{format specifies type 'int *' but the argument has type 'char *'}}
96 printf("%n", &x); // no-warning
98 printf("%hhn", (signed char*)0); // no-warning
99 printf("%hhn", (char*)0); // no-warning
100 printf("%hhn", (unsigned char*)0); // no-warning
101 printf("%hhn", (int*)0); // expected-warning{{format specifies type 'signed char *' but the argument has type 'int *'}}
103 printf("%hn", (short*)0); // no-warning
104 printf("%hn", (unsigned short*)0); // no-warning
105 printf("%hn", (int*)0); // expected-warning{{format specifies type 'short *' but the argument has type 'int *'}}
107 printf("%n", (int*)0); // no-warning
108 printf("%n", (unsigned int*)0); // no-warning
109 printf("%n", (char*)0); // expected-warning{{format specifies type 'int *' but the argument has type 'char *'}}
111 printf("%ln", (long*)0); // no-warning
112 printf("%ln", (unsigned long*)0); // no-warning
113 printf("%ln", (int*)0); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}}
115 printf("%lln", (long long*)0); // no-warning
116 printf("%lln", (unsigned long long*)0); // no-warning
117 printf("%lln", (int*)0); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}}
119 printf("%qn", (long long*)0); // no-warning
120 printf("%qn", (unsigned long long*)0); // no-warning
121 printf("%qn", (int*)0); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}}
123 printf("%Ln", 0); // expected-warning{{length modifier 'L' results in undefined behavior or no effect with 'n' conversion specifier}}
129 printf("%s%lb%d","unix",10,20); // expected-warning {{invalid conversion specifier 'b'}}
137 printf("\0this is bogus%d",1); // expected-warning {{string contains '\0'}}
139 printf("%\0d",1); // expected-warning {{string contains '\0'}}
160 printf(L"foo %d",2); // expected-warning {{incompatible pointer types}}, expected-warning {{should not be a wide string}}
165 printf("%*d"); // expected-warning {{'*' specified field width is missing a matching 'int' argument}}
166 printf("%.*d"); // expected-warning {{'.*' specified field precision is missing a matching 'int' argument}}
167 printf("%*d",12,x); // no-warning
168 printf("%*d","foo",x); // expected-warning {{field width should have type 'int', but argument has type 'char *'}}
169 printf("%.*d","foo",x); // expected-warning {{field precision should have type 'int', but argument has type 'char *'}}
172 void __attribute__((format(printf,1,3))) myprintf(const char*, int blah, ...);
185 printf(s1); // no-warning
186 printf(s2); // no-warning
187 printf(s3); // expected-warning{{not a string literal}}
188 printf(s4); // expected-warning{{not a string literal}}
189 printf(s5); // expected-warning{{not a string literal}}
199 printf(P); // expected-warning {{format string is not a string literal (potentially insecure)}}
200 printf(P, 42);
209 printf("%s"); // expected-warning{{more '%' conversions than data arguments}}
210 printf("%@", 12); // expected-warning{{invalid conversion specifier '@'}}
211 printf("\0"); // expected-warning{{format string contains '\0' within the string body}}
212 printf("xs\0"); // expected-warning{{format string contains '\0' within the string body}}
213 printf("%*d\n"); // expected-warning{{'*' specified field width is missing a matching 'int' argument}}
214 printf("%*.*d\n", x); // expected-warning{{'.*' specified field precision is missing a matching 'int' argument}}
215 printf("%*d\n", f, x); // expected-warning{{field width should have type 'int', but argument has type 'double'}}
216 printf("%*.*d\n", x, f, x); // expected-warning{{field precision should have type 'int', but argument has type 'double'}}
217 printf("%**\n"); // expected-warning{{invalid conversion specifier '*'}}
218 printf("%d%d\n", x); // expected-warning{{more '%' conversions than data arguments}}
219 printf("%d\n", x, x); // expected-warning{{data argument not used by format string}}
220 printf("%W%d%Z\n", x, x, x); // expected-warning{{invalid conversion specifier 'W'}} expected-warning{{invalid conversion specifier 'Z'}}
221 printf("%"); // expected-warning{{incomplete format specifier}}
222 printf("%.d", x); // no-warning
223 printf("%.", x); // expected-warning{{incomplete format specifier}}
224 printf("%f", 4); // expected-warning{{format specifies type 'double' but the argument has type 'int'}}
225 printf("%qd", lli); // no-warning
226 printf("%qd", x); // expected-warning{{format specifies type 'long long' but the argument has type 'int'}}
227 printf("%qp", (void *)0); // expected-warning{{length modifier 'q' results in undefined behavior or no effect with 'p' conversion specifier}}
228 printf("hhX %hhX", (unsigned char)10); // no-warning
229 printf("llX %llX", (long long) 10); // no-warning
231 printf("%d", (unsigned char) 10); // no-warning
232 printf("%d", (long long) 10); // expected-warning{{format specifies type 'int' but the argument has type 'long long'}}
233 printf("%Lf\n", (long double) 1.0); // no-warning
234 printf("%f\n", (long double) 1.0); // expected-warning{{format specifies type 'double' but the argument has type 'long double'}}
236 printf("%.0Lf", (long double) 1.0); // no-warning
237 printf("%c\n", "x"); // expected-warning{{format specifies type 'int' but the argument has type 'char *'}}
238 printf("%c\n", 1.23); // expected-warning{{format specifies type 'int' but the argument has type 'double'}}
239 printf("Format %d, is %! %f", 1, 2, 4.4); // expected-warning{{invalid conversion specifier '!'}}
245 printf("%hhu", (short) 10); // expected-warning{{format specifies type 'unsigned char' but the argument has type 'short'}}
246 printf("%hu\n", (unsigned char) 1); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'unsigned char'}}
247 printf("%hu\n", (uint8_t)1); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'uint8_t'}}
251 printf("%p", p); // no-warning
252 printf("%p", 123); // expected-warning{{format specifies type 'void *' but the argument has type 'int'}}
253 printf("%.4p", p); // expected-warning{{precision used with 'p' conversion specifier, resulting in undefined behavior}}
254 printf("%+p", p); // expected-warning{{flag '+' results in undefined behavior with 'p' conversion specifier}}
255 printf("% p", p); // expected-warning{{flag ' ' results in undefined behavior with 'p' conversion specifier}}
256 printf("%0p", p); // expected-warning{{flag '0' results in undefined behavior with 'p' conversion specifier}}
257 printf("%s", s); // no-warning
258 printf("%+s", p); // expected-warning{{flag '+' results in undefined behavior with 's' conversion specifier}}
259 printf("% s", p); // expected-warning{{flag ' ' results in undefined behavior with 's' conversion specifier}}
260 printf("%0s", p); // expected-warning{{flag '0' results in undefined behavior with 's' conversion specifier}}
265 printf ("%.4s\n", buf); // no-warning
266 printf ("%.4s\n", &buf); // expected-warning{{format specifies type 'char *' but the argument has type 'unsigned char (*)[4]'}}
274 printf("bel: '0%hhd'\n", bel); // no-warning
275 printf("x: '0%hhd'\n", x); // expected-warning {{format specifies type 'char' but the argument has type 'short'}}
289 void f0(int_t x) { printf("%d\n", x); }
295 printf("%S", s); // no-warning
296 printf("%s", s); // expected-warning{{format specifies type 'char *' but the argument has type 'wchar_t *'}}
297 printf("%C", s[0]); // no-warning
298 printf("%c", s[0]);
301 // printf("%C", 10);
302 printf("%S", "hello"); // expected-warning{{but the argument has type 'char *'}}
309 printf("%0$", (int)2); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}}
310 printf("%1$*0$d", (int) 2); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}}
311 printf("%1$d", (int) 2); // no-warning
312 printf("%1$d", (int) 2, 2); // expected-warning{{data argument not used by format string}}
313 printf("%1$d%1$f", (int) 2); // expected-warning{{format specifies type 'double' but the argument has type 'int'}}
314 printf("%1$2.2d", (int) 2); // no-warning
315 printf("%2$*1$.2d", (int) 2, (int) 3); // no-warning
316 printf("%2$*8$d", (int) 2, (int) 3); // expected-warning{{specified field width is missing a matching 'int' argument}}
317 printf("%%%1$d", (int) 2); // no-warning
318 printf("%1$d%%", (int) 2); // no-warning
322 void myprintf_PR_6697(const char *format, int x, ...) __attribute__((__format__(printf,1, 3)));
340 printf("%hhs", "foo"); // expected-warning{{length modifier 'hh' results in undefined behavior or no effect with 's' conversion specifier}}
341 printf("%1$zp", (void *)0); // expected-warning{{length modifier 'z' results in undefined behavior or no effect with 'p' conversion specifier}}
342 printf("%ls", L"foo"); // no-warning
343 printf("%#.2Lf", (long double)1.234); // no-warning
346 printf("%#p", (void *) 0); // expected-warning{{flag '#' results in undefined behavior with 'p' conversion specifier}}
347 printf("%0d", -1); // no-warning
348 printf("%#n", (int *) 0); // expected-warning{{flag '#' results in undefined behavior with 'n' conversion specifier}}
349 printf("%-n", (int *) 0); // expected-warning{{flag '-' results in undefined behavior with 'n' conversion specifier}}
350 printf("%-p", (void *) 0); // no-warning
353 printf("%.2c", 'a'); // expected-warning{{precision used with 'c' conversion specifier, resulting in undefined behavior}}
354 printf("%1n", (int *) 0); // expected-warning{{field width used with 'n' conversion specifier, resulting in undefined behavior}}
355 printf("%.9n", (int *) 0); // expected-warning{{precision used with 'n' conversion specifier, resulting in undefined behavior}}
358 printf("% +f", 1.23); // expected-warning{{flag ' ' is ignored when flag '+' is present}}
359 printf("%+ f", 1.23); // expected-warning{{flag ' ' is ignored when flag '+' is present}}
360 printf("%0-f", 1.23); // expected-warning{{flag '0' is ignored when flag '-' is present}}
361 printf("%-0f", 1.23); // expected-warning{{flag '0' is ignored when flag '-' is present}}
362 printf("%-+f", 1.23); // no-warning
368 printf("%lc", c); // no-warning
369 printf("%lc", 1.0); // expected-warning{{the argument has type 'double'}}
370 printf("%lc", (char) 1); // no-warning
371 printf("%lc", &c); // expected-warning{{the argument has type 'wint_t *'}}
376 printf("%lc", c2); // no-warning
384 printf(0); // no-warning
398 printf("%#x\n", 10);
399 printf("%#X\n", 10);
405 printf("%'d\n", 123456789); // no-warning
406 printf("%'i\n", 123456789); // no-warning
407 printf("%'f\n", (float) 1.0); // no-warning
408 printf("%'p\n", (void*) 0); // expected-warning{{results in undefined behavior with 'p' conversion specifier}}
418 printf("%s", 1); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
424 printf(__PRETTY_FUNCTION__); // no-warning
425 printf(__func__); // no-warning
428 int printf(const char * restrict, ...) __attribute__((__format__ (__printf__, 1, 2)));
431 printf("%s", 2); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
435 printf("%c", y); // no-warning
436 printf("%hhu", x); // no-warning
437 printf("%hhi", y); // no-warning
438 printf("%hhi", x); // no-warning
439 printf("%c", x); // no-warning
440 printf("%hhu", y); // no-warning
448 printf("%@", 12); // no-warning
456 // Test that the printf call site is where the warning is attached. If the
460 printf(kFormat1, 0); // expected-warning{{more '%' conversions than data arguments}}
461 printf("%d %s\n", 0); // expected-warning{{more '%' conversions than data arguments}}
464 printf(kFormat2, 1, "foo"); // expected-warning{{data argument position '18' exceeds the number of data arguments (2)}}
465 printf("%18$s\n", 1, "foo"); // expected-warning{{data argument position '18' exceeds the number of data arguments (2)}}
468 printf(kFormat4, 5); // expected-warning{{invalid conversion specifier 'y'}}
469 printf("%y", 5); // expected-warning{{invalid conversion specifier 'y'}}
472 printf(kFormat5, 5); // expected-warning{{incomplete format specifier}}
473 printf("%.", 5); // expected-warning{{incomplete format specifier}}
476 printf(kFormat6, 5); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
477 printf("%s", 5); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
480 printf(kFormat7, 5); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}}
481 printf("%0$", 5); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}}
484 printf(kFormat8, 4, 4); // expected-warning{{cannot mix positional and non-positional arguments in format string}}
485 printf("%1$d %d", 4, 4); // expected-warning{{cannot mix positional and non-positional arguments in format string}}
488 printf(kFormat9, 4, 4); // expected-warning{{format string is empty}}
489 printf("", 4, 4); // expected-warning{{format string is empty}}
492 printf(kFormat10, 4); // expected-warning{{format string contains '\0' within the string body}}
493 printf("\0%d", 4); // expected-warning{{format string contains '\0' within the string body}}
496 printf(kFormat11); // expected-warning{{'*' specified field width is missing a matching 'int' argument}}
497 printf("%*d"); // expected-warning{{'*' specified field width is missing a matching 'int' argument}}
500 printf(kFormat12, 4.4); // expected-warning{{field width should have type 'int', but argument has type 'double'}}
501 printf("%*d", 4.4); // expected-warning{{field width should have type 'int', but argument has type 'double'}}
505 printf(kFormat13, p); // expected-warning{{precision used with 'p' conversion specifier, resulting in undefined behavior}}
506 printf("%.3p", p); // expected-warning{{precision used with 'p' conversion specifier, resulting in undefined behavior}}
509 printf(kFormat14, "a"); // expected-warning{{flag '0' results in undefined behavior with 's' conversion specifier}}
510 printf("%0s", "a"); // expected-warning{{flag '0' results in undefined behavior with 's' conversion specifier}}
513 printf(kFormat15, "a"); // expected-warning{{length modifier 'hh' results in undefined behavior or no effect with 's' conversion specifier}}
514 printf("%hhs", "a"); // expected-warning{{length modifier 'hh' results in undefined behavior or no effect with 's' conversion specifier}}
517 printf(kFormat16, 5); // expected-warning{{flag '0' is ignored when flag '-' is present}}
518 printf("%-0d", 5); // expected-warning{{flag '0' is ignored when flag '-' is present}}
522 printf(1 ? "yes %d" : "no %d"); // expected-warning 2{{more '%' conversions than data arguments}}
525 printf(kFormat17, (int[]){0}); // expected-warning{{format specifies type 'unsigned short' but the argument}}
527 printf("%a", (long double)0); // expected-warning{{format specifies type 'double' but the argument has type 'long double'}}
531 printf(kFormat18, 0); // expected-warning{{format specifies type}}
535 printf(kFormat19,
547 printf(s1); // expected-warning{{format string contains '\0' within the string body}}
548 printf(s2); // expected-warning{{format string is not null-terminated}}
549 printf(s3); // no-warning
550 printf(s4); // no-warning
551 printf(s5); // expected-warning{{format string is not null-terminated}}
575 printf("%hhx", c);
597 printf("%n", cip); // expected-warning{{format specifies type 'int *' but the argument has type 'const int *'}}
598 printf("%n", cvip); // expected-warning{{format specifies type 'int *' but the argument has type 'const volatile int *'}}
600 printf("%n", vip); // No warning.
601 printf("%p", cip); // No warning.
602 printf("%p", cvip); // No warning.
607 printf("%n", (ip_t)0); // No warning.
608 printf("%n", (cip_t)0); // expected-warning{{format specifies type 'int *' but the argument has type 'cip_t' (aka 'const int *')}}