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 } } */
6 
7 #include <stdio.h>
8 #include <stdarg.h>
9 
10 void
foo(const char * fmt,...)11 foo (const char *fmt, ...)
12 {
13   va_list ap;
14   va_start (ap, fmt);
15   vprintf (fmt, ap); /* { dg-warning "candidate" "printf attribute warning" } */
16   va_end (ap);
17 }
18 
19 void
bar(const char * fmt,...)20 bar (const char *fmt, ...)
21 {
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);
28 }
29 
30 __attribute__((__format__(__printf__, 1, 2))) void
foo2(const char * fmt,...)31 foo2 (const char *fmt, ...)
32 {
33   va_list ap;
34   va_start (ap, fmt);
35   vprintf (fmt, ap);
36   va_end (ap);
37 }
38 
39 void
vfoo(const char * fmt,va_list arg)40 vfoo (const char *fmt, va_list arg)
41 {
42   vprintf (fmt, arg); /* { dg-warning "candidate" "printf attribute warning 2" } */
43 }
44