1 // Test for format attributes: test applying them to types in C++.
2 // Origin: Joseph Myers <jsm28@cam.ac.uk>
4 // { dg-options "-Wformat" }
6 __attribute__((format(printf, 1, 2))) void (*tformatprintf0) (const char *, ...);
7 void (*tformatprintf1) (const char *, ...) __attribute__((format(printf, 1, 2)));
8 void (__attribute__((format(printf, 1, 2))) *tformatprintf2) (const char *, ...);
9 void (__attribute__((format(printf, 1, 2))) ****tformatprintf3) (const char *, ...);
11 char * (__attribute__((format_arg(1))) *tformat_arg) (const char *);
16 (*tformatprintf0) ("%d", i);
17 (*tformatprintf0) ((*tformat_arg) ("%d"), i);
18 (*tformatprintf0) ("%"); // { dg-warning "format" "prefix" }
19 (*tformatprintf0) ((*tformat_arg) ("%")); // { dg-warning "format" "prefix" }
20 (*tformatprintf1) ("%d", i);
21 (*tformatprintf1) ((*tformat_arg) ("%d"), i);
22 (*tformatprintf1) ("%"); // { dg-warning "format" "postfix" }
23 (*tformatprintf1) ((*tformat_arg) ("%")); // { dg-warning "format" "postfix" }
24 (*tformatprintf2) ("%d", i);
25 (*tformatprintf2) ((*tformat_arg) ("%d"), i);
26 (*tformatprintf2) ("%"); // { dg-warning "format" "nested" }
27 (*tformatprintf2) ((*tformat_arg) ("%")); // { dg-warning "format" "nested" }
28 (****tformatprintf3) ("%d", i);
29 (****tformatprintf3) ((*tformat_arg) ("%d"), i);
30 (****tformatprintf3) ("%"); // { dg-warning "format" "nested 2" }
31 (****tformatprintf3) ((*tformat_arg) ("%")); // { dg-warning "format" "nested 2" }