Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/gcc.dg/format/miss-7.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children |
line wrap: on
line source
/* PR77336 - -Wsuggest-attribute=format warning overly simplistic */ /* { dg-do compile } */ /* { dg-options "-Wsuggest-attribute=format" } */ #include "format.h" const char format[] = "%i"; void foo (char *d, unsigned n, va_list va) { (void)&n; /* The following calls don't imply that the enclosing function is a candiate for the format attribute because it uses a string constant as the format. */ vsnprintf (d, n, "%i", va); vsnprintf (d, n, format, va); /* In theory this should not trigger the warning either but GCC doesn't treat the local static constant the same way as the global and issues a false positive. const char fmt[] = "%i"; vsnprintf (d, n, fmt, va); */ } void bar (char *d, unsigned n, const char *f, va_list va) { (void)&n; /* The following call suggests that the enclosing function might be a candiate for the format attribute because it doesn't use a string literal as the format. */ vsnprintf (d, n, f, va); /* { dg-warning "function .bar. might be a candidate for .gnu_printf. format attribute" } */ }