1 | // RUN: %clang_cc1 -fsyntax-only -std=c++17 -pedantic -verify %s |
2 | // RUN: %clang_cc1 -fsyntax-only -std=c++2a -Wc++17-compat-pedantic -verify %s -Wno-defaulted-function-deleted |
3 | |
4 | struct A {}; |
5 | int (A::*pa)() const&; |
6 | int use_pa = (A().*pa)(); |
7 | #if __cplusplus <= 201703L |
8 | // expected-warning@-2 {{invoking a pointer to a 'const &' member function on an rvalue is a C++2a extension}} |
9 | #else |
10 | // expected-warning@-4 {{invoking a pointer to a 'const &' member function on an rvalue is incompatible with C++ standards before C++2a}} |
11 | #endif |
12 | |
13 | struct B { |
14 | void b() { |
15 | (void) [=, this] {}; |
16 | #if __cplusplus <= 201703L |
17 | // expected-warning@-2 {{explicit capture of 'this' with a capture default of '=' is a C++2a extension}} |
18 | #else |
19 | // expected-warning@-4 {{explicit capture of 'this' with a capture default of '=' is incompatible with C++ standards before C++2a}} |
20 | #endif |
21 | } |
22 | |
23 | int n : 5 = 0; |
24 | #if __cplusplus <= 201703L |
25 | // expected-warning@-2 {{default member initializer for bit-field is a C++2a extension}} |
26 | #else |
27 | // expected-warning@-4 {{default member initializer for bit-field is incompatible with C++ standards before C++2a}} |
28 | #endif |
29 | }; |
30 | |
31 | auto Lambda = []{}; |
32 | decltype(Lambda) AnotherLambda; |
33 | #if __cplusplus <= 201703L |
34 | // expected-error@-2 {{no matching constructor}} expected-note@-3 2{{candidate}} |
35 | #else |
36 | // expected-warning@-4 {{default construction of lambda is incompatible with C++ standards before C++2a}} |
37 | #endif |
38 | |
39 | void copy_lambda() { Lambda = Lambda; } |
40 | #if __cplusplus <= 201703L |
41 | // expected-error@-2 {{deleted}} expected-note@-10 {{lambda}} |
42 | #else |
43 | // expected-warning@-4 {{assignment of lambda is incompatible with C++ standards before C++2a}} |
44 | #endif |
45 | |
46 | struct DefaultDeleteWrongTypeBase { |
47 | DefaultDeleteWrongTypeBase(DefaultDeleteWrongTypeBase&); |
48 | }; |
49 | struct DefaultDeleteWrongType : DefaultDeleteWrongTypeBase { |
50 | DefaultDeleteWrongType(const DefaultDeleteWrongType&) = default; |
51 | #if __cplusplus <= 201703L |
52 | // expected-error@-2 {{a member or base requires it to be non-const}} |
53 | #else |
54 | // expected-warning@-4 {{explicitly defaulting this copy constructor with a type different from the implicit type is incompatible with C++ standards before C++2a}} |
55 | #endif |
56 | }; |
57 | |
58 | void ForRangeInit() { |
59 | for (int arr[3] = {1, 2, 3}; int n : arr) {} |
60 | #if __cplusplus <= 201703L |
61 | // expected-warning@-2 {{range-based for loop initialization statements are a C++2a extension}} |
62 | #else |
63 | // expected-warning@-4 {{range-based for loop initialization statements are incompatible with C++ standards before C++2a}} |
64 | #endif |
65 | } |
66 | |