PR lto/84212 - -Wno-* does not disable warnings from -flto link stage
[official-gcc.git] / gcc / testsuite / g++.dg / warn / miss-format-1.C
blob65a34282ad784faededd1d6d17cf24352c8f7822
1 /* Test for warnings for missing format attributes.  */
2 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
3 /* { dg-do compile } */
4 /* { dg-options "-Wmissing-format-attribute" } */
5 /* { dg-options "-Wmissing-format-attribute -Wno-abi" { target arm_eabi } } */
7 #include <stdio.h>
8 #include <stdarg.h>
10 void
11 foo (const char *fmt, ...)
13   va_list ap;
14   va_start (ap, fmt);
15   vprintf (fmt, ap); /* { dg-warning "candidate" "printf attribute warning" } */
16   va_end (ap);
19 void
20 bar (const char *fmt, ...)
22   va_list ap;
23   va_start (ap, fmt);
24   vscanf (fmt, ap); /* { dg-warning "candidate" "scanf attribute warning" { xfail *-*-vxworks* } } */
25   /* VxWorks does not provide vscanf, either in kernel or RTP mode.  */
26   /* { dg-error "not declared" "" { target *-*-vxworks* } .-2 } */
27   va_end (ap);
30 __attribute__((__format__(__printf__, 1, 2))) void
31 foo2 (const char *fmt, ...)
33   va_list ap;
34   va_start (ap, fmt);
35   vprintf (fmt, ap);
36   va_end (ap);
39 void
40 vfoo (const char *fmt, va_list arg)
42   vprintf (fmt, arg); /* { dg-warning "candidate" "printf attribute warning 2" } */