[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / CXX / expr / expr.prim / expr.prim.lambda / p23.cpp
blob028fcee5fda433454b13d2c41fd856b9893287c5
1 // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wno-c++1y-extensions -Wno-c++2a-extensions
2 // RUN: %clang_cc1 -fsyntax-only -std=c++1y %s -verify -Wno-c++2a-extensions
3 // RUN: %clang_cc1 -fsyntax-only -std=c++2a %s -verify
5 void print();
7 template<typename T, typename... Ts>
8 void print(T first, Ts... rest) {
9 (void)first;
10 print(rest...);
13 template<typename... Ts>
14 void unexpanded_capture(Ts ...values) {
15 auto unexp = [values] {}; // expected-error{{initializer contains unexpanded parameter pack 'values'}}
18 template<typename... Ts>
19 void implicit_capture(Ts ...values) {
20 auto implicit = [&] { print(values...); };
21 implicit();
24 template<typename... Ts>
25 void do_print(Ts... values) {
26 auto bycopy = [values...]() { print(values...); };
27 bycopy();
28 auto byref = [&values...]() { print(values...); };
29 byref();
31 auto bycopy2 = [=]() { print(values...); };
32 bycopy2();
33 auto byref2 = [&]() { print(values...); };
34 byref2();
37 template void do_print(int, float, double);
39 template<typename T, int... Values>
40 void bogus_expansions(T x) {
41 auto l1 = [x...] {}; // expected-error{{pack expansion does not contain any unexpanded parameter packs}}
42 auto l2 = [Values...] {}; // expected-error{{'Values' in capture list does not name a variable}}
45 void g(int*, float*, double*);
47 template<class... Args>
48 void std_example(Args... args) {
49 auto lm = [&, args...] { return g(args...); };
52 template void std_example(int*, float*, double*);
54 template<typename ...Args>
55 void variadic_lambda(Args... args) {
56 auto lambda = [](Args... inner_args) { return g(inner_args...); };
57 lambda(args...);
60 template void variadic_lambda(int*, float*, double*);
62 template<typename ...Args>
63 void init_capture_pack_err(Args ...args) {
64 [...as(args)]{} ();
65 [as(args)...] {} (); // expected-error {{ellipsis in pack init-capture must appear before the name of the capture}}
66 [as...(args)]{} (); // expected-error {{ellipsis in pack init-capture must appear before the name of the capture}}
67 [...as{args}]{} ();
68 [as{args}...] {} (); // expected-error {{ellipsis in pack init-capture must appear before the name of the capture}}
69 [as...{args}]{} (); // expected-error {{ellipsis in pack init-capture must appear before the name of the capture}}
70 [...as = args]{} ();
71 [as = args...] {} (); // expected-error {{ellipsis in pack init-capture must appear before the name of the capture}}
72 [as... = args]{} (); // expected-error {{ellipsis in pack init-capture must appear before the name of the capture}}
74 [&...as(args)]{} ();
75 [...&as(args)]{} (); // expected-error {{ellipsis in pack init-capture must appear before the name of the capture}}
77 [args...] {} ();
78 [...args] {} (); // expected-error {{ellipsis in pack capture must appear after the name of the capture}}
80 [&args...] {} ();
81 [...&args] {} (); // expected-error {{ellipsis in pack capture must appear after the name of the capture}}
82 [&...args] {} (); // expected-error {{ellipsis in pack capture must appear after the name of the capture}}
85 template<typename ...Args>
86 void init_capture_pack_multi(Args ...args) {
87 [as(args...)] {} (); // expected-error {{initializer missing for lambda capture 'as'}} expected-error {{multiple}}
89 template void init_capture_pack_multi(); // expected-note {{instantiation}}
90 template void init_capture_pack_multi(int);
91 template void init_capture_pack_multi(int, int); // expected-note {{instantiation}}
93 template<typename ...Args>
94 void init_capture_pack_outer(Args ...args) {
95 print([as(args)] { return sizeof(as); } () ...);
97 template void init_capture_pack_outer();
98 template void init_capture_pack_outer(int);
99 template void init_capture_pack_outer(int, int);