1 // RUN: %clang_cc1 -fsyntax-only -std=c++17 -pedantic -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -std=c++20 -Wc++17-compat-pedantic -verify %s -Wno-defaulted-function-deleted
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++20 extension}}
10 // expected-warning@-4 {{invoking a pointer to a 'const &' member function on an rvalue is incompatible with C++ standards before C++20}}
16 #if __cplusplus <= 201703L
17 // expected-warning@-2 {{explicit capture of 'this' with a capture default of '=' is a C++20 extension}}
19 // expected-warning@-4 {{explicit capture of 'this' with a capture default of '=' is incompatible with C++ standards before C++20}}
24 #if __cplusplus <= 201703L
25 // expected-warning@-2 {{default member initializer for bit-field is a C++20 extension}}
27 // expected-warning@-4 {{default member initializer for bit-field is incompatible with C++ standards before C++20}}
32 decltype(Lambda
) AnotherLambda
;
33 #if __cplusplus <= 201703L
34 // expected-error@-2 {{no matching constructor}} expected-note@-3 2{{candidate}}
36 // expected-warning@-4 {{default construction of lambda is incompatible with C++ standards before C++20}}
39 void copy_lambda() { Lambda
= Lambda
; }
40 #if __cplusplus <= 201703L
41 // expected-error@-2 {{deleted}} expected-note@-10 {{lambda}}
43 // expected-warning@-4 {{assignment of lambda is incompatible with C++ standards before C++20}}
46 struct DefaultDeleteWrongTypeBase
{
47 DefaultDeleteWrongTypeBase(DefaultDeleteWrongTypeBase
&);
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}}
54 // expected-warning@-4 {{explicitly defaulting this copy constructor with a type different from the implicit type is incompatible with C++ standards before C++20}}
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++20 extension}}
63 // expected-warning@-4 {{range-based for loop initialization statements are incompatible with C++ standards before C++20}}
67 struct ConstexprVirtual
{
68 virtual constexpr void f() {}
69 #if __cplusplus <= 201703L
70 // expected-error@-2 {{virtual function cannot be constexpr}}
72 // expected-warning@-4 {{virtual constexpr functions are incompatible with C++ standards before C++20}}
76 struct C
{ int x
, y
, z
; };
77 static auto [cx
, cy
, cz
] = C();
78 #if __cplusplus <= 201703L
79 // expected-warning@-2 {{decomposition declaration declared 'static' is a C++20 extension}}
81 // expected-warning@-4 {{decomposition declaration declared 'static' is incompatible with C++ standards before C++20}}
84 static thread_local
auto [cx
, cy
, cz
] = C();
85 #if __cplusplus <= 201703L
86 // expected-warning@-2 {{decomposition declaration declared with 'static thread_local' specifiers is a C++20 extension}}
88 // expected-warning@-4 {{decomposition declaration declared with 'static thread_local' specifiers is incompatible with C++ standards before C++20}}
92 struct DefaultedComparisons
{
93 bool operator==(const DefaultedComparisons
&) const = default;
94 bool operator!=(const DefaultedComparisons
&) const = default;
95 #if __cplusplus <= 201703L
96 // expected-warning@-3 {{defaulted comparison operators are a C++20 extension}}
97 // expected-warning@-3 {{defaulted comparison operators are a C++20 extension}}
99 // expected-warning@-6 {{defaulted comparison operators are incompatible with C++ standards before C++20}}
100 // expected-warning@-6 {{defaulted comparison operators are incompatible with C++ standards before C++20}}
102 bool operator<=>(const DefaultedComparisons
&) const = default;
103 #if __cplusplus <= 201703L
104 // expected-error@-2 {{'operator<=' cannot be the name of a variable or data member}} expected-error@-2 0+{{}} expected-warning@-2 {{}}
106 // expected-warning@-4 {{'<=>' operator is incompatible with C++ standards before C++20}}
108 bool operator<(const DefaultedComparisons
&) const = default;
109 bool operator<=(const DefaultedComparisons
&) const = default;
110 bool operator>(const DefaultedComparisons
&) const = default;
111 bool operator>=(const DefaultedComparisons
&) const = default;
112 #if __cplusplus <= 201703L
113 // expected-error@-5 {{only special member functions}}
114 // expected-error@-5 {{only special member functions}}
115 // expected-error@-5 {{only special member functions}}
116 // expected-error@-5 {{only special member functions}}
118 // expected-warning@-10 {{defaulted comparison operators are incompatible with C++ standards before C++20}}
119 // expected-warning@-10 {{defaulted comparison operators are incompatible with C++ standards before C++20}}
120 // expected-warning@-10 {{defaulted comparison operators are incompatible with C++ standards before C++20}}
121 // expected-warning@-10 {{defaulted comparison operators are incompatible with C++ standards before C++20}}
127 template<A
> struct Class
{};
128 #if __cplusplus <= 201703L
129 // expected-error@-2 {{non-type template parameter cannot have type 'NTTP::A' before C++20}}
131 // expected-warning@-4 {{non-type template parameter of type 'NTTP::A' is incompatible with C++ standards before C++20}}