[RISCV] Simplify usage of SplatPat_simm5_plus1. NFC (#125340)
[llvm-project.git] / clang / test / SemaCXX / cxx2a-explicit-bool.cpp
blobc106de1e5efd09f92dd1f89bfb1cb094607c877a
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 {{cannot create object of function 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 // expected-note@-2+ {{implicit deduction guide}}
398 explicit(false)
399 A(typename nondeduced<T1>::type, typename nondeduced<T2>::type, typename nondeduced<B<b>>::type) {}
400 // expected-note@-1+ {{candidate template ignored}}
401 // expected-note@-2+ {{implicit deduction guide}}
404 template<typename T1, typename T2, bool b>
405 explicit(enable_ifv<is_same<T1, T2>::value, b>::value)
406 A(T1, T2, B<b>) -> A<T1, T2, b>;
407 // expected-note@-1+ {{explicit deduction guide declared here}}
408 // expected-note@-2+ {{candidate template ignored}}
409 void f() {
411 A a0( 0.0, 1, b_true); // expected-error {{no viable constructor or deduction guide}}
412 A a1{ 0.0, 1, b_true}; // expected-error {{no viable constructor or deduction guide}}
413 A a2 = { 0.0, 1, b_true}; // expected-error {{no viable constructor or deduction guide}}
414 auto a4 = A( 0.0, 1, b_true); // expected-error {{no viable constructor or deduction guide}}
415 auto a5 = A{ 0.0, 1, b_true}; // expected-error {{no viable constructor or deduction guide}}
417 A b0( 0, 1, b_true);
418 A b1{ 0, 1, b_true};
419 A b2 = { 0, 1, b_true}; // expected-error {{explicit deduction guide for copy-list-initialization}}
420 auto b4 = A( 0, 1, b_true);
421 auto b5 = A{ 0, 1, b_true};
422 b0 = { 0, 1, b_false}; // expected-error {{no viable overloaded '='}}
424 A c0( 0, 1, b_false);
425 A c1{ 0, 1, b_false};
426 A c2 = { 0, 1, b_false};
427 auto c4 = A( 0, 1, b_false);
428 auto c5 = A{ 0, 1, b_false};
429 c2 = { 0, 1, b_false};
435 namespace test8 {
437 template<bool b>
438 struct A {
439 //expected-note@-1+ {{candidate function}}
440 template<typename T1, typename T2>
441 explicit(b)
442 A(T1, T2) {}
443 //expected-note@-1 {{explicit constructor declared here}}
446 template<typename T1, typename T2>
447 explicit(!is_same<T1, int>::value)
448 A(T1, T2) -> A<!is_same<int, T2>::value>;
449 // expected-note@-1+ {{explicit deduction guide declared here}}
451 template<bool b>
452 A<b> v();
454 void f() {
456 A a0( 0, 1);
457 A a1{ 0, 1};
458 A a2 = { 0, 1};
459 auto a4 = A( 0, 1);
460 auto a5 = A{ 0, 1};
461 auto a6(v<false>());
462 a6 = { 0, 1};
464 A b0( 0.0, 1);
465 A b1{ 0.0, 1};
466 A b2 = { 0.0, 1}; // expected-error {{explicit deduction guide for copy-list-initialization}}
467 auto b4 = A( 0.0, 1);
468 auto b5 = A{ 0.0, 1};
470 A c0( 0, 1.0);
471 A c1{ 0, 1.0};
472 A c2 = { 0, 1.0}; // expected-error {{chosen constructor is explicit}}
473 auto c4 = A( 0, 1.0);
474 auto c5 = A{ 0, 1.0};
475 auto c6(v<true>());
476 c0 = { 0, 1.0}; // expected-error {{no viable overloaded '='}}
478 A d0( 0.0, 1.0);
479 A d1{ 0.0, 1.0};
480 A d2 = { 0.0, 1.0}; // expected-error {{explicit deduction guide for copy-list-initialization}}
481 auto d4 = A( 0.0, 1.0);
482 auto d5 = A{ 0.0, 1.0};
488 namespace conversion3 {
490 template<bool b>
491 struct A {
492 explicit(!b) operator int();
493 explicit(b) operator bool();
496 template<bool b>
497 A<b>::operator bool() { return false; }
499 struct B {
500 void f(int);
501 void f(bool);
504 void f(A<true> a, B b) {
505 b.f(a);
508 void f1(A<false> a, B b) {
509 b.f(a);
512 // Taken from 12.3.2p2
513 class X { X(); };
514 class Y { }; // expected-note+ {{candidate constructor (the implicit}}
516 template<bool b>
517 struct Z {
518 explicit(b) operator X() const;
519 explicit(b) operator Y() const; // expected-note 2{{not a candidate}}
520 explicit(b) operator int() const; // expected-note {{not a candidate}}
523 void testExplicit()
525 Z<true> z;
526 // 13.3.1.4p1 & 8.5p16:
527 Y y2 = z; // expected-error {{no viable conversion}}
528 Y y2b(z);
529 Y y3 = (Y)z;
530 Y y4 = Y(z);
531 Y y5 = static_cast<Y>(z);
532 // 13.3.1.5p1 & 8.5p16:
533 int i1 = (int)z;
534 int i2 = int(z);
535 int i3 = static_cast<int>(z);
536 int i4(z);
537 // 13.3.1.6p1 & 8.5.3p5:
538 const Y& y6 = z; // expected-error {{no viable conversion}}
539 const int& y7 = z; // expected-error {{no viable conversion}}
540 const Y& y8(z);
541 const int& y9(z);
543 // Y is an aggregate, so aggregate-initialization is performed and the
544 // conversion function is not considered.
545 const Y y10{z}; // expected-error {{excess elements}}
546 const Y& y11{z}; // expected-error {{excess elements}} expected-note {{in initialization of temporary}}
547 const int& y12{z};
549 // X is not an aggregate, so constructors are considered,
550 // per 13.3.3.1/4 & DR1467.
551 const X x1{z};
552 const X& x2{z};
555 struct tmp {};
557 template<typename T1>
558 struct C {
559 template<typename T>
560 explicit(!is_same<T1, T>::value)
561 operator T(); // expected-note+ {{explicit conversion function is not a candidate}}
564 using Bool = C<bool>;
565 using Integral = C<int>;
566 using Unrelated = C<tmp>;
568 void testBool() {
569 Bool b;
570 Integral n;
571 Unrelated u;
573 (void) (1 + b); // expected-error {{invalid operands to binary expression}}
574 (void) (1 + n);
575 (void) (1 + u); // expected-error {{invalid operands to binary expression}}
577 // 5.3.1p9:
578 (void) (!b);
579 (void) (!n);
580 (void) (!u);
582 // 5.14p1:
583 (void) (b && true);
584 (void) (n && true);
585 (void) (u && true);
587 // 5.15p1:
588 (void) (b || true);
589 (void) (n || true);
590 (void) (u || true);
592 // 5.16p1:
593 (void) (b ? 0 : 1);
594 (void) (n ? 0: 1);
595 (void) (u ? 0: 1);
597 // // 5.19p5:
598 // // TODO: After constexpr has been implemented
600 // 6.4p4:
601 if (b) {}
602 if (n) {}
603 if (u) {}
605 // 6.4.2p2:
606 switch (b) {} // expected-error {{statement requires expression of integer type}}
607 switch (n) {} // expected-error {{statement requires expression of integer type}}
608 switch (u) {} // expected-error {{statement requires expression of integer type}}
610 // 6.5.1:
611 while (b) {}
612 while (n) {}
613 while (u) {}
615 // 6.5.2p1:
616 do {} while (b);
617 do {} while (n);
618 do {} while (u);
620 // 6.5.3:
621 for (;b;) {}
622 for (;n;) {}
623 for (;u;) {}
625 // 13.3.1.5p1:
626 bool db1(b);
627 bool db2(n);
628 bool db3(u);
629 int di1(b);
630 int di2(n);
631 int di3(n);
632 const bool &direct_cr1(b);
633 const bool &direct_cr2(n);
634 const bool &direct_cr3(n);
635 const int &direct_cr4(b);
636 const int &direct_cr5(n);
637 const int &direct_cr6(n);
638 bool directList1{b};
639 bool directList2{n};
640 bool directList3{n};
641 int directList4{b};
642 int directList5{n};
643 int directList6{n};
644 const bool &directList_cr1{b};
645 const bool &directList_cr2{n};
646 const bool &directList_cr3{n};
647 const int &directList_cr4{b};
648 const int &directList_cr5{n};
649 const int &directList_cr6{n};
650 bool copy1 = b;
651 bool copy2 = n;// expected-error {{no viable conversion}}
652 bool copyu2 = u;// expected-error {{no viable conversion}}
653 int copy3 = b;// expected-error {{no viable conversion}}
654 int copy4 = n;
655 int copyu4 = u;// expected-error {{no viable conversion}}
656 const bool &copy5 = b;
657 const bool &copy6 = n;// expected-error {{no viable conversion}}
658 const bool &copyu6 = u;// expected-error {{no viable conversion}}
659 const int &copy7 = b;// expected-error {{no viable conversion}}
660 const int &copy8 = n;
661 const int &copyu8 = u;// expected-error {{no viable conversion}}
662 bool copyList1 = {b};
663 bool copyList2 = {n};// expected-error {{no viable conversion}}
664 bool copyListu2 = {u};// expected-error {{no viable conversion}}
665 int copyList3 = {b};// expected-error {{no viable conversion}}
666 int copyList4 = {n};
667 int copyListu4 = {u};// expected-error {{no viable conversion}}
668 const bool &copyList5 = {b};
669 const bool &copyList6 = {n};// expected-error {{no viable conversion}}
670 const bool &copyListu6 = {u};// expected-error {{no viable conversion}}
671 const int &copyList7 = {b};// expected-error {{no viable conversion}}
672 const int &copyList8 = {n};
673 const int &copyListu8 = {u};// expected-error {{no viable conversion}}
678 namespace deduction_guide2 {
680 template<typename T1 = int, typename T2 = int>
681 struct A {
682 // expected-note@-1+ {{candidate template ignored}}
683 // expected-note@-2+ {{implicit deduction guide}}
684 explicit(!is_same<T1, T2>::value)
685 A(T1 = 0, T2 = 0) {}
686 // expected-note@-1 {{explicit constructor declared here}}
687 // expected-note@-2 2{{explicit constructor is not a candidate}}
688 // expected-note@-3 2{{implicit deduction guide declared}}
691 A a0 = 0;
692 A a1(0, 0);
693 A a2{0, 0};
694 A a3 = {0, 0};
696 A b0 = 0.0; // expected-error {{no viable constructor or deduction guide}}
697 A b1(0.0, 0.0);
698 A b2{0.0, 0.0};
699 A b3 = {0.0, 0.0};
701 A b4 = {0.0, 0}; // expected-error {{explicit constructor}}
703 template<typename T1, typename T2>
704 explicit A(T1, T2) -> A<T1, T2>;
705 // expected-note@-1+ {{explicit deduction guide}}
707 A c0 = 0;
708 A c1(0, 0);
709 A c2{0, 0};
710 A c3 = {0, 0};// expected-error {{explicit deduction guide}}
712 A d0 = 0.0; // expected-error {{no viable constructor or deduction guide}}
713 A d1(0, 0);
714 A d2{0, 0};
715 A d3 = {0.0, 0.0};// expected-error {{explicit deduction guide}}
719 namespace PR42980 {
720 using size_t = decltype(sizeof(0));
722 struct Str {// expected-note+ {{candidate constructor}}
723 template <size_t N>
724 explicit(N > 7)
725 Str(char const (&str)[N]); // expected-note {{explicit constructor is not a candidate}}
728 template <size_t N>
729 Str::Str(char const(&str)[N]) { }
731 Str a = "short";
732 Str b = "not so short";// expected-error {{no viable conversion}}
736 namespace P1401 {
738 const int *ptr;
740 struct S {
741 explicit(sizeof(char[2])) S(char); // expected-error {{explicit specifier argument evaluates to 2, which cannot be narrowed to type 'bool'}}
742 explicit(ptr) S(long); // expected-error {{conversion from 'const int *' to 'bool' is not allowed in a converted constant expression}}
743 explicit(nullptr) S(int); // expected-error {{conversion from 'std::nullptr_t' to 'bool' is not allowed in a converted constant expression}}
744 explicit(42L) S(int, int); // expected-error {{explicit specifier argument evaluates to 42, which cannot be narrowed to type 'bool'}}
745 explicit(sizeof(char)) S();
746 explicit(0) S(char, char);
747 explicit(1L) S(char, char, char);
749 } // namespace P1401