Home | History | Annotate | Download | only in Sema

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}}
57 printf(fmt, 1, 2); // expected-warning{{data argument not used}}
60 printf("abc"
62 printf("abc\
69 printf("%*d", (unsigned) 1, 1); // no-warning
81 printf(s); // expected-warning {{format string is not a string literal}}
100 printf(i == 1 ? "yes" : "no"); // no-warning
101 printf(i == 0 ? (i == 1 ? "yes" : "no") : "dont know"); // no-warning
102 printf(i == 0 ? (i == 1 ? s : "no") : "dont know"); // expected-warning{{format string is not a string literal}}
104 printf("yes" ?: "no %d", 1); // expected-warning{{data argument not used by format string}}
105 printf(0 ? "yes %s" : "no %d", 1); // no-warning
106 printf(0 ? "yes %d" : "no %s", 1); // expected-warning{{format specifies type 'char *'}}
108 printf(0 ? "yes" : "no %d", 1); // no-warning
109 printf(0 ? "yes %d" : "no", 1); // expected-warning{{data argument not used by format string}}
110 printf(1 ? "yes" : "no %d", 1); // expected-warning{{data argument not used by format string}}
111 printf(1 ? "yes %d" : "no", 1); // no-warning
112 printf(i ? "yes" : "no %d", 1); // no-warning
113 printf(i ? "yes %s" : "no %d", 1); // expected-warning{{format specifies type 'char *'}}
114 printf(i ? "yes" : "no %d", 1, 2); // expected-warning{{data argument not used by format string}}
116 printf(i ? "%*s" : "-", i, s); // no-warning
117 printf(i ? "yes" : 0 ? "no %*d" : "dont know %d", 1, 2); // expected-warning{{data argument not used by format string}}
118 printf(i ? "%i\n" : "%i %s %s\n", i, s); // expected-warning{{more '%' conversions than data arguments}}
125 printf("%n", b); // expected-warning{{format specifies type 'int *' but the argument has type 'char *'}}
126 printf("%n", &x); // no-warning
128 printf("%hhn", (signed char*)0); // no-warning
129 printf("%hhn", (char*)0); // no-warning
130 printf("%hhn", (unsigned char*)0); // no-warning
131 printf("%hhn", (int*)0); // expected-warning{{format specifies type 'signed char *' but the argument has type 'int *'}}
133 printf("%hn", (short*)0); // no-warning
134 printf("%hn", (unsigned short*)0); // no-warning
135 printf("%hn", (int*)0); // expected-warning{{format specifies type 'short *' but the argument has type 'int *'}}
137 printf("%n", (int*)0); // no-warning
138 printf("%n", (unsigned int*)0); // no-warning
139 printf("%n", (char*)0); // expected-warning{{format specifies type 'int *' but the argument has type 'char *'}}
141 printf("%ln", (long*)0); // no-warning
142 printf("%ln", (unsigned long*)0); // no-warning
143 printf("%ln", (int*)0); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}}
145 printf("%lln", (long long*)0); // no-warning
146 printf("%lln", (unsigned long long*)0); // no-warning
147 printf("%lln", (int*)0); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}}
149 printf("%qn", (long long*)0); // no-warning
150 printf("%qn", (unsigned long long*)0); // no-warning
151 printf("%qn", (int*)0); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}}
153 printf("%Ln", 0); // expected-warning{{length modifier 'L' results in undefined behavior or no effect with 'n' conversion specifier}}
159 printf("%s%lb%d","unix",10,20); // expected-warning {{invalid conversion specifier 'b'}}
167 printf("\0this is bogus%d",1); // expected-warning {{string contains '\0'}}
169 printf("%\0d",1); // expected-warning {{string contains '\0'}}
190 printf(L"foo %d",2); // expected-warning {{incompatible pointer types}}, expected-warning {{should not be a wide string}}
195 printf("%*d"); // expected-warning {{'*' specified field width is missing a matching 'int' argument}}
196 printf("%.*d"); // expected-warning {{'.*' specified field precision is missing a matching 'int' argument}}
197 printf("%*d",12,x); // no-warning
198 printf("%*d","foo",x); // expected-warning {{field width should have type 'int', but argument has type 'char *'}}
199 printf("%.*d","foo",x); // expected-warning {{field precision should have type 'int', but argument has type 'char *'}}
202 void __attribute__((format(printf,1,3))) myprintf(const char*, int blah, ...);
215 printf(s1); // no-warning
216 printf(s2); // no-warning
217 printf(s3); // expected-warning{{not a string literal}}
219 printf(s4); // expected-warning{{not a string literal}}
221 printf(s5); // expected-warning{{not a string literal}}
232 printf(P); // expected-warning {{format string is not a string literal (potentially insecure)}}
234 printf(P, 42);
243 printf("%s"); // expected-warning{{more '%' conversions than data arguments}}
244 printf("%@", 12); // expected-warning{{invalid conversion specifier '@'}}
245 printf("\0"); // expected-warning{{format string contains '\0' within the string body}}
246 printf("xs\0"); // expected-warning{{format string contains '\0' within the string body}}
247 printf("%*d\n"); // expected-warning{{'*' specified field width is missing a matching 'int' argument}}
248 printf("%*.*d\n", x); // expected-warning{{'.*' specified field precision is missing a matching 'int' argument}}
249 printf("%*d\n", f, x); // expected-warning{{field width should have type 'int', but argument has type 'double'}}
250 printf("%*.*d\n", x, f, x); // expected-warning{{field precision should have type 'int', but argument has type 'double'}}
251 printf("%**\n"); // expected-warning{{invalid conversion specifier '*'}}
252 printf("%d%d\n", x); // expected-warning{{more '%' conversions than data arguments}}
253 printf("%d\n", x, x); // expected-warning{{data argument not used by format string}}
254 printf("%W%d\n", x, x); // expected-warning{{invalid conversion specifier 'W'}}
255 printf("%"); // expected-warning{{incomplete format specifier}}
256 printf("%.d", x); // no-warning
257 printf("%.", x); // expected-warning{{incomplete format specifier}}
258 printf("%f", 4); // expected-warning{{format specifies type 'double' but the argument has type 'int'}}
259 printf("%qd", lli); // no-warning
260 printf("%qd", x); // expected-warning{{format specifies type 'long long' but the argument has type 'int'}}
261 printf("%qp", (void *)0); // expected-warning{{length modifier 'q' results in undefined behavior or no effect with 'p' conversion specifier}}
262 printf("hhX %hhX", (unsigned char)10); // no-warning
263 printf("llX %llX", (long long) 10); // no-warning
265 printf("%d", (unsigned char) 10); // no-warning
266 printf("%d", (long long) 10); // expected-warning{{format specifies type 'int' but the argument has type 'long long'}}
267 printf("%Lf\n", (long double) 1.0); // no-warning
268 printf("%f\n", (long double) 1.0); // expected-warning{{format specifies type 'double' but the argument has type 'long double'}}
270 printf("%.0Lf", (long double) 1.0); // no-warning
271 printf("%c\n", "x"); // expected-warning{{format specifies type 'int' but the argument has type 'char *'}}
272 printf("%c\n", 1.23); // expected-warning{{format specifies type 'int' but the argument has type 'double'}}
273 printf("Format %d, is %! %f", 1, 2, 4.4); // expected-warning{{invalid conversion specifier '!'}}
279 printf("%hhu", (short) 10); // expected-warning{{format specifies type 'unsigned char' but the argument has type 'short'}}
280 printf("%hu\n", (unsigned char) 1); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'unsigned char'}}
281 printf("%hu\n", (uint8_t)1); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'uint8_t'}}
285 printf("%p", p); // no-warning
286 printf("%p", 123); // expected-warning{{format specifies type 'void *' but the argument has type 'int'}}
287 printf("%.4p", p); // expected-warning{{precision used with 'p' conversion specifier, resulting in undefined behavior}}
288 printf("%+p", p); // expected-warning{{flag '+' results in undefined behavior with 'p' conversion specifier}}
289 printf("% p", p); // expected-warning{{flag ' ' results in undefined behavior with 'p' conversion specifier}}
290 printf("%0p", p); // expected-warning{{flag '0' results in undefined behavior with 'p' conversion specifier}}
291 printf("%s", s); // no-warning
292 printf("%+s", p); // expected-warning{{flag '+' results in undefined behavior with 's' conversion specifier}}
293 printf("% s", p); // expected-warning{{flag ' ' results in undefined behavior with 's' conversion specifier}}
294 printf("%0s", p); // expected-warning{{flag '0' results in undefined behavior with 's' conversion specifier}}
299 printf ("%.4s\n", buf); // no-warning
300 printf ("%.4s\n", &buf); // expected-warning{{format specifies type 'char *' but the argument has type 'unsigned char (*)[4]'}}
308 printf("bel: '0%hhd'\n", bel); // no-warning
309 printf("x: '0%hhd'\n", x); // expected-warning {{format specifies type 'char' but the argument has type 'short'}}
323 void f0(int_t x) { printf("%d\n", x); }
329 printf("%S", s); // no-warning
330 printf("%s", s); // expected-warning{{format specifies type 'char *' but the argument has type 'wchar_t *'}}
331 printf("%C", s[0]); // no-warning
332 printf("%c", s[0]);
335 // printf("%C", 10);
336 printf("%S", "hello"); // expected-warning{{but the argument has type 'char *'}}
343 printf("%0$", (int)2); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}}
344 printf("%1$*0$d", (int) 2); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}}
345 printf("%1$d", (int) 2); // no-warning
346 printf("%1$d", (int) 2, 2); // expected-warning{{data argument not used by format string}}
347 printf("%1$d%1$f", (int) 2); // expected-warning{{format specifies type 'double' but the argument has type 'int'}}
348 printf("%1$2.2d", (int) 2); // no-warning
349 printf("%2$*1$.2d", (int) 2, (int) 3); // no-warning
350 printf("%2$*8$d", (int) 2, (int) 3); // expected-warning{{specified field width is missing a matching 'int' argument}}
351 printf("%%%1$d", (int) 2); // no-warning
352 printf("%1$d%%", (int) 2); // no-warning
356 void myprintf_PR_6697(const char *format, int x, ...) __attribute__((__format__(printf,1, 3)));
374 printf("%hhs", "foo"); // expected-warning{{length modifier 'hh' results in undefined behavior or no effect with 's' conversion specifier}}
375 printf("%1$zp", (void *)0); // expected-warning{{length modifier 'z' results in undefined behavior or no effect with 'p' conversion specifier}}
376 printf("%ls", L"foo"); // no-warning
377 printf("%#.2Lf", (long double)1.234); // no-warning
380 printf("%#p", (void *) 0); // expected-warning{{flag '#' results in undefined behavior with 'p' conversion specifier}}
381 printf("%0d", -1); // no-warning
382 printf("%#n", (int *) 0); // expected-warning{{flag '#' results in undefined behavior with 'n' conversion specifier}}
383 printf("%-n", (int *) 0); // expected-warning{{flag '-' results in undefined behavior with 'n' conversion specifier}}
384 printf("%-p", (void *) 0); // no-warning
387 printf("%.2c", 'a'); // expected-warning{{precision used with 'c' conversion specifier, resulting in undefined behavior}}
388 printf("%1n", (int *) 0); // expected-warning{{field width used with 'n' conversion specifier, resulting in undefined behavior}}
389 printf("%.9n", (int *) 0); // expected-warning{{precision used with 'n' conversion specifier, resulting in undefined behavior}}
392 printf("% +f", 1.23); // expected-warning{{flag ' ' is ignored when flag '+' is present}}
393 printf("%+ f", 1.23); // expected-warning{{flag ' ' is ignored when flag '+' is present}}
394 printf("%0-f", 1.23); // expected-warning{{flag '0' is ignored when flag '-' is present}}
395 printf("%-0f", 1.23); // expected-warning{{flag '0' is ignored when flag '-' is present}}
396 printf("%-+f", 1.23); // no-warning
402 printf("%lc", c); // no-warning
403 printf("%lc", 1.0); // expected-warning{{the argument has type 'double'}}
404 printf("%lc", (char) 1); // no-warning
405 printf("%lc", &c); // expected-warning{{the argument has type 'wint_t *'}}
410 printf("%lc", c2); // no-warning
418 printf(0); // no-warning
432 printf("%#x\n", 10);
433 printf("%#X\n", 10);
439 printf("%'d\n", 123456789); // no-warning
440 printf("%'i\n", 123456789); // no-warning
441 printf("%'f\n", (float) 1.0); // no-warning
442 printf("%'p\n", (void*) 0); // expected-warning{{results in undefined behavior with 'p' conversion specifier}}
452 printf("%s", 1); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
458 printf(__PRETTY_FUNCTION__); // no-warning
459 printf(__func__); // no-warning
462 int printf(const char * restrict, ...) __attribute__((__format__ (__printf__, 1, 2)));
465 printf("%s", 2); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
469 printf("%c", y); // no-warning
470 printf("%hhu", x); // no-warning
471 printf("%hhi", y); // no-warning
472 printf("%hhi", x); // no-warning
473 printf("%c", x); // no-warning
474 printf("%hhu", y); // no-warning
482 printf("%@", 12); // no-warning
490 // Test that the printf call site is where the warning is attached. If the
494 printf(kFormat1, 0); // expected-warning{{more '%' conversions than data arguments}}
495 printf("%d %s\n", 0); // expected-warning{{more '%' conversions than data arguments}}
498 printf(kFormat2, 1, "foo"); // expected-warning{{data argument position '18' exceeds the number of data arguments (2)}}
499 printf("%18$s\n", 1, "foo"); // expected-warning{{data argument position '18' exceeds the number of data arguments (2)}}
502 printf(kFormat4, 5); // expected-warning{{invalid conversion specifier 'y'}}
503 printf("%y", 5); // expected-warning{{invalid conversion specifier 'y'}}
506 printf(kFormat5, 5); // expected-warning{{incomplete format specifier}}
507 printf("%.", 5); // expected-warning{{incomplete format specifier}}
510 printf(kFormat6, 5); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
511 printf("%s", 5); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
514 printf(kFormat7, 5); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}}
515 printf("%0$", 5); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}}
518 printf(kFormat8, 4, 4); // expected-warning{{cannot mix positional and non-positional arguments in format string}}
519 printf("%1$d %d", 4, 4); // expected-warning{{cannot mix positional and non-positional arguments in format string}}
522 printf(kFormat9, 4, 4); // expected-warning{{format string is empty}}
523 printf("", 4, 4); // expected-warning{{format string is empty}}
526 printf(kFormat10, 4); // expected-warning{{format string contains '\0' within the string body}}
527 printf("\0%d", 4); // expected-warning{{format string contains '\0' within the string body}}
530 printf(kFormat11); // expected-warning{{'*' specified field width is missing a matching 'int' argument}}
531 printf("%*d"); // expected-warning{{'*' specified field width is missing a matching 'int' argument}}
534 printf(kFormat12, 4.4); // expected-warning{{field width should have type 'int', but argument has type 'double'}}
535 printf("%*d", 4.4); // expected-warning{{field width should have type 'int', but argument has type 'double'}}
539 printf(kFormat13, p); // expected-warning{{precision used with 'p' conversion specifier, resulting in undefined behavior}}
540 printf("%.3p", p); // expected-warning{{precision used with 'p' conversion specifier, resulting in undefined behavior}}
543 printf(kFormat14, "a"); // expected-warning{{flag '0' results in undefined behavior with 's' conversion specifier}}
544 printf("%0s", "a"); // expected-warning{{flag '0' results in undefined behavior with 's' conversion specifier}}
547 printf(kFormat15, "a"); // expected-warning{{length modifier 'hh' results in undefined behavior or no effect with 's' conversion specifier}}
548 printf("%hhs", "a"); // expected-warning{{length modifier 'hh' results in undefined behavior or no effect with 's' conversion specifier}}
551 printf(kFormat16, 5); // expected-warning{{flag '0' is ignored when flag '-' is present}}
552 printf("%-0d", 5); // expected-warning{{flag '0' is ignored when flag '-' is present}}
556 printf(1 ? "yes %d" : "no %d"); // expected-warning{{more '%' conversions than data arguments}}
559 printf(kFormat17, (int[]){0}); // expected-warning{{format specifies type 'unsigned short' but the argument}}
561 printf("%a", (long double)0); // expected-warning{{format specifies type 'double' but the argument has type 'long double'}}
565 printf(kFormat18, 0); // expected-warning{{format specifies type}}
569 printf(kFormat19,
581 printf(s1); // expected-warning{{format string contains '\0' within the string body}}
582 printf(s2); // expected-warning{{format string is not null-terminated}}
583 printf(s3); // no-warning
584 printf(s4); // no-warning
585 printf(s5); // expected-warning{{format string is not null-terminated}}
609 printf("%hhx", c);
631 printf("%n", cip); // expected-warning{{format specifies type 'int *' but the argument has type 'const int *'}}
632 printf("%n", cvip); // expected-warning{{format specifies type 'int *' but the argument has type 'const volatile int *'}}
634 printf("%n", vip); // No warning.
635 printf("%p", cip); // No warning.
636 printf("%p", cvip); // No warning.
641 printf("%n", (ip_t)0); // No warning.
642 printf("%n", (cip_t)0); // expected-warning{{format specifies type 'int *' but the argument has type 'cip_t' (aka 'const int *')}}