xref: /llvm-project/clang/test/CXX/drs/cwg5xx.cpp (revision 14ba3f9d07ea1664497c5d117120fb243ca221aa)
1 // RUN: %clang_cc1 -std=c++98 %s -verify=expected,cxx98-23,cxx98-11,cxx98-14,cxx98-17,cxx98 -fexceptions -fcxx-exceptions -pedantic-errors
2 // RUN: %clang_cc1 -std=c++11 %s -verify=expected,cxx98-23,cxx98-11,cxx98-14,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
3 // RUN: %clang_cc1 -std=c++14 %s -verify=expected,cxx98-23,cxx98-14,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
4 // RUN: %clang_cc1 -std=c++17 %s -verify=expected,cxx98-23,since-cxx17,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
5 // RUN: %clang_cc1 -std=c++20 %s -verify=expected,cxx98-23,since-cxx20,since-cxx17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
6 // RUN: %clang_cc1 -std=c++23 %s -verify=expected,cxx98-23,since-cxx23,since-cxx20,since-cxx17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
7 // RUN: %clang_cc1 -std=c++2c %s -verify=expected,since-cxx26,since-cxx23,since-cxx20,since-cxx17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
8 
9 #if __cplusplus == 199711L
10 #define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
11 // cxx98-error@-1 {{variadic macros are a C99 feature}}
12 #endif
13 
14 // FIXME: This is included to avoid a diagnostic with no source location
15 // pointing at the implicit operator new. We can't match such a diagnostic
16 // with -verify.
17 __extension__ typedef __SIZE_TYPE__ size_t;
18 void *operator new(size_t); // #cwg5xx-global-operator-new
19 // cxx98-error@-1 {{'operator new' is missing exception specification 'throw(std::bad_alloc)'}}
20 #if __cplusplus >= 201703L
21 namespace std {
22   enum class align_val_t : size_t {};
23 } // namespace std
24 void *operator new(size_t, std::align_val_t); // #cwg5xx-global-operator-new-aligned
25 #endif
26 
27 namespace std {
28   struct type_info;
29 } // namespace std
30 
31 namespace cwg500 { // cwg500: dup 372
32   class D;
33   class A {
34     class B;
35     class C;
36     friend class D;
37   };
38   class A::B {};
39   class A::C : public A::B {};
40   class D : public A::B {};
41 } // namespace cwg500
42 
43 namespace cwg501 { // cwg501: 2.7
44   struct A {
45     friend void f() {}
46     void g() {
47       void (*p)() = &f;
48       // expected-error@-1 {{use of undeclared identifier 'f'}}
49     }
50   };
51 } // namespace cwg501
52 
53 namespace cwg502 { // cwg502: 2.7
54   struct Q {};
55   template<typename T> struct A {
56     enum E { e = 1 };
57     void q1() { f(e); }
58     void q2() { Q arr[sizeof(E)]; f(arr); }
59     void q3() { Q arr[e]; f(arr); }
60     void sanity() { Q arr[1]; f(arr); }
61     // expected-error@-1 {{use of undeclared identifier 'f'}}
62   };
63   int f(A<int>::E);
64   template<int N> int f(Q (&)[N]);
65   template struct A<int>;
66 } // namespace cwg502
67 
68 namespace cwg505 { // cwg505: 2.7
69   const char *exts = "\e\(\{\[\%";
70   // expected-error@-1 {{use of non-standard escape character '\e'}}
71   // expected-error@-2 {{use of non-standard escape character '\('}}
72   // expected-error@-3 {{use of non-standard escape character '\{'}}
73   // expected-error@-4 {{use of non-standard escape character '\['}}
74   // expected-error@-5 {{use of non-standard escape character '\%'}}
75   const char *unknown = "\Q";
76   // expected-error@-1 {{unknown escape sequence '\Q'}}
77 } // namespace cwg505
78 
79 namespace cwg506 { // cwg506: 2.7
80   struct NonPod { ~NonPod(); };
81   void f(...);
82   void g(NonPod np) { f(np); }
83   // cxx98-error@-1 {{cannot pass object of non-POD type 'NonPod' through variadic function; call will abort at runtime}}
84   // since-cxx11-error@-2 {{cannot pass object of non-trivial type 'NonPod' through variadic function; call will abort at runtime}}
85 } // namespace cwg506
86 
87 // FIXME: Add tests here once CWG260 is resolved.
88 // cwg507: dup 260
89 
90 // cwg508: na
91 // cwg509: na
92 // cwg510: na
93 
94 namespace cwg512 { // cwg512: 3.0
95   struct A { // #cwg512-A
96     A(int); // #cwg512-A-ctor
97   };
98   union U { A a; };
99   // cxx98-error@-1 {{union member 'a' has a non-trivial default constructor}}
100   //   cxx98-note@#cwg512-A {{because type 'cwg512::A' has no default constructor}}
101   //   cxx98-note@#cwg512-A-ctor {{implicit default constructor suppressed by user-declared constructor}}
102 } // namespace cwg512
103 
104 // cwg513: na
105 
106 namespace cwg514 { // cwg514: 2.7
107   namespace A { extern int x, y; }
108   int A::x = y;
109 } // namespace cwg514
110 
111 namespace cwg515 { // cwg515: sup 1017
112   // FIXME: cwg1017 reverses the wording of cwg515, but the current draft has
113   // cwg515's wording, with a different fix for cwg1017.
114 
115   struct X { int n; };
116   template<typename T> struct Y : T {
117     int f() { return X::n; }
118   };
119   int k = Y<X>().f();
120 
121   struct A { int a; };
122   struct B { void f() { int k = sizeof(A::a); } };
123   // cxx98-error@-1 {{invalid use of non-static data member 'a'}}
124 } // namespace cwg515
125 
126 // cwg516: na
127 
128 namespace cwg517 { // cwg517: no
129   // This is NDR, but we should diagnose it anyway.
130   template<typename T> struct S {};
131   template<typename T> int v = 0;
132   // cxx98-11-error@-1 {{variable templates are a C++14 extension}}
133 
134   template struct S<int*>;
135   template int v<int*>;
136 
137   S<char&> s;
138   int k = v<char&>;
139 
140   // FIXME: These are both ill-formed.
141   template<typename T> struct S<T*> {};
142   template<typename T> int v<T*> = 0;
143 
144   // FIXME: These are both ill-formed.
145   template<typename T> struct S<T&> {};
146   template<typename T> int v<T&> = 0;
147 } // namespace cwg517
148 
149 namespace cwg518 { // cwg518: 2.7 c++11
150   enum E { e, };
151   // cxx98-error@-1 {{commas at the end of enumerator lists are a C++11 extension}}
152 } // namespace cwg518
153 
154 // cwg519 is in cwg519.cpp
155 // cwg520: na
156 
157 // cwg521: no
158 // FIXME: The wording here is broken. It's not reasonable to expect a
159 // diagnostic here. Once the relevant DR gets a number, mark this as a dup.
160 
161 namespace cwg522 { // cwg522: 2.7
162   struct S {};
163   template<typename T> void b1(volatile T &);
164   template<typename T> void b2(volatile T * const *);
165   template<typename T> void b2(volatile T * const S::*);
166   template<typename T> void b2(volatile T * const S::* const *);
167   template<typename T> void b2a(volatile T *S::* const *); // #cwg522-b2a
168 
169   template<typename T> struct Base {};
170   struct Derived : Base<int> {};
171   template<typename T> void b3(Base<T>);
172   template<typename T> void b3(Base<T> *);
173 
174   void test(int n, const int cn, int **p, int *S::*pm) {
175     int *a[3], *S::*am[3];
176     const Derived cd = Derived();
177     Derived d[3];
178 
179     b1(n);
180     b1(cn);
181     b2(p);
182     b2(pm);
183     b2(a);
184     b2(am);
185     b2a(am);
186     // expected-error@-1 {{no matching function for call to 'b2a'}}
187     //   expected-note@#cwg522-b2a {{candidate template ignored: deduced type 'volatile int *S::*const *' of 1st parameter does not match adjusted type 'int *S::**' of argument}}
188     b3(d);
189     b3(cd);
190   }
191 } // namespace cwg522
192 
193 namespace cwg524 { // cwg524: 2.7
194   template<typename T> void f(T a, T b) { operator+(a, b); }
195   // expected-error@-1 {{call to function 'operator+' that is neither visible in the template definition nor found by argument-dependent lookup}}
196   //   expected-note@#cwg524-f-N-S {{in instantiation of function template specialization 'cwg524::f<cwg524::N::S>' requested here}}
197   //   expected-note@#cwg524-operator-plus {{'operator+' should be declared prior to the call site or in namespace 'cwg524::N'}}
198 
199   struct S {};
200   void operator+(S, S);
201   template void f(S, S);
202 
203   namespace N { struct S {}; }
204   void operator+(N::S, N::S); // #cwg524-operator-plus
205   template void f(N::S, N::S); // #cwg524-f-N-S
206 } // namespace cwg524
207 
208 namespace cwg525 { // cwg525: 2.7
209   namespace before {
210     // Note, the example was correct prior to the change; instantiation is
211     // required for cases like this:
212     template <class T> struct D { operator T*(); };
213     void g(D<double> ppp) {
214       delete ppp;
215     }
216   }
217   namespace after {
218     template <class T> struct D { typename T::error e; };
219     // expected-error@-1 {{type 'double' cannot be used prior to '::' because it has no members}}
220     //   expected-note@#cwg525-ppp {{in instantiation of template class 'cwg525::after::D<double>' requested here}}
221     void g(D<double> *ppp) {
222       delete ppp; // #cwg525-ppp
223     }
224   }
225 } // namespace cwg525
226 
227 namespace cwg526 { // cwg526: 2.7
228   template<int> struct S {};
229   template<int N> void f1(S<N> s);
230   template<int N> void f2(S<(N)> s); // #cwg526-f2
231   template<int N> void f3(S<+N> s); // #cwg526-f3
232   template<int N> void g1(int (&)[N]);
233   template<int N> void g2(int (&)[(N)]); // #cwg526-g2
234   template<int N> void g3(int (&)[+N]); // #cwg526-g3
235 
236   void test(int (&a)[3], S<3> s) {
237     f1(s);
238     f2(s);
239     // expected-error@-1 {{no matching function for call to 'f2'}}
240     //   expected-note@#cwg526-f2 {{candidate template ignored: couldn't infer template argument 'N'}}
241     f3(s);
242     // expected-error@-1 {{no matching function for call to 'f3'}}
243     //   expected-note@#cwg526-f3 {{candidate template ignored: couldn't infer template argument 'N'}}
244     g1(a);
245     g2(a);
246     // expected-error@-1 {{no matching function for call to 'g2'}}
247     //   expected-note@#cwg526-g2 {{candidate template ignored: couldn't infer template argument 'N'}}
248     g3(a);
249     // expected-error@-1 {{no matching function for call to 'g3'}}
250     //   expected-note@#cwg526-g3 {{candidate template ignored: couldn't infer template argument 'N'}}
251   }
252 
253   template<int N> struct X {
254     typedef int type;
255     X<N>::type v1;
256     X<(N)>::type v2;
257     // cxx98-17-error@-1 {{missing 'typename' prior to dependent type name X<(N)>::type; implicit 'typename' is a C++20 extension}}
258     X<+N>::type v3;
259     // cxx98-17-error@-1 {{missing 'typename' prior to dependent type name X<+N>::type; implicit 'typename' is a C++20 extension}}
260   };
261 } // namespace cwg526
262 
263 namespace cwg527 { // cwg527: na
264   // This DR is meaningless. It removes a required diagnostic from the case
265   // where a not-externally-visible object is odr-used but not defined, which
266   // requires a diagnostic for a different reason.
267   extern struct { int x; } a; // FIXME: We should reject this, per cwg389.
268   static struct { int x; } b;
269   extern "C" struct { int x; } c;
270   namespace { extern struct { int x; } d; }
271   typedef struct { int x; } *P;
272   struct E { static P e; }; // FIXME: We should reject this, per cwg389.
273   namespace { struct F { static P f; }; }
274 
275   int ax = a.x, bx = b.x, cx = c.x, dx = d.x, ex = E::e->x, fx = F::f->x;
276 } // namespace cwg527
277 
278 namespace cwg528 { // cwg528: 2.7
279 
280 struct S; // #cwg528-S
281 
282 void f() {
283   typeid(S);
284   // expected-error@-1 {{'typeid' of incomplete type 'S'}}
285   //   expected-note@#cwg528-S {{forward declaration of 'cwg528::S'}}
286 }
287 
288 } // namespace cwg528
289 
290 namespace cwg530 { // cwg530: 2.7
291   template<int*> struct S { enum { N = 1 }; };
292   template<void(*)()> struct T { enum { N = 1 }; };
293   int n;
294   void f();
295   int a[S<&n>::N];
296   int b[T<&f>::N];
297 } // namespace cwg530
298 
299 namespace cwg531 { // cwg531: partial
300   namespace good {
301     template<typename T> struct A {
302       void f(T) { T::error; }
303       template<typename U> void g(T, U) { T::error; }
304       struct B { typename T::error error; };
305       template<typename U> struct C { typename T::error error; };
306       static T n;
307     };
308     template<typename T> T A<T>::n = T::error;
309 
310     template<> void A<int>::f(int) {}
311     template<> template<typename U> void A<int>::g(int, U) {}
312     template<> struct A<int>::B {};
313     template<> template<typename U> struct A<int>::C {};
314     template<> int A<int>::n = 0;
315 
316     void use(A<int> a) {
317       a.f(a.n);
318       a.g(0, 0);
319       A<int>::B b;
320       A<int>::C<int> c;
321     }
322 
323     template<> struct A<char> {
324       void f(char);
325       template<typename U> void g(char, U);
326       struct B;
327       template<typename U> struct C;
328       static char n;
329     };
330 
331     void A<char>::f(char) {}
332     template<typename U> void A<char>::g(char, U) {}
333     struct A<char>::B {};
334     template<typename U> struct A<char>::C {};
335     char A<char>::n = 0;
336   }
337 
338   namespace bad {
339     template<typename T> struct A {
340       void f(T) { T::error; }
341       template<typename U> void g(T, U) { T::error; }
342       struct B { typename T::error error; };
343       template<typename U> struct C { typename T::error error; }; // #cwg531-C
344       static T n;
345     };
346     template<typename T> T A<T>::n = T::error;
347 
348     void A<int>::f(int) {}
349     // expected-error@-1 {{template specialization requires 'template<>'}}
350     template<typename U> void A<int>::g(int, U) {}
351     // expected-error@-1 {{template parameter list matching the non-templated nested type 'cwg531::bad::A<int>' should be empty}}
352     struct A<int>::B {};
353     // expected-error@-1 {{template specialization requires 'template<>'}}
354     template<typename U> struct A<int>::C {};
355     // expected-error@-1 {{template parameter list matching the non-templated nested type 'cwg531::bad::A<int>' should be empty}}
356     // expected-error@-2 {{redefinition of 'C' as different kind of symbol}}
357     //   expected-note@#cwg531-C {{previous definition is here}}
358     int A<int>::n = 0;
359     // expected-error@-1 {{template specialization requires 'template<>'}}
360 
361     template<> struct A<char> { // #cwg531-A-char
362       void f(char);
363       template<typename U> void g(char, U);
364       struct B; // #cwg531-B
365       template<typename U> struct C;
366       static char n;
367     };
368 
369     template<> void A<char>::f(char) {}
370     // expected-error@-1 {{no function template matches function template specialization 'f'}}
371     template<> template<typename U> void A<char>::g(char, U) {}
372     // expected-error@-1 {{extraneous template parameter list in template specialization}}
373     //   expected-note@#cwg531-A-char {{'template<>' header not required for explicitly-specialized class 'cwg531::bad::A<char>' declared here}}
374     template<> struct A<char>::B {};
375     // expected-error@-1 {{extraneous 'template<>' in declaration of struct 'B'}}
376     // expected-error@-2 {{specialization of member 'cwg531::bad::A<char>::B' does not specialize an instantiated member}}
377     //  expected-note@#cwg531-B {{attempt to specialize declaration here}}
378     template<> template<typename U> struct A<char>::C {};
379     // expected-error@-1 {{extraneous template parameter list in template specialization}}
380     //   expected-note@#cwg531-A-char {{'template<>' header not required for explicitly-specialized class 'cwg531::bad::A<char>' declared here}}
381     template<> char A<char>::n = 0;
382     // expected-error@-1 {{extraneous 'template<>' in declaration of variable 'n'}}
383   }
384 
385   namespace nested {
386     template<typename T> struct A {
387       template<typename U> struct B;
388     };
389     template<> template<typename U> struct A<int>::B {
390       void f();
391       void g();
392       template<typename V> void h();
393       template<typename V> void i();
394     };
395     template<> template<typename U> void A<int>::B<U>::f() {}
396     template<typename U> void A<int>::B<U>::g() {}
397     // expected-error@-1 {{template parameter list matching the non-templated nested type 'cwg531::nested::A<int>' should be empty ('template<>')}}
398 
399     template<> template<typename U> template<typename V> void A<int>::B<U>::h() {}
400     template<typename U> template<typename V> void A<int>::B<U>::i() {}
401     // expected-error@-1 {{template parameter list matching the non-templated nested type 'cwg531::nested::A<int>' should be empty ('template<>')}}
402 
403 #if __cplusplus <= 201703L
404     // FIXME: All of those declarations shouldn't crash in C++20 mode.
405     template<> template<> void A<int>::B<int>::f() {}
406     template<> template<> template<typename V> void A<int>::B<int>::h() {}
407     template<> template<> template<> void A<int>::B<int>::h<int>() {}
408 
409     template<> void A<int>::B<char>::f() {}
410     // cxx98-17-error@-1 {{template specialization requires 'template<>'}}
411     template<> template<typename V> void A<int>::B<char>::h() {}
412     // cxx98-17-error@-1 {{template parameter list matching the non-templated nested type 'cwg531::nested::A<int>::B<char>' should be empty ('template<>')}}
413 #endif
414   }
415 } // namespace cwg531
416 
417 // PR8130
418 namespace cwg532 { // cwg532: 3.5
419   struct A { };
420 
421   template<class T> struct B {
422     template<class R> int &operator*(R&);
423   };
424 
425   template<class T, class R> float &operator*(T&, R&);
426   void test() {
427     A a;
428     B<A> b;
429     int &ir = b * a;
430   }
431 } // namespace cwg532
432 
433 // cwg533: na
434 
435 namespace cwg534 { // cwg534: 2.9
436   struct S {};
437   template<typename T> void operator+(S, T);
438   template<typename T> void operator+<T*>(S, T*) {}
439   // expected-error@-1 {{function template partial specialization is not allowed}}
440 } // namespace cwg534
441 
442 namespace cwg535 { // cwg535: 3.1
443   class X { private: X(const X&); };
444   struct A {
445     X x;
446     template<typename T> A(T&);
447   };
448   struct B : A {
449     X y;
450     B(volatile A&);
451   };
452 
453   extern A a1;
454   A a2(a1); // ok, uses constructor template
455 
456   extern volatile B b1;
457   B b2(b1); // ok, uses converting constructor
458 
459   void f() { throw a1; }
460 
461 #if __cplusplus >= 201103L
462   struct C {
463     constexpr C() : n(0) {}
464     template<typename T> constexpr C(T&t) : n(t.n == 0 ? throw 0 : 0) {}
465     int n;
466   };
467   constexpr C c() { return C(); }
468   // ok, copy is elided
469   constexpr C x = c();
470 #endif
471 } // namespace cwg535
472 
473 // cwg536: na
474 // cwg537: na
475 // cwg538: na
476 
477 namespace cwg539 { // cwg539: 3.4
478 const f(
479 // expected-error@-1 {{a type specifier is required for all declarations}}
480     const a) {
481     // expected-error@-1 {{unknown type name 'a'}}
482   const b;
483   // expected-error@-1 {{a type specifier is required for all declarations}}
484   new const;
485   // expected-error@-1 {{expected a type}}
486   try {} catch (const n) {}
487   // expected-error@-1 {{unknown type name 'n'}}
488   try {} catch (const) {}
489   // expected-error@-1 {{expected a type}}
490   if (const n = 0) {}
491   // expected-error@-1 {{a type specifier is required for all declarations}}
492   switch (const n = 0) {}
493   // expected-error@-1 {{a type specifier is required for all declarations}}
494   while (const n = 0) {}
495   // expected-error@-1 {{a type specifier is required for all declarations}}
496   for (const n = 0;
497   // expected-error@-1 {{a type specifier is required for all declarations}}
498        const m = 0; ) {}
499        // expected-error@-1 {{a type specifier is required for all declarations}}
500   sizeof(const);
501   // expected-error@-1 {{a type specifier is required for all declarations}}
502   struct S {
503     const n;
504     // expected-error@-1 {{a type specifier is required for all declarations}}
505     operator const();
506     // expected-error@-1 {{expected a type}}
507   };
508 #if __cplusplus >= 201103L
509   int arr[3];
510   // FIXME: The extra braces here are to avoid the parser getting too
511   // badly confused when recovering here. We should fix this recovery.
512   { for (const n // #cwg539-for
513   // since-cxx11-error@-1 {{unknown type name 'n'}}
514          : arr) ; {} }
515          // since-cxx11-error@-1 +{{}}
516          //   since-cxx11-note@#cwg539-for {{}}
517   (void) [](const) {};
518   // since-cxx11-error@-1 {{a type specifier is required for all declarations}}
519   (void) [](const n) {};
520   // since-cxx11-error@-1 {{unknown type name 'n'}}
521   enum E : const {};
522   // since-cxx11-error@-1 {{expected a type}}
523   using T = const;
524   // since-cxx11-error@-1 {{expected a type}}
525   auto f() -> const;
526   // since-cxx11-error@-1 {{expected a type}}
527 #endif
528 }
529 } // namespace cwg539
530 
531 namespace cwg540 { // cwg540: 2.7
532   typedef int &a;
533   typedef const a &a;
534   // expected-warning@-1 {{'const' qualifier on reference type 'a' (aka 'int &') has no effect}}
535   typedef const int &b;
536   typedef b &b;
537   typedef const a &c; // #cwg540-typedef-a-c
538   // expected-warning@-1 {{'const' qualifier on reference type 'a' (aka 'int &') has no effect}}
539   typedef const b &c; // #cwg540-typedef-b-c
540   // expected-error@#cwg540-typedef-b-c {{typedef redefinition with different types ('const int &' vs 'int &')}}
541   //   expected-note@#cwg540-typedef-a-c {{previous definition is here}}
542   // expected-warning@#cwg540-typedef-b-c {{'const' qualifier on reference type 'b' (aka 'const int &') has no effect}}
543 } // namespace cwg540
544 
545 namespace cwg541 { // cwg541: 2.7
546   template<int> struct X { typedef int type; };
547   template<typename T> struct S {
548     int f(T);
549 
550     int g(int);
551     T g(bool);
552 
553     int h();
554     int h(T);
555 
556     void x() {
557       // These are type-dependent expressions, even though we could
558       // determine that all calls have type 'int'.
559       X<sizeof(f(0))>::type a;
560       // expected-error@-1 {{expected ';' after expression}}
561       // expected-error@-2 {{use of undeclared identifier 'a'}}
562       X<sizeof(g(0))>::type b;
563       // expected-error@-1 {{expected ';' after expression}}
564       // expected-error@-2 {{use of undeclared identifier 'b'}}
565       X<sizeof(h(0))>::type b;
566       // expected-error@-1 {{expected ';' after expression}}
567       // expected-error@-2 {{use of undeclared identifier 'b'}}
568 
569       typename X<sizeof(f(0))>::type a;
570       typename X<sizeof(h(0))>::type b;
571     }
572   };
573 } // namespace cwg541
574 
575 namespace cwg542 { // cwg542: 3.5
576 #if __cplusplus >= 201103L
577   // In C++20 A and B are no longer aggregates and thus the constructor is
578   // called, which fails.
579   struct A { A() = delete; int n; }; // #cwg542-A
580   // ok, constructor not called
581   A a[32] = {}; // #cwg542-a
582   // since-cxx20-error@-1 {{call to deleted constructor of 'A'}}
583   //   since-cxx20-note@#cwg542-A {{'A' has been explicitly marked deleted here}}
584   //   since-cxx20-note@#cwg542-a {{in implicit initialization of array element 0 with omitted initializer}}
585 
586   struct B {
587     int n;
588   private:
589     B() = default; // #cwg542-B-ctor
590   };
591   B b[32] = {}; // ok, constructor not called
592   // since-cxx20-error@-1 {{calling a private constructor of class 'cwg542::B'}}
593   //   since-cxx20-note@#cwg542-B-ctor {{declared private here}}
594 #endif
595 } // namespace cwg542
596 
597 namespace cwg543 { // cwg543: 3.0
598   // In C++98+CWG543, this is valid because value-initialization doesn't call a
599   // trivial default constructor, so we never notice that defining the
600   // constructor would be ill-formed.
601   //
602   // In C++11+CWG543, this is ill-formed, because the default constructor is
603   // deleted, and value-initialization *does* call a deleted default
604   // constructor, even if it is trivial.
605   struct A {
606     const int n; // #cwg543-A-n
607   };
608   A a = A();
609   // since-cxx11-error@-1 {{call to implicitly-deleted default constructor of 'A'}}
610   //   since-cxx11-note@#cwg543-A-n {{default constructor of 'A' is implicitly deleted because field 'n' of const-qualified type 'const int' would not be initialized}}
611 } // namespace cwg543
612 
613 namespace cwg544 { // cwg544: 2.7
614   int *n;
615 
616   template<class T> struct A { int n; };
617   template<class T> struct B : A<T> { int get(); };
618   template<> int B<int>::get() { return n; }
619   int k = B<int>().get();
620 } // namespace cwg544
621 
622 namespace cwg546 { // cwg546: 2.7
623   template<typename T> struct A { void f(); };
624   template struct A<int>;
625   template<typename T> void A<T>::f() { T::error; }
626 } // namespace cwg546
627 
628 namespace cwg547 { // cwg547: 3.2
629   template<typename T> struct X;
630   template<typename T> struct X<T() const> {};
631   template<typename T, typename C> X<T> f(T C::*) { return X<T>(); }
632 
633   struct S { void f() const; };
634   X<void() const> x = f(&S::f);
635 } // namespace cwg547
636 
637 namespace cwg548 { // cwg548: dup 482
638   template<typename T> struct S {};
639   template<typename T> void f() {}
640   template struct cwg548::S<int>;
641   template void cwg548::f<int>();
642 } // namespace cwg548
643 
644 // cwg550: dup 393
645 
646 namespace cwg551 { // cwg551: 2.7 c++11
647   // FIXME: This obviously should apply in C++98 mode too.
648   template<typename T> void f() {}
649   template inline void f<int>();
650   // since-cxx11-error@-1 {{explicit instantiation cannot be 'inline'}}
651 
652   template<typename T> inline void g() {}
653   template inline void g<int>();
654   // since-cxx11-error@-1 {{explicit instantiation cannot be 'inline'}}
655 
656   template<typename T> struct X {
657     void f() {}
658   };
659   template inline void X<int>::f();
660   // since-cxx11-error@-1 {{explicit instantiation cannot be 'inline'}}
661 } // namespace cwg551
662 
663 namespace cwg552 { // cwg552: 2.7
664   template<typename T, typename T::U> struct X {};
665   struct Y { typedef int U; };
666   X<Y, 0> x;
667 } // namespace cwg552
668 
669 // cwg553: 2.7
670 struct cwg553_class {
671   friend void *operator new(size_t, cwg553_class);
672 };
673 namespace cwg553 {
674   cwg553_class c;
675   // Contrary to the apparent intention of the DR, operator new is not actually
676   // looked up with a lookup mechanism that performs ADL; the standard says it
677   // "is looked up in global scope", where it is not visible.
678   void *p = new (c) int;
679   // expected-error@-1 {{no matching function for call to 'operator new'}}
680   //   since-cxx17-note@#cwg5xx-global-operator-new-aligned {{candidate function not viable: no known conversion from 'cwg553_class' to 'std::align_val_t' for 2nd argument}}
681   //   expected-note@#cwg5xx-global-operator-new {{candidate function not viable: requires 1 argument, but 2 were provided}}
682 
683   struct namespace_scope {
684     friend void *operator new(size_t, namespace_scope);
685     // expected-error@-1 {{'operator new' cannot be declared inside a namespace}}
686   };
687 } // namespace cwg553
688 
689 // cwg554: na
690 
691 namespace cwg555 { // cwg555: 2.8
692 typedef int I;
693 typedef const int CI;
694 typedef volatile int VI;
695 void f(int *a, CI *b, VI *c) {
696   a->~I();
697   a->~CI();
698   a->~VI();
699   a->I::~I();
700   a->CI::~CI();
701   a->VI::~VI();
702 
703   a->CI::~VI(); // allowed by changes to [expr.id.prim.qual]/2 introduced in P1131R2
704 
705   b->~I();
706   b->~CI();
707   b->~VI();
708   b->I::~I();
709   b->CI::~CI();
710   b->VI::~VI();
711 
712   c->~I();
713   c->~CI();
714   c->~VI();
715   c->I::~I();
716   c->CI::~CI();
717   c->VI::~VI();
718 }
719 
720 void g(int &a, CI &b, VI &c) {
721   a.~I();
722   a.~CI();
723   a.~VI();
724   a.I::~I();
725   a.CI::~CI();
726   a.VI::~VI();
727 
728   a.CI::~VI(); // allowed by changes to [expr.id.prim.qual]/2 introduced in P1131R2
729 
730   b.~I();
731   b.~CI();
732   b.~VI();
733   b.I::~I();
734   b.CI::~CI();
735   b.VI::~VI();
736 
737   c.~I();
738   c.~CI();
739   c.~VI();
740   c.I::~I();
741   c.CI::~CI();
742   c.VI::~VI();
743 }
744 } // namespace cwg555
745 
746 // cwg556: na
747 
748 namespace cwg557 { // cwg557: 3.1
749   template<typename T> struct S {
750     friend void f(S<T> *);
751     friend void g(S<S<T> > *);
752   };
753   void x(S<int> *p, S<S<int> > *q) {
754     f(p);
755     g(q);
756   }
757 } // namespace cwg557
758 
759 namespace cwg558 { // cwg558: 2.9
760   wchar_t a = L'\uD7FF';
761   wchar_t b = L'\xD7FF';
762   wchar_t c = L'\uD800';
763   // expected-error@-1 {{invalid universal character}}
764   wchar_t d = L'\xD800';
765   wchar_t e = L'\uDFFF';
766   // expected-error@-1 {{invalid universal character}}
767   wchar_t f = L'\xDFFF';
768   wchar_t g = L'\uE000';
769   wchar_t h = L'\xE000';
770 } // namespace cwg558
771 
772 namespace cwg559 { // cwg559: 2.7
773 template<typename> struct S { typedef int T; S::T u; };
774 } // namespace cwg559
775 
776 namespace cwg560 { // cwg560: 16
777 
778 template <class T>
779 struct Outer {
780   struct Inner {
781     Inner* self();
782   };
783 };
784 template <class T>
785 Outer<T>::Inner* Outer<T>::Inner::self() { return this; }
786 // cxx98-17-error@-1 {{missing 'typename' prior to dependent type name Outer<T>::Inner; implicit 'typename' is a C++20 extension}}
787 
788 } // namespace cwg560
789 
790 namespace cwg561 { // cwg561: 2.7
791   template<typename T> void f(int);
792   template<typename T> void g(T t) {
793     f<T>(t);
794   }
795   namespace {
796     struct S {};
797     template<typename T> static void f(S);
798   }
799   void h(S s) {
800     g(s);
801   }
802 } // namespace cwg561
803 
804 // cwg562: na
805 // cwg563 is in cwg563.cpp
806 
807 namespace cwg564 { // cwg564: 2.7
808   extern "C++" void f(int);
809   void f(int); // ok
810   extern "C++" { extern int n; }
811   int n; // ok
812 } // namespace cwg564
813 
814 namespace cwg565 { // cwg565: 2.7
815   namespace N {
816     template<typename T> int f(T); // #cwg565-f
817   }
818   using N::f; // #cwg565-using
819   template<typename T> int f(T*);
820   template<typename T> void f(T);
821   template<typename T, int = 0> int f(T);
822   // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
823   template<typename T> int f(T, int = 0);
824   template<typename T> int f(T);
825   // expected-error@-1 {{declaration conflicts with target of using declaration already in scope}}
826   //   expected-note@#cwg565-f {{target of using declaration}}
827   //   expected-note@#cwg565-using {{using declaration}}
828 } // namespace cwg565
829 
830 namespace cwg566 { // cwg566: 3.1
831 #if __cplusplus >= 201103L
832   static_assert(int(-3.99) == -3, "");
833 #endif
834 } // namespace cwg566
835 
836 // cwg567: na
837 
838 namespace cwg568 { // cwg568: 3.0 c++11
839   // FIXME: This is a DR issue against C++98, so should probably apply there
840   // too.
841   struct x { int y; };
842   class trivial : x {
843     x y;
844   public:
845     int n;
846   };
847   static_assert(__is_trivial(trivial), "");
848 
849   struct std_layout {
850     std_layout();
851     std_layout(const std_layout &);
852     ~std_layout();
853   private:
854     int n;
855   };
856   static_assert(__is_standard_layout(std_layout), "");
857 
858   struct aggregate {
859     int x;
860     int y;
861     trivial t;
862     std_layout sl;
863   };
864   aggregate aggr = {};
865 
866   void f(...);
867   void g(trivial t) { f(t); }
868   // cxx98-error@-1 {{cannot pass object of non-POD type 'trivial' through variadic function; call will abort at runtime}}
869 
870   void jump() {
871     goto x;
872     // cxx98-error@-1 {{cannot jump from this goto statement to its label}}
873     //   cxx98-note@#cwg568-t {{jump bypasses initialization of non-POD variable}}
874     trivial t; // #cwg568-t
875   x: ;
876   }
877 } // namespace cwg568
878 
879 namespace cwg569 { // cwg569: 2.7 c++11
880   // FIXME: This is a DR issue against C++98, so should probably apply there
881   // too.
882   ;;;;;
883   // cxx98-error@-1 {{C++11 extension}}
884 } // namespace cwg569
885 
886 namespace cwg570 { // cwg570: dup 633
887   int n;
888   int &r = n; // #cwg570-r
889   int &r = n;
890   // expected-error@-1 {{redefinition of 'r'}}
891   //   expected-note@#cwg570-r {{previous definition is here}}
892 } // namespace cwg570
893 
894 // cwg571 is in cwg571.cpp
895 
896 namespace cwg572 { // cwg572: 2.7
897   enum E { a = 1, b = 2 };
898   static_assert(a + b == 3, "");
899 } // namespace cwg572
900 
901 namespace cwg573 { // cwg573: no
902   void *a;
903   int *b = reinterpret_cast<int*>(a);
904   void (*c)() = reinterpret_cast<void(*)()>(a);
905   // cxx98-error@-1 {{cast between pointer-to-function and pointer-to-object is an extension}}
906   void *d = reinterpret_cast<void*>(c);
907   // cxx98-error@-1 {{cast between pointer-to-function and pointer-to-object is an extension}}
908   void f() { delete a; }
909   // cxx98-23-error@-1 {{cannot delete expression with pointer-to-'void' type 'void *'}}
910   // since-cxx26-error@-2 {{cannot delete pointer to incomplete type 'void'}}
911   int n = d - a;
912   // expected-error@-1 {{arithmetic on pointers to void}}
913   // FIXME: This is ill-formed.
914   template<void*> struct S;
915   template<int*> struct T;
916 } // namespace cwg573
917 
918 namespace cwg574 { // cwg574: 3.0
919   struct A {
920     A &operator=(const A&) const; // #cwg574-A-copy-assign
921   };
922   struct B {
923     B &operator=(const B&) volatile; // #cwg574-B-copy-assign
924   };
925 #if __cplusplus >= 201103L
926   struct C {
927     C &operator=(const C&) &; // #cwg574-C-copy-assign
928   };
929   struct D {
930     D &operator=(const D&) &&; // #cwg574-D-copy-assign
931   };
932   void test(C c, D d) {
933     c = c;
934     C() = c;
935     // since-cxx11-error@-1 {{no viable overloaded '='}}
936     //   since-cxx11-note@#cwg574-C-copy-assign {{candidate function not viable: expects an lvalue for object argument}}
937     d = d;
938     // since-cxx11-error@-1 {{no viable overloaded '='}}
939     //   since-cxx11-note@#cwg574-D-copy-assign {{candidate function not viable: expects an rvalue for object argument}}
940     D() = d;
941   }
942 #endif
943   struct Test {
944     friend A &A::operator=(const A&);
945     // expected-error@-1 {{friend declaration of 'operator=' does not match any declaration in 'cwg574::A'}}
946     //   expected-note@#cwg574-A-copy-assign {{candidate function has different qualifiers (expected unqualified but found 'const')}}
947     friend B &B::operator=(const B&);
948     // expected-error@-1 {{friend declaration of 'operator=' does not match any declaration in 'cwg574::B'}}
949     //   expected-note@#cwg574-B-copy-assign {{candidate function has different qualifiers (expected unqualified but found 'volatile')}}
950 #if __cplusplus >= 202302L
951     friend C &C::operator=(const C&);
952     // since-cxx23-error@-1 {{conflicting types for 'operator='}}
953     //   since-cxx23-note@#cwg574-C-copy-assign {{previous declaration is here}}
954     friend D &D::operator=(const D&);
955     // since-cxx23-error@-1 {{conflicting types for 'operator='}}
956     //   since-cxx23-note@#cwg574-D-copy-assign {{previous declaration is here}}
957 #elif __cplusplus >= 201103L
958     // FIXME: We shouldn't produce the 'cannot overload' diagnostics here.
959     friend C &C::operator=(const C&); // #cwg574-test-C
960     // since-cxx11-error@#cwg574-test-C {{cannot overload}}
961     //   since-cxx11-note@#cwg574-C-copy-assign {{previous declaration is here}}
962     // since-cxx11-error@#cwg574-test-C {{friend declaration of 'operator=' does not match any declaration in 'cwg574::C'}}
963     //   since-cxx11-note@#cwg574-C-copy-assign {{candidate function}}
964     friend D &D::operator=(const D&); // #cwg574-test-D
965     // since-cxx11-error@#cwg574-test-D {{cannot overload a member function without a ref-qualifier with a member function with ref-qualifier '&&'}}
966     //   since-cxx11-note@#cwg574-D-copy-assign {{previous declaration is here}}
967     // since-cxx11-error@#cwg574-test-D {{friend declaration of 'operator=' does not match any declaration in 'cwg574::D'}}
968     //   since-cxx11-note@#cwg574-D-copy-assign {{candidate function}}
969 #endif
970   };
971 } // namespace cwg574
972 
973 namespace cwg575 { // cwg575: 2.7
974   template<typename T, typename U = typename T::type> void a(T); void a(...);
975   // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
976   template<typename T, typename T::type U = 0> void b(T); void b(...);
977   // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
978   template<typename T, int U = T::value> void c(T); void c(...);
979   // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
980   template<typename T> void d(T, int = T::value); void d(...);
981   // expected-error@-1 {{type 'int' cannot be used prior to '::' because it has no members}}
982   //   expected-note@#cwg575-d {{in instantiation of default function argument expression for 'd<int>' required here}}
983   void x() {
984     a(0);
985     b(0);
986     c(0);
987     d(0); // #cwg575-d
988   }
989 
990   template<typename T = int&> void f(T* = 0);
991   // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
992   template<typename T = int> void f(T = 0);
993   // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}}
994   void g() { f<>(); }
995 
996   template<typename T> T &h(T *);
997   template<typename T> T *h(T *);
998   void *p = h((void*)0);
999 } // namespace cwg575
1000 
1001 namespace cwg576 { // cwg576: 3.5
1002   typedef void f() {}
1003   // expected-error@-1 {{function definition declared 'typedef'}}
1004   void f(typedef int n);
1005   // expected-error@-1 {{invalid storage class specifier in function declarator}}
1006   void f(char c) { typedef int n; }
1007 } // namespace cwg576
1008 
1009 namespace cwg577 { // cwg577: 3.5
1010   typedef void V;
1011   typedef const void CV;
1012   void a(void);
1013   void b(const void);
1014   // expected-error@-1 {{'void' as parameter must not have type qualifiers}}
1015   void c(V);
1016   void d(CV);
1017   // expected-error@-1 {{'void' as parameter must not have type qualifiers}}
1018   void (*e)(void) = c;
1019   void (*f)(const void);
1020   // expected-error@-1 {{'void' as parameter must not have type qualifiers}}
1021   void (*g)(V) = a;
1022   void (*h)(CV);
1023   // expected-error@-1 {{'void' as parameter must not have type qualifiers}}
1024   template<typename T> void i(T); // #cwg577-i
1025   template<typename T> void j(void (*)(T)); // #cwg577-j
1026   void k() {
1027     a();
1028     c();
1029     i<void>();
1030     // expected-error@-1 {{no matching function for call to 'i'}}
1031     //   expected-note@#cwg577-i {{candidate function template not viable: requires 1 argument, but 0 were provided}}
1032     i<const void>();
1033     // expected-error@-1 {{no matching function for call to 'i'}}
1034     //   expected-note@#cwg577-i {{candidate function template not viable: requires 1 argument, but 0 were provided}}
1035     j<void>(0);
1036     // expected-error@-1 {{no matching function for call to 'j'}}
1037     //   expected-note@#cwg577-j {{candidate template ignored: substitution failure [with T = void]: argument may not have 'void' type}}
1038     j<const void>(0);
1039     // expected-error@-1 {{no matching function for call to 'j'}}
1040     //   expected-note@#cwg577-j {{candidate template ignored: substitution failure [with T = const void]: argument may not have 'void' type}}
1041   }
1042 } // namespace cwg577
1043 
1044 namespace cwg580 { // cwg580: partial
1045   class C;
1046   struct A { static C c; };
1047   struct B { static C c; };
1048   class C {
1049     C(); // #cwg580-C-ctor
1050     ~C(); // #cwg580-C-dtor
1051 
1052     typedef int I; // #cwg580-I
1053     template<int> struct X;
1054     template<int> friend struct Y;
1055     template<int> void f();
1056     template<int> friend void g();
1057     friend struct A;
1058   };
1059 
1060   template<C::I> struct C::X {};
1061   template<C::I> struct Y {};
1062   template<C::I> struct Z {};
1063   // expected-error@-1 {{'I' is a private member of 'cwg580::C'}}
1064   //   expected-note@#cwg580-I {{implicitly declared private here}}
1065 
1066   struct C2 {
1067     class X {
1068       struct A;
1069       typedef int I;
1070       friend struct A;
1071     };
1072     class Y {
1073       // FIXME: We incorrectly accept this
1074       // because we think C2::Y::A<...> might
1075       // instantiate to C2::X::A
1076       template<X::I> struct A {};
1077     };
1078   };
1079 
1080   template<C::I> void C::f() {}
1081   template<C::I> void g() {}
1082   template<C::I> void h() {}
1083   // expected-error@-1 {{'I' is a private member of 'cwg580::C'}}
1084   //   expected-note@#cwg580-I {{implicitly declared private here}}
1085 
1086   C A::c;
1087   C B::c; // #cwg580-c
1088   // expected-error@#cwg580-c {{calling a private constructor of class 'cwg580::C'}}
1089   //   expected-note@#cwg580-C-ctor {{implicitly declared private here}}
1090   // expected-error@#cwg580-c {{variable of type 'C' has private destructor}}
1091   //   expected-note@#cwg580-C-dtor {{implicitly declared private here}}
1092 } // namespace cwg580
1093 
1094 // cwg582: na
1095 
1096 namespace cwg583 { // cwg583: 4
1097   // see n3624
1098   int *p;
1099   bool b1 = p < 0;
1100   // expected-error@-1 {{ordered comparison between pointer and zero ('int *' and 'int')}}
1101   bool b2 = p > 0;
1102   // expected-error@-1 {{ordered comparison between pointer and zero ('int *' and 'int')}}
1103   bool b3 = p <= 0;
1104   // expected-error@-1 {{ordered comparison between pointer and zero ('int *' and 'int')}}
1105   bool b4 = p >= 0;
1106   // expected-error@-1 {{ordered comparison between pointer and zero ('int *' and 'int')}}
1107 } // namespace cwg583
1108 
1109 // cwg584: na
1110 
1111 namespace cwg585 { // cwg585: 3.0
1112   template<typename> struct T; // #cwg585-struct-T
1113   struct A {
1114     friend T;
1115     // cxx98-14-error@-1 {{a type specifier is required for all declarations}}
1116     // cxx98-14-error@-2 {{friends can only be classes or functions}}
1117     // since-cxx17-error@-3 {{use of class template 'T' requires template arguments; argument deduction not allowed in friend declaration}}
1118     //   since-cxx17-note@#cwg585-struct-T {{template is declared here}}
1119     // FIXME: It's not clear whether the standard allows this or what it means,
1120     // but the CWG585 writeup suggests it as an alternative.
1121     template<typename U> friend T<U>;
1122     // expected-error@-1 {{friend type templates must use an elaborated type}}
1123   };
1124   template<template<typename> class T> struct B { // #cwg585-template-T
1125     friend T;
1126     // cxx98-14-error@-1 {{a type specifier is required for all declarations}}
1127     // cxx98-14-error@-2 {{friends can only be classes or functions}}
1128     // since-cxx17-error@-3 {{use of template template parameter 'T' requires template arguments; argument deduction not allowed in friend declaration}}
1129     //   since-cxx17-note@#cwg585-template-T {{template is declared here}}
1130     template<typename U> friend T<U>;
1131     // expected-error@-1 {{friend type templates must use an elaborated type}}
1132   };
1133 } // namespace cwg585
1134 
1135 // cwg586: na
1136 
1137 namespace cwg587 { // cwg587: 3.2
1138   template<typename T> void f(bool b, const T x, T y) {
1139     const T *p = &(b ? x : y);
1140   }
1141   struct S {};
1142   template void f(bool, const int, int);
1143   template void f(bool, const S, S);
1144 } // namespace cwg587
1145 
1146 namespace cwg588 { // cwg588: 2.7
1147   struct A { int n; }; // #cwg588-A
1148   template<typename T> int f() {
1149     struct S : A, T { int f() { return n; } } s;
1150     int a = s.f();
1151     int b = s.n;
1152     // expected-error@-1 {{member 'n' found in multiple base classes of different types}}
1153     //   expected-note@#cwg588-k {{in instantiation of function template specialization 'cwg588::f<cwg588::B>' requested here}}
1154     //   expected-note@#cwg588-A {{member found by ambiguous name lookup}}
1155     //   expected-note@#cwg588-B {{member found by ambiguous name lookup}}
1156   }
1157   struct B { int n; }; // #cwg588-B
1158   int k = f<B>(); // #cwg588-k
1159 } // namespace cwg588
1160 
1161 namespace cwg589 { // cwg589: 2.7
1162   struct B { };
1163   struct D : B { };
1164   D f();
1165   extern const B &b;
1166   bool a;
1167   const B *p = &(a ? f() : b);
1168   // expected-error@-1 {{taking the address of a temporary object of type 'const B'}}
1169   const B *q = &(a ? D() : b);
1170   // expected-error@-1 {{taking the address of a temporary object of type 'const B'}}
1171 } // namespace cwg589
1172 
1173 namespace cwg590 { // cwg590: 2.7
1174   template<typename T> struct A {
1175     struct B {
1176       struct C {
1177         A<T>::B::C f(A<T>::B::C); // ok, no 'typename' required.
1178       };
1179     };
1180   };
1181   template<typename T> typename A<T>::B::C A<T>::B::C::f(A<T>::B::C) {}
1182 } // namespace cwg590
1183 
1184 namespace cwg591 { // cwg591: 20
1185   template<typename T> struct A {
1186     typedef int M;
1187     struct B {
1188       typedef void M;
1189       struct C;
1190       struct D;
1191     };
1192   };
1193 
1194   template<typename T> struct G {
1195     struct B {
1196       typedef int M;
1197       struct C {
1198         typedef void M;
1199         struct D;
1200       };
1201     };
1202   };
1203 
1204   template<typename T> struct H {
1205     template<typename U> struct B {
1206       typedef int M;
1207       template<typename F> struct C {
1208         typedef void M;
1209         struct D;
1210         struct P;
1211       };
1212     };
1213   };
1214 
1215   template <typename, bool> struct M {
1216     class P;
1217     int M;
1218   };
1219 
1220   template<typename T> struct A<T>::B::C : A<T> {
1221     M m;
1222   };
1223 
1224   template<typename T> struct G<T>::B::C::D : B {
1225     M m;
1226   };
1227 
1228   template<typename T>
1229   template<typename U>
1230   template<typename F>
1231   struct H<T>::B<U>::C<F>::D : B<U> {
1232     M m;
1233   };
1234 
1235   template<typename T, bool B> class M<T,B>::P : M {
1236     int foo() { (void) M; }
1237   };
1238 
1239   template<typename T> struct A<T>::B::D : A<T*> {
1240     M m;
1241     // expected-error@-1 {{field has incomplete type 'M' (aka 'void'}}
1242   };
1243 
1244   template<typename T>
1245   template<typename U>
1246   template<typename F>
1247   struct H<T>::B<U>::C<F>::P : B<F> {
1248     M m;
1249     // expected-error@-1 {{field has incomplete type 'M' (aka 'void'}}
1250   };
1251 } // namespace cwg591
1252 
1253 // cwg592: na
1254 // cwg593 is in cwg593.cpp
1255 // cwg594: na
1256 
1257 namespace cwg595 { // cwg595: dup 1330
1258   template<class T> struct X {
1259     void f() throw(T) {}
1260     // since-cxx17-error@-1 {{ISO C++17 does not allow dynamic exception specifications}}
1261     //   since-cxx17-note@-2 {{use 'noexcept(false)' instead}}
1262   };
1263   struct S {
1264     X<S> xs;
1265   };
1266 } // namespace cwg595
1267 
1268 // cwg597: na
1269 
1270 namespace cwg598 { // cwg598: 2.7
1271   namespace N {
1272     void f(int);
1273     void f(char);
1274     // Not found by ADL.
1275     void g(void (*)(int));
1276     void h(void (*)(int));
1277 
1278     namespace M {
1279       struct S {};
1280       int &h(void (*)(S));
1281     }
1282     void i(M::S);
1283     void i();
1284   }
1285   int &g(void(*)(char));
1286   int &r = g(N::f);
1287   int &s = h(N::f);
1288   // expected-error@-1 {{use of undeclared identifier 'h'}}
1289   int &t = h(N::i);
1290 } // namespace cwg598
1291 
1292 namespace cwg599 { // cwg599: partial
1293   typedef int Fn();
1294   struct S { operator void*(); };
1295   struct T { operator Fn*(); };
1296   struct U { operator int*(); operator void*(); }; // #cwg599-U
1297   struct V { operator int*(); operator Fn*(); };
1298   void f(void *p, void (*q)(), S s, T t, U u, V v) {
1299     delete p;
1300     // cxx98-23-error@-1 {{cannot delete expression with pointer-to-'void' type 'void *'}}
1301     // since-cxx26-error@-2 {{cannot delete pointer to incomplete type 'void'}}
1302     delete q;
1303     // expected-error@-1 {{cannot delete expression of type 'void (*)()'}}
1304     delete s;
1305     // cxx98-23-error@-1 {{cannot delete expression with pointer-to-'void' type 'void *'}}
1306     // since-cxx26-error@-2 {{cannot delete pointer to incomplete type 'void'}}
1307     delete t;
1308     // expected-error@-1 {{cannot delete expression of type 'T'}}
1309     // FIXME: This is valid, but is rejected due to a non-conforming GNU
1310     // extension allowing deletion of pointers to void.
1311     delete u;
1312     // expected-error@-1 {{ambiguous conversion of delete expression of type 'U' to a pointer}}
1313     //   expected-note@#cwg599-U {{conversion to pointer type 'int *'}}
1314     //   expected-note@#cwg599-U {{conversion to pointer type 'void *'}}
1315     delete v;
1316   }
1317 } // namespace cwg599
1318