| 1 |
// PR c++/116175 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-options "-Wformat" } |
| 4 |
|
| 5 |
template <typename ...T> |
| 6 |
int foo (T ...args, const char *fmt, ...) |
| 7 |
[[gnu::format (printf, 1 + sizeof... (T), 2 + sizeof... (T))]]; |
| 8 |
|
| 9 |
int a = foo <> ("%d", 1); |
| 10 |
int b = foo <int, int, int, int, int> (1, 2, 3, 4, 5, "%d", 1); |
| 11 |
int c = foo <> ("%f", 1); // { dg-warning "format '%f' expects argument of type 'double', but argument 2 has type 'int'" } |
| 12 |
int d = foo <int, int, int, int, int> (1, 2, 3, 4, 5, "%f", 1); // { dg-warning "format '%f' expects argument of type 'double', but argument 7 has type 'int'" } |