brintos

brintos / llvm-project-archived public Read only

0
0
Text · 872 B · 5bdc7c6 Raw
25 lines · cpp
1// RUN: %check_clang_tidy %s modernize-avoid-variadic-functions %t2 3// Variadic function definitions are diagnosed.4void 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 [modernize-avoid-variadic-functions]6 7// Variadic function *declarations* are not diagnosed.8void f2(int, ...); // ok9 10// Function parameter packs are good, however.11template <typename Arg, typename... Ts>12void f3(Arg F, Ts... Rest) {}13 14struct S {15  void f(int, ...); // ok16  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 instead18};19 20// Function definitions that are extern "C" are good.21extern "C" void f4(int, ...) {} // ok22extern "C" {23  void f5(int, ...) {} // ok24}25