Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / cxx2a-explicit-bool.cpp
blob9fdc059493aacb93146b477adf28692cecd38818
1 // RUN: %clang_cc1 -std=c++17 -fsyntax-only %s -verify=expected,pre20 -Wno-c++2a-extensions
2 // RUN: %clang_cc1 -std=c++2a -fsyntax-only %s -verify=expected,post20
4 template <bool b, auto val> struct enable_ifv {};
6 template <auto val> struct enable_ifv<true, val> {
7 static constexpr auto value = val;
8 };
10 template <typename T1, typename T2> struct is_same {
11 static constexpr bool value = false;
14 template <typename T> struct is_same<T, T> {
15 static constexpr bool value = true;
18 namespace special_cases
21 template<int a>
22 struct A {
23 // pre20-note@-1+ {{candidate constructor}}
24 explicit(1 << a)
25 // expected-note@-1 {{negative shift count -1}}
26 // expected-error@-2 {{explicit specifier argument is not a constant expression}}
27 A(int);
30 A<-1> a(0);
31 // pre20-error@-1 {{no matching constructor}}
32 // post20-error@-2 {{excess elements in struct initializer}}
33 // expected-note@-3 {{in instantiation of template class}}
35 template<int a>
36 struct B {
37 explicit(b)
38 // expected-error@-1 {{use of undeclared identifier}}
39 B(int);
42 template<int a>
43 struct B1 {
44 explicit(a +)
45 // expected-error@-1 {{expected expression}}
46 B1(int);
49 struct B2 {
50 explicit(false) explicit
51 B2(int);
52 // expected-error@-2 {{duplicate 'explicit' declaration specifier}}
55 template<int a>
56 struct C {
57 // expected-note@-1 {{candidate constructor}} expected-note@-1 {{candidate constructor}}
58 // expected-note@-2 {{candidate constructor}} expected-note@-2 {{candidate constructor}}
59 explicit(a == 0)
60 C(int), // expected-note 2{{not a candidate}}
61 C(double); // expected-note 2{{not a candidate}}
64 C<0> c0 = 0.0; // expected-error {{no viable conversion}}
65 C<0> c1 = 0; // expected-error {{no viable conversion}}
66 C<1> c2 = 0.0;
67 C<1> c3 = 0;
69 explicit(false) void f(int);// expected-error {{'explicit' can only be specified inside the class definition}}
71 struct D {
72 explicit(false) void f(int);// expected-error {{'explicit' can only be applied to a constructor or conversion function}}
75 template <typename T> struct E {
76 // expected-note@-1+ {{candidate constructor}}
77 explicit((T{}, false))
78 // expected-error@-1 {{illegal initializer type 'void'}}
79 E(int);
82 E<void> e = 1;
83 // expected-error@-1 {{no viable conversion}}
84 // expected-note@-2 {{in instantiation of}}
88 namespace trailing_object {
90 template<bool b>
91 struct B {
92 explicit(b) B(int) {}
95 template<bool b>
96 struct A : B<b> {
97 explicit(b) A(int) : B<b>(0) {}
100 A<true> a(0);
104 namespace constructor1 {
106 template<bool b>
107 struct A {
108 // expected-note@-1+ {{candidate constructor}}
109 // expected-note@-2+ {{candidate function}}
110 explicit(b) A(int, int = 0); // expected-note {{not a candidate}}
111 // expected-note@-1+ {{explicit constructor declared here}}
114 template<bool b>
115 A<b>::A(int, int) {}
117 void f()
119 A<true> a0 = 0; // expected-error {{no viable conversion}}
120 A<true> a1( 0);
121 A<true> && a2 = 0;// expected-error {{could not bind}}
122 A<true> && a3( 0);// expected-error {{could not bind}}
123 A<true> a4{ 0};
124 A<true> && a5 = { 0};// expected-error {{chosen constructor is explicit}}
125 A<true> && a6{ 0};
126 A<true> a7 = { 0}; // expected-error {{chosen constructor is explicit in copy-initialization}}
128 a0 = 0; // expected-error {{no viable overloaded '='}}
129 a1 = { 0}; // expected-error {{no viable overloaded '='}}
130 a2 = A<true>( 0);
131 a3 = A<true>{ 0};
133 A<false> c0 = ((short)0);
134 A<false> c1( ((short)0));
135 A<false> && c2 = ((short)0);
136 A<false> && c3( ((short)0));
137 A<false> c4{ ((short)0)};
138 A<false> && c5 = { ((short)0)};
139 A<false> && c6{ ((short)0)};
141 A<true> d1( 0, 0);
142 A<true> d2{ 0, 0};
143 A<true> d3 = { 0, 0}; // expected-error {{chosen constructor is explicit in copy-initialization}}
145 d1 = { 0, 0}; // expected-error {{no viable overloaded '='}}
146 d2 = A<true>( 0, 0);
147 d3 = A<true>{ 0, 0};
151 namespace constructor2 {
153 template<bool a, typename T1>
154 struct A {
155 // expected-note@-1 {{candidate constructor}} expected-note@-1 {{candidate constructor}}
156 // expected-note@-2 {{candidate constructor}} expected-note@-2 {{candidate constructor}}
157 template<typename T2>
158 explicit(a ^ is_same<T1, T2>::value)
159 A(T2) {}
160 // expected-note@-1+ {{explicit constructor declared here}}
161 // expected-note@-2+ {{not a candidate}}
164 A<true, int> a0 = 0.0; // expected-error {{no viable conversion}}
165 A<true, int> a1( 0.0);
166 A<true, int> && a2 = 0.0;// expected-error {{could not bind}}
167 A<true, int> && a3( 0.0);// expected-error {{could not bind}}
168 A<true, int> a4{ 0.0};
169 A<true, int> && a5 = { 0.0};// expected-error {{chosen constructor is explicit}}
170 A<true, int> && a6{ 0.0};
171 A<true, int> a7 = { 0.0}; // expected-error {{chosen constructor is explicit in copy-initialization}}
173 A<true, int> b0 = 0;
174 A<true, int> b1( 0);
175 A<true, int> && b2 = 0;
176 A<true, int> && b3( 0);
177 A<true, int> b4{ 0};
178 A<true, int> && b5 = { 0};
179 A<true, int> && b6{ 0};
180 A<true, int> b7 = { 0};
182 A<true, double> c0 = 0; // expected-error {{no viable conversion}}
183 A<true, double> c1( 0);
184 A<true, double> && c2 = 0;// expected-error {{could not bind}}
185 A<true, double> && c3( 0);// expected-error {{could not bind}}
186 A<true, double> c4{ 0};
187 A<true, double> && c5 = { 0};// expected-error {{chosen constructor is explicit}}
188 A<true, double> && c6{ 0};
189 A<true, double> c7 = { 0}; // expected-error {{chosen constructor is explicit in copy-initialization}}
193 namespace constructor_sfinae {
195 template<bool a>
196 struct A {
197 // expected-note@-1+ {{candidate constructor}}
198 template<typename T>
199 explicit(enable_ifv<is_same<int, T>::value, a>::value)
200 A(T) {}
201 // expected-note@-1+ {{substitution failure}}
202 // expected-note@-2 {{not a candidate}}
203 // expected-note@-3 {{explicit constructor declared here}}
204 template<typename T, bool c = true>
205 explicit(enable_ifv<is_same<bool, T>::value, a>::value)
206 A(T) {}
207 // expected-note@-1+ {{substitution failure}}
208 // expected-note@-2 {{not a candidate}}
209 // expected-note@-3 {{explicit constructor declared here}}
212 A<true> a0 = 0.0; // expected-error {{no viable conversion}}
213 A<true> a1( 0.0); // expected-error {{no matching constructor}}
214 A<true> a4{ 0.0}; // expected-error {{no matching constructor}}
215 A<true> a7 = { 0.0}; // expected-error {{no matching constructor}}
217 A<true> b0 = 0; // expected-error {{no viable conversion}}
218 A<true> b1( 0);
219 A<true> b4{ 0};
220 A<true> b7 = { 0}; // expected-error {{chosen constructor is explicit}}
222 A<false> c0 = 0;
223 A<false> c1( 0);
224 A<false> c4{ 0};
225 A<false> c7 = { 0};
227 A<true> d0 = true; // expected-error {{no viable conversion}}
228 A<true> d1( true);
229 A<true> d4{ true};
230 A<true> d7 = { true}; // expected-error {{chosen constructor is explicit}}
234 namespace conversion {
236 template<bool a>
237 struct A {
238 explicit(a) operator int (); // expected-note+ {{not a candidate}}
241 template<bool a>
242 A<a>::operator int() {
243 return 0;
246 A<true> A_true;
247 A<false> A_false;
249 int ai0 = A<true>(); // expected-error {{no viable conversion}}
250 const int& ai1 = A<true>(); // expected-error {{no viable conversion}}
251 int&& ai3 = A<true>(); // expected-error {{no viable conversion}}
252 int ai4 = A_true; // expected-error {{no viable conversion}}
253 const int& ai5 = A_true; // expected-error {{no viable conversion}}
255 int ai01 = {A<true>()}; // expected-error {{no viable conversion}}
256 const int& ai11 = {A<true>()}; // expected-error {{no viable conversion}}
257 int&& ai31 = {A<true>()}; // expected-error {{no viable conversion}}
258 int ai41 = {A_true}; // expected-error {{no viable conversion}}
259 const int& ai51 = {A_true}; // expected-error {{no viable conversion}}
261 int ae0(A<true>());
262 const int& ae1(A<true>());
263 int&& ae3(A<true>());
264 int ae4(A_true);
265 const int& ae5(A_true);
267 int bi0 = A<false>();
268 const int& bi1 = A<false>();
269 int&& bi3 = A<false>();
270 int bi4 = A_false;
271 const int& bi5 = A_false;
273 int bi01 = {A<false>()};
274 const int& bi11 = {A<false>()};
275 int&& bi31 = {A<false>()};
276 int bi41 = {A_false};
277 const int& bi51 = {A_false};
279 int be0(A<true>());
280 const int& be1(A<true>());
281 int&& be3(A<true>());
282 int be4(A_true);
283 const int& be5(A_true);
287 namespace conversion2 {
289 struct B {};
290 // expected-note@-1+ {{candidate constructor}}
291 template<bool a>
292 struct A {
293 template<typename T2>
294 explicit(enable_ifv<is_same<B, T2>::value, a>::value)
295 operator T2() { return T2(); };
296 // expected-note@-1+ {{substitution failure}}
297 // expected-note@-2+ {{not a candidate}}
300 A<false> A_false;
301 A<true> A_true;
303 int ai0 = A<true>(); // expected-error {{no viable conversion}}
304 const int& ai1 = A<true>(); // expected-error {{no viable conversion}}
305 int&& ai3 = A<true>(); // expected-error {{no viable conversion}}
306 int ai4 = A_false; // expected-error {{no viable conversion}}
307 const int& ai5 = A_false; // expected-error {{no viable conversion}}
309 int ae0{A<true>()}; // expected-error {{no viable conversion}}
310 const int& ae1{A<true>()}; // expected-error {{no viable conversion}}
311 int&& ae3{A<true>()}; // expected-error {{no viable conversion}}
312 int ae4{A_true}; // expected-error {{no viable conversion}}
313 const int& ae5{A_true}; // expected-error {{no viable conversion}}
315 int ap0((A<true>())); // expected-error {{no viable conversion}}
316 const int& ap1((A<true>())); // expected-error {{no viable conversion}}
317 int&& ap3((A<true>())); // expected-error {{no viable conversion}}
318 int ap4(A_true); // expected-error {{no viable conversion}}
319 const int& ap5(A_true); // expected-error {{no viable conversion}}
321 B b0 = A<true>(); // expected-error {{no viable conversion}}
322 const B & b1 = A<true>(); // expected-error {{no viable conversion}}
323 B && b3 = A<true>(); // expected-error {{no viable conversion}}
324 B b4 = A_true; // expected-error {{no viable conversion}}
325 const B & b5 = A_true; // expected-error {{no viable conversion}}
327 B be0(A<true>());
328 const B& be1(A<true>());
329 B&& be3(A<true>());
330 B be4(A_true);
331 const B& be5(A_true);
333 B c0 = A<false>();
334 const B & c1 = A<false>();
335 B && c3 = A<false>();
336 B c4 = A_false;
337 const B & c5 = A_false;
341 namespace parameter_pack {
343 template<typename T>
344 struct A {
345 // expected-note@-1+ {{candidate constructor}}
346 // expected-note@-2+ {{candidate function}}
347 template<typename ... Ts>
348 explicit((is_same<T, Ts>::value && ...))
349 A(Ts...);
350 // expected-note@-1 {{not a candidate}}
351 // expected-note@-2 {{explicit constructor}}
354 template<typename T>
355 template<typename ... Ts>
356 A<T>::A(Ts ...) {}
358 void f() {
360 A<int> a0 = 0; // expected-error {{no viable conversion}}
361 A<int> a1( 0, 1);
362 A<int> a2{ 0, 1};
363 A<int> a3 = { 0, 1}; // expected-error {{chosen constructor is explicit}}
365 a1 = 0; // expected-error {{no viable overloaded '='}}
366 a2 = { 0, 1}; // expected-error {{no viable overloaded '='}}
368 A<double> b0 = 0;
369 A<double> b1( 0, 1);
370 A<double> b2{ 0, 1};
371 A<double> b3 = { 0, 1};
373 b1 = 0;
374 b2 = { 0, 1};
380 namespace deduction_guide {
382 template<bool b>
383 struct B {};
385 B<true> b_true;
386 B<false> b_false;
388 template<typename T>
389 struct nondeduced
391 using type = T;
394 template<typename T1, typename T2, bool b>
395 struct A {
396 // expected-note@-1+ {{candidate function}}
397 explicit(false)
398 A(typename nondeduced<T1>::type, typename nondeduced<T2>::type, typename nondeduced<B<b>>::type) {}
399 // expected-note@-1+ {{candidate template ignored}}
402 template<typename T1, typename T2, bool b>
403 explicit(enable_ifv<is_same<T1, T2>::value, b>::value)
404 A(T1, T2, B<b>) -> A<T1, T2, b>;
405 // expected-note@-1+ {{explicit deduction guide declared here}}
406 // expected-note@-2+ {{candidate template ignored}}
407 void f() {
409 A a0( 0.0, 1, b_true); // expected-error {{no viable constructor or deduction guide}}
410 A a1{ 0.0, 1, b_true}; // expected-error {{no viable constructor or deduction guide}}
411 A a2 = { 0.0, 1, b_true}; // expected-error {{no viable constructor or deduction guide}}
412 auto a4 = A( 0.0, 1, b_true); // expected-error {{no viable constructor or deduction guide}}
413 auto a5 = A{ 0.0, 1, b_true}; // expected-error {{no viable constructor or deduction guide}}
415 A b0( 0, 1, b_true);
416 A b1{ 0, 1, b_true};
417 A b2 = { 0, 1, b_true}; // expected-error {{explicit deduction guide for copy-list-initialization}}
418 auto b4 = A( 0, 1, b_true);
419 auto b5 = A{ 0, 1, b_true};
420 b0 = { 0, 1, b_false}; // expected-error {{no viable overloaded '='}}
422 A c0( 0, 1, b_false);
423 A c1{ 0, 1, b_false};
424 A c2 = { 0, 1, b_false};
425 auto c4 = A( 0, 1, b_false);
426 auto c5 = A{ 0, 1, b_false};
427 c2 = { 0, 1, b_false};
433 namespace test8 {
435 template<bool b>
436 struct A {
437 //expected-note@-1+ {{candidate function}}
438 template<typename T1, typename T2>
439 explicit(b)
440 A(T1, T2) {}
441 //expected-note@-1 {{explicit constructor declared here}}
444 template<typename T1, typename T2>
445 explicit(!is_same<T1, int>::value)
446 A(T1, T2) -> A<!is_same<int, T2>::value>;
447 // expected-note@-1+ {{explicit deduction guide declared here}}
449 template<bool b>
450 A<b> v();
452 void f() {
454 A a0( 0, 1);
455 A a1{ 0, 1};
456 A a2 = { 0, 1};
457 auto a4 = A( 0, 1);
458 auto a5 = A{ 0, 1};
459 auto a6(v<false>());
460 a6 = { 0, 1};
462 A b0( 0.0, 1);
463 A b1{ 0.0, 1};
464 A b2 = { 0.0, 1}; // expected-error {{explicit deduction guide for copy-list-initialization}}
465 auto b4 = A( 0.0, 1);
466 auto b5 = A{ 0.0, 1};
468 A c0( 0, 1.0);
469 A c1{ 0, 1.0};
470 A c2 = { 0, 1.0}; // expected-error {{chosen constructor is explicit}}
471 auto c4 = A( 0, 1.0);
472 auto c5 = A{ 0, 1.0};
473 auto c6(v<true>());
474 c0 = { 0, 1.0}; // expected-error {{no viable overloaded '='}}
476 A d0( 0.0, 1.0);
477 A d1{ 0.0, 1.0};
478 A d2 = { 0.0, 1.0}; // expected-error {{explicit deduction guide for copy-list-initialization}}
479 auto d4 = A( 0.0, 1.0);
480 auto d5 = A{ 0.0, 1.0};
486 namespace conversion3 {
488 template<bool b>
489 struct A {
490 explicit(!b) operator int();
491 explicit(b) operator bool();
494 template<bool b>
495 A<b>::operator bool() { return false; }
497 struct B {
498 void f(int);
499 void f(bool);
502 void f(A<true> a, B b) {
503 b.f(a);
506 void f1(A<false> a, B b) {
507 b.f(a);
510 // Taken from 12.3.2p2
511 class X { X(); };
512 class Y { }; // expected-note+ {{candidate constructor (the implicit}}
514 template<bool b>
515 struct Z {
516 explicit(b) operator X() const;
517 explicit(b) operator Y() const; // expected-note 2{{not a candidate}}
518 explicit(b) operator int() const; // expected-note {{not a candidate}}
521 void testExplicit()
523 Z<true> z;
524 // 13.3.1.4p1 & 8.5p16:
525 Y y2 = z; // expected-error {{no viable conversion}}
526 Y y2b(z);
527 Y y3 = (Y)z;
528 Y y4 = Y(z);
529 Y y5 = static_cast<Y>(z);
530 // 13.3.1.5p1 & 8.5p16:
531 int i1 = (int)z;
532 int i2 = int(z);
533 int i3 = static_cast<int>(z);
534 int i4(z);
535 // 13.3.1.6p1 & 8.5.3p5:
536 const Y& y6 = z; // expected-error {{no viable conversion}}
537 const int& y7 = z; // expected-error {{no viable conversion}}
538 const Y& y8(z);
539 const int& y9(z);
541 // Y is an aggregate, so aggregate-initialization is performed and the
542 // conversion function is not considered.
543 const Y y10{z}; // expected-error {{excess elements}}
544 const Y& y11{z}; // expected-error {{excess elements}} expected-note {{in initialization of temporary}}
545 const int& y12{z};
547 // X is not an aggregate, so constructors are considered,
548 // per 13.3.3.1/4 & DR1467.
549 const X x1{z};
550 const X& x2{z};
553 struct tmp {};
555 template<typename T1>
556 struct C {
557 template<typename T>
558 explicit(!is_same<T1, T>::value)
559 operator T(); // expected-note+ {{explicit conversion function is not a candidate}}
562 using Bool = C<bool>;
563 using Integral = C<int>;
564 using Unrelated = C<tmp>;
566 void testBool() {
567 Bool b;
568 Integral n;
569 Unrelated u;
571 (void) (1 + b); // expected-error {{invalid operands to binary expression}}
572 (void) (1 + n);
573 (void) (1 + u); // expected-error {{invalid operands to binary expression}}
575 // 5.3.1p9:
576 (void) (!b);
577 (void) (!n);
578 (void) (!u);
580 // 5.14p1:
581 (void) (b && true);
582 (void) (n && true);
583 (void) (u && true);
585 // 5.15p1:
586 (void) (b || true);
587 (void) (n || true);
588 (void) (u || true);
590 // 5.16p1:
591 (void) (b ? 0 : 1);
592 (void) (n ? 0: 1);
593 (void) (u ? 0: 1);
595 // // 5.19p5:
596 // // TODO: After constexpr has been implemented
598 // 6.4p4:
599 if (b) {}
600 if (n) {}
601 if (u) {}
603 // 6.4.2p2:
604 switch (b) {} // expected-error {{statement requires expression of integer type}}
605 switch (n) {} // expected-error {{statement requires expression of integer type}}
606 switch (u) {} // expected-error {{statement requires expression of integer type}}
608 // 6.5.1:
609 while (b) {}
610 while (n) {}
611 while (u) {}
613 // 6.5.2p1:
614 do {} while (b);
615 do {} while (n);
616 do {} while (u);
618 // 6.5.3:
619 for (;b;) {}
620 for (;n;) {}
621 for (;u;) {}
623 // 13.3.1.5p1:
624 bool db1(b);
625 bool db2(n);
626 bool db3(u);
627 int di1(b);
628 int di2(n);
629 int di3(n);
630 const bool &direct_cr1(b);
631 const bool &direct_cr2(n);
632 const bool &direct_cr3(n);
633 const int &direct_cr4(b);
634 const int &direct_cr5(n);
635 const int &direct_cr6(n);
636 bool directList1{b};
637 bool directList2{n};
638 bool directList3{n};
639 int directList4{b};
640 int directList5{n};
641 int directList6{n};
642 const bool &directList_cr1{b};
643 const bool &directList_cr2{n};
644 const bool &directList_cr3{n};
645 const int &directList_cr4{b};
646 const int &directList_cr5{n};
647 const int &directList_cr6{n};
648 bool copy1 = b;
649 bool copy2 = n;// expected-error {{no viable conversion}}
650 bool copyu2 = u;// expected-error {{no viable conversion}}
651 int copy3 = b;// expected-error {{no viable conversion}}
652 int copy4 = n;
653 int copyu4 = u;// expected-error {{no viable conversion}}
654 const bool &copy5 = b;
655 const bool &copy6 = n;// expected-error {{no viable conversion}}
656 const bool &copyu6 = u;// expected-error {{no viable conversion}}
657 const int &copy7 = b;// expected-error {{no viable conversion}}
658 const int &copy8 = n;
659 const int &copyu8 = u;// expected-error {{no viable conversion}}
660 bool copyList1 = {b};
661 bool copyList2 = {n};// expected-error {{no viable conversion}}
662 bool copyListu2 = {u};// expected-error {{no viable conversion}}
663 int copyList3 = {b};// expected-error {{no viable conversion}}
664 int copyList4 = {n};
665 int copyListu4 = {u};// expected-error {{no viable conversion}}
666 const bool &copyList5 = {b};
667 const bool &copyList6 = {n};// expected-error {{no viable conversion}}
668 const bool &copyListu6 = {u};// expected-error {{no viable conversion}}
669 const int &copyList7 = {b};// expected-error {{no viable conversion}}
670 const int &copyList8 = {n};
671 const int &copyListu8 = {u};// expected-error {{no viable conversion}}
676 namespace deduction_guide2 {
678 template<typename T1 = int, typename T2 = int>
679 struct A {
680 // expected-note@-1+ {{candidate template ignored}}
681 explicit(!is_same<T1, T2>::value)
682 A(T1 = 0, T2 = 0) {}
683 // expected-note@-1 {{explicit constructor declared here}}
684 // expected-note@-2 2{{explicit constructor is not a candidate}}
687 A a0 = 0;
688 A a1(0, 0);
689 A a2{0, 0};
690 A a3 = {0, 0};
692 A b0 = 0.0; // expected-error {{no viable constructor or deduction guide}}
693 A b1(0.0, 0.0);
694 A b2{0.0, 0.0};
695 A b3 = {0.0, 0.0};
697 A b4 = {0.0, 0}; // expected-error {{explicit constructor}}
699 template<typename T1, typename T2>
700 explicit A(T1, T2) -> A<T1, T2>;
701 // expected-note@-1+ {{explicit deduction guide}}
703 A c0 = 0;
704 A c1(0, 0);
705 A c2{0, 0};
706 A c3 = {0, 0};// expected-error {{explicit deduction guide}}
708 A d0 = 0.0; // expected-error {{no viable constructor or deduction guide}}
709 A d1(0, 0);
710 A d2{0, 0};
711 A d3 = {0.0, 0.0};// expected-error {{explicit deduction guide}}
715 namespace PR42980 {
716 using size_t = decltype(sizeof(0));
718 struct Str {// expected-note+ {{candidate constructor}}
719 template <size_t N>
720 explicit(N > 7)
721 Str(char const (&str)[N]); // expected-note {{explicit constructor is not a candidate}}
724 template <size_t N>
725 Str::Str(char const(&str)[N]) { }
727 Str a = "short";
728 Str b = "not so short";// expected-error {{no viable conversion}}
732 namespace P1401 {
734 const int *ptr;
736 struct S {
737 explicit(sizeof(char[2])) S(char); // expected-error {{explicit specifier argument evaluates to 2, which cannot be narrowed to type 'bool'}}
738 explicit(ptr) S(long); // expected-error {{conversion from 'const int *' to 'bool' is not allowed in a converted constant expression}}
739 explicit(nullptr) S(int); // expected-error {{conversion from 'std::nullptr_t' to 'bool' is not allowed in a converted constant expression}}
740 explicit(42L) S(int, int); // expected-error {{explicit specifier argument evaluates to 42, which cannot be narrowed to type 'bool'}}
741 explicit(sizeof(char)) S();
742 explicit(0) S(char, char);
743 explicit(1L) S(char, char, char);
745 } // namespace P1401