Debian Codegraph @

clang/test/CXX/drs/cwg14xx.cpp

raw
1 // RUN: %clang_cc1 -std=c++98 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors
2 // RUN: %clang_cc1 -std=c++11 %s -verify=expected,cxx11-17,since-cxx11, -fexceptions -fcxx-exceptions -pedantic-errors
3 // RUN: %clang_cc1 -std=c++14 %s -verify=expected,cxx14-17,cxx11-17,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors
4 // RUN: %clang_cc1 -std=c++17 %s -verify=expected,cxx14-17,cxx11-17,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors
5 // RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions -fcxx-exceptions -pedantic-errors
6 // RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions -fcxx-exceptions -pedantic-errors
7 // RUN: %clang_cc1 -std=c++2c %s -verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions -fcxx-exceptions -pedantic-errors
8
9 namespace cwg1413 { // cwg1413: 12
10 template<int> struct Check {
11 typedef int type;
12 };
13 template<typename T> struct A : T {
14 static const int a = 1;
15 static const int b;
16 static void c();
17 void d();
18
19 void f() {
20 Check<true ? 0 : A::unknown_spec>::type *var1;
21 // expected-error@-1 {{use of undeclared identifier 'var1'}}
22
23 // ok, variable declaration
24 Check<true ? 0 : a>::type *var2; // #cwg1413-var2
25 Check<true ? 0 : b>::type *var3;
26 // expected-error@-1 {{use of undeclared identifier 'var3'}}
27 // expected-note@#cwg1413-var2 {{'var2' declared here}}
28 Check<true ? 0 : ((void)c, 0)>::type *var4;
29 // expected-error@-1 {{use of undeclared identifier 'var4'}}
30 // expected-note@#cwg1413-var2 {{'var2' declared here}}
31
32 // value-dependent because of the implied type-dependent 'this->', not because of 'd'
33 Check<true ? 0 : (d(), 0)>::type *var5;
34 // expected-error@-1 {{use of undeclared identifier 'var5'}}
35 // expected-note@#cwg1413-var2 {{'var2' declared here}}
36
37 // value-dependent because of the value-dependent '&' operator, not because of 'A::d'
38 Check<true ? 0 : (&A::d(), 0)>::type *var5;
39 // expected-error@-1 {{use of undeclared identifier 'var5'}}
40 // expected-note@#cwg1413-var2 {{'var2' declared here}}
41 }
42 };
43 }
44
45 namespace cwg1423 { // cwg1423: 11
46 #if __cplusplus >= 201103L
47 bool b1 = nullptr;
48 // since-cxx11-error@-1 {{cannot initialize a variable of type 'bool' with an rvalue of type 'std::nullptr_t'}}
49 bool b2(nullptr);
50 // since-cxx11-warning@-1 {{implicit conversion of nullptr constant to 'bool'}}
51 bool b3 = {nullptr};
52 // since-cxx11-error@-1 {{cannot initialize a variable of type 'bool' with an rvalue of type 'std::nullptr_t'}}
53 bool b4{nullptr};
54 // since-cxx11-warning@-1 {{implicit conversion of nullptr constant to 'bool'}}
55 #endif
56 }
57
58 // cwg1425: na abi
59
60 namespace cwg1432 { // cwg1432: 16
61 #if __cplusplus >= 201103L
62 template<typename T> T declval();
63
64 template <class... T>
65 struct common_type;
66
67 template <class T, class U>
68 struct common_type<T, U> {
69 typedef decltype(true ? declval<T>() : declval<U>()) type;
70 };
71
72 template <class T, class U, class... V>
73 struct common_type<T, U, V...> {
74 typedef typename common_type<typename common_type<T, U>::type, V...>::type type;
75 };
76
77 template struct common_type<int, double>;
78 #endif
79 }
80
81 namespace cwg1443 { // cwg1443: yes
82 struct A {
83 int i;
84 A() { void foo(int=i); }
85 // expected-error@-1 {{default argument references 'this'}}
86 };
87 }
88
89 namespace cwg1458 { // cwg1458: 3.1
90 #if __cplusplus >= 201103L
91 struct A;
92
93 void f() {
94 constexpr A* a = nullptr;
95 constexpr int p = &*a;
96 // expected-error@-1 {{cannot initialize a variable of type 'const int' with an rvalue of type 'A *'}}
97 constexpr A *p2 = &*a;
98 }
99
100 struct A {
101 int operator&();
102 };
103 #endif
104 } // namespace cwg1458
105
106 namespace cwg1460 { // cwg1460: 3.5
107 #if __cplusplus >= 201103L
108 namespace DRExample {
109 union A {
110 union {};
111 // expected-error@-1 {{declaration does not declare anything}}
112 union {};
113 // expected-error@-1 {{declaration does not declare anything}}
114 constexpr A() {}
115 };
116 constexpr A a = A();
117
118 union B {
119 union {};
120 // expected-error@-1 {{declaration does not declare anything}}
121 union {};
122 // expected-error@-1 {{declaration does not declare anything}}
123 constexpr B() = default;
124 };
125 constexpr B b = B();
126
127 union C {
128 union {};
129 // expected-error@-1 {{declaration does not declare anything}}
130 union {};
131 // expected-error@-1 {{declaration does not declare anything}}
132 };
133 constexpr C c = C();
134 #if __cplusplus >= 201403L
135 constexpr void f() { C c; }
136 static_assert((f(), true), "");
137 #endif
138 }
139
140 union A {};
141 union B { int n; }; // #cwg1460-B
142 union C { int n = 0; };
143 struct D { union {}; };
144 // expected-error@-1 {{declaration does not declare anything}}
145 struct E { union { int n; }; }; // #cwg1460-E
146 struct F { union { int n = 0; }; };
147
148 struct X {
149 friend constexpr A::A() noexcept;
150 friend constexpr B::B() noexcept;
151 // cxx11-17-error@-1 {{constexpr declaration of 'B' follows non-constexpr declaration}}
152 // cxx11-17-note@#cwg1460-B {{previous declaration is here}}
153 friend constexpr C::C() noexcept;
154 friend constexpr D::D() noexcept;
155 friend constexpr E::E() noexcept;
156 // cxx11-17-error@-1 {{constexpr declaration of 'E' follows non-constexpr declaration}}
157 // cxx11-17-note@#cwg1460-E {{previous declaration is here}}
158 friend constexpr F::F() noexcept;
159 };
160
161 // These are OK, because value-initialization doesn't actually invoke the
162 // constructor.
163 constexpr A a = A();
164 constexpr B b = B();
165 constexpr C c = C();
166 constexpr D d = D();
167 constexpr E e = E();
168 constexpr F f = F();
169
170 namespace Defaulted {
171 union A { constexpr A() = default; };
172 union B { int n; constexpr B() = default; };
173 // cxx11-17-error@-1 {{defaulted definition of default constructor cannot be marked constexpr}}
174 union C { int n = 0; constexpr C() = default; };
175 struct D { union {}; constexpr D() = default; };
176 // expected-error@-1 {{declaration does not declare anything}}
177 struct E { union { int n; }; constexpr E() = default; };
178 // cxx11-17-error@-1 {{defaulted definition of default constructor cannot be marked constexpr}}
179 struct F { union { int n = 0; }; constexpr F() = default; };
180
181 struct G { union { int n = 0; }; union { int m; }; constexpr G() = default; };
182 // cxx11-17-error@-1 {{defaulted definition of default constructor cannot be marked constexpr}}
183 struct H {
184 union {
185 int n = 0;
186 };
187 union { // #cwg1460-H-union
188 int m;
189 };
190 constexpr H() {}
191 // cxx11-17-error@-1 {{constexpr constructor that does not initialize all members is a C++20 extension}}
192 // cxx11-17-note@#cwg1460-H-union {{member not initialized by constructor}}
193 constexpr H(bool) : m(1) {}
194 constexpr H(char) : n(1) {}
195 // cxx11-17-error@-1 {{constexpr constructor that does not initialize all members is a C++20 extension}}
196 // cxx11-17-note@#cwg1460-H-union {{member not initialized by constructor}}
197 constexpr H(double) : m(1), n(1) {}
198 };
199 }
200
201 #if __cplusplus >= 201403L
202 template<typename T> constexpr bool check() {
203 T t; // #cwg1460-t
204 return true;
205 }
206 static_assert(check<A>(), "");
207 static_assert(check<B>(), ""); // #cwg1460-check-B
208 // cxx14-17-error@-1 {{static assertion expression is not an integral constant expression}}
209 // cxx14-17-note@#cwg1460-t {{non-constexpr constructor 'B' cannot be used in a constant expression}}
210 // cxx14-17-note@#cwg1460-check-B {{in call to 'check<cwg1460::B>()'}}
211 // cxx14-17-note@#cwg1460-B {{declared here}}
212 static_assert(check<C>(), "");
213 static_assert(check<D>(), "");
214 static_assert(check<E>(), ""); // #cwg1460-check-E
215 // cxx14-17-error@-1 {{static assertion expression is not an integral constant expression}}
216 // cxx14-17-note@#cwg1460-t {{non-constexpr constructor 'E' cannot be used in a constant expression}}
217 // cxx14-17-note@#cwg1460-check-E {{in call to 'check<cwg1460::E>()'}}
218 // cxx14-17-note@#cwg1460-E {{declared here}}
219 static_assert(check<F>(), "");
220 #endif
221
222 union G {
223 int a = 0; // #cwg1460-G-a
224 int b = 0;
225 // expected-error@-1 {{initializing multiple members of union}}
226 // expected-note@#cwg1460-G-a {{previous initialization is here}}
227 };
228 union H {
229 union {
230 int a = 0; // #cwg1460-H-a
231 };
232 union {
233 int b = 0;
234 // expected-error@-1 {{initializing multiple members of union}}
235 // expected-note@#cwg1460-H-a {{previous initialization is here}}
236 };
237 };
238 struct I {
239 union {
240 int a = 0; // #cwg1460-I-a
241 int b = 0;
242 // expected-error@-1 {{initializing multiple members of union}}
243 // expected-note@#cwg1460-I-a {{previous initialization is here}}
244 };
245 };
246 struct J {
247 union { int a = 0; };
248 union { int b = 0; };
249 };
250
251 namespace Overriding {
252 struct A {
253 int a = 1, b, c = 3;
254 constexpr A() : b(2) {}
255 };
256 static_assert(A().a == 1 && A().b == 2 && A().c == 3, "");
257
258 union B {
259 int a, b = 2, c;
260 constexpr B() : a(1) {}
261 constexpr B(char) : b(4) {}
262 constexpr B(int) : c(3) {}
263 constexpr B(const char*) {}
264 };
265 static_assert(B().a == 1, "");
266 static_assert(B().b == 2, "");
267 // expected-error@-1 {{static assertion expression is not an integral constant expression}}
268 // expected-note@-2 {{read of member 'b' of union with active member 'a' is not allowed in a constant expression}}
269 static_assert(B('x').a == 0, "");
270 // expected-error@-1 {{static assertion expression is not an integral constant expression}}
271 // expected-note@-2 {{read of member 'a' of union with active member 'b' is not allowed in a constant expression}}
272 static_assert(B('x').b == 4, "");
273 static_assert(B(123).b == 2, "");
274 // expected-error@-1 {{static assertion expression is not an integral constant expression}}
275 // expected-note@-2 {{read of member 'b' of union with active member 'c' is not allowed in a constant expression}}
276 static_assert(B(123).c == 3, "");
277 static_assert(B("").a == 1, "");
278 // expected-error@-1 {{static assertion expression is not an integral constant expression}}
279 // expected-note@-2 {{read of member 'a' of union with active member 'b' is not allowed in a constant expression}}
280 static_assert(B("").b == 2, "");
281 static_assert(B("").c == 3, "");
282 // expected-error@-1 {{static assertion expression is not an integral constant expression}}
283 // expected-note@-2 {{read of member 'c' of union with active member 'b' is not allowed in a constant expression}}
284
285 struct C {
286 union { int a, b = 2, c; };
287 union { int d, e = 5, f; };
288 constexpr C() : a(1) {}
289 constexpr C(char) : c(3) {}
290 constexpr C(int) : d(4) {}
291 constexpr C(float) : f(6) {}
292 constexpr C(const char*) {}
293 };
294
295 static_assert(C().a == 1, "");
296 static_assert(C().b == 2, "");
297 // expected-error@-1 {{static assertion expression is not an integral constant expression}}
298 // expected-note@-2 {{read of member 'b' of union with active member 'a' is not allowed in a constant expression}}
299 static_assert(C().d == 4, "");
300 // expected-error@-1 {{static assertion expression is not an integral constant expression}}
301 // expected-note@-2 {{read of member 'd' of union with active member 'e' is not allowed in a constant expression}}
302 static_assert(C().e == 5, "");
303
304 static_assert(C('x').b == 2, "");
305 // expected-error@-1 {{static assertion expression is not an integral constant expression}}
306 // expected-note@-2 {{read of member 'b' of union with active member 'c' is not allowed in a constant expression}}
307 static_assert(C('x').c == 3, "");
308 static_assert(C('x').d == 4, "");
309 // expected-error@-1 {{static assertion expression is not an integral constant expression}}
310 // expected-note@-2 {{read of member 'd' of union with active member 'e' is not allowed in a constant expression}}
311 static_assert(C('x').e == 5, "");
312
313 static_assert(C(1).b == 2, "");
314 static_assert(C(1).c == 3, "");
315 // expected-error@-1 {{static assertion expression is not an integral constant expression}}
316 // expected-note@-2 {{read of member 'c' of union with active member 'b' is not allowed in a constant expression}}
317 static_assert(C(1).d == 4, "");
318 static_assert(C(1).e == 5, "");
319 // expected-error@-1 {{static assertion expression is not an integral constant expression}}
320 // expected-note@-2 {{read of member 'e' of union with active member 'd' is not allowed in a constant expression}}
321
322 static_assert(C(1.f).b == 2, "");
323 static_assert(C(1.f).c == 3, "");
324 // expected-error@-1 {{static assertion expression is not an integral constant expression}}
325 // expected-note@-2 {{read of member 'c' of union with active member 'b' is not allowed in a constant expression}}
326 static_assert(C(1.f).e == 5, "");
327 // expected-error@-1 {{static assertion expression is not an integral constant expression}}
328 // expected-note@-2 {{read of member 'e' of union with active member 'f' is not allowed in a constant expression}}
329 static_assert(C(1.f).f == 6, "");
330
331 static_assert(C("").a == 1, "");
332 // expected-error@-1 {{static assertion expression is not an integral constant expression}}
333 // expected-note@-2 {{read of member 'a' of union with active member 'b' is not allowed in a constant expression}}
334 static_assert(C("").b == 2, "");
335 static_assert(C("").c == 3, "");
336 // expected-error@-1 {{static assertion expression is not an integral constant expression}}
337 // expected-note@-2 {{read of member 'c' of union with active member 'b' is not allowed in a constant expression}}
338 static_assert(C("").d == 4, "");
339 // expected-error@-1 {{static assertion expression is not an integral constant expression}}
340 // expected-note@-2 {{read of member 'd' of union with active member 'e' is not allowed in a constant expression}}
341 static_assert(C("").e == 5, "");
342 static_assert(C("").f == 6, "");
343 // expected-error@-1 {{static assertion expression is not an integral constant expression}}
344 // expected-note@-2 {{read of member 'f' of union with active member 'e' is not allowed in a constant expression}}
345
346 struct D;
347 extern const D d;
348 struct D {
349 int a;
350 union {
351 int b = const_cast<D&>(d).a = 1; // not evaluated
352 int c;
353 };
354 constexpr D() : a(0), c(0) {}
355 };
356 constexpr D d {};
357 static_assert(d.a == 0, "");
358 }
359 #endif
360 }
361
362 #if __cplusplus >= 201103L
363 namespace std {
364 typedef decltype(sizeof(int)) size_t;
365
366 // libc++'s implementation
367 template <class _E>
368 class initializer_list
369 {
370 const _E* __begin_;
371 size_t __size_;
372
373 initializer_list(const _E* __b, size_t __s)
374 : __begin_(__b), __size_(__s) {}
375
376 public:
377 typedef _E value_type;
378 typedef const _E& reference;
379 typedef const _E& const_reference;
380 typedef size_t size_type;
381
382 typedef const _E* iterator;
383 typedef const _E* const_iterator;
384
385 initializer_list() : __begin_(nullptr), __size_(0) {}
386
387 size_t size() const {return __size_;}
388 const _E* begin() const {return __begin_;}
389 const _E* end() const {return __begin_ + __size_;}
390 };
391 } // std
392 #endif
393
394 namespace cwg1467 { // cwg1467: 3.7 c++11
395 #if __cplusplus >= 201103L
396 // Note that the change to [over.best.ics] was partially undone by CWG2076;
397 // the resulting rule is tested with the tests for that change.
398
399 // List-initialization of aggregate from same-type object
400
401 namespace basic0 {
402 struct S {
403 int i = 42;
404 };
405
406 S a;
407 S b(a);
408 S c{a};
409
410 struct SS : public S { } x;
411 S y(x);
412 S z{x};
413 } // basic0
414
415 namespace basic1 {
416 struct S {
417 int i{42};
418 };
419
420 S a;
421 S b(a);
422 S c{a};
423
424 struct SS : public S { } x;
425 S y(x);
426 S z{x};
427 } // basic1
428
429 namespace basic2 {
430 struct S {
431 int i = {42};
432 };
433
434 S a;
435 S b(a);
436 S c{a};
437
438 struct SS : public S { } x;
439 S y(x);
440 S z{x};
441 } // basic2
442
443 namespace dr_example {
444 struct OK {
445 OK() = default;
446 OK(const OK&) = default;
447 OK(int) { }
448 };
449
450 OK ok;
451 OK ok2{ok};
452
453 struct X {
454 X() = default;
455 X(const X&) = default;
456 };
457
458 X x;
459 X x2{x};
460
461 void f1(int); // #cwg1467-f1
462 void f1(std::initializer_list<long>) = delete; // #cwg1467-f1-deleted
463 void g1() { f1({42}); }
464 // since-cxx11-error@-1 {{call to deleted function 'f1'}}
465 // since-cxx11-note@#cwg1467-f1 {{candidate function}}
466 // since-cxx11-note@#cwg1467-f1-deleted {{candidate function has been explicitly deleted}}
467
468 template <class T, class U>
469 struct Pair {
470 Pair(T, U);
471 };
472 struct String {
473 String(const char *);
474 };
475
476 void f2(Pair<const char *, const char *>); // #cwg1467-f2
477 void f2(std::initializer_list<String>) = delete; // #cwg1467-f2-deleted
478 void g2() { f2({"foo", "bar"}); }
479 // since-cxx11-error@-1 {{call to deleted function 'f2'}}
480 // since-cxx11-note@#cwg1467-f2 {{candidate function}}
481 // since-cxx11-note@#cwg1467-f2-deleted {{candidate function has been explicitly deleted}}
482 } // dr_example
483
484 namespace nonaggregate {
485 struct NonAggregate {
486 NonAggregate() {}
487 };
488
489 struct WantsIt {
490 WantsIt(NonAggregate);
491 };
492
493 void f(NonAggregate);
494 void f(WantsIt);
495
496 void test1() {
497 NonAggregate n;
498 f({n});
499 }
500
501 void test2() {
502 NonAggregate x;
503 NonAggregate y{x};
504 NonAggregate z{{x}};
505 }
506 } // nonaggregate
507
508 namespace SelfInitIsNotListInit {
509 struct S {
510 S();
511 explicit S(S &);
512 S(const S &);
513 };
514 S s1;
515 S s2 = {s1}; // ok, not list-initialization so we pick the non-explicit constructor
516 }
517
518 struct NestedInit { int a, b, c; };
519 NestedInit ni[1] = {{NestedInit{1, 2, 3}}};
520
521 namespace NestedInit2 {
522 struct Pair { int a, b; };
523 struct TwoPairs { TwoPairs(Pair, Pair); };
524 struct Value { Value(Pair); Value(TwoPairs); };
525 void f() { Value{{{1,2},{3,4}}}; }
526 }
527 namespace NonAmbiguous {
528 // The original implementation made this case ambiguous due to the special
529 // handling of one element initialization lists.
530 void f(int(&&)[1]);
531 void f(unsigned(&&)[1]);
532
533 void g(unsigned i) {
534 f({i});
535 }
536 } // namespace NonAmbiguous
537
538 namespace StringLiterals {
539 // When the array size is 4 the call will attempt to bind an lvalue to an
540 // rvalue and fail. Therefore #2 will be called. (rsmith will bring this
541 // issue to CWG)
542 void f(const char(&&)[4]); // #cwg1467-f-char-4
543 void f(const char(&&)[5]) = delete; // #cwg1467-f-char-5
544 void f(const wchar_t(&&)[4]); // #cwg1467-f-wchar-4
545 void f(const wchar_t(&&)[5]) = delete; // #cwg1467-f-wchar-5
546 #if __cplusplus >= 202002L
547 void f2(const char8_t(&&)[4]); // #cwg1467-f2-char8-4
548 void f2(const char8_t(&&)[5]) = delete; // #cwg1467-f2-char8-5
549 #endif
550 void f(const char16_t(&&)[4]); // #cwg1467-f-char16-4
551 void f(const char16_t(&&)[5]) = delete; // #cwg1467-f-char16-5
552 void f(const char32_t(&&)[4]); // #cwg1467-f-char32-4
553 void f(const char32_t(&&)[5]) = delete; // #cwg1467-f-char32-5
554 void g() {
555 f({"abc"});
556 // since-cxx11-error@-1 {{call to deleted function 'f'}}
557 // since-cxx11-note@#cwg1467-f-char-5 {{candidate function has been explicitly deleted}}
558 // since-cxx11-note@#cwg1467-f-char-4 {{candidate function not viable: expects an rvalue for 1st argument}}
559 // since-cxx11-note@#cwg1467-f-wchar-4 {{candidate function not viable: no known conversion from 'const char[4]' to 'const wchar_t' for 1st argument}}
560 // since-cxx11-note@#cwg1467-f-wchar-5 {{candidate function not viable: no known conversion from 'const char[4]' to 'const wchar_t' for 1st argument}}
561 // since-cxx11-note@#cwg1467-f-char16-4 {{candidate function not viable: no known conversion from 'const char[4]' to 'const char16_t' for 1st argument}}
562 // since-cxx11-note@#cwg1467-f-char16-5 {{candidate function not viable: no known conversion from 'const char[4]' to 'const char16_t' for 1st argument}}
563 // since-cxx11-note@#cwg1467-f-char32-4 {{candidate function not viable: no known conversion from 'const char[4]' to 'const char32_t' for 1st argument}}
564 // since-cxx11-note@#cwg1467-f-char32-5 {{candidate function not viable: no known conversion from 'const char[4]' to 'const char32_t' for 1st argument}}
565 f({((("abc")))});
566 // since-cxx11-error@-1 {{call to deleted function 'f'}}
567 // since-cxx11-note@#cwg1467-f-char-5 {{candidate function has been explicitly deleted}}
568 // since-cxx11-note@#cwg1467-f-char-4 {{candidate function not viable: expects an rvalue for 1st argument}}
569 // since-cxx11-note@#cwg1467-f-wchar-4 {{candidate function not viable: no known conversion from 'const char[4]' to 'const wchar_t' for 1st argument}}
570 // since-cxx11-note@#cwg1467-f-wchar-5 {{candidate function not viable: no known conversion from 'const char[4]' to 'const wchar_t' for 1st argument}}
571 // since-cxx11-note@#cwg1467-f-char16-4 {{candidate function not viable: no known conversion from 'const char[4]' to 'const char16_t' for 1st argument}}
572 // since-cxx11-note@#cwg1467-f-char16-5 {{candidate function not viable: no known conversion from 'const char[4]' to 'const char16_t' for 1st argument}}
573 // since-cxx11-note@#cwg1467-f-char32-4 {{candidate function not viable: no known conversion from 'const char[4]' to 'const char32_t' for 1st argument}}
574 // since-cxx11-note@#cwg1467-f-char32-5 {{candidate function not viable: no known conversion from 'const char[4]' to 'const char32_t' for 1st argument}}
575 f({L"abc"});
576 // since-cxx11-error@-1 {{call to deleted function 'f'}}
577 // since-cxx11-note@#cwg1467-f-wchar-5 {{candidate function has been explicitly deleted}}
578 // since-cxx11-note@#cwg1467-f-char-4 {{candidate function not viable: no known conversion from 'const wchar_t[4]' to 'const char' for 1st argument}}
579 // since-cxx11-note@#cwg1467-f-char-5 {{candidate function not viable: no known conversion from 'const wchar_t[4]' to 'const char' for 1st argument}}
580 // since-cxx11-note@#cwg1467-f-wchar-4 {{candidate function not viable: expects an rvalue for 1st argument}}
581 // since-cxx11-note@#cwg1467-f-char16-4 {{candidate function not viable: no known conversion from 'const wchar_t[4]' to 'const char16_t' for 1st argument}}
582 // since-cxx11-note@#cwg1467-f-char16-5 {{candidate function not viable: no known conversion from 'const wchar_t[4]' to 'const char16_t' for 1st argument}}
583 // since-cxx11-note@#cwg1467-f-char32-4 {{candidate function not viable: no known conversion from 'const wchar_t[4]' to 'const char32_t' for 1st argument}}
584 // since-cxx11-note@#cwg1467-f-char32-5 {{candidate function not viable: no known conversion from 'const wchar_t[4]' to 'const char32_t' for 1st argument}}
585 #if __cplusplus >= 202002L
586 f2({u8"abc"});
587 // since-cxx20-error@-1 {{call to deleted function 'f2'}}
588 // since-cxx20-note@#cwg1467-f2-char8-5 {{candidate function has been explicitly deleted}}
589 // since-cxx20-note@#cwg1467-f2-char8-4 {{candidate function not viable: expects an rvalue for 1st argument}}
590 #endif
591 f({uR"(abc)"});
592 // since-cxx11-error@-1 {{call to deleted function 'f'}}
593 // since-cxx11-note@#cwg1467-f-char16-5 {{candidate function has been explicitly deleted}}
594 // since-cxx11-note@#cwg1467-f-char-4 {{candidate function not viable: no known conversion from 'const char16_t[4]' to 'const char' for 1st argument}}
595 // since-cxx11-note@#cwg1467-f-char-5 {{candidate function not viable: no known conversion from 'const char16_t[4]' to 'const char' for 1st argument}}
596 // since-cxx11-note@#cwg1467-f-wchar-4 {{candidate function not viable: no known conversion from 'const char16_t[4]' to 'const wchar_t' for 1st argument}}
597 // since-cxx11-note@#cwg1467-f-wchar-5 {{candidate function not viable: no known conversion from 'const char16_t[4]' to 'const wchar_t' for 1st argument}}
598 // since-cxx11-note@#cwg1467-f-char16-4 {{candidate function not viable: expects an rvalue for 1st argument}}
599 // since-cxx11-note@#cwg1467-f-char32-4 {{candidate function not viable: no known conversion from 'const char16_t[4]' to 'const char32_t' for 1st argument}}
600 // since-cxx11-note@#cwg1467-f-char32-5 {{candidate function not viable: no known conversion from 'const char16_t[4]' to 'const char32_t' for 1st argument}}
601 f({(UR"(abc)")});
602 // since-cxx11-error@-1 {{call to deleted function 'f'}}
603 // since-cxx11-note@#cwg1467-f-char32-5 {{candidate function has been explicitly deleted}}
604 // since-cxx11-note@#cwg1467-f-char-4 {{candidate function not viable: no known conversion from 'const char32_t[4]' to 'const char' for 1st argument}}
605 // since-cxx11-note@#cwg1467-f-char-5 {{candidate function not viable: no known conversion from 'const char32_t[4]' to 'const char' for 1st argument}}
606 // since-cxx11-note@#cwg1467-f-wchar-4 {{candidate function not viable: no known conversion from 'const char32_t[4]' to 'const wchar_t' for 1st argument}}
607 // since-cxx11-note@#cwg1467-f-wchar-5 {{candidate function not viable: no known conversion from 'const char32_t[4]' to 'const wchar_t' for 1st argument}}
608 // since-cxx11-note@#cwg1467-f-char16-4 {{candidate function not viable: no known conversion from 'const char32_t[4]' to 'const char16_t' for 1st argument}}
609 // since-cxx11-note@#cwg1467-f-char16-5 {{candidate function not viable: no known conversion from 'const char32_t[4]' to 'const char16_t' for 1st argument}}
610 // since-cxx11-note@#cwg1467-f-char32-4 {{candidate function not viable: expects an rvalue for 1st argument}}
611 }
612 } // namespace StringLiterals
613 #endif
614 } // cwg1467
615
616 namespace cwg1479 { // cwg1479: 3.1
617 #if __cplusplus >= 201103L
618 int operator"" _a(const char*, std::size_t = 0);
619 // since-cxx11-error@-1 {{literal operator cannot have a default argument}}
620 #endif
621 }
622
623 namespace cwg1482 { // cwg1482: 3.0
624 // NB: sup 2516, test reused there
625 #if __cplusplus >= 201103L
626 template <typename T> struct S {
627 typedef char I;
628 };
629 enum E2 : S<E2>::I { e };
630 // since-cxx11-error@-1 {{use of undeclared identifier 'E2'}}
631 #endif
632 } // namespace cwg1482
633
634 namespace cwg1487 { // cwg1487: 3.3
635 #if __cplusplus >= 201103L
636 struct A { // #cwg1482-A
637 struct B {
638 using A::A;
639 // since-cxx11-error@-1 {{using declaration refers into 'A::', which is not a base class of 'B'}}
640 };
641
642 struct C : A {
643 // since-cxx11-error@-1 {{base class has incomplete type}}
644 // since-cxx11-note@#cwg1482-A {{definition of 'cwg1487::A' is not complete until the closing '}'}}
645 using A::A;
646 // since-cxx11-error@-1 {{using declaration refers into 'A::', which is not a base class of 'C'}}
647 };
648
649 struct D;
650 };
651
652 struct D : A {
653 using A::A;
654 };
655 #endif
656 } // namespace cwg1487
657
658 namespace cwg1490 { // cwg1490: 3.7 c++11
659 #if __cplusplus >= 201103L
660 // List-initialization from a string literal
661
662 char s[4]{"abc"}; // Ok
663 std::initializer_list<char>{"abc"};
664 // since-cxx11-error@-1 {{expected unqualified-id}}}
665 #endif
666 } // cwg1490
667
668 namespace cwg1495 { // cwg1495: 4
669 #if __cplusplus >= 201103L
670 // Deduction succeeds in both directions.
671 template<typename T, typename U> struct A {}; // #cwg1495-A
672 template<typename T, typename U> struct A<U, T> {};
673 // since-cxx11-error@-1 {{class template partial specialization is not more specialized than the primary template}}
674 // since-cxx11-note@#cwg1495-A {{template is declared here}}
675
676 // Primary template is more specialized.
677 template<typename, typename...> struct B {}; // #cwg1495-B
678 template<typename ...Ts> struct B<Ts...> {};
679 // since-cxx11-error@-1 {{class template partial specialization is not more specialized than the primary template}}
680 // since-cxx11-note@#cwg1495-B {{template is declared here}}
681
682 // Deduction fails in both directions.
683 template<int, typename, typename ...> struct C {}; // #cwg1495-C
684 template<typename ...Ts> struct C<0, Ts...> {};
685 // since-cxx11-error@-1 {{class template partial specialization is not more specialized than the primary template}}
686 // since-cxx11-note@#cwg1495-C {{template is declared here}}
687
688 #if __cplusplus >= 201402L
689 // Deduction succeeds in both directions.
690 template<typename T, typename U> int a; // #cwg1495-a
691 template<typename T, typename U> int a<U, T>;
692 // since-cxx14-error@-1 {{variable template partial specialization is not more specialized than the primary template}}
693 // since-cxx14-note@#cwg1495-a {{template is declared here}}
694
695 // Primary template is more specialized.
696 template<typename, typename...> int b; // #cwg1495-b
697 template<typename ...Ts> int b<Ts...>;
698 // since-cxx14-error@-1 {{variable template partial specialization is not more specialized than the primary template}}
699 // since-cxx14-note@#cwg1495-b {{template is declared here}}
700
701 // Deduction fails in both directions.
702 template<int, typename, typename ...> int c; // #cwg1495-c
703 template<typename ...Ts> int c<0, Ts...>;
704 // since-cxx14-error@-1 {{variable template partial specialization is not more specialized than the primary template}}
705 // since-cxx14-note@#cwg1495-c {{template is declared here}}
706 #endif
707 #endif
708 }
709
710 namespace cwg1496 { // cwg1496: no
711 #if __cplusplus >= 201103L
712 struct A {
713 A() = delete;
714 };
715 // FIXME: 'A' should not be trivial because the class lacks at least one
716 // default constructor which is not deleted.
717 static_assert(__is_trivial(A), "");
718 #endif
719 }