[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CXX / drs / cwg2xx.cpp
blobec37b420880e28ab1b7ba53609525e63bb010562
1 // RUN: %clang_cc1 -std=c++98 %s -verify=expected,cxx98,cxx98-11,cxx98-14,cxx98-17 -fexceptions -fcxx-exceptions -pedantic-errors
2 // RUN: %clang_cc1 -std=c++11 %s -verify=expected,since-cxx11,cxx98-11,cxx98-14,cxx98-17 -fexceptions -fcxx-exceptions -pedantic-errors
3 // RUN: %clang_cc1 -std=c++14 %s -verify=expected,since-cxx11,since-cxx14,cxx98-14,cxx98-17 -fexceptions -fcxx-exceptions -pedantic-errors
4 // RUN: %clang_cc1 -std=c++17 %s -verify=expected,since-cxx11,since-cxx14,since-cxx17,cxx98-17 -fexceptions -fcxx-exceptions -pedantic-errors
5 // RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx11,since-cxx14,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors
6 // RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx11,since-cxx14,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors
8 // FIXME: diagnostic above is emitted only on Windows platforms
9 // PR13819 -- __SIZE_TYPE__ is incompatible.
10 typedef __SIZE_TYPE__ size_t;
11 // cxx98-error@-1 0-1 {{'long long' is a C++11 extension}}
13 #if __cplusplus == 199711L
14 #define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
15 // cxx98-error@-1 {{variadic macros are a C99 feature}}
16 #endif
18 #if __cplusplus == 199711L
19 #define __enable_constant_folding(x) (__builtin_constant_p(x) ? (x) : (x))
20 #else
21 #define __enable_constant_folding
22 #endif
24 namespace cwg200 { // cwg200: dup 214
25 template <class T> T f(int);
26 template <class T, class U> T f(U) = delete;
27 // cxx98-error@-1 {{deleted function definitions are a C++11 extension}}
29 void g() {
30 f<int>(1);
34 // cwg201 is in cwg201.cpp
36 namespace cwg202 { // cwg202: 3.1
37 template<typename T> T f();
38 template<int (*g)()> struct X {
39 static_assert(__enable_constant_folding(g == &f<int>), "");
41 template struct X<f>;
44 // cwg204: sup 820
46 namespace cwg206 { // cwg206: yes
47 struct S; // #cwg206-S
48 template<typename T> struct Q { S s; };
49 // expected-error@-1 {{field has incomplete type 'S'}}
50 // expected-note@#cwg206-S {{forward declaration of 'cwg206::S'}}
51 template<typename T> void f() { S s; }
52 // expected-error@-1 {{variable has incomplete type 'S'}}
53 // expected-note@#cwg206-S {{forward declaration of 'cwg206::S'}}
56 namespace cwg207 { // cwg207: yes
57 class A {
58 protected:
59 static void f() {}
61 class B : A {
62 public:
63 using A::f;
64 void g() {
65 A::f();
66 f();
71 // cwg208 FIXME: write codegen test
73 namespace cwg209 { // cwg209: 3.2
74 class A {
75 void f(); // #cwg209-A-f
77 class B {
78 friend void A::f();
79 // expected-error@-1 {{friend function 'f' is a private member of 'cwg209::A'}}
80 // expected-note@#cwg209-A-f {{implicitly declared private here}}
84 // cwg210 is in cwg210.cpp
86 namespace cwg211 { // cwg211: yes
87 struct A {
88 A() try {
89 throw 0;
90 } catch (...) {
91 return;
92 // expected-error@-1 {{return in the catch of a function try block of a constructor is illegal}}
97 namespace cwg213 { // cwg213: yes
98 template <class T> struct A : T {
99 void h(T t) {
100 char &r1 = f(t);
101 int &r2 = g(t);
102 // expected-error@-1 {{explicit qualification required to use member 'g' from dependent base class}}
103 // expected-note@#cwg213-instantiation {{in instantiation of member function 'cwg213::A<cwg213::B>::h' requested here}}
104 // expected-note@#cwg213-B-g {{member is declared here}}
107 struct B {
108 int &f(B);
109 int &g(B); // #cwg213-B-g
111 char &f(B);
113 template void A<B>::h(B); // #cwg213-instantiation
116 namespace cwg214 { // cwg214: yes
117 template<typename T, typename U> T checked_cast(U from) { U::error; }
118 template<typename T, typename U> T checked_cast(U *from);
119 class C {};
120 void foo(int *arg) { checked_cast<const C *>(arg); }
122 template<typename T> T f(int);
123 template<typename T, typename U> T f(U) { T::error; }
124 void g() {
125 f<int>(1);
129 namespace cwg215 { // cwg215: 2.9
130 template<typename T> class X {
131 friend void T::foo();
132 int n;
134 struct Y {
135 void foo() { (void)+X<Y>().n; }
139 namespace cwg216 { // cwg216: no
140 // FIXME: Should reject this: 'f' has linkage but its type does not,
141 // and 'f' is odr-used but not defined in this TU.
142 typedef enum { e } *E;
143 void f(E);
144 void g(E e) { f(e); }
146 struct S {
147 // FIXME: Should reject this: 'f' has linkage but its type does not,
148 // and 'f' is odr-used but not defined in this TU.
149 typedef enum { e } *E;
150 void f(E);
152 void g(S s, S::E e) { s.f(e); }
155 namespace cwg217 { // cwg217: yes
156 template<typename T> struct S {
157 void f(int);
159 template<typename T> void S<T>::f(int = 0) {}
160 // expected-error@-1 {{default arguments cannot be added to an out-of-line definition of a member of a class template}}
163 namespace cwg218 { // cwg218: yes
164 // NB: also dup 405
165 namespace A {
166 struct S {};
167 void f(S);
169 namespace B {
170 struct S {};
171 void f(S);
174 struct C {
175 int f;
176 void test1(A::S as) { f(as); }
177 // expected-error@-1 {{called object type 'int' is not a function or function pointer}}
178 void test2(A::S as) { void f(); f(as); }
179 // expected-error@-1 {{too many arguments to function call, expected 0, have 1}}
180 // expected-note@-2 {{'f' declared here}}
181 void test3(A::S as) { using A::f; f(as); } // ok
182 void test4(A::S as) { using B::f; f(as); } // ok
183 void test5(A::S as) { int f; f(as); }
184 // expected-error@-1 {{called object type 'int' is not a function or function pointer}}
185 void test6(A::S as) { struct f {}; (void) f(as); }
186 // expected-error@-1 {{no matching conversion for functional-style cast from 'A::S' to 'f'}}
187 // expected-note@-2 {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'A::S' to 'const f' for 1st argument}}
188 // since-cxx11-note@-3 {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'A::S' to 'f' for 1st argument}}
189 // expected-note@-4 {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
192 namespace D {
193 struct S {};
194 struct X { void operator()(S); } f;
196 void testD(D::S ds) { f(ds); }
197 // expected-error@-1 {{use of undeclared identifier 'f'}}
199 namespace E {
200 struct S {};
201 struct f { f(S); };
203 void testE(E::S es) { f(es); }
204 // expected-error@-1 {{use of undeclared identifier 'f'}}
206 namespace F {
207 struct S {
208 template<typename T> friend void f(S, T) {}
211 void testF(F::S fs) { f(fs, 0); }
213 namespace G {
214 namespace X {
215 int f;
216 struct A {};
218 namespace Y {
219 template<typename T> void f(T);
220 struct B {};
222 template<typename A, typename B> struct C {};
224 void testG(G::C<G::X::A, G::Y::B> gc) { f(gc); }
227 // cwg219: na
228 // cwg220: na
230 namespace cwg221 { // cwg221: 3.6
231 struct A { // #cwg221-S
232 A &operator=(int&); // #cwg221-S-copy-assign
233 A &operator+=(int&);
234 static A &operator=(A&, double&);
235 // expected-error@-1 {{overloaded 'operator=' cannot be a static member function}}
236 static A &operator+=(A&, double&);
237 // expected-error@-1 {{overloaded 'operator+=' cannot be a static member function}}
238 friend A &operator=(A&, char&);
239 // expected-error@-1 {{overloaded 'operator=' must be a non-static member function}}
240 friend A &operator+=(A&, char&);
242 A &operator=(A&, float&);
243 // expected-error@-1 {{overloaded 'operator=' must be a non-static member function}}
244 A &operator+=(A&, float&);
246 void test(A a, int n, char c, float f) {
247 a = n;
248 a += n;
249 a = c;
250 // expected-error@-1 {{no viable overloaded '='}}
251 // expected-note@#cwg221-S-copy-assign {{candidate function not viable: no known conversion from 'char' to 'int &' for 1st argument}}
252 // since-cxx11-note@#cwg221-S {{candidate function (the implicit move assignment operator) not viable: no known conversion from 'char' to 'A' for 1st argument}}
253 // expected-note@#cwg221-S {{candidate function (the implicit copy assignment operator) not viable: no known conversion from 'char' to 'const A' for 1st argument}}
254 a += c;
255 a = f;
256 // expected-error@-1 {{no viable overloaded '='}}
257 // expected-note@#cwg221-S-copy-assign {{candidate function not viable: no known conversion from 'float' to 'int &' for 1st argument}}
258 // since-cxx11-note@#cwg221-S {{candidate function (the implicit move assignment operator) not viable: no known conversion from 'float' to 'A' for 1st argument}}
259 // expected-note@#cwg221-S {{candidate function (the implicit copy assignment operator) not viable: no known conversion from 'float' to 'const A' for 1st argument}}
260 a += f;
264 namespace cwg222 { // cwg222: dup 637
265 void f(int a, int b, int c, int *x) {
266 #pragma clang diagnostic push
267 #pragma clang diagnostic warning "-Wunsequenced"
268 void((a += b) += c);
269 void((a += b) + (a += c));
270 // expected-warning@-1 {{multiple unsequenced modifications to 'a'}}
272 x[a++] = a;
273 // cxx98-14-warning@-1 {{unsequenced modification and access to 'a'}}
275 a = b = 0; // ok, read and write of 'b' are sequenced
277 a = (b = a++);
278 // cxx98-14-warning@-1 {{multiple unsequenced modifications to 'a'}}
279 a = (b = ++a);
280 #pragma clang diagnostic pop
284 // cwg223: na
286 namespace cwg224 { // cwg224: 16
287 namespace example1 {
288 template <class T> class A {
289 typedef int type;
290 A::type a;
291 A<T>::type b;
292 A<T*>::type c;
293 // cxx98-17-error@-1 {{missing 'typename' prior to dependent type name A<T *>::type; implicit 'typename' is a C++20 extension}}
294 ::cwg224::example1::A<T>::type d;
296 class B {
297 typedef int type;
299 A::type a;
300 A<T>::type b;
301 A<T*>::type c;
302 // cxx98-17-error@-1 {{missing 'typename' prior to dependent type name A<T *>::type; implicit 'typename' is a C++20 extension}}
303 ::cwg224::example1::A<T>::type d;
305 B::type e;
306 A<T>::B::type f;
307 A<T*>::B::type g;
308 // cxx98-17-error@-1 {{missing 'typename' prior to dependent type name A<T *>::B::type; implicit 'typename' is a C++20 extension}}
309 typename A<T*>::B::type h;
313 template <class T> class A<T*> {
314 typedef int type;
315 A<T*>::type a;
316 A<T>::type b;
317 // cxx98-17-error@-1 {{missing 'typename' prior to dependent type name A<T>::type; implicit 'typename' is a C++20 extension}}
320 template <class T1, class T2, int I> struct B {
321 typedef int type;
322 B<T1, T2, I>::type b1;
323 B<T2, T1, I>::type b2;
324 // cxx98-17-error@-1 {{missing 'typename' prior to dependent type name B<T2, T1, I>::type; implicit 'typename' is a C++20 extension}}
326 typedef T1 my_T1;
327 static const int my_I = I;
328 static const int my_I2 = I+0;
329 static const int my_I3 = my_I;
330 B<my_T1, T2, my_I>::type b3;
331 // cxx98-17-error@-1 {{missing 'typename' prior to dependent type name B<my_T1, T2, my_I>::type; implicit 'typename' is a C++20 extension}}
332 B<my_T1, T2, my_I2>::type b4;
333 // cxx98-17-error@-1 {{missing 'typename' prior to dependent type name B<my_T1, T2, my_I2>::type; implicit 'typename' is a C++20 extension}}
334 B<my_T1, T2, my_I3>::type b5;
335 // cxx98-17-error@-1 {{missing 'typename' prior to dependent type name B<my_T1, T2, my_I3>::type; implicit 'typename' is a C++20 extension}}
339 namespace example2 {
340 template <int, typename T> struct X { typedef T type; };
341 template <class T> class A {
342 static const int i = 5;
343 X<i, int>::type w;
344 X<A::i, char>::type x;
345 X<A<T>::i, double>::type y;
346 X<A<T*>::i, long>::type z;
347 // cxx98-17-error@-1 {{missing 'typename' prior to dependent type name X<A<T *>::i, long>::type; implicit 'typename' is a C++20 extension}}
348 int f();
350 template <class T> int A<T>::f() {
351 return i;
356 // cwg225: yes
357 template<typename T> void cwg225_f(T t) { cwg225_g(t); }
358 // expected-error@-1 {{call to function 'cwg225_g' that is neither visible in the template definition nor found by argument-dependent lookup}}
359 // expected-note@#cwg225-f {{in instantiation of function template specialization 'cwg225_f<int>' requested here}}
360 // expected-note@#cwg225-g {{'cwg225_g' should be declared prior to the call site}}
361 void cwg225_g(int); // #cwg225-g
362 template void cwg225_f(int); // #cwg225-f
364 namespace cwg226 { // cwg226: no
365 // FIXME: This appears to be wrong: default arguments for function templates
366 // are listed as a defect (in c++98) not an extension. EDG accepts them in
367 // strict c++98 mode.
368 template<typename T = void> void f() {}
369 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
370 template<typename T> struct S {
371 template<typename U = void> void g();
372 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
373 template<typename U> struct X;
374 template<typename U> void h();
376 template<typename T> template<typename U> void S<T>::g() {}
377 template<typename T> template<typename U = void> struct S<T>::X {};
378 // expected-error@-1 {{cannot add a default template argument to the definition of a member of a class template}}
379 template<typename T> template<typename U = void> void S<T>::h() {}
380 // expected-error@-1 {{cannot add a default template argument to the definition of a member of a class template}}
382 template<typename> void friend_h();
383 struct A {
384 // FIXME: This is ill-formed.
385 template<typename=void> struct friend_B;
386 // FIXME: f, h, and i are ill-formed.
387 // f is ill-formed because it is not a definition.
388 // h and i are ill-formed because they are not the only declarations of the
389 // function in the translation unit.
390 template<typename=void> void friend_f();
391 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
392 template<typename=void> void friend_g() {}
393 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
394 template<typename=void> void friend_h() {}
395 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
396 template<typename=void> void friend_i() {}
397 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
399 template<typename> void friend_i();
401 template<typename=void, typename X> void foo(X) {}
402 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
403 template<typename=void, typename X> struct Foo {};
404 // expected-error@-1 {{template parameter missing a default argument}}
405 // expected-note@-2 {{previous default template argument defined here}}
407 template<typename=void, typename X, typename, typename Y> int foo(X, Y);
408 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
409 template<typename, typename X, typename=void, typename Y> int foo(X, Y);
410 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
411 int x = foo(0, 0);
414 void cwg227(bool b) { // cwg227: yes
415 if (b)
416 int n;
417 else
418 int n;
421 namespace cwg228 { // cwg228: yes
422 template <class T> struct X {
423 void f();
425 template <class T> struct Y {
426 void g(X<T> x) { x.template X<T>::f(); }
430 namespace cwg229 { // cwg229: 2.9
431 template<typename T> void f();
432 template<typename T> void f<T*>() {}
433 // expected-error@-1 {{function template partial specialization is not allowed}}
434 template<> void f<int>() {}
437 namespace cwg230 { // cwg230: 3.0
438 struct S {
439 S() { f(); }
440 // expected-warning@-1 {{call to pure virtual member function 'f' has undefined behavior; overrides of 'f' in subclasses are not available in the constructor of 'cwg230::S'}}
441 // expected-note@#cwg230-f {{'f' declared here}}
442 virtual void f() = 0; // #cwg230-f
446 namespace cwg231 { // cwg231: yes
447 namespace outer {
448 namespace inner {
449 int i; // #cwg231-i
451 void f() { using namespace inner; }
452 int j = i;
453 // expected-error@-1 {{use of undeclared identifier 'i'; did you mean 'inner::i'?}}
454 // expected-note@#cwg231-i {{'inner::i' declared here}}
458 // cwg234: na
459 // cwg235: na
461 namespace cwg236 { // cwg236: 3.2
462 void *p = int();
463 // cxx98-warning@-1 {{expression which evaluates to zero treated as a null pointer constant of type 'void *'}}
464 // since-cxx11-error@-2 {{cannot initialize a variable of type 'void *' with an rvalue of type 'int'}}
467 namespace cwg237 { // cwg237: dup 470
468 template<typename T> struct A { void f() { T::error; } };
469 template<typename T> struct B : A<T> {};
470 template struct B<int>; // ok
473 namespace cwg239 { // cwg239: yes
474 namespace NS {
475 class T {};
476 void f(T);
477 float &g(T, int);
479 NS::T parm;
480 int &g(NS::T, float);
481 int main() {
482 f(parm);
483 float &r = g(parm, 1);
484 extern int &g(NS::T, float);
485 int &s = g(parm, 1);
489 // cwg240: dup 616
491 namespace cwg241 { // cwg241: yes
492 namespace A {
493 struct B {};
494 template <int X> void f(); // #cwg241-A-f
495 template <int X> void g(B);
497 namespace C {
498 template <class T> void f(T t); // #cwg241-C-f
499 template <class T> void g(T t); // #cwg241-C-g
501 void h(A::B b) {
502 f<3>(b);
503 // expected-error@-1 {{no matching function for call to 'f'}}
504 // expected-note@#cwg241-A-f {{candidate function template not viable: requires 0 arguments, but 1 was provided}}
505 // cxx98-17-error@-3 {{use of function template name with no prior declaration in function call with explicit template arguments is a C++20 extension}}
506 g<3>(b);
507 // cxx98-17-error@-1 {{use of function template name with no prior declaration in function call with explicit template arguments is a C++20 extension}}
508 A::f<3>(b);
509 // expected-error@-1 {{no matching function for call to 'f'}}
510 // expected-note@#cwg241-A-f {{candidate function template not viable: requires 0 arguments, but 1 was provided}}
511 A::g<3>(b);
512 C::f<3>(b);
513 // expected-error@-1 {{no matching function for call to 'f'}}
514 // expected-note@#cwg241-C-f {{candidate template ignored: invalid explicitly-specified argument for template parameter 'T'}}
515 C::g<3>(b);
516 // expected-error@-1 {{no matching function for call to 'g'}}
517 // expected-note@#cwg241-C-g {{candidate template ignored: invalid explicitly-specified argument for template parameter 'T'}}
518 using C::f;
519 using C::g;
520 f<3>(b);
521 // expected-error@-1 {{no matching function for call to 'f'}}
522 // expected-note@#cwg241-C-f {{candidate template ignored: invalid explicitly-specified argument for template parameter 'T'}}
523 // expected-note@#cwg241-A-f {{candidate function template not viable: requires 0 arguments, but 1 was provided}}
524 g<3>(b);
528 namespace cwg243 { // cwg243: yes
529 struct B;
530 struct A {
531 A(B); // #cwg243-A
533 struct B {
534 operator A() = delete; // #cwg243-B
535 // cxx98-error@-1 {{deleted function definitions are a C++11 extension}}
536 } b;
537 A a1(b);
538 A a2 = b;
539 // expected-error@-1 {{conversion from 'struct B' to 'A' is ambiguous}}
540 // expected-note@#cwg243-A {{candidate constructor}}
541 // expected-note@#cwg243-B {{candidate function has been explicitly deleted}}
544 namespace cwg244 { // cwg244: 11
545 // NB: this test is reused by cwg399
546 struct B {}; // #cwg244-B
547 struct D : B {};
549 D D_object;
550 typedef B B_alias;
551 B* B_ptr = &D_object;
553 void f() {
554 D_object.~B();
555 // expected-error@-1 {{destructor type 'cwg244::B' in object destruction expression does not match the type 'D' of the object being destroyed}}
556 // expected-note@#cwg244-B {{type 'cwg244::B' found by destructor name lookup}}
557 D_object.B::~B();
558 D_object.D::~B(); // FIXME: Missing diagnostic for this.
559 B_ptr->~B();
560 B_ptr->~B_alias();
561 B_ptr->B_alias::~B();
562 B_ptr->B_alias::~B_alias();
563 B_ptr->cwg244::~B();
564 // expected-error@-1 {{no member named '~B' in namespace 'cwg244'}}
565 B_ptr->cwg244::~B_alias();
566 // expected-error@-1 {{no member named '~B' in namespace 'cwg244'}}
569 template<typename T, typename U>
570 void f(T *B_ptr, U D_object) {
571 D_object.~B(); // FIXME: Missing diagnostic for this.
572 D_object.B::~B();
573 D_object.D::~B(); // FIXME: Missing diagnostic for this.
574 B_ptr->~B();
575 B_ptr->~B_alias();
576 B_ptr->B_alias::~B();
577 B_ptr->B_alias::~B_alias();
578 B_ptr->cwg244::~B();
579 // expected-error@-1 {{'cwg244' does not refer to a type name in pseudo-destructor expression; expected the name of type 'T'}}
580 B_ptr->cwg244::~B_alias();
581 // expected-error@-1 {{'cwg244' does not refer to a type name in pseudo-destructor expression; expected the name of type 'T'}}
583 template void f<B, D>(B*, D);
585 namespace N {
586 template<typename T> struct E {};
587 typedef E<int> F;
589 void g(N::F f) {
590 typedef N::F G; // #cwg244-G
591 f.~G();
592 f.G::~E();
593 // expected-error@-1 {{ISO C++ requires the name after '::~' to be found in the same scope as the name before '::~'}}
594 f.G::~F();
595 // expected-error@-1 {{undeclared identifier 'F' in destructor name}}
596 f.G::~G();
597 // This is technically ill-formed; E is looked up in 'N::' and names the
598 // class template, not the injected-class-name of the class. But that's
599 // probably a bug in the standard.
600 f.N::F::~E();
601 // expected-error@-1 {{ISO C++ requires the name after '::~' to be found in the same scope as the name before '::~'}}
602 // This is valid; we look up the second F in the same scope in which we
603 // found the first one, that is, 'N::'.
604 f.N::F::~F();
605 // This is technically ill-formed; G is looked up in 'N::' and is not found.
606 // Rejecting this seems correct, but most compilers accept, so we do also.
607 f.N::F::~G();
608 // expected-error@-1 {{qualified destructor name only found in lexical scope; omit the qualifier to find this type name by unqualified lookup}}
609 // expected-note@#cwg244-G {{type 'G' (aka 'E<int>') found by destructor name lookup}}
612 // Bizarrely, compilers perform lookup in the scope for qualified destructor
613 // names, if the nested-name-specifier is non-dependent. Ensure we diagnose
614 // this.
615 namespace QualifiedLookupInScope {
616 namespace N {
617 template <typename> struct S { struct Inner {}; };
619 template <typename U> void f(typename N::S<U>::Inner *p) {
620 typedef typename N::S<U>::Inner T;
621 p->::cwg244::QualifiedLookupInScope::N::S<U>::Inner::~T();
622 // expected-error@-1 {{no type named 'T' in 'cwg244::QualifiedLookupInScope::N::S<int>'}}
623 // expected-note@#cwg244-f {{in instantiation of function template specialization 'cwg244::QualifiedLookupInScope::f<int>' requested here}}
625 template void f<int>(N::S<int>::Inner *); // #cwg244-f
627 template <typename U> void g(U *p) {
628 typedef U T;
629 p->T::~T();
630 p->U::~T();
631 p->::cwg244::QualifiedLookupInScope::N::S<int>::Inner::~T();
632 // expected-error@-1 {{'T' does not refer to a type name in pseudo-destructor expression; expected the name of type 'U'}}
634 template void g(N::S<int>::Inner *);
638 namespace cwg245 { // cwg245: yes
639 struct S {
640 enum E {}; // #cwg245-E
641 class E *p;
642 // expected-error@-1 {{use of 'E' with tag type that does not match previous declaration}}
643 // expected-note@#cwg245-E {{previous use is here}}
647 namespace cwg246 { // cwg246: 3.2
648 struct S {
649 S() try { // #cwg246-try
650 throw 0;
651 X: ;
652 } catch (int) {
653 goto X;
654 // expected-error@-1 {{cannot jump from this goto statement to its label}}
655 // expected-note@#cwg246-try {{jump bypasses initialization of try block}}
660 namespace cwg247 { // cwg247: yes
661 struct A {};
662 struct B : A {
663 void f();
664 void f(int);
666 void (A::*f)() = (void (A::*)())&B::f;
668 struct C {
669 void f();
670 void f(int);
672 struct D : C {};
673 void (C::*g)() = &D::f;
674 void (D::*h)() = &D::f;
676 struct E {
677 void f();
679 struct F : E {
680 using E::f;
681 void f(int);
683 void (F::*i)() = &F::f;
686 namespace cwg248 { // cwg248: sup P1949
687 int \u040d\u040e = 0;
690 namespace cwg249 { // cwg249: yes
691 template<typename T> struct X { void f(); };
692 template<typename T> void X<T>::f() {}
695 namespace cwg250 { // cwg250: yes
696 typedef void (*FPtr)(double x[]);
698 template<int I> void f(double x[]);
699 FPtr fp = &f<3>;
701 template<int I = 3> void g(double x[]);
702 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
703 FPtr gp = &g<>;
706 namespace cwg252 { // cwg252: 3.1
707 struct A {
708 void operator delete(void*); // #cwg252-A
710 struct B {
711 void operator delete(void*); // #cwg252-B
713 struct C : A, B {
714 virtual ~C();
716 C::~C() {}
717 // expected-error@-1 {{member 'operator delete' found in multiple base classes of different types}}
718 // expected-note@#cwg252-A {{member found by ambiguous name lookup}}
719 // expected-note@#cwg252-B {{member found by ambiguous name lookup}}
721 struct D {
722 void operator delete(void*, int); // #cwg252-D
723 virtual ~D();
725 D::~D() {}
726 // expected-error@-1 {{no suitable member 'operator delete' in 'D'}}
727 // expected-note@#cwg252-D {{member 'operator delete' declared here}}
729 struct E {
730 void operator delete(void*, int);
731 void operator delete(void*) = delete; // #cwg252-E
732 // cxx98-error@-1 {{deleted function definitions are a C++11 extension}}
733 virtual ~E();
735 E::~E() {}
736 // expected-error@-1 {{attempt to use a deleted function}}
737 // expected-note@#cwg252-E {{'operator delete' has been explicitly marked deleted here}}
739 struct F {
740 // If both functions are available, the first one is a placement delete.
741 void operator delete(void*, size_t);
742 void operator delete(void*) = delete; // #cwg252-F
743 // cxx98-error@-1 {{deleted function definitions are a C++11 extension}}
744 virtual ~F();
746 F::~F() {}
747 // expected-error@-1 {{attempt to use a deleted function}}
748 // expected-note@#cwg252-F {{'operator delete' has been explicitly marked deleted here}}
750 struct G {
751 void operator delete(void*, size_t);
752 virtual ~G();
754 G::~G() {}
757 namespace cwg254 { // cwg254: 2.9
758 template<typename T> struct A {
759 typedef typename T::type type; // ok even if this is a typedef-name, because
760 // it's not an elaborated-type-specifier
761 typedef struct T::type foo;
762 // expected-error@-1 {{typedef 'type' cannot be referenced with the 'struct' specifier}}
763 // expected-note@#cwg254-instantiation {{in instantiation of template class 'cwg254::A<cwg254::C>' requested here}}
764 // expected-note@#cwg254-C {{declared here}}
766 struct B { struct type {}; };
767 struct C { typedef struct {} type; }; // #cwg254-C
768 A<B>::type n;
769 A<C>::type n; // #cwg254-instantiation
772 namespace cwg255 { // cwg255: yes
773 struct S {
774 void operator delete(void *){};
775 void operator delete(void *, int){};
777 void f(S *p) { delete p; }
778 } // namespace cwg255
780 // cwg256: dup 624
782 namespace cwg257 { // cwg257: 3.4
783 struct A { A(int); }; // #cwg257-A
784 struct B : virtual A {
785 B() {}
786 virtual void f() = 0;
788 struct C : B {
789 C() {}
791 struct D : B {
792 D() {}
793 // expected-error@-1 {{constructor for 'cwg257::D' must explicitly initialize the base class 'A' which does not have a default constructor}}
794 // expected-note@#cwg257-A {{'cwg257::A' declared here}}
795 void f();
799 namespace cwg258 { // cwg258: 2.8
800 struct A {
801 void f(const int);
802 template<typename> void g(int);
803 float &h() const;
805 struct B : A {
806 using A::f;
807 using A::g;
808 using A::h;
809 int &f(int);
810 template<int> int &g(int); // #cwg258-B-g
811 int &h();
812 } b;
813 int &w = b.f(0);
814 int &x = b.g<int>(0);
815 // expected-error@-1 {{no matching member function for call to 'g'}}
816 // expected-note@#cwg258-B-g {{candidate template ignored: invalid explicitly-specified argument for 1st template parameter}}
817 int &y = b.h();
818 float &z = const_cast<const B&>(b).h();
820 struct C {
821 virtual void f(const int) = 0;
823 struct D : C {
824 void f(int);
825 } d;
827 struct E {
828 virtual void f() = 0; // #cwg258-E-f
830 struct F : E {
831 void f() const {}
832 } f;
833 // expected-error@-1 {{variable type 'struct F' is an abstract class}}
834 // expected-note@#cwg258-E-f {{unimplemented pure virtual method 'f' in 'F'}}
837 namespace cwg259 { // cwg259: 4
838 template<typename T> struct A {};
839 template struct A<int>; // #cwg259-A-int
840 template struct A<int>;
841 // expected-error@-1 {{duplicate explicit instantiation of 'A<int>'}}
842 // expected-note@#cwg259-A-int {{previous explicit instantiation is here}}
844 template<> struct A<float>; // #cwg259-A-float
845 template struct A<float>;
846 // expected-warning@-1 {{explicit instantiation of 'A<float>' that occurs after an explicit specialization has no effect}}
847 // expected-note@#cwg259-A-float {{previous template specialization is here}}
849 template struct A<char>; // #cwg259-A-char
850 template<> struct A<char>;
851 // expected-error@-1 {{explicit specialization of 'cwg259::A<char>' after instantiation}}
852 // expected-note@#cwg259-A-char {{explicit instantiation first required here}}
854 template<> struct A<double>;
855 template<> struct A<double>;
856 template<> struct A<double> {}; // #cwg259-A-double
857 template<> struct A<double> {};
858 // expected-error@-1 {{redefinition of 'A<double>'}}
859 // expected-note@#cwg259-A-double {{previous definition is here}}
861 template<typename T> struct B; // #cwg259-B
862 template struct B<int>;
863 // expected-error@-1 {{explicit instantiation of undefined template 'cwg259::B<int>'}}
864 // expected-note@#cwg259-B {{template is declared here}}
866 template<> struct B<float>; // #cwg259-B-float
867 template struct B<float>;
868 // expected-warning@-1 {{explicit instantiation of 'B<float>' that occurs after an explicit specialization has no effect}}
869 // expected-note@#cwg259-B-float {{previous template specialization is here}}
872 // FIXME: When cwg260 is resolved, also add tests for CWG507.
874 namespace cwg261 { // cwg261: no
875 #pragma clang diagnostic push
876 #pragma clang diagnostic warning "-Wused-but-marked-unused"
878 // FIXME: This is ill-formed, with a diagnostic required, because operator new
879 // and operator delete are inline and odr-used, but not defined in this
880 // translation unit.
881 // We're also missing the -Wused-but-marked-unused diagnostic here.
882 struct A {
883 inline void *operator new(size_t) __attribute__((unused));
884 inline void operator delete(void*) __attribute__((unused));
885 A() {}
888 // FIXME: This is ill-formed, with a required diagnostic, for the same
889 // reason.
890 struct B {
891 inline void operator delete(void*) __attribute__((unused));
892 ~B() {}
894 struct C {
895 inline void operator delete(void*) __attribute__((unused));
896 virtual ~C() {}
897 // expected-warning@-1 {{'operator delete' was marked unused but was used}}
900 struct D {
901 inline void operator delete(void*) __attribute__((unused));
903 void h() { C::operator delete(0); }
904 // expected-warning@-1 {{'operator delete' was marked unused but was used}}
906 #pragma clang diagnostic pop
909 namespace cwg262 { // cwg262: yes
910 int f(int = 0, ...);
911 int k = f();
912 int l = f(0);
913 int m = f(0, 0);
916 namespace cwg263 { // cwg263: 3.3
917 struct X {};
918 struct Y {
919 #if __cplusplus < 201103L
920 friend X::X() throw();
921 friend X::~X() throw();
922 #elif __cplusplus <= 201703L
923 friend constexpr X::X() noexcept;
924 friend X::~X();
925 #else
926 friend constexpr X::X() noexcept;
927 friend constexpr X::~X();
928 #endif
929 Y::Y();
930 // expected-error@-1 {{extra qualification on member 'Y'}}
931 Y::~Y();
932 // expected-error@-1 {{extra qualification on member '~Y'}}
936 // cwg265: dup 353
937 // cwg266: na
938 // cwg269: na
939 // cwg270: na
941 namespace cwg272 { // cwg272: yes
942 struct X {
943 void f() {
944 this->~X();
945 X::~X();
946 ~X();
947 // expected-error@-1 {{invalid argument type 'X' to unary expression}}
952 #include <stdarg.h>
953 #include <stddef.h>
954 namespace cwg273 { // cwg273: yes
955 struct A {
956 int n;
958 void operator&(A);
959 void f(A a, ...) {
960 offsetof(A, n);
961 va_list val;
962 va_start(val, a);
963 va_end(val);
967 // cwg274: na
969 namespace cwg275 { // cwg275: no
970 namespace N {
971 template <class T> void f(T) {} // #cwg275-N-f
972 template <class T> void g(T) {} // #cwg275-N-g
973 template <> void f(int);
974 template <> void f(char);
975 template <> void f(double);
976 template <> void g(char);
979 using namespace N;
981 namespace M {
982 template <> void N::f(char) {}
983 // expected-error@-1 {{cannot define or redeclare 'f' here because namespace 'M' does not enclose namespace 'N'}}
984 template <class T> void g(T) {}
985 template <> void g(char) {}
986 // FIXME: this should be rejected in c++98 too
987 template void f(long);
988 // since-cxx11-error@-1 {{explicit instantiation of 'cwg275::N::f' must occur in namespace 'N'}}
989 // since-cxx11-note@#cwg275-N-f {{explicit instantiation refers here}}
990 // FIXME: this should be rejected in c++98 too
991 template void N::f(unsigned long);
992 // since-cxx11-error@-1 {{explicit instantiation of 'f' not in a namespace enclosing 'N'}}
993 // since-cxx11-note@#cwg275-N-f {{explicit instantiation refers here}}
994 template void h(long);
995 // expected-error@-1 {{explicit instantiation of 'h' does not refer to a function template, variable template, member function, member class, or static data member}}
996 template <> void f(double) {}
997 // expected-error@-1 {{no function template matches function template specialization 'f'}}
1000 template <class T> void g(T) {} // #cwg275-g
1002 template <> void N::f(char) {}
1003 template <> void f(int) {}
1004 // expected-error@-1 {{no function template matches function template specialization 'f'}}
1006 // FIXME: this should be rejected in c++98 too
1007 template void f(short);
1008 // since-cxx11-error@-1 {{explicit instantiation of 'cwg275::N::f' must occur in namespace 'N'}}
1009 // since-cxx11-note@#cwg275-N-f {{explicit instantiation refers here}}
1010 template void N::f(unsigned short);
1012 // FIXME: this should probably be valid. the wording from the issue
1013 // doesn't clarify this, but it follows from the usual rules.
1014 template void g(int);
1015 // expected-error@-1 {{partial ordering for explicit instantiation of 'g' is ambiguous}}
1016 // expected-note@#cwg275-g {{explicit instantiation candidate function 'cwg275::g<int>' template here [with T = int]}}
1017 // expected-note@#cwg275-N-g {{explicit instantiation candidate function 'cwg275::N::g<int>' template here [with T = int]}}
1019 // FIXME: likewise, this should also be valid.
1020 template<typename T> void f(T) {} // #cwg275-f
1021 template void f(short);
1022 // expected-error@-1 {{partial ordering for explicit instantiation of 'f' is ambiguous}}
1023 // expected-note@#cwg275-f {{explicit instantiation candidate function 'cwg275::f<short>' template here [with T = short]}}
1024 // expected-note@#cwg275-N-f {{explicit instantiation candidate function 'cwg275::N::f<short>' template here [with T = short]}}
1027 // cwg276: na
1029 namespace cwg277 { // cwg277: 3.1
1030 typedef int *intp;
1031 int *p = intp();
1032 static_assert(__enable_constant_folding(!intp()), "");
1035 // cwg279 is in cwg279.cpp
1037 namespace cwg280 { // cwg280: 2.9
1038 typedef void f0();
1039 typedef void f1(int);
1040 typedef void f2(int, int);
1041 typedef void f3(int, int, int);
1042 struct A {
1043 operator f1*(); // #cwg280-A-f1
1044 operator f2*();
1046 struct B {
1047 operator f0*(); // #cwg280-B-f0
1048 private:
1049 operator f3*(); // #cwg280-B-f3
1051 struct C {
1052 operator f0*(); // #cwg280-C-f0
1053 operator f1*(); // #cwg280-C-f1
1054 operator f2*(); // #cwg280-C-f2
1055 operator f3*(); // #cwg280-C-f3
1057 struct D : private A, B { // #cwg280-D
1058 operator f2*(); // #cwg280-D-f2
1059 } d;
1060 struct E : C, D {} e;
1061 void g() {
1062 d(); // ok, public
1063 d(0);
1064 // expected-error@-1 {{'operator void (*)(int)' is a private member of 'cwg280::A'}}
1065 // expected-note@#cwg280-D {{constrained by private inheritance here}}
1066 // expected-note@#cwg280-A-f1 {{member is declared here}}
1067 d(0, 0); // ok, suppressed by member in D
1068 d(0, 0, 0);
1069 // expected-error@-1 {{'operator void (*)(int, int, int)' is a private member of 'cwg280::B'}}
1070 // expected-note@#cwg280-B-f3 {{declared private here}}
1071 e();
1072 // expected-error@-1 {{call to object of type 'struct E' is ambiguous}}
1073 // expected-note@#cwg280-B-f0 {{conversion candidate of type 'void (*)()'}}
1074 // expected-note@#cwg280-C-f0 {{conversion candidate of type 'void (*)()'}}
1075 e(0);
1076 // expected-error@-1 {{call to object of type 'struct E' is ambiguous}}
1077 // expected-note@#cwg280-A-f1 {{conversion candidate of type 'void (*)(int)'}}
1078 // expected-note@#cwg280-C-f1 {{conversion candidate of type 'void (*)(int)'}}
1079 e(0, 0);
1080 // expected-error@-1 {{call to object of type 'struct E' is ambiguous}}
1081 // expected-note@#cwg280-C-f2 {{conversion candidate of type 'void (*)(int, int)'}}
1082 // expected-note@#cwg280-D-f2 {{conversion candidate of type 'void (*)(int, int)'}}
1083 e(0, 0, 0);
1084 // expected-error@-1 {{call to object of type 'struct E' is ambiguous}}
1085 // expected-note@#cwg280-B-f3 {{conversion candidate of type 'void (*)(int, int, int)'}}
1086 // expected-note@#cwg280-C-f3 {{conversion candidate of type 'void (*)(int, int, int)'}}
1090 namespace cwg281 { // cwg281: no
1091 void a();
1092 inline void b();
1094 void d();
1095 inline void e();
1097 struct S {
1098 friend inline void a(); // FIXME: ill-formed
1099 friend inline void b();
1100 friend inline void c(); // FIXME: ill-formed
1101 friend inline void d() {}
1102 friend inline void e() {}
1103 friend inline void f() {}
1107 namespace cwg283 { // cwg283: yes
1108 template<typename T> // #cwg283-template
1109 struct S {
1110 friend class T;
1111 // expected-error@-1 {{declaration of 'T' shadows template parameter}}
1112 // expected-note@#cwg283-template {{template parameter is declared here}}
1113 class T;
1114 // expected-error@-1 {{declaration of 'T' shadows template parameter}}
1115 // expected-note@#cwg283-template {{template parameter is declared here}}
1119 namespace cwg284 { // cwg284: no
1120 namespace A {
1121 struct X;
1122 enum Y {};
1123 class Z {};
1125 namespace B {
1126 struct W;
1127 using A::X;
1128 using A::Y;
1129 using A::Z;
1131 struct B::V {};
1132 // expected-error@-1 {{no struct named 'V' in namespace 'cwg284::B'}}
1133 struct B::W {};
1134 struct B::X {}; // FIXME: ill-formed
1135 enum B::Y e; // ok per cwg417
1136 class B::Z z; // ok per cwg417
1138 struct C {
1139 struct X;
1140 enum Y {};
1141 class Z {};
1143 struct D : C {
1144 struct W;
1145 using C::X;
1146 using C::Y;
1147 using C::Z;
1149 struct D::V {};
1150 // expected-error@-1 {{no struct named 'V' in 'cwg284::D'}}
1151 struct D::W {};
1152 struct D::X {}; // FIXME: ill-formed
1153 enum D::Y e2; // ok per cwg417
1154 class D::Z z2; // ok per cwg417
1157 namespace cwg285 { // cwg285: yes
1158 template<typename T> void f(T, int); // #cwg285-f-T-int
1159 template<typename T> void f(int, T); // #cwg285-f-int-T
1160 template<> void f<int>(int, int) {}
1161 // expected-error@-1 {{function template specialization 'f' ambiguously refers to more than one function template; explicitly specify additional template arguments to identify a particular function template}}
1162 // expected-note@#cwg285-f-int-T {{function template 'cwg285::f<int>' matches specialization [with T = int]}}
1163 // expected-note@#cwg285-f-T-int {{function template 'cwg285::f<int>' matches specialization [with T = int]}}
1166 namespace cwg286 { // cwg286: 2.8
1167 template<class T> struct A {
1168 class C {
1169 template<class T2> struct B {}; // #cwg286-B
1173 template<class T>
1174 template<class T2>
1175 struct A<T>::C::B<T2*> { };
1177 A<short>::C::B<int*> absip;
1178 // expected-error@-1 {{'B' is a private member of 'cwg286::A<short>::C'}}
1179 // expected-note@#cwg286-B {{implicitly declared private here}}
1182 // cwg288: na
1184 namespace cwg289 { // cwg289: yes
1185 struct A; // #cwg289-A
1186 struct B : A {};
1187 // expected-error@-1 {{base class has incomplete type}}
1188 // expected-note@#cwg289-A {{forward declaration of 'cwg289::A'}}
1190 template<typename T> struct C { typename T::error error; };
1191 // expected-error@-1 {{type 'int' cannot be used prior to '::' because it has no members}}
1192 // expected-note@#cwg289-C-int {{in instantiation of template class 'cwg289::C<int>' requested here}}
1193 struct D : C<int> {}; // #cwg289-C-int
1196 // cwg290: na
1197 // cwg291: dup 391
1198 // cwg292 is in cwg292.cpp
1200 namespace cwg294 { // cwg294: no
1201 void f() throw(int);
1202 // since-cxx17-error@-1 {{ISO C++17 does not allow dynamic exception specifications}}
1203 // since-cxx17-note@-2 {{use 'noexcept(false)' instead}}
1204 int main() {
1205 (void)static_cast<void (*)() throw()>(f); // FIXME: ill-formed in C++14 and before
1206 // FIXME: since-cxx17-error@-1 {{static_cast from 'void (*)() throw(int)' to 'void (*)() throw()' is not allowed}}
1208 // Irony: the above is valid in C++17 and beyond, but that's exactly when
1209 // we reject it. In C++14 and before, this is ill-formed because an
1210 // exception-specification is not permitted in a type-id. In C++17, this is
1211 // valid because it's the inverse of a standard conversion sequence
1212 // containing a function pointer conversion. (Well, it's actually not valid
1213 // yet, as a static_cast is not permitted to reverse a function pointer
1214 // conversion, but that is being changed by core issue).
1215 (void)static_cast<void (*)() throw(int)>(f); // FIXME: ill-formed in C++14 and before
1216 // since-cxx17-error@-1 {{ISO C++17 does not allow dynamic exception specifications}}
1217 // since-cxx17-note@-2 {{use 'noexcept(false)' instead}}
1219 void (*p)() throw() = f;
1220 // cxx98-14-error@-1 {{target exception specification is not superset of source}}
1221 // since-cxx17-error@-2 {{cannot initialize a variable of type 'void (*)() throw()' with an lvalue of type 'void () throw(int)': different exception specifications}}
1222 void (*q)() throw(int) = f;
1223 // since-cxx17-error@-1 {{ISO C++17 does not allow dynamic exception specifications}}
1224 // since-cxx17-note@-2 {{use 'noexcept(false)' instead}}
1228 namespace cwg295 { // cwg295: 3.7
1229 typedef int f();
1230 const f g;
1231 // expected-warning@-1 {{'const' qualifier on function type 'f' (aka 'int ()') has no effect}}
1232 f &r = g;
1233 template<typename T> struct X {
1234 const T &f;
1236 X<f> x = {g};
1238 typedef int U();
1239 typedef const U U;
1240 // expected-warning@-1 {{'const' qualifier on function type 'U' (aka 'int ()') has no effect}}
1242 typedef int (*V)();
1243 typedef volatile U *V;
1244 // expected-warning@-1 {{'volatile' qualifier on function type 'U' (aka 'int ()') has no effect}}
1247 namespace cwg296 { // cwg296: yes
1248 struct A {
1249 static operator int() { return 0; }
1250 // expected-error@-1 {{conversion function must be a non-static member function}}
1254 namespace cwg298 { // cwg298: 3.1
1255 struct A {
1256 typedef int type;
1257 A();
1258 ~A();
1260 typedef A B; // #cwg298-B
1261 typedef const A C; // #cwg298-C
1263 A::type i1;
1264 B::type i2;
1265 C::type i3;
1267 struct A a;
1268 struct B b;
1269 // expected-error@-1 {{typedef 'B' cannot be referenced with the 'struct' specifier}}
1270 // expected-note@#cwg298-B {{declared here}}
1271 struct C c;
1272 // expected-error@-1 {{typedef 'C' cannot be referenced with the 'struct' specifier}}
1273 // expected-note@#cwg298-C {{declared here}}
1275 B::B() {}
1276 // expected-error@-1 {{a type specifier is required for all declarations}}
1277 B::A() {} // ok
1278 C::~C() {}
1279 // expected-error@-1 {{destructor cannot be declared using a typedef 'C' (aka 'const cwg298::A') of the class name}}
1281 typedef struct D E; // #cwg298-E
1282 struct E {};
1283 // expected-error@-1 {{definition of type 'E' conflicts with typedef of the same name}}
1284 // expected-note@#cwg298-E {{'E' declared here}}
1286 struct F {
1287 ~F();
1289 typedef const F G;
1290 G::~F() {} // ok
1293 namespace cwg299 { // cwg299: 2.8 c++11
1294 struct S {
1295 operator int();
1297 struct T {
1298 operator int(); // #cwg299-int
1299 operator unsigned short(); // #cwg299-ushort
1301 // FIXME: should this apply to c++98 mode?
1302 int *p = new int[S()];
1303 // cxx98-error@-1 {{implicit conversion from array size expression of type 'S' to integral type 'int' is a C++11 extension}}
1304 int *q = new int[T()]; // #cwg299-q
1305 // cxx98-11-error@#cwg299-q {{ambiguous conversion of array size expression of type 'T' to an integral or enumeration type}}
1306 // cxx98-11-note@#cwg299-int {{conversion to integral type 'int' declared here}}
1307 // cxx98-11-note@#cwg299-ushort {{conversion to integral type 'unsigned short' declared here}}
1308 // since-cxx14-error-re@#cwg299-q {{{{conversion from 'T' to 'unsigned (long long|long|int)' is ambiguous}}}}
1309 // since-cxx14-note@#cwg299-int {{candidate function}}
1310 // since-cxx14-note@#cwg299-ushort {{candidate function}}