2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.dg / format / attr-7.c
blob78526a5e9bbe8387942a7c2a06757eb0a739b800
1 /* Test for format attributes: test applying them to types. */
2 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
3 /* { dg-do compile } */
4 /* { dg-options "-std=gnu99 -Wformat" } */
6 #include "format.h"
8 __attribute__((format(printf, 1, 2))) void (*tformatprintf0) (const char *, ...);
9 void (*tformatprintf1) (const char *, ...) __attribute__((format(printf, 1, 2)));
10 void (__attribute__((format(printf, 1, 2))) *tformatprintf2) (const char *, ...);
11 void (__attribute__((format(printf, 1, 2))) ****tformatprintf3) (const char *, ...);
13 char * (__attribute__((format_arg(1))) *tformat_arg) (const char *);
15 void
16 baz (int i)
18 (*tformatprintf0) ("%d", i);
19 (*tformatprintf0) ((*tformat_arg) ("%d"), i);
20 (*tformatprintf0) ("%"); /* { dg-warning "format" "prefix" } */
21 (*tformatprintf0) ((*tformat_arg) ("%")); /* { dg-warning "format" "prefix" } */
22 (*tformatprintf1) ("%d", i);
23 (*tformatprintf1) ((*tformat_arg) ("%d"), i);
24 (*tformatprintf1) ("%"); /* { dg-warning "format" "postfix" } */
25 (*tformatprintf1) ((*tformat_arg) ("%")); /* { dg-warning "format" "postfix" } */
26 (*tformatprintf2) ("%d", i);
27 (*tformatprintf2) ((*tformat_arg) ("%d"), i);
28 (*tformatprintf2) ("%"); /* { dg-warning "format" "nested" } */
29 (*tformatprintf2) ((*tformat_arg) ("%")); /* { dg-warning "format" "nested" } */
30 (****tformatprintf3) ("%d", i);
31 (****tformatprintf3) ((*tformat_arg) ("%d"), i);
32 (****tformatprintf3) ("%"); /* { dg-warning "format" "nested 2" } */
33 (****tformatprintf3) ((*tformat_arg) ("%")); /* { dg-warning "format" "nested 2" } */