OSDN Git Service

* MAINTAINERS (mt port): Remove.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / warn / miss-format-1.C
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 /* VxWorks does not provide vscanf, either in kernel or RTP mode.  */
6 /* { dg-error "not declared" "" { target *-*-solaris2.[7-8] *-*-vxworks* } 25 } */
7
8 #include <stdio.h>
9 #include <stdarg.h>
10
11 void
12 foo (const char *fmt, ...)
13 {
14   va_list ap;
15   va_start (ap, fmt);
16   vprintf (fmt, ap); /* { dg-warning "candidate" "printf attribute warning" } */
17   va_end (ap);
18 }
19
20 void
21 bar (const char *fmt, ...)
22 {
23   va_list ap;
24   va_start (ap, fmt);
25   vscanf (fmt, ap); /* { dg-warning "candidate" "scanf attribute warning" { xfail *-*-solaris2.[7-8] *-*-vxworks* } } */
26   va_end (ap);
27 }
28
29 __attribute__((__format__(__printf__, 1, 2))) void
30 foo2 (const char *fmt, ...)
31 {
32   va_list ap;
33   va_start (ap, fmt);
34   vprintf (fmt, ap);
35   va_end (ap);
36 }
37
38 void
39 vfoo (const char *fmt, va_list arg)
40 {
41   vprintf (fmt, arg); /* { dg-warning "candidate" "printf attribute warning 2" } */
42 }