DAG: Fix assuming f16 is the only 16-bit fp type in concat vector combine (#121637)
[llvm-project.git] / clang / test / CXX / drs / cwg2xx.cpp
blobf9010235b82473e5aaf392d30a26dc6cd6545a6a
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
7 // RUN: %clang_cc1 -std=c++2c %s -verify=expected,since-cxx11,since-cxx14,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors
9 // FIXME: diagnostic above is emitted only on Windows platforms
10 // PR13819 -- __SIZE_TYPE__ is incompatible.
11 typedef __SIZE_TYPE__ size_t;
12 // cxx98-error@-1 0-1 {{'long long' is a C++11 extension}}
14 #if __cplusplus == 199711L
15 #define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
16 // cxx98-error@-1 {{variadic macros are a C99 feature}}
17 #endif
19 #if __cplusplus == 199711L
20 #define __enable_constant_folding(x) (__builtin_constant_p(x) ? (x) : (x))
21 #else
22 #define __enable_constant_folding
23 #endif
25 namespace cwg200 { // cwg200: dup 214
26 template <class T> T f(int);
27 template <class T, class U> T f(U) = delete;
28 // cxx98-error@-1 {{deleted function definitions are a C++11 extension}}
30 void g() {
31 f<int>(1);
33 } // namespace cwg200
35 // cwg201 is in cwg201.cpp
37 namespace cwg202 { // cwg202: 3.1
38 template<typename T> T f();
39 template<int (*g)()> struct X {
40 static_assert(__enable_constant_folding(g == &f<int>), "");
42 template struct X<f>;
43 } // namespace cwg202
45 // cwg204: sup 820
47 namespace cwg206 { // cwg206: yes
48 struct S; // #cwg206-S
49 template<typename T> struct Q { S s; };
50 // expected-error@-1 {{field has incomplete type 'S'}}
51 // expected-note@#cwg206-S {{forward declaration of 'cwg206::S'}}
52 template<typename T> void f() { S s; }
53 // expected-error@-1 {{variable has incomplete type 'S'}}
54 // expected-note@#cwg206-S {{forward declaration of 'cwg206::S'}}
55 } // namespace cwg206
57 namespace cwg207 { // cwg207: yes
58 class A {
59 protected:
60 static void f() {}
62 class B : A {
63 public:
64 using A::f;
65 void g() {
66 A::f();
67 f();
70 } // namespace cwg207
72 // cwg208 FIXME: write codegen test
74 namespace cwg209 { // cwg209: 3.2
75 class A {
76 void f(); // #cwg209-A-f
78 class B {
79 friend void A::f();
80 // expected-error@-1 {{friend function 'f' is a private member of 'cwg209::A'}}
81 // expected-note@#cwg209-A-f {{implicitly declared private here}}
83 } // namespace cwg209
85 // cwg210 is in cwg210.cpp
87 namespace cwg211 { // cwg211: yes
88 struct A {
89 A() try {
90 throw 0;
91 } catch (...) {
92 return;
93 // expected-error@-1 {{return in the catch of a function try block of a constructor is illegal}}
96 } // namespace cwg211
98 namespace cwg213 { // cwg213: yes
99 template <class T> struct A : T {
100 void h(T t) {
101 char &r1 = f(t);
102 int &r2 = g(t);
103 // expected-error@-1 {{explicit qualification required to use member 'g' from dependent base class}}
104 // expected-note@#cwg213-instantiation {{in instantiation of member function 'cwg213::A<cwg213::B>::h' requested here}}
105 // expected-note@#cwg213-B-g {{member is declared here}}
108 struct B {
109 int &f(B);
110 int &g(B); // #cwg213-B-g
112 char &f(B);
114 template void A<B>::h(B); // #cwg213-instantiation
115 } // namespace cwg213
117 namespace cwg214 { // cwg214: yes
118 template<typename T, typename U> T checked_cast(U from) { U::error; }
119 template<typename T, typename U> T checked_cast(U *from);
120 class C {};
121 void foo(int *arg) { checked_cast<const C *>(arg); }
123 template<typename T> T f(int);
124 template<typename T, typename U> T f(U) { T::error; }
125 void g() {
126 f<int>(1);
128 } // namespace cwg214
130 namespace cwg215 { // cwg215: 2.9
131 template<typename T> class X {
132 friend void T::foo();
133 int n;
135 struct Y {
136 void foo() { (void)+X<Y>().n; }
138 } // namespace cwg215
140 namespace cwg216 { // cwg216: no
141 // FIXME: Should reject this: 'f' has linkage but its type does not,
142 // and 'f' is odr-used but not defined in this TU.
143 typedef enum { e } *E;
144 void f(E);
145 void g(E e) { f(e); }
147 struct S {
148 // FIXME: Should reject this: 'f' has linkage but its type does not,
149 // and 'f' is odr-used but not defined in this TU.
150 typedef enum { e } *E;
151 void f(E);
153 void g(S s, S::E e) { s.f(e); }
154 } // namespace cwg216
156 namespace cwg217 { // cwg217: yes
157 template<typename T> struct S {
158 void f(int);
160 template<typename T> void S<T>::f(int = 0) {}
161 // expected-error@-1 {{default arguments cannot be added to an out-of-line definition of a member of a class template}}
162 } // namespace cwg217
164 namespace cwg218 { // cwg218: yes
165 // NB: also dup 405
166 namespace A {
167 struct S {};
168 void f(S);
170 namespace B {
171 struct S {};
172 void f(S);
175 struct C {
176 int f;
177 void test1(A::S as) { f(as); }
178 // expected-error@-1 {{called object type 'int' is not a function or function pointer}}
179 void test2(A::S as) { void f(); f(as); }
180 // expected-error@-1 {{too many arguments to function call, expected 0, have 1}}
181 // expected-note@-2 {{'f' declared here}}
182 void test3(A::S as) { using A::f; f(as); } // ok
183 void test4(A::S as) { using B::f; f(as); } // ok
184 void test5(A::S as) { int f; f(as); }
185 // expected-error@-1 {{called object type 'int' is not a function or function pointer}}
186 void test6(A::S as) { struct f {}; (void) f(as); }
187 // expected-error@-1 {{no matching conversion for functional-style cast from 'A::S' to 'f'}}
188 // expected-note@-2 {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'A::S' to 'const f' for 1st argument}}
189 // since-cxx11-note@-3 {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'A::S' to 'f' for 1st argument}}
190 // expected-note@-4 {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
193 namespace D {
194 struct S {};
195 struct X { void operator()(S); } f;
197 void testD(D::S ds) { f(ds); }
198 // expected-error@-1 {{use of undeclared identifier 'f'}}
200 namespace E {
201 struct S {};
202 struct f { f(S); };
204 void testE(E::S es) { f(es); }
205 // expected-error@-1 {{use of undeclared identifier 'f'}}
207 namespace F {
208 struct S {
209 template<typename T> friend void f(S, T) {}
212 void testF(F::S fs) { f(fs, 0); }
214 namespace G {
215 namespace X {
216 int f;
217 struct A {};
219 namespace Y {
220 template<typename T> void f(T);
221 struct B {};
223 template<typename A, typename B> struct C {};
225 void testG(G::C<G::X::A, G::Y::B> gc) { f(gc); }
226 } // namespace cwg218
228 // cwg219: na
229 // cwg220: na
231 namespace cwg221 { // cwg221: 3.6
232 struct A { // #cwg221-S
233 A &operator=(int&); // #cwg221-S-copy-assign
234 A &operator+=(int&);
235 static A &operator=(A&, double&);
236 // expected-error@-1 {{overloaded 'operator=' cannot be a static member function}}
237 static A &operator+=(A&, double&);
238 // expected-error@-1 {{overloaded 'operator+=' cannot be a static member function}}
239 friend A &operator=(A&, char&);
240 // expected-error@-1 {{overloaded 'operator=' must be a non-static member function}}
241 friend A &operator+=(A&, char&);
243 A &operator=(A&, float&);
244 // expected-error@-1 {{overloaded 'operator=' must be a non-static member function}}
245 A &operator+=(A&, float&);
247 void test(A a, int n, char c, float f) {
248 a = n;
249 a += n;
250 a = c;
251 // expected-error@-1 {{no viable overloaded '='}}
252 // expected-note@#cwg221-S-copy-assign {{candidate function not viable: no known conversion from 'char' to 'int &' for 1st argument}}
253 // since-cxx11-note@#cwg221-S {{candidate function (the implicit move assignment operator) not viable: no known conversion from 'char' to 'A' for 1st argument}}
254 // expected-note@#cwg221-S {{candidate function (the implicit copy assignment operator) not viable: no known conversion from 'char' to 'const A' for 1st argument}}
255 a += c;
256 a = f;
257 // expected-error@-1 {{no viable overloaded '='}}
258 // expected-note@#cwg221-S-copy-assign {{candidate function not viable: no known conversion from 'float' to 'int &' for 1st argument}}
259 // since-cxx11-note@#cwg221-S {{candidate function (the implicit move assignment operator) not viable: no known conversion from 'float' to 'A' for 1st argument}}
260 // expected-note@#cwg221-S {{candidate function (the implicit copy assignment operator) not viable: no known conversion from 'float' to 'const A' for 1st argument}}
261 a += f;
263 } // namespace cwg221
265 namespace cwg222 { // cwg222: dup 637
266 void f(int a, int b, int c, int *x) {
267 #pragma clang diagnostic push
268 #pragma clang diagnostic warning "-Wunsequenced"
269 void((a += b) += c);
270 void((a += b) + (a += c));
271 // expected-warning@-1 {{multiple unsequenced modifications to 'a'}}
273 x[a++] = a;
274 // cxx98-14-warning@-1 {{unsequenced modification and access to 'a'}}
276 a = b = 0; // ok, read and write of 'b' are sequenced
278 a = (b = a++);
279 // cxx98-14-warning@-1 {{multiple unsequenced modifications to 'a'}}
280 a = (b = ++a);
281 #pragma clang diagnostic pop
283 } // namespace cwg222
285 // cwg223: na
287 namespace cwg224 { // cwg224: 16
288 namespace example1 {
289 template <class T> class A {
290 typedef int type;
291 A::type a;
292 A<T>::type b;
293 A<T*>::type c;
294 // cxx98-17-error@-1 {{missing 'typename' prior to dependent type name A<T *>::type; implicit 'typename' is a C++20 extension}}
295 ::cwg224::example1::A<T>::type d;
297 class B {
298 typedef int type;
300 A::type a;
301 A<T>::type b;
302 A<T*>::type c;
303 // cxx98-17-error@-1 {{missing 'typename' prior to dependent type name A<T *>::type; implicit 'typename' is a C++20 extension}}
304 ::cwg224::example1::A<T>::type d;
306 B::type e;
307 A<T>::B::type f;
308 A<T*>::B::type g;
309 // cxx98-17-error@-1 {{missing 'typename' prior to dependent type name A<T *>::B::type; implicit 'typename' is a C++20 extension}}
310 typename A<T*>::B::type h;
314 template <class T> class A<T*> {
315 typedef int type;
316 A<T*>::type a;
317 A<T>::type b;
318 // cxx98-17-error@-1 {{missing 'typename' prior to dependent type name A<T>::type; implicit 'typename' is a C++20 extension}}
321 template <class T1, class T2, int I> struct B {
322 typedef int type;
323 B<T1, T2, I>::type b1;
324 B<T2, T1, I>::type b2;
325 // cxx98-17-error@-1 {{missing 'typename' prior to dependent type name B<T2, T1, I>::type; implicit 'typename' is a C++20 extension}}
327 typedef T1 my_T1;
328 static const int my_I = I;
329 static const int my_I2 = I+0;
330 static const int my_I3 = my_I;
331 B<my_T1, T2, my_I>::type b3;
332 // 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}}
333 B<my_T1, T2, my_I2>::type b4;
334 // 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}}
335 B<my_T1, T2, my_I3>::type b5;
336 // 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}}
340 namespace example2 {
341 template <int, typename T> struct X { typedef T type; };
342 template <class T> class A {
343 static const int i = 5;
344 X<i, int>::type w;
345 X<A::i, char>::type x;
346 X<A<T>::i, double>::type y;
347 X<A<T*>::i, long>::type z;
348 // cxx98-17-error@-1 {{missing 'typename' prior to dependent type name X<A<T *>::i, long>::type; implicit 'typename' is a C++20 extension}}
349 int f();
351 template <class T> int A<T>::f() {
352 return i;
355 } // namespace cwg224
357 // cwg225: yes
358 template<typename T> void cwg225_f(T t) { cwg225_g(t); }
359 // expected-error@-1 {{call to function 'cwg225_g' that is neither visible in the template definition nor found by argument-dependent lookup}}
360 // expected-note@#cwg225-f {{in instantiation of function template specialization 'cwg225_f<int>' requested here}}
361 // expected-note@#cwg225-g {{'cwg225_g' should be declared prior to the call site}}
362 void cwg225_g(int); // #cwg225-g
363 template void cwg225_f(int); // #cwg225-f
365 namespace cwg226 { // cwg226: no
366 // FIXME: This appears to be wrong: default arguments for function templates
367 // are listed as a defect (in c++98) not an extension. EDG accepts them in
368 // strict c++98 mode.
369 template<typename T = void> void f() {}
370 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
371 template<typename T> struct S {
372 template<typename U = void> void g();
373 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
374 template<typename U> struct X;
375 template<typename U> void h();
377 template<typename T> template<typename U> void S<T>::g() {}
378 template<typename T> template<typename U = void> struct S<T>::X {};
379 // expected-error@-1 {{cannot add a default template argument to the definition of a member of a class template}}
380 template<typename T> template<typename U = void> void S<T>::h() {}
381 // expected-error@-1 {{cannot add a default template argument to the definition of a member of a class template}}
383 template<typename> void friend_h();
384 struct A {
385 // FIXME: This is ill-formed.
386 template<typename=void> struct friend_B;
387 // FIXME: f, h, and i are ill-formed.
388 // f is ill-formed because it is not a definition.
389 // h and i are ill-formed because they are not the only declarations of the
390 // function in the translation unit.
391 template<typename=void> void friend_f();
392 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
393 template<typename=void> void friend_g() {}
394 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
395 template<typename=void> void friend_h() {}
396 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
397 template<typename=void> void friend_i() {}
398 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
400 template<typename> void friend_i();
402 template<typename=void, typename X> void foo(X) {}
403 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
404 template<typename=void, typename X> struct Foo {};
405 // expected-error@-1 {{template parameter missing a default argument}}
406 // expected-note@-2 {{previous default template argument defined here}}
408 template<typename=void, typename X, typename, typename Y> int foo(X, Y);
409 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
410 template<typename, typename X, typename=void, typename Y> int foo(X, Y);
411 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
412 int x = foo(0, 0);
413 } // namespace cwg226
415 void cwg227(bool b) { // cwg227: yes
416 if (b)
417 int n;
418 else
419 int n;
422 namespace cwg228 { // cwg228: yes
423 template <class T> struct X {
424 void f();
426 template <class T> struct Y {
427 void g(X<T> x) { x.template X<T>::f(); }
429 } // namespace cwg228
431 namespace cwg229 { // cwg229: 2.9
432 template<typename T> void f();
433 template<typename T> void f<T*>() {}
434 // expected-error@-1 {{function template partial specialization is not allowed}}
435 template<> void f<int>() {}
436 } // namespace cwg229
438 namespace cwg230 { // cwg230: 3.0
439 struct S {
440 S() { f(); }
441 // 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'}}
442 // expected-note@#cwg230-f {{'f' declared here}}
443 virtual void f() = 0; // #cwg230-f
445 } // namespace cwg230
447 namespace cwg231 { // cwg231: yes
448 namespace outer {
449 namespace inner {
450 int i; // #cwg231-i
452 void f() { using namespace inner; }
453 int j = i;
454 // expected-error@-1 {{use of undeclared identifier 'i'; did you mean 'inner::i'?}}
455 // expected-note@#cwg231-i {{'inner::i' declared here}}
457 } // namespace cwg231
459 // cwg234: na
460 // cwg235: na
462 namespace cwg236 { // cwg236: 3.2
463 void *p = int();
464 // cxx98-warning@-1 {{expression which evaluates to zero treated as a null pointer constant of type 'void *'}}
465 // since-cxx11-error@-2 {{cannot initialize a variable of type 'void *' with an rvalue of type 'int'}}
466 } // namespace cwg236
468 namespace cwg237 { // cwg237: dup 470
469 template<typename T> struct A { void f() { T::error; } };
470 template<typename T> struct B : A<T> {};
471 template struct B<int>; // ok
472 } // namespace cwg237
474 namespace cwg239 { // cwg239: yes
475 namespace NS {
476 class T {};
477 void f(T);
478 float &g(T, int);
480 NS::T parm;
481 int &g(NS::T, float);
482 int main() {
483 f(parm);
484 float &r = g(parm, 1);
485 extern int &g(NS::T, float);
486 int &s = g(parm, 1);
488 } // namespace cwg239
490 // cwg240: dup 616
492 namespace cwg241 { // cwg241: yes
493 namespace A {
494 struct B {};
495 template <int X> void f(); // #cwg241-A-f
496 template <int X> void g(B);
498 namespace C {
499 template <class T> void f(T t); // #cwg241-C-f
500 template <class T> void g(T t); // #cwg241-C-g
502 void h(A::B b) {
503 f<3>(b);
504 // expected-error@-1 {{no matching function for call to 'f'}}
505 // expected-note@#cwg241-A-f {{candidate function template not viable: requires 0 arguments, but 1 was provided}}
506 // 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}}
507 g<3>(b);
508 // 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}}
509 A::f<3>(b);
510 // expected-error@-1 {{no matching function for call to 'f'}}
511 // expected-note@#cwg241-A-f {{candidate function template not viable: requires 0 arguments, but 1 was provided}}
512 A::g<3>(b);
513 C::f<3>(b);
514 // expected-error@-1 {{no matching function for call to 'f'}}
515 // expected-note@#cwg241-C-f {{candidate template ignored: invalid explicitly-specified argument for template parameter 'T'}}
516 C::g<3>(b);
517 // expected-error@-1 {{no matching function for call to 'g'}}
518 // expected-note@#cwg241-C-g {{candidate template ignored: invalid explicitly-specified argument for template parameter 'T'}}
519 using C::f;
520 using C::g;
521 f<3>(b);
522 // expected-error@-1 {{no matching function for call to 'f'}}
523 // expected-note@#cwg241-C-f {{candidate template ignored: invalid explicitly-specified argument for template parameter 'T'}}
524 // expected-note@#cwg241-A-f {{candidate function template not viable: requires 0 arguments, but 1 was provided}}
525 g<3>(b);
527 } // namespace cwg241
529 namespace cwg243 { // cwg243: yes
530 struct B;
531 struct A {
532 A(B); // #cwg243-A
534 struct B {
535 operator A() = delete; // #cwg243-B
536 // cxx98-error@-1 {{deleted function definitions are a C++11 extension}}
537 } b;
538 A a1(b);
539 A a2 = b;
540 // expected-error@-1 {{conversion from 'struct B' to 'A' is ambiguous}}
541 // expected-note@#cwg243-A {{candidate constructor}}
542 // expected-note@#cwg243-B {{candidate function has been explicitly deleted}}
543 } // namespace cwg243
545 namespace cwg244 { // cwg244: 11
546 // NB: this test is reused by cwg399
547 struct B {}; // #cwg244-B
548 struct D : B {};
550 D D_object;
551 typedef B B_alias;
552 B* B_ptr = &D_object;
554 void f() {
555 D_object.~B();
556 // expected-error@-1 {{destructor type 'cwg244::B' in object destruction expression does not match the type 'D' of the object being destroyed}}
557 // expected-note@#cwg244-B {{type 'cwg244::B' found by destructor name lookup}}
558 D_object.B::~B();
559 D_object.D::~B(); // FIXME: Missing diagnostic for this.
560 B_ptr->~B();
561 B_ptr->~B_alias();
562 B_ptr->B_alias::~B();
563 B_ptr->B_alias::~B_alias();
564 B_ptr->cwg244::~B();
565 // expected-error@-1 {{no member named '~B' in namespace 'cwg244'}}
566 B_ptr->cwg244::~B_alias();
567 // expected-error@-1 {{no member named '~B' in namespace 'cwg244'}}
570 template<typename T, typename U>
571 void f(T *B_ptr, U D_object) {
572 D_object.~B(); // FIXME: Missing diagnostic for this.
573 D_object.B::~B();
574 D_object.D::~B(); // FIXME: Missing diagnostic for this.
575 B_ptr->~B();
576 B_ptr->~B_alias();
577 B_ptr->B_alias::~B();
578 B_ptr->B_alias::~B_alias();
579 B_ptr->cwg244::~B();
580 // expected-error@-1 {{'cwg244' does not refer to a type name in pseudo-destructor expression; expected the name of type 'T'}}
581 B_ptr->cwg244::~B_alias();
582 // expected-error@-1 {{'cwg244' does not refer to a type name in pseudo-destructor expression; expected the name of type 'T'}}
584 template void f<B, D>(B*, D);
586 namespace N {
587 template<typename T> struct E {};
588 typedef E<int> F;
590 void g(N::F f) {
591 typedef N::F G; // #cwg244-G
592 f.~G();
593 f.G::~E();
594 // expected-error@-1 {{ISO C++ requires the name after '::~' to be found in the same scope as the name before '::~'}}
595 f.G::~F();
596 // expected-error@-1 {{undeclared identifier 'F' in destructor name}}
597 f.G::~G();
598 // This is technically ill-formed; E is looked up in 'N::' and names the
599 // class template, not the injected-class-name of the class. But that's
600 // probably a bug in the standard.
601 f.N::F::~E();
602 // expected-error@-1 {{ISO C++ requires the name after '::~' to be found in the same scope as the name before '::~'}}
603 // This is valid; we look up the second F in the same scope in which we
604 // found the first one, that is, 'N::'.
605 f.N::F::~F();
606 // This is technically ill-formed; G is looked up in 'N::' and is not found.
607 // Rejecting this seems correct, but most compilers accept, so we do also.
608 f.N::F::~G();
609 // expected-error@-1 {{qualified destructor name only found in lexical scope; omit the qualifier to find this type name by unqualified lookup}}
610 // expected-note@#cwg244-G {{type 'G' (aka 'E<int>') found by destructor name lookup}}
613 // Bizarrely, compilers perform lookup in the scope for qualified destructor
614 // names, if the nested-name-specifier is non-dependent. Ensure we diagnose
615 // this.
616 namespace QualifiedLookupInScope {
617 namespace N {
618 template <typename> struct S { struct Inner {}; };
620 template <typename U> void f(typename N::S<U>::Inner *p) {
621 typedef typename N::S<U>::Inner T;
622 p->::cwg244::QualifiedLookupInScope::N::S<U>::Inner::~T();
623 // expected-error@-1 {{no type named 'T' in 'cwg244::QualifiedLookupInScope::N::S<int>'}}
624 // expected-note@#cwg244-f {{in instantiation of function template specialization 'cwg244::QualifiedLookupInScope::f<int>' requested here}}
626 template void f<int>(N::S<int>::Inner *); // #cwg244-f
628 template <typename U> void g(U *p) {
629 typedef U T;
630 p->T::~T();
631 p->U::~T();
632 p->::cwg244::QualifiedLookupInScope::N::S<int>::Inner::~T();
633 // expected-error@-1 {{'T' does not refer to a type name in pseudo-destructor expression; expected the name of type 'U'}}
635 template void g(N::S<int>::Inner *);
637 } // namespace cwg244
639 namespace cwg245 { // cwg245: yes
640 struct S {
641 enum E {}; // #cwg245-E
642 class E *p;
643 // expected-error@-1 {{use of 'E' with tag type that does not match previous declaration}}
644 // expected-note@#cwg245-E {{previous use is here}}
646 } // namespace cwg245
648 namespace cwg246 { // cwg246: 3.2
649 struct S {
650 S() try { // #cwg246-try
651 throw 0;
652 X: ;
653 } catch (int) {
654 goto X;
655 // expected-error@-1 {{cannot jump from this goto statement to its label}}
656 // expected-note@#cwg246-try {{jump bypasses initialization of try block}}
659 } // namespace cwg246
661 namespace cwg247 { // cwg247: yes
662 struct A {};
663 struct B : A {
664 void f();
665 void f(int);
667 void (A::*f)() = (void (A::*)())&B::f;
669 struct C {
670 void f();
671 void f(int);
673 struct D : C {};
674 void (C::*g)() = &D::f;
675 void (D::*h)() = &D::f;
677 struct E {
678 void f();
680 struct F : E {
681 using E::f;
682 void f(int);
684 void (F::*i)() = &F::f;
685 } // namespace cwg247
687 namespace cwg248 { // cwg248: sup P1949
688 int \u040d\u040e = 0;
689 } // namespace cwg248
691 namespace cwg249 { // cwg249: yes
692 template<typename T> struct X { void f(); };
693 template<typename T> void X<T>::f() {}
694 } // namespace cwg249
696 namespace cwg250 { // cwg250: yes
697 typedef void (*FPtr)(double x[]);
699 template<int I> void f(double x[]);
700 FPtr fp = &f<3>;
702 template<int I = 3> void g(double x[]);
703 // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
704 FPtr gp = &g<>;
705 } // namespace cwg250
707 namespace cwg252 { // cwg252: 3.1
708 struct A {
709 void operator delete(void*); // #cwg252-A
711 struct B {
712 void operator delete(void*); // #cwg252-B
714 struct C : A, B {
715 virtual ~C();
717 C::~C() {}
718 // expected-error@-1 {{member 'operator delete' found in multiple base classes of different types}}
719 // expected-note@#cwg252-A {{member found by ambiguous name lookup}}
720 // expected-note@#cwg252-B {{member found by ambiguous name lookup}}
722 struct D {
723 void operator delete(void*, int); // #cwg252-D
724 virtual ~D();
726 D::~D() {}
727 // expected-error@-1 {{no suitable member 'operator delete' in 'D'}}
728 // expected-note@#cwg252-D {{member 'operator delete' declared here}}
730 struct E {
731 void operator delete(void*, int);
732 void operator delete(void*) = delete; // #cwg252-E
733 // cxx98-error@-1 {{deleted function definitions are a C++11 extension}}
734 virtual ~E();
736 E::~E() {}
737 // expected-error@-1 {{attempt to use a deleted function}}
738 // expected-note@#cwg252-E {{'operator delete' has been explicitly marked deleted here}}
740 struct F {
741 // If both functions are available, the first one is a placement delete.
742 void operator delete(void*, size_t);
743 void operator delete(void*) = delete; // #cwg252-F
744 // cxx98-error@-1 {{deleted function definitions are a C++11 extension}}
745 virtual ~F();
747 F::~F() {}
748 // expected-error@-1 {{attempt to use a deleted function}}
749 // expected-note@#cwg252-F {{'operator delete' has been explicitly marked deleted here}}
751 struct G {
752 void operator delete(void*, size_t);
753 virtual ~G();
755 G::~G() {}
756 } // namespace cwg252
758 namespace cwg254 { // cwg254: 2.9
759 template<typename T> struct A {
760 typedef typename T::type type; // ok even if this is a typedef-name, because
761 // it's not an elaborated-type-specifier
762 typedef struct T::type foo;
763 // expected-error@-1 {{typedef 'type' cannot be referenced with the 'struct' specifier}}
764 // expected-note@#cwg254-instantiation {{in instantiation of template class 'cwg254::A<cwg254::C>' requested here}}
765 // expected-note@#cwg254-C {{declared here}}
767 struct B { struct type {}; };
768 struct C { typedef struct {} type; }; // #cwg254-C
769 A<B>::type n;
770 A<C>::type n; // #cwg254-instantiation
771 } // namespace cwg254
773 namespace cwg255 { // cwg255: yes
774 struct S {
775 void operator delete(void *){};
776 void operator delete(void *, int){};
778 void f(S *p) { delete p; }
779 } // namespace cwg255
781 // cwg256: dup 624
783 namespace cwg257 { // cwg257: 3.4
784 struct A { A(int); }; // #cwg257-A
785 struct B : virtual A {
786 B() {}
787 virtual void f() = 0;
789 struct C : B {
790 C() {}
792 struct D : B {
793 D() {}
794 // expected-error@-1 {{constructor for 'cwg257::D' must explicitly initialize the base class 'A' which does not have a default constructor}}
795 // expected-note@#cwg257-A {{'cwg257::A' declared here}}
796 void f();
798 } // namespace cwg257
800 namespace cwg258 { // cwg258: 2.8
801 struct A {
802 void f(const int);
803 template<typename> void g(int);
804 float &h() const;
806 struct B : A {
807 using A::f;
808 using A::g;
809 using A::h;
810 int &f(int);
811 template<int> int &g(int); // #cwg258-B-g
812 int &h();
813 } b;
814 int &w = b.f(0);
815 int &x = b.g<int>(0);
816 // expected-error@-1 {{no matching member function for call to 'g'}}
817 // expected-note@#cwg258-B-g {{candidate template ignored: invalid explicitly-specified argument for 1st template parameter}}
818 int &y = b.h();
819 float &z = const_cast<const B&>(b).h();
821 struct C {
822 virtual void f(const int) = 0;
824 struct D : C {
825 void f(int);
826 } d;
828 struct E {
829 virtual void f() = 0; // #cwg258-E-f
831 struct F : E {
832 void f() const {}
833 } f;
834 // expected-error@-1 {{variable type 'struct F' is an abstract class}}
835 // expected-note@#cwg258-E-f {{unimplemented pure virtual method 'f' in 'F'}}
836 } // namespace cwg258
838 namespace cwg259 { // cwg259: 4
839 template<typename T> struct A {};
840 template struct A<int>; // #cwg259-A-int
841 template struct A<int>;
842 // expected-error@-1 {{duplicate explicit instantiation of 'A<int>'}}
843 // expected-note@#cwg259-A-int {{previous explicit instantiation is here}}
845 template<> struct A<float>; // #cwg259-A-float
846 template struct A<float>;
847 // expected-warning@-1 {{explicit instantiation of 'A<float>' that occurs after an explicit specialization has no effect}}
848 // expected-note@#cwg259-A-float {{previous template specialization is here}}
850 template struct A<char>; // #cwg259-A-char
851 template<> struct A<char>;
852 // expected-error@-1 {{explicit specialization of 'cwg259::A<char>' after instantiation}}
853 // expected-note@#cwg259-A-char {{explicit instantiation first required here}}
855 template<> struct A<double>;
856 template<> struct A<double>;
857 template<> struct A<double> {}; // #cwg259-A-double
858 template<> struct A<double> {};
859 // expected-error@-1 {{redefinition of 'A<double>'}}
860 // expected-note@#cwg259-A-double {{previous definition is here}}
862 template<typename T> struct B; // #cwg259-B
863 template struct B<int>;
864 // expected-error@-1 {{explicit instantiation of undefined template 'cwg259::B<int>'}}
865 // expected-note@#cwg259-B {{template is declared here}}
867 template<> struct B<float>; // #cwg259-B-float
868 template struct B<float>;
869 // expected-warning@-1 {{explicit instantiation of 'B<float>' that occurs after an explicit specialization has no effect}}
870 // expected-note@#cwg259-B-float {{previous template specialization is here}}
871 } // namespace cwg259
873 // FIXME: When cwg260 is resolved, also add tests for CWG507.
875 namespace cwg261 { // cwg261: no
876 #pragma clang diagnostic push
877 #pragma clang diagnostic warning "-Wused-but-marked-unused"
879 // FIXME: This is ill-formed, with a diagnostic required, because operator new
880 // and operator delete are inline and odr-used, but not defined in this
881 // translation unit.
882 // We're also missing the -Wused-but-marked-unused diagnostic here.
883 struct A {
884 inline void *operator new(size_t) __attribute__((unused));
885 inline void operator delete(void*) __attribute__((unused));
886 A() {}
889 // FIXME: This is ill-formed, with a required diagnostic, for the same
890 // reason.
891 struct B {
892 inline void operator delete(void*) __attribute__((unused));
893 ~B() {}
895 struct C {
896 inline void operator delete(void*) __attribute__((unused));
897 virtual ~C() {}
898 // expected-warning@-1 {{'operator delete' was marked unused but was used}}
901 struct D {
902 inline void operator delete(void*) __attribute__((unused));
904 void h() { C::operator delete(0); }
905 // expected-warning@-1 {{'operator delete' was marked unused but was used}}
907 #pragma clang diagnostic pop
908 } // namespace cwg261
910 namespace cwg262 { // cwg262: yes
911 int f(int = 0, ...);
912 int k = f();
913 int l = f(0);
914 int m = f(0, 0);
915 } // namespace cwg262
917 namespace cwg263 { // cwg263: 3.3
918 struct X {};
919 struct Y {
920 #if __cplusplus < 201103L
921 friend X::X() throw();
922 friend X::~X() throw();
923 #elif __cplusplus <= 201703L
924 friend constexpr X::X() noexcept;
925 friend X::~X();
926 #else
927 friend constexpr X::X() noexcept;
928 friend constexpr X::~X();
929 #endif
930 Y::Y();
931 // expected-error@-1 {{extra qualification on member 'Y'}}
932 Y::~Y();
933 // expected-error@-1 {{extra qualification on member '~Y'}}
935 } // namespace cwg263
937 // cwg265: dup 353
938 // cwg266: na
939 // cwg269: na
940 // cwg270: na
942 namespace cwg272 { // cwg272: yes
943 struct X {
944 void f() {
945 this->~X();
946 X::~X();
947 ~X();
948 // expected-error@-1 {{invalid argument type 'X' to unary expression}}
951 } // namespace cwg272
953 #include <stdarg.h>
954 #include <stddef.h>
955 namespace cwg273 { // cwg273: yes
956 struct A {
957 int n;
959 void operator&(A);
960 void f(A a, ...) {
961 offsetof(A, n);
962 va_list val;
963 va_start(val, a);
964 va_end(val);
966 } // namespace cwg273
968 // cwg274: na
970 namespace cwg275 { // cwg275: no
971 namespace N {
972 template <class T> void f(T) {} // #cwg275-N-f
973 template <class T> void g(T) {} // #cwg275-N-g
974 template <> void f(int);
975 template <> void f(char);
976 template <> void f(double);
977 template <> void g(char);
980 using namespace N;
982 namespace M {
983 template <> void N::f(char) {}
984 // expected-error@-1 {{cannot define or redeclare 'f' here because namespace 'M' does not enclose namespace 'N'}}
985 template <class T> void g(T) {}
986 template <> void g(char) {}
987 // FIXME: this should be rejected in c++98 too
988 template void f(long);
989 // since-cxx11-error@-1 {{explicit instantiation of 'cwg275::N::f' must occur in namespace 'N'}}
990 // since-cxx11-note@#cwg275-N-f {{explicit instantiation refers here}}
991 // FIXME: this should be rejected in c++98 too
992 template void N::f(unsigned long);
993 // since-cxx11-error@-1 {{explicit instantiation of 'f' not in a namespace enclosing 'N'}}
994 // since-cxx11-note@#cwg275-N-f {{explicit instantiation refers here}}
995 template void h(long);
996 // expected-error@-1 {{explicit instantiation of 'h' does not refer to a function template, variable template, member function, member class, or static data member}}
997 template <> void f(double) {}
998 // expected-error@-1 {{no function template matches function template specialization 'f'}}
1001 template <class T> void g(T) {} // #cwg275-g
1003 template <> void N::f(char) {}
1004 template <> void f(int) {}
1005 // expected-error@-1 {{no function template matches function template specialization 'f'}}
1007 // FIXME: this should be rejected in c++98 too
1008 template void f(short);
1009 // since-cxx11-error@-1 {{explicit instantiation of 'cwg275::N::f' must occur in namespace 'N'}}
1010 // since-cxx11-note@#cwg275-N-f {{explicit instantiation refers here}}
1011 template void N::f(unsigned short);
1013 // FIXME: this should probably be valid. the wording from the issue
1014 // doesn't clarify this, but it follows from the usual rules.
1015 template void g(int);
1016 // expected-error@-1 {{partial ordering for explicit instantiation of 'g' is ambiguous}}
1017 // expected-note@#cwg275-g {{explicit instantiation candidate function 'cwg275::g<int>' template here [with T = int]}}
1018 // expected-note@#cwg275-N-g {{explicit instantiation candidate function 'cwg275::N::g<int>' template here [with T = int]}}
1020 // FIXME: likewise, this should also be valid.
1021 template<typename T> void f(T) {} // #cwg275-f
1022 template void f(short);
1023 // expected-error@-1 {{partial ordering for explicit instantiation of 'f' is ambiguous}}
1024 // expected-note@#cwg275-f {{explicit instantiation candidate function 'cwg275::f<short>' template here [with T = short]}}
1025 // expected-note@#cwg275-N-f {{explicit instantiation candidate function 'cwg275::N::f<short>' template here [with T = short]}}
1026 } // namespace cwg275
1028 // cwg276: na
1030 namespace cwg277 { // cwg277: 3.1
1031 typedef int *intp;
1032 int *p = intp();
1033 static_assert(__enable_constant_folding(!intp()), "");
1034 } // namespace cwg277
1036 // cwg279 is in cwg279.cpp
1038 namespace cwg280 { // cwg280: 2.9
1039 typedef void f0();
1040 typedef void f1(int);
1041 typedef void f2(int, int);
1042 typedef void f3(int, int, int);
1043 struct A {
1044 operator f1*(); // #cwg280-A-f1
1045 operator f2*();
1047 struct B {
1048 operator f0*(); // #cwg280-B-f0
1049 private:
1050 operator f3*(); // #cwg280-B-f3
1052 struct C {
1053 operator f0*(); // #cwg280-C-f0
1054 operator f1*(); // #cwg280-C-f1
1055 operator f2*(); // #cwg280-C-f2
1056 operator f3*(); // #cwg280-C-f3
1058 struct D : private A, B { // #cwg280-D
1059 operator f2*(); // #cwg280-D-f2
1060 } d;
1061 struct E : C, D {} e;
1062 void g() {
1063 d(); // ok, public
1064 d(0);
1065 // expected-error@-1 {{'operator void (*)(int)' is a private member of 'cwg280::A'}}
1066 // expected-note@#cwg280-D {{constrained by private inheritance here}}
1067 // expected-note@#cwg280-A-f1 {{member is declared here}}
1068 d(0, 0); // ok, suppressed by member in D
1069 d(0, 0, 0);
1070 // expected-error@-1 {{'operator void (*)(int, int, int)' is a private member of 'cwg280::B'}}
1071 // expected-note@#cwg280-B-f3 {{declared private here}}
1072 e();
1073 // expected-error@-1 {{call to object of type 'struct E' is ambiguous}}
1074 // expected-note@#cwg280-B-f0 {{conversion candidate of type 'void (*)()'}}
1075 // expected-note@#cwg280-C-f0 {{conversion candidate of type 'void (*)()'}}
1076 e(0);
1077 // expected-error@-1 {{call to object of type 'struct E' is ambiguous}}
1078 // expected-note@#cwg280-A-f1 {{conversion candidate of type 'void (*)(int)'}}
1079 // expected-note@#cwg280-C-f1 {{conversion candidate of type 'void (*)(int)'}}
1080 e(0, 0);
1081 // expected-error@-1 {{call to object of type 'struct E' is ambiguous}}
1082 // expected-note@#cwg280-C-f2 {{conversion candidate of type 'void (*)(int, int)'}}
1083 // expected-note@#cwg280-D-f2 {{conversion candidate of type 'void (*)(int, int)'}}
1084 e(0, 0, 0);
1085 // expected-error@-1 {{call to object of type 'struct E' is ambiguous}}
1086 // expected-note@#cwg280-B-f3 {{conversion candidate of type 'void (*)(int, int, int)'}}
1087 // expected-note@#cwg280-C-f3 {{conversion candidate of type 'void (*)(int, int, int)'}}
1089 } // namespace cwg280
1091 namespace cwg281 { // cwg281: no
1092 void a();
1093 inline void b();
1095 void d();
1096 inline void e();
1098 struct S {
1099 friend inline void a(); // FIXME: ill-formed
1100 friend inline void b();
1101 friend inline void c(); // FIXME: ill-formed
1102 friend inline void d() {}
1103 friend inline void e() {}
1104 friend inline void f() {}
1106 } // namespace cwg281
1108 namespace cwg283 { // cwg283: yes
1109 template<typename T> // #cwg283-template
1110 struct S {
1111 friend class T;
1112 // expected-error@-1 {{declaration of 'T' shadows template parameter}}
1113 // expected-note@#cwg283-template {{template parameter is declared here}}
1114 class T;
1115 // expected-error@-1 {{declaration of 'T' shadows template parameter}}
1116 // expected-note@#cwg283-template {{template parameter is declared here}}
1118 } // namespace cwg283
1120 namespace cwg284 { // cwg284: no
1121 namespace A {
1122 struct X;
1123 enum Y {};
1124 class Z {};
1126 namespace B {
1127 struct W;
1128 using A::X;
1129 using A::Y;
1130 using A::Z;
1132 struct B::V {};
1133 // expected-error@-1 {{no struct named 'V' in namespace 'cwg284::B'}}
1134 struct B::W {};
1135 struct B::X {}; // FIXME: ill-formed
1136 enum B::Y e; // ok per cwg417
1137 class B::Z z; // ok per cwg417
1139 struct C {
1140 struct X;
1141 enum Y {};
1142 class Z {};
1144 struct D : C {
1145 struct W;
1146 using C::X;
1147 using C::Y;
1148 using C::Z;
1150 struct D::V {};
1151 // expected-error@-1 {{no struct named 'V' in 'cwg284::D'}}
1152 struct D::W {};
1153 struct D::X {}; // FIXME: ill-formed
1154 enum D::Y e2; // ok per cwg417
1155 class D::Z z2; // ok per cwg417
1156 } // namespace cwg284
1158 namespace cwg285 { // cwg285: yes
1159 template<typename T> void f(T, int); // #cwg285-f-T-int
1160 template<typename T> void f(int, T); // #cwg285-f-int-T
1161 template<> void f<int>(int, int) {}
1162 // 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}}
1163 // expected-note@#cwg285-f-int-T {{function template 'cwg285::f<int>' matches specialization [with T = int]}}
1164 // expected-note@#cwg285-f-T-int {{function template 'cwg285::f<int>' matches specialization [with T = int]}}
1165 } // namespace cwg285
1167 namespace cwg286 { // cwg286: 2.8
1168 template<class T> struct A {
1169 class C {
1170 template<class T2> struct B {}; // #cwg286-B
1174 template<class T>
1175 template<class T2>
1176 struct A<T>::C::B<T2*> { };
1178 A<short>::C::B<int*> absip;
1179 // expected-error@-1 {{'B' is a private member of 'cwg286::A<short>::C'}}
1180 // expected-note@#cwg286-B {{implicitly declared private here}}
1181 } // namespace cwg286
1183 // cwg288: na
1185 namespace cwg289 { // cwg289: yes
1186 struct A; // #cwg289-A
1187 struct B : A {};
1188 // expected-error@-1 {{base class has incomplete type}}
1189 // expected-note@#cwg289-A {{forward declaration of 'cwg289::A'}}
1191 template<typename T> struct C { typename T::error error; };
1192 // expected-error@-1 {{type 'int' cannot be used prior to '::' because it has no members}}
1193 // expected-note@#cwg289-C-int {{in instantiation of template class 'cwg289::C<int>' requested here}}
1194 struct D : C<int> {}; // #cwg289-C-int
1195 } // namespace cwg289
1197 // cwg290: na
1198 // cwg291: dup 391
1199 // cwg292 is in cwg292.cpp
1201 namespace cwg294 { // cwg294: no
1202 void f() throw(int);
1203 // since-cxx17-error@-1 {{ISO C++17 does not allow dynamic exception specifications}}
1204 // since-cxx17-note@-2 {{use 'noexcept(false)' instead}}
1205 int main() {
1206 (void)static_cast<void (*)() throw()>(f); // FIXME: ill-formed in C++14 and before
1207 // FIXME: since-cxx17-error@-1 {{static_cast from 'void (*)() throw(int)' to 'void (*)() throw()' is not allowed}}
1209 // Irony: the above is valid in C++17 and beyond, but that's exactly when
1210 // we reject it. In C++14 and before, this is ill-formed because an
1211 // exception-specification is not permitted in a type-id. In C++17, this is
1212 // valid because it's the inverse of a standard conversion sequence
1213 // containing a function pointer conversion. (Well, it's actually not valid
1214 // yet, as a static_cast is not permitted to reverse a function pointer
1215 // conversion, but that is being changed by core issue).
1216 (void)static_cast<void (*)() throw(int)>(f); // FIXME: ill-formed in C++14 and before
1217 // since-cxx17-error@-1 {{ISO C++17 does not allow dynamic exception specifications}}
1218 // since-cxx17-note@-2 {{use 'noexcept(false)' instead}}
1220 void (*p)() throw() = f;
1221 // cxx98-14-error@-1 {{target exception specification is not superset of source}}
1222 // since-cxx17-error@-2 {{cannot initialize a variable of type 'void (*)() throw()' with an lvalue of type 'void () throw(int)': different exception specifications}}
1223 void (*q)() throw(int) = f;
1224 // since-cxx17-error@-1 {{ISO C++17 does not allow dynamic exception specifications}}
1225 // since-cxx17-note@-2 {{use 'noexcept(false)' instead}}
1227 } // namespace cwg294
1229 namespace cwg295 { // cwg295: 3.7
1230 typedef int f();
1231 const f g;
1232 // expected-warning@-1 {{'const' qualifier on function type 'f' (aka 'int ()') has no effect}}
1233 f &r = g;
1234 template<typename T> struct X {
1235 const T &f;
1237 X<f> x = {g};
1239 typedef int U();
1240 typedef const U U;
1241 // expected-warning@-1 {{'const' qualifier on function type 'U' (aka 'int ()') has no effect}}
1243 typedef int (*V)();
1244 typedef volatile U *V;
1245 // expected-warning@-1 {{'volatile' qualifier on function type 'U' (aka 'int ()') has no effect}}
1246 } // namespace cwg295
1248 namespace cwg296 { // cwg296: yes
1249 struct A {
1250 static operator int() { return 0; }
1251 // expected-error@-1 {{conversion function must be a non-static member function}}
1253 } // namespace cwg296
1255 namespace cwg298 { // cwg298: 3.1
1256 struct A {
1257 typedef int type;
1258 A();
1259 ~A();
1261 typedef A B; // #cwg298-B
1262 typedef const A C; // #cwg298-C
1264 A::type i1;
1265 B::type i2;
1266 C::type i3;
1268 struct A a;
1269 struct B b;
1270 // expected-error@-1 {{typedef 'B' cannot be referenced with the 'struct' specifier}}
1271 // expected-note@#cwg298-B {{declared here}}
1272 struct C c;
1273 // expected-error@-1 {{typedef 'C' cannot be referenced with the 'struct' specifier}}
1274 // expected-note@#cwg298-C {{declared here}}
1276 B::B() {}
1277 // expected-error@-1 {{a type specifier is required for all declarations}}
1278 B::A() {} // ok
1279 C::~C() {}
1280 // expected-error@-1 {{destructor cannot be declared using a typedef 'C' (aka 'const cwg298::A') of the class name}}
1282 typedef struct D E; // #cwg298-E
1283 struct E {};
1284 // expected-error@-1 {{definition of type 'E' conflicts with typedef of the same name}}
1285 // expected-note@#cwg298-E {{'E' declared here}}
1287 struct F {
1288 ~F();
1290 typedef const F G;
1291 G::~F() {} // ok
1292 } // namespace cwg298
1294 namespace cwg299 { // cwg299: 2.8 c++11
1295 struct S {
1296 operator int();
1298 struct T {
1299 operator int(); // #cwg299-int
1300 operator unsigned short(); // #cwg299-ushort
1302 // FIXME: should this apply to c++98 mode?
1303 int *p = new int[S()];
1304 // cxx98-error@-1 {{implicit conversion from array size expression of type 'S' to integral type 'int' is a C++11 extension}}
1305 int *q = new int[T()]; // #cwg299-q
1306 // cxx98-11-error@#cwg299-q {{ambiguous conversion of array size expression of type 'T' to an integral or enumeration type}}
1307 // cxx98-11-note@#cwg299-int {{conversion to integral type 'int' declared here}}
1308 // cxx98-11-note@#cwg299-ushort {{conversion to integral type 'unsigned short' declared here}}
1309 // since-cxx14-error-re@#cwg299-q {{{{conversion from 'T' to 'unsigned (long long|long|int)' is ambiguous}}}}
1310 // since-cxx14-note@#cwg299-int {{candidate function}}
1311 // since-cxx14-note@#cwg299-ushort {{candidate function}}
1312 } // namespace cwg299