1 /* Test warnings for missing format attributes on function pointers. */
2 /* Origin: Kaveh Ghazi <ghazi@caip.rutgers.edu> */
3 /* { dg-do compile } */
4 /* { dg-options "-std=gnu99 -Wmissing-format-attribute" } */
5
6 #define DONT_GNU_PROTOTYPE
7 #include "format.h"
8
9 typedef void (*noattr_t) (const char *, ...);
10 typedef noattr_t __attribute__ ((__format__(gnu_attr___printf__, 1, 2))) attr_t;
11
12 typedef void (*vnoattr_t) (const char *, va_list);
13 typedef vnoattr_t __attribute__ ((__format__(gnu_attr___printf__, 1, 0))) vattr_t;
14
15 noattr_t
foo1(noattr_t na,attr_t a,int i)16 foo1 (noattr_t na, attr_t a, int i)
17 {
18 if (i)
19 return na;
20 else
21 return a; /* { dg-warning "candidate" "return type warning" } */
22 }
23
24 attr_t
foo2(noattr_t na,attr_t a,int i)25 foo2 (noattr_t na, attr_t a, int i)
26 {
27 if (i)
28 return na;
29 else
30 return a;
31 }
32
33 vnoattr_t
foo3(vnoattr_t vna,vattr_t va,int i)34 foo3 (vnoattr_t vna, vattr_t va, int i)
35 {
36 if (i)
37 return vna;
38 else
39 return va; /* { dg-warning "candidate" "return type warning" } */
40 }
41
42 vattr_t
foo4(vnoattr_t vna,vattr_t va,int i)43 foo4 (vnoattr_t vna, vattr_t va, int i)
44 {
45 if (i)
46 return vna;
47 else
48 return va;
49 }
50