1 // RUN: %clang_cc1 -std=c++98 -pedantic-errors %s -verify=expected,cxx98-14
2 // RUN: %clang_cc1 -std=c++11 -pedantic-errors %s -verify=expected,cxx98-14
3 // RUN: %clang_cc1 -std=c++14 -pedantic-errors %s -verify=expected,cxx98-14
4 // RUN: %clang_cc1 -std=c++17 -pedantic-errors %s -verify=expected,since-cxx17
5 // RUN: %clang_cc1 -std=c++20 -pedantic-errors %s -verify=expected,since-cxx17
6 // RUN: %clang_cc1 -std=c++23 -pedantic-errors %s -verify=expected,since-cxx17
7 // RUN: %clang_cc1 -std=c++2c -pedantic-errors %s -verify=expected,since-cxx17
9 namespace cwg2406
{ // cwg2406: 5
10 #if __cplusplus >= 201703L
11 void fallthrough(int n
) {
18 case 3: // warning on fallthrough discouraged
21 // since-cxx17-error@-1 {{fallthrough annotation does not directly precede switch label}}
26 // since-cxx17-error@-1 {{fallthrough annotation does not directly precede switch label}}
31 // since-cxx17-error@-1 {{fallthrough annotation does not directly precede switch label}}
35 case 4: // implementation may warn on fallthrough
38 // since-cxx17-error@-1 {{fallthrough annotation does not directly precede switch label}}
44 namespace cwg2428
{ // cwg2428: 19
45 #if __cplusplus >= 202002L
47 concept C
[[deprecated
]] = true; // #cwg2428-C
50 [[deprecated
]] concept C2
= true;
51 // expected-error@-1 {{expected unqualified-id}}
55 // expected-warning@-1 {{'C' is deprecated}}
56 // expected-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
58 template <typename T
, C U
>
59 // expected-warning@-1 {{'C' is deprecated}}
60 // expected-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
62 // expected-warning@-1 {{'C' is deprecated}}
63 // expected-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
66 // expected-warning@-1 {{'C' is deprecated}}
67 // expected-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
71 // expected-warning@-1 {{'C' is deprecated}}
72 // expected-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
76 // expected-warning@-1 {{'C' is deprecated}}
77 // expected-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
79 // expected-warning@-1 {{'C' is deprecated}}
80 // expected-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
82 // expected-warning@-1 {{'C' is deprecated}}
83 // expected-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
85 // expected-warning@-1 {{'C' is deprecated}}
86 // expected-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
88 // expected-warning@-1 {{'C' is deprecated}}
89 // expected-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
93 } // namespace cwg2428
95 namespace cwg2430
{ // cwg2430: 2.7
97 S
f(S s
) { return s
; }
99 } // namespace cwg2430
101 namespace cwg2450
{ // cwg2450: 18
102 #if __cplusplus >= 202302L
115 namespace cwg2459
{ // cwg2459: 18
116 #if __cplusplus >= 202302L
118 constexpr A(float) {}
120 template<A
> struct X
{};
125 namespace cwg2445
{ // cwg2445: 19
126 #if __cplusplus >= 202002L
127 template <typename
> constexpr bool F
= false;
128 template <typename T
> struct A
{ };
130 template <typename T
, typename U
>
131 bool operator==(T
, A
<U
*>);
133 template <typename T
, typename U
>
134 bool operator!=(A
<T
>, U
) {
135 static_assert(F
<T
>, "Isn't this less specialized?");
139 bool f(A
<int> ax
, A
<int *> ay
) { return ay
!= ax
; }
141 template<class T
> concept AlwaysTrue
=true;
142 template <class T
> struct B
{
143 template <AlwaysTrue U
>
144 bool operator==(const B
<U
>&)const;
148 template <typename U
>
149 bool operator==(const B
<int>&,const B
<U
>&) {
150 static_assert(F
<int>, "Isn't this less specialized?");
154 bool g(B
<int> bx
, B
<int *> by
) { return bx
== by
; }
157 template<AlwaysTrue T
>
158 int operator+(T
){return 0;}
163 void operator+(C
&&,T
){}
164 template<AlwaysTrue T
>
165 int operator-(C
&&,T
){return 0;}
173 template<AlwaysTrue T
>
174 int operator+(T
) volatile {return 1;}
178 void operator+(volatile D
&,T
) {}
180 int foo(volatile D
& d
){
186 namespace cwg2486
{ // cwg2486: 4 c++17
191 static void call(C
& c
, void (C::*f
)()) {
195 static void callNE(C
& c
, void (C::*f
)() throw()) {
196 // cxx98-14-warning@-1 {{mangled name of 'callNE' will change in C++17 due to non-throwing exception specification in function signature}}
202 call(c
, &C::fn
); // <= implicit cast removes noexcept
207 void (*pp
)() throw() = p
;
208 // since-cxx17-error@-1 {{cannot initialize a variable of type 'void (*)() throw()' with an lvalue of type 'void (*)()': different exception specifications}}
212 operator p(); // #cwg2486-conv
214 void (*q
)() throw() = S();
215 // since-cxx17-error@-1 {{no viable conversion from 'S' to 'void (*)() throw()'}}
216 // since-cxx17-note@#cwg2486-conv {{candidate function}}
217 } // namespace cwg2486