xref: /llvm-project/clang/test/Parser/cxx2c-oxford-variadic-comma.cpp (revision 54fcf3ec26ad192e91b6ac924f6d3eb562e3647d)
1 // RUN: %clang_cc1 -std=c++2c -fsyntax-only -fblocks -verify %s
2 
3 void a(...);
4 
5 void b(auto...);
6 void c(auto, ...);
7 
8 void d(auto......); // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}} \
9                     // expected-warning {{'...' in this location creates a C-style varargs function}} \
10                     // expected-note {{preceding '...' declares a function parameter pack}} \
11                     // expected-note {{insert ',' before '...' to silence this warning}}
12 void e(auto..., ...);
13 
14 void f(auto x...); // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}}
15 void g(auto x, ...);
16 
17 void h(auto... x...); // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}} \
18                       // expected-warning {{'...' in this location creates a C-style varargs function}} \
19                       // expected-note {{preceding '...' declares a function parameter pack}} \
20                       // expected-note {{insert ',' before '...' to silence this warning}}
21 void i(auto... x, ...);
22 
23 template<class ...Ts>
24 void j(Ts... t...) {}; // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}} \
25                        // expected-warning {{'...' in this location creates a C-style varargs function}} \
26                        // expected-note {{preceding '...' declares a function parameter pack}} \
27                        // expected-note {{insert ',' before '...' to silence this warning}}
28 template<class ...Ts>
29 void k(Ts... t, ...) {}
30 
31 void l(int...); // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}}
32 void m(int, ...);
33 
34 void n(int x...); // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}}
35 void o(int x, ...);
36 
37 struct S {
38   void p(this S...) {} // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}}
39 };
40 
41 template<class ...Ts>
42 void q(Ts......) {} // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}} \
43                     // expected-warning {{'...' in this location creates a C-style varargs function}} \
44                     // expected-note {{preceding '...' declares a function parameter pack}} \
45                     // expected-note {{insert ',' before '...' to silence this warning}}
46 
47 template<class T>
48 void r(T...) {} // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}}
49 
50 auto type_specifier = (void (*)(int...)) nullptr; // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}}
51 
52 auto lambda = [](int...) {}; // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}}
53 
54 auto block = ^(int...){}; // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}}
55