| 1 |
// RUN: %check_clang_tidy %s cert-dcl50-cpp %t |
| 2 |
|
| 3 |
// Variadic function definitions are diagnosed. |
| 4 |
void f1(int, ...) {} |
| 5 |
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: do not define a C-style variadic function; consider using a function parameter pack or currying instead [cert-dcl50-cpp] |
| 6 |
|
| 7 |
// Variadic function *declarations* are not diagnosed. |
| 8 |
void f2(int, ...); // ok |
| 9 |
|
| 10 |
// Function parameter packs are good, however. |
| 11 |
template <typename Arg, typename... Ts> |
| 12 |
void f3(Arg F, Ts... Rest) {} |
| 13 |
|
| 14 |
struct S { |
| 15 |
void f(int, ...); // ok |
| 16 |
void f1(int, ...) {} |
| 17 |
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: do not define a C-style variadic function; consider using a function parameter pack or currying instead |
| 18 |
}; |
| 19 |
|
| 20 |
// Function definitions that are extern "C" are good. |
| 21 |
extern "C" void f4(int, ...) {} // ok |
| 22 |
extern "C" { |
| 23 |
void f5(int, ...) {} // ok |
| 24 |
} |