[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Parser / lambda-misplaced-capture-default.cpp
blobd65b875102da7540b64b1f588becc244fbe66702
1 // RUN: %clang_cc1 -std=c++20 -Wno-unused-value -fsyntax-only -verify %s
3 namespace misplaced_capture_default {
4 void Test() {
5 int i = 0;
6 [&, i, &] {}; // expected-error {{expected variable name or 'this' in lambda capture list}}
7 [&, i, = ] {}; // expected-error {{expected variable name or 'this' in lambda capture list}}
8 [=, &i, &] {}; // expected-error {{expected variable name or 'this' in lambda capture list}}
9 [=, &i, = ] {}; // expected-error {{expected variable name or 'this' in lambda capture list}}
11 [i, &] {}; // expected-error {{capture default must be first}}
12 [i, = ] {}; // expected-error {{capture default must be first}}
13 [i, = x] {}; // expected-error {{expected variable name or 'this' in lambda capture list}}
14 [=, &i] {}; // ok
15 [&, &i] {}; // expected-error {{'&' cannot precede a capture when the capture default is '&'}}
16 [&x = i] {}; // ok
17 [=, &x = i] {}; // ok
18 [x = &i] {}; // ok
19 [=, &x = &i] {}; // expected-error {{non-const lvalue reference to type 'int *' cannot bind to a temporary of type 'int *'}}
20 [&, this] {}; // expected-error {{'this' cannot be captured in this context}}
22 [i, &, x = 2] {}; // expected-error {{capture default must be first}}
23 [i, =, x = 2] {}; // expected-error {{capture default must be first}}
25 } // namespace misplaced_capture_default
27 namespace misplaced_capture_default_pack {
28 template <typename... Args> void Test(Args... args) {
29 [&, args...] {}; // ok
30 [args..., &] {}; // expected-error {{capture default must be first}}
31 [=, &args...] {}; // ok
32 [&, ... xs = &args] {}; // ok
33 [&, ... xs = &] {}; // expected-error {{expected expression}}
34 [... xs = &] {}; // expected-error {{expected expression}}
35 [... xs = &args, = ] {}; // expected-error {{capture default must be first}}
36 [... xs = &args, &] {}; // expected-error {{capture default must be first}}
38 } // namespace misplaced_capture_default_pack