PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / format / miss-7.c
blob828b781e0e697e97d84a3e363a7c692bb0c494d5
1 /* PR77336 - -Wsuggest-attribute=format warning overly simplistic */
2 /* { dg-do compile } */
3 /* { dg-options "-Wsuggest-attribute=format" } */
5 #include "format.h"
7 const char format[] = "%i";
9 void foo (char *d, unsigned n, va_list va)
11 (void)&n;
13 /* The following calls don't imply that the enclosing function is
14 a candiate for the format attribute because it uses a string
15 constant as the format. */
16 vsnprintf (d, n, "%i", va);
18 vsnprintf (d, n, format, va);
20 /* In theory this should not trigger the warning either but GCC
21 doesn't treat the local static constant the same way as the
22 global and issues a false positive.
23 const char fmt[] = "%i";
24 vsnprintf (d, n, fmt, va);
28 void bar (char *d, unsigned n, const char *f, va_list va)
30 (void)&n;
32 /* The following call suggests that the enclosing function might
33 be a candiate for the format attribute because it doesn't use
34 a string literal as the format. */
35 vsnprintf (d, n, f, va); /* { dg-warning "function .bar. might be a candidate for .gnu_printf. format attribute" } */